Put in hooks for nova subcomponent install, and begin work on 'start' support

This commit is contained in:
Ken 2012-01-23 14:45:09 -08:00
parent b834b541c9
commit 0ab95ee62c
3 changed files with 99 additions and 1 deletions

@ -139,8 +139,16 @@ class PkgInstallComponent(ComponentBase, InstallComponent):
def _get_param_map(self, _):
return None
def install(self):
# Note that there's no underscore on this method because it's two levels
# in so that the component installers can't access it as a 'protected'
# method. E.g. componentInstall inherits from PythonInstallComponent
# which then inherits from here.
def get_pkglist(self):
pkgs = utils.get_pkg_list(self.distro, self.component_name)
return pkgs
def install(self):
pkgs = self.get_pkglist()
if(len(pkgs)):
pkgnames = sorted(pkgs.keys())
LOG.info("Installing packages (%s)." % (", ".join(pkgnames)))

@ -16,7 +16,9 @@
from devstack import component as comp
from devstack import log as logging
from devstack import settings
from devstack import utils
from devstack import shell as sh
from devstack.components import db
from devstack.components import nova_conf as nc
LOG = logging.getLogger("devstack.components.nova")
@ -29,6 +31,25 @@ DB_NAME = "nova"
BIN_DIR = 'bin'
TYPE = settings.NOVA
#what to start
APP_OPTIONS = {
'nova-api': [],
settings.NCPU: [],
settings.NVOL: [],
'nova-network': [],
'nova-scheduler': []
}
# In case we need to map names to the image to run
APP_NAME_MAP = {
settings.NCPU: 'nova-compute',
settings.NVOL: 'nova-volume',
}
CONFIG_ACTUAL_DIR = 'etc'
BIN_DIR = 'bin'
# FIXME, need base bin dir
DB_SYNC = ['/bin/nova-manage', 'db', 'sync']
class NovaUninstaller(comp.PythonUninstallComponent):
def __init__(self, *args, **kargs):
@ -43,6 +64,17 @@ class NovaInstaller(comp.PythonInstallComponent):
self.git_branch = self.cfg.get("git", "nova_branch")
self.bindir = sh.joinpths(self.appdir, BIN_DIR)
def get_pkglist(self):
pkgs = comp.PkgInstallComponent.get_pkglist(self)
LOG.debug("pkg list from parent: %s" % (pkgs))
# Walk through the subcomponents (like 'vol' and 'cpu') and add those
# those packages as well. (Let utils.get_pkg_list handle any missing
# entries
LOG.debug("get_pkglist looking for extras: %s" % (self.component_opts))
for cname in self.component_opts:
pkgs.update(utils.get_pkg_list(self.distro, cname))
return pkgs
def _get_download_locations(self):
places = comp.PythonInstallComponent._get_download_locations(self)
places.append({
@ -51,6 +83,24 @@ class NovaInstaller(comp.PythonInstallComponent):
})
return places
def post_install(self):
parent_result = comp.PkgInstallComponent.post_install(self)
#extra actions to do nova setup
LOG.debug("Setting up our database")
self._setup_db()
# Need to do db sync
# Need to do nova-managber create private
# TBD, do we need to so nova-api start first?
# If using q-qvc, skip
# $NOVA_DIR/bin/nova-manage floating create $FLOATING_RANGE
# $NOVA_DIR/bin/nova-manage floating create --ip_range=$TEST_FLOATING_RANGE --pool=$TEST_FLOATING_POOL
return parent_result
def _setup_db(self):
LOG.debug("setting up nova DB")
db.drop_db(self.cfg, DB_NAME)
db.create_db(self.cfg, DB_NAME)
def _generate_nova_conf(self):
LOG.debug("Generating dynamic content for nova configuration")
dirs = dict()
@ -74,3 +124,31 @@ class NovaInstaller(comp.PythonInstallComponent):
class NovaRuntime(comp.PythonRuntime):
def __init__(self, *args, **kargs):
comp.PythonRuntime.__init__(self, TYPE, *args, **kargs)
def _get_aps_to_start(self):
# Check if component_opts was set to a subset of apps to be started
apps = list()
if (not self.component_opts and len(self.component_opts) > 0):
LOG.debug("Attempt to use subset of components:%s" % (self.component_opts))
# check if the specified sub components exist
delta = set(self.component_opts) - set(APP_OPTIONS.keys())
if (delta):
# FIXME, error, something was specified that we don't have
LOG.error("sub items that we don't know about:%s" % delta)
else:
apps = self.component_opts
else:
apps = APP_OPTIONS.keys()
result = list()
for app_name in apps:
if (app_name in APP_NAME_MAP):
app_name = APP_NAME_MAP.get(app_name)
list.append({
'name': app_name,
'path': sh.joinpths(self.appdir, BIN_DIR, app_name),
})
return result
def _get_app_options(self, app):
return APP_OPTIONS.get(app)

@ -52,6 +52,9 @@ DB = "db"
RABBIT = "rabbit"
OPENSTACK_X = 'openstack-x'
NOVNC = 'novnc'
# NCPU and NVOL are here as possible subcomponents of nova
NCPU = "cpu"
NVOL = "vol"
COMPONENT_NAMES = [
NOVA, NOVA_CLIENT,
GLANCE,
@ -207,6 +210,15 @@ PKG_MAP = {
[
os.path.join(STACK_PKG_DIR, 'n-vnc.json'),
],
NCPU:
[
os.path.join(STACK_PKG_DIR, 'n-cpu.json'),
],
NVOL:
[
os.path.join(STACK_PKG_DIR, 'n-vol.json'),
],
}