diff --git a/README.md b/README.md index 487b6367..4641822b 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Devstack v2 is a set of python scripts and utilities to quickly deploy an OpenSt # Goals -* To quickly build dev OpenStack environments in a clean environment (as well as start, stop, and uninstall those environments) +* To quickly build dev OpenStack environments in a clean environment (as well as start, stop, and uninstall those environments) with as little baggage as possible * To describe working configurations of OpenStack (which code branches work together? what do config files look like for those branches? what packages are needed for installation?) * To make it easier for developers to dive into OpenStack so that they can productively contribute without having to understand every part of the system at once * To make it easy to prototype cross-project features @@ -38,6 +38,9 @@ This will typically produce: # Stack prerequisites +* linux (tested on ubuntu 11 and rhel 6) +* python 2.6 or 2.7 (not tested with python 3.0) +* git * easy_install termcolor (used for colored console logging) * easy_install netifaces (used to determine host ip information) diff --git a/conf/stack.ini b/conf/stack.ini index 07e83446..ee9f0a2a 100644 --- a/conf/stack.ini +++ b/conf/stack.ini @@ -10,13 +10,15 @@ # Set api host endpoint host_ip = ${HOST_IP:-} -#Sys log enabled or not +# Sys log enabled or not syslog = 0 [db] +# Where you db is located at and how to access it sql_host = ${SQL_HOST:-localhost} sql_user = ${SQL_USER:-root} +port = ${SQL_PORT:-3306} #internal commands are dependent on this... type = mysql diff --git a/devstack/Component.py b/devstack/Component.py index f5238956..ce3d32ca 100644 --- a/devstack/Component.py +++ b/devstack/Component.py @@ -182,6 +182,7 @@ class PythonInstallComponent(PkgInstallComponent): (sysout, stderr) = execute(*PY_INSTALL, cwd=self.appdir, run_as_root=True) write_file(recordwhere, sysout) + # Overridden def install(self): self._do_pkg_install() self._python_install() diff --git a/devstack/Config.py b/devstack/Config.py index acc231ca..90e15816 100644 --- a/devstack/Config.py +++ b/devstack/Config.py @@ -33,7 +33,7 @@ class EnvConfigParser(ConfigParser.RawConfigParser): ConfigParser.RawConfigParser.__init__(self) self.pws = dict() self.configs_fetched = dict() - self.dbdsns = dict() + self.db_dsns = dict() def _makekey(self, section, option): return option + "@" + section @@ -50,23 +50,42 @@ class EnvConfigParser(ConfigParser.RawConfigParser): self.configs_fetched[key] = v return v + def __len__(self): + return (len(self.pws) + + len(self.configs_fetched) + + len(self.db_dsns)) + def __str__(self): - str_repr = "" + #this will make the items nice and pretty + def item_format(k, v): + return "\t%s=%s" % (str(k), str(v)) + #collect all the lines + password_lines = list() if(len(self.pws)): - str_repr += "Passwords:" + os.linesep - for (k,v) in self.pws.items(): - str_repr += "\t" + str(k) + " = " + str(v) + os.linesep + password_lines.append("Passwords:") + keys = sorted(self.pws.keys()) + for key in keys: + value = self.pws.get(key) + password_lines.append(item_format(key, value)) + cfg_lines = list() if(len(self.configs_fetched)): - str_repr += "Configs:" + os.linesep - for (k,v) in self.configs_fetched.items(): - if(k in self.pws): + cfg_lines.append("Configs:") + keys = sorted(self.configs_fetched.keys()) + for key in keys: + if(key in self.pws): continue - str_repr += "\t" + str(k) + " = " + str(v) + os.linesep - if(len(self.dbdsns)): - str_repr += "Data source names:" + os.linesep - for (k, v) in self.dbdsns.items(): - str_repr += "\t" + str(k) + " = " + str(v) + os.linesep - return str_repr + value = self.configs_fetched.get(key) + cfg_lines.append(item_format(key, value)) + dsn_lines = list() + if(len(self.db_dsns)): + dsn_lines.append("Data source names:") + keys = sorted(self.db_dsns.keys()) + for key in keys: + value = self.db_dsns.get(key) + dsn_lines.append(item_format(key, value)) + #make a nice string + combined_lines = cfg_lines + password_lines + dsn_lines + return os.linesep.join(combined_lines) def _get_special(self, section, option): key = self._makekey(section, option) @@ -89,14 +108,14 @@ class EnvConfigParser(ConfigParser.RawConfigParser): else: return v - def get_dbdsn(dbname): + def get_dbdsn(self, dbname): user = self.get("db", "sql_user") host = self.get("db", "sql_host") port = self.get("db", "port") pw = self.getpw("passwords", "sql") #check the dsn cache - if(dbname in self.dbdsns): - return self.dbdsns[dbname] + if(dbname in self.db_dsns): + return self.db_dsns[dbname] #form the dsn (from components we have...) #dsn = "://:@:/" if(not host): @@ -109,9 +128,9 @@ class EnvConfigParser(ConfigParser.RawConfigParser): dsn = driver + "://" if(user): dsn += user - if(password): - dsn += ":" + password - if(user or password): + if(pw): + dsn += ":" + pw + if(user or pw): dsn += "@" dsn += host if(port): @@ -120,8 +139,9 @@ class EnvConfigParser(ConfigParser.RawConfigParser): dsn += "/" + dbname else: dsn += "/" + LOG.debug("For database %s fetched dsn %s" % (dbname, dsn)) #store for later... - self.dbdsns[dbname] = dsn + self.db_dsns[dbname] = dsn return dsn def getpw(self, section, option): diff --git a/devstack/Glance.py b/devstack/Glance.py index a91fd782..2864a130 100644 --- a/devstack/Glance.py +++ b/devstack/Glance.py @@ -24,6 +24,7 @@ from Util import (GLANCE, get_host_ip, param_replace) from Shell import (deldir, mkdirslist, unlink, joinpths, touch_file) +import Db LOG = Logger.getLogger("install.glance") @@ -75,6 +76,16 @@ class GlanceInstaller(PythonInstallComponent): #these are the config files we will be adjusting return list(CONFIGS) + def install(self): + parent_res = PythonInstallComponent.install(self) + #setup the database + self._setup_db() + return parent_res + + def _setup_db(self): + Db.drop_db(self.cfg, DB_NAME) + Db.create_db(self.cfg, DB_NAME) + def _config_adjust(self, contents, fn): lines = contents.splitlines() for line in lines: diff --git a/devstack/Keystone.py b/devstack/Keystone.py index f5e8323c..5b10c015 100644 --- a/devstack/Keystone.py +++ b/devstack/Keystone.py @@ -58,17 +58,15 @@ class KeystoneInstaller(PythonInstallComponent): self.bindir = joinpths(self.appdir, BIN_DIR) def _get_download_location(self): - uri = self.gitloc - branch = self.brch - return (uri, branch) + return (self.gitloc, self.brch) def install(self): - PythonInstallComponent.install(self) + parent_res = PythonInstallComponent.install(self) #adjust db self._setup_db() #setup any data self._setup_data() - return self.tracedir + return parent_res def _get_config_files(self): return list(CONFIGS) diff --git a/run_checks.sh b/run_checks.sh index b3f02e2b..c097166b 100755 --- a/run_checks.sh +++ b/run_checks.sh @@ -39,8 +39,9 @@ function run_pep8 { srcfiles=`find devstack -type f | grep "py\$"` srcfiles+=" stack" pep_ignores="E202" + tee_fn="pep8.log" pep8_opts="--ignore=$pep_ignores --repeat" - echo "$(${wrapper} pep8 ${pep8_opts} ${srcfiles} 2>&1)" + echo "$(${wrapper} pep8 ${pep8_opts} ${srcfiles} 2>&1 | tee $tee_fn)" if [ "$?" -ne "0" ]; then echo "Sorry, cannot run pep8 ..." exit 1 @@ -54,8 +55,9 @@ function run_pylint { echo "Running pylint ..." srcfiles=`find devstack -type f | grep "py\$"` srcfiles+=" stack" + tee_fn="pylint.log" pylint_opts="--rcfile=$pylintrc_fn" - echo "$(${wrapper} pylint ${pylint_opts} ${srcfiles} 2>&1)" + echo "$(${wrapper} pylint ${pylint_opts} ${srcfiles} 2>&1 | tee $tee_fn)" if [ "$?" -ne "0" ]; then echo "Sorry, cannot run pylint ..." exit 1 diff --git a/stack b/stack index 1fd980f9..0213f814 100755 --- a/stack +++ b/stack @@ -116,8 +116,10 @@ def get_config(action): def print_cfgs(cfg, action): - LOG.info("After %s your config is:" % (action)) - LOG.info(str(cfg).rstrip()) + cfg_str = str(cfg).strip() + if(len(cfg)): + LOG.info("After %s your config is:" % (action)) + LOG.info(cfg_str) def runner(action_name, component_set, distro, root_dir, program_args):