Updated with glance and keystone working! Ya! And added a check bash script to check pep8 and pylint. Useful soon.

This commit is contained in:
Joshua Harlow 2012-01-17 17:04:51 -08:00
parent fbe934bcbc
commit 59a883249e
8 changed files with 71 additions and 32 deletions

View File

@ -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)

View File

@ -15,8 +15,10 @@ 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

View File

@ -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()

View File

@ -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 = "<driver>://<username>:<password>@<host>:<port>/<database>"
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):

View File

@ -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:

View File

@ -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)

View File

@ -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

4
stack
View File

@ -116,8 +116,10 @@ def get_config(action):
def print_cfgs(cfg, action):
cfg_str = str(cfg).strip()
if(len(cfg)):
LOG.info("After %s your config is:" % (action))
LOG.info(str(cfg).rstrip())
LOG.info(cfg_str)
def runner(action_name, component_set, distro, root_dir, program_args):