Started to add keystone client (for horizon) and adjusted install, start and other runtime routines to return ints so that we can know how many items were started/stoped....

This commit is contained in:
Joshua Harlow 2012-01-18 15:49:01 -08:00
parent 701502991f
commit feb0a25d34
11 changed files with 197 additions and 72 deletions

@ -0,0 +1,22 @@
# This is a extended json package definition file
# We allow simple comments (lines starting with a hash symbol)
{
"ubuntu-oneiric": {
"python-prettytable": {
"version": "0.5-1ubuntu1",
"allowed": ">=",
"removable": true
},
"python-simplejson": {
"version": "2.1.6-1",
"allowed": ">=",
"removable": true
},
"python-argparse": {
"version": "1.1-1ubuntu1",
"allowed": ">=",
"removable": false
}
},
"rhel-6": {}
}

@ -109,6 +109,10 @@ novnc_branch = master
horizon_repo = https://github.com/openstack/horizon.git
horizon_branch = master
# python keystone client library to nova that horizon uses
keystoneclient_repo = git://github.com/openstack/python-keystoneclient.git
keystoneclient_branch = master
# python client library to nova that horizon (and others) use
novaclient_repo = https://github.com/openstack/python-novaclient.git
novaclient_branch = master

@ -106,20 +106,29 @@ class PkgInstallComponent(ComponentBase, InstallComponent):
ComponentBase.__init__(self, component_name, *args, **kargs)
self.tracewriter = TraceWriter(self.tracedir, IN_TRACE)
def _get_download_location(self):
raise NotImplementedError()
def _get_download_locations(self):
return list()
def download(self):
#find out where to get it
(uri, branch) = self._get_download_location()
if(uri):
#now get it
dirsmade = Downloader.download(self.appdir, uri, branch)
#this trace isn't used yet but could be
self.tracewriter.downloaded(self.appdir, uri)
#this trace is used to remove the dirs created
locations = self._get_download_locations()
base_dir = self.appdir
am_downloaded = 0
for location_info in locations:
uri = location_info.get("uri")
if(not uri):
continue
branch = location_info.get("branch")
subdir = location_info.get("subdir")
target_loc = None
if(subdir and len(subdir)):
target_loc = joinpths(base_dir, subdir)
else:
target_loc = base_dir
dirsmade = Downloader.download(target_loc, uri, branch)
self.tracewriter.downloaded(target_loc, uri)
self.tracewriter.dir_made(*dirsmade)
return self.tracedir
am_downloaded += 1
return am_downloaded
def _get_param_map(self, fn=None):
return None
@ -159,23 +168,23 @@ class PkgInstallComponent(ComponentBase, InstallComponent):
dirsmade = mkdirslist(self.cfgdir)
self.tracewriter.dir_made(*dirsmade)
configs = self._get_config_files()
if(configs and len(configs)):
for fn in configs:
parameters = self._get_param_map(fn)
sourcefn = joinpths(STACK_CONFIG_DIR, self.component_name, fn)
tgtfn = joinpths(self.cfgdir, fn)
LOG.info("Configuring template file %s" % (sourcefn))
contents = load_file(sourcefn)
LOG.info("Replacing parameters in file %s" % (sourcefn))
LOG.debug("Replacements = %s" % (parameters))
contents = param_replace(contents, parameters)
LOG.debug("Applying side-effects of param replacement for template %s" % (sourcefn))
contents = self._config_adjust(contents, fn)
LOG.info("Writing configuration file %s" % (tgtfn))
write_file(tgtfn, contents)
#this trace is used to remove the files configured
self.tracewriter.cfg_write(tgtfn)
return self.tracedir
am = len(configs)
for fn in configs:
parameters = self._get_param_map(fn)
sourcefn = joinpths(STACK_CONFIG_DIR, self.component_name, fn)
tgtfn = joinpths(self.cfgdir, fn)
LOG.info("Configuring template file %s" % (sourcefn))
contents = load_file(sourcefn)
LOG.info("Replacing parameters in file %s" % (sourcefn))
LOG.debug("Replacements = %s" % (parameters))
contents = param_replace(contents, parameters)
LOG.debug("Applying side-effects of param replacement for template %s" % (sourcefn))
contents = self._config_adjust(contents, fn)
LOG.info("Writing configuration file %s" % (tgtfn))
write_file(tgtfn, contents)
#this trace is used to remove the files configured
self.tracewriter.cfg_write(tgtfn)
return am
class PythonInstallComponent(PkgInstallComponent):
@ -382,6 +391,7 @@ class ProgramRuntime(ComponentBase, RuntimeComponent):
fn = self.starttracereader.trace_fn
LOG.info("Deleting trace file %s" % (fn))
unlink(fn)
return killedam
class PythonRuntime(ProgramRuntime):
@ -392,7 +402,7 @@ class PythonRuntime(ProgramRuntime):
return None
def restart(self):
return None
return 0
def _was_installed(self):
parent_result = ProgramRuntime._was_installed(self)
@ -403,3 +413,20 @@ class PythonRuntime(ProgramRuntime):
return False
else:
return True
class NullRuntime(ComponentBase, RuntimeComponent):
def __init__(self, component_name, *args, **kargs):
ComponentBase.__init__(self, component_name, *args, **kargs)
def start(self):
return 0
def stop(self):
return 0
def status(self):
return None
def restart(self):
return 0

@ -67,9 +67,6 @@ class DBInstaller(PkgInstallComponent):
PkgInstallComponent.__init__(self, TYPE, *args, **kargs)
self.runtime = DBRuntime(*args, **kargs)
def _get_download_location(self):
return (None, None)
def _get_param_map(self, fn=None):
#this dictionary will be used for parameter replacement
#in pre-install and post-install sections
@ -137,12 +134,13 @@ class DBRuntime(ComponentBase, RuntimeComponent):
if(self.status().find('stop') == -1):
stopcmd = self._gettypeactions('stop', StopException)
execute(*stopcmd, run_as_root=True)
return None
return 1
return 0
def restart(self):
restartcmd = self._gettypeactions('restart', RestartException)
execute(*restartcmd, run_as_root=True)
return None
return 1
def status(self):
statuscmd = self._gettypeactions('status', StatusException)

@ -73,9 +73,13 @@ class GlanceInstaller(PythonInstallComponent):
self.brch = self.cfg.get("git", "glance_branch")
self.cfgdir = joinpths(self.appdir, CONFIG_ACTUAL_DIR)
def _get_download_location(self):
#where we get glance from
return (self.gitloc, self.brch)
def _get_download_locations(self):
places = PythonInstallComponent._get_download_locations(self)
places.append({
'uri': self.gitloc,
'branch': self.brch,
})
return places
def _get_config_files(self):
#these are the config files we will be adjusting

@ -15,34 +15,27 @@
import Logger
import Util
#TODO fix these
from Component import (ComponentBase, RuntimeComponent,
UninstallComponent, InstallComponent)
from Component import (PythonUninstallComponent,
PythonInstallComponent,
RuntimeComponent, ComponentBase, NullRuntime)
LOG = Logger.getLogger("install.horizon")
TYPE = Util.HORIZON
class HorizonTraceWriter():
def __init__(self, root):
pass
class HorizonTraceReader():
def __init__(self, root):
pass
class HorizonUninstaller(UninstallComponent):
class HorizonUninstaller(PythonUninstallComponent):
def __init__(self, *args, **kargs):
pass
PythonUninstallComponent.__init__(self, TYPE, *args, **kargs)
class HorizonInstaller(InstallComponent):
class HorizonInstaller(PythonInstallComponent):
def __init__(self, *args, **kargs):
pass
PythonInstallComponent.__init__(self, TYPE, *args, **kargs)
class HorizonRuntime(RuntimeComponent):
class HorizonRuntime(NullRuntime):
def __init__(self, *args, **kargs):
pass
NullRuntime.__init__(self, TYPE, *args, **kargs)

@ -63,8 +63,13 @@ class KeystoneInstaller(PythonInstallComponent):
self.cfgdir = joinpths(self.appdir, CONFIG_DIR)
self.bindir = joinpths(self.appdir, BIN_DIR)
def _get_download_location(self):
return (self.gitloc, self.brch)
def _get_download_locations(self):
places = PythonInstallComponent._get_download_locations(self)
places.append({
'uri': self.gitloc,
'branch': self.brch,
})
return places
def post_install(self):
parent_result = PythonInstallComponent.post_install(self)

@ -0,0 +1,52 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import Logger
import Util
#TODO fix these
from Component import (PythonUninstallComponent,
PythonInstallComponent,
NullRuntime)
LOG = Logger.getLogger("install.keystone.client")
TYPE = Util.KEYSTONE_CLIENT
class KeyStoneClientUninstaller(PythonUninstallComponent):
def __init__(self, *args, **kargs):
PythonUninstallComponent.__init__(self, TYPE, *args, **kargs)
class KeyStoneClientInstaller(PythonInstallComponent):
def __init__(self, *args, **kargs):
PythonInstallComponent.__init__(self, TYPE, *args, **kargs)
self.gitloc = self.cfg.get("git", "keystoneclient_repo")
self.brch = self.cfg.get("git", "keystoneclient_branch")
def _get_download_locations(self):
places = PythonInstallComponent._get_download_locations(self)
places.append({
'uri': self.gitloc,
'branch': self.brch,
})
return places
class KeyStoneClientRuntime(NullRuntime):
def __init__(self, *args, **kargs):
NullRuntime.__init__(self, TYPE, *args, **kargs)

@ -50,9 +50,6 @@ class RabbitInstaller(PkgInstallComponent):
PkgInstallComponent.__init__(self, TYPE, *args, **kargs)
self.runtime = RabbitRuntime(*args, **kargs)
def _get_download_location(self):
return (None, None)
def _setup_pw(self):
passwd = self.cfg.getpw("passwords", "rabbit")
cmd = PWD_CMD + [passwd]

@ -60,11 +60,12 @@ QUANTUM = "quantum"
SWIFT = "swift"
HORIZON = "horizon"
KEYSTONE = "keystone"
KEYSTONE_CLIENT = 'keystone-client'
DB = "db"
RABBIT = "rabbit"
COMPONENT_NAMES = [NOVA, GLANCE, QUANTUM,
SWIFT, HORIZON, KEYSTONE,
DB, RABBIT]
DB, RABBIT, KEYSTONE_CLIENT]
#ordering of install (lower priority means earlier)
NAMES_PRIORITY = {
@ -75,6 +76,7 @@ NAMES_PRIORITY = {
QUANTUM: 4,
NOVA: 5,
SWIFT: 6,
KEYSTONE_CLIENT: 6,
HORIZON: 7,
}
@ -83,12 +85,13 @@ NAMES_PRIORITY = {
#map is listed here...
COMPONENT_DEPENDENCIES = {
DB: [],
KEYSTONE_CLIENT: [],
RABBIT: [],
GLANCE: [KEYSTONE, DB],
KEYSTONE: [DB],
NOVA: [KEYSTONE, GLANCE, DB, RABBIT],
SWIFT: [],
HORIZON: [],
HORIZON: [KEYSTONE_CLIENT],
QUANTUM: [],
}
@ -137,6 +140,8 @@ PIP_MAP = {
],
SWIFT:
[],
KEYSTONE_CLIENT:
[],
DB:
[],
RABBIT:
@ -171,6 +176,10 @@ PKG_MAP = {
joinpths(STACK_CONFIG_DIR, "pkgs", "general.json"),
joinpths(STACK_CONFIG_DIR, "pkgs", 'swift.json'),
],
KEYSTONE_CLIENT:
[
joinpths(STACK_CONFIG_DIR, "pkgs", "keystone-client.json"),
],
DB:
[
joinpths(STACK_CONFIG_DIR, "pkgs", 'db.json'),

34
stack

@ -26,7 +26,7 @@ import Options
#TODO fix these
from Util import (welcome, rcf8222date, determine_os,
prioritize_components, resolve_dependencies)
from Util import (NOVA, GLANCE, QUANTUM, SWIFT, KEYSTONE, HORIZON, DB, RABBIT,
from Util import (NOVA, GLANCE, QUANTUM, SWIFT, KEYSTONE, HORIZON, DB, RABBIT, KEYSTONE_CLIENT,
INSTALL, UNINSTALL, START, STOP,
ACTIONS, COMPONENT_NAMES, NAMES_PRIORITY,
UBUNTU11, RHEL6,
@ -44,6 +44,7 @@ import Swift
import Db
import Rabbit
import Config
import KeystoneClient
LOG = Logger.getLogger("install")
@ -58,6 +59,7 @@ ACTION_CLASSES = {
KEYSTONE: Keystone.KeystoneInstaller,
DB: Db.DBInstaller,
RABBIT: Rabbit.RabbitInstaller,
KEYSTONE_CLIENT: KeystoneClient.KeyStoneClientInstaller,
},
UNINSTALL: {
NOVA: Nova.NovaUninstaller,
@ -68,6 +70,7 @@ ACTION_CLASSES = {
KEYSTONE: Keystone.KeystoneUninstaller,
DB: Db.DBUninstaller,
RABBIT: Rabbit.RabbitUninstaller,
KEYSTONE_CLIENT: KeystoneClient.KeyStoneClientUninstaller,
},
START: {
NOVA: Nova.NovaRuntime,
@ -78,6 +81,7 @@ ACTION_CLASSES = {
KEYSTONE: Keystone.KeystoneRuntime,
DB: Db.DBRuntime,
RABBIT: Rabbit.RabbitRuntime,
KEYSTONE_CLIENT: KeystoneClient.KeyStoneClientRuntime,
},
STOP: {
NOVA: Nova.NovaRuntime,
@ -88,6 +92,7 @@ ACTION_CLASSES = {
KEYSTONE: Keystone.KeystoneRuntime,
DB: Db.DBRuntime,
RABBIT: Rabbit.RabbitRuntime,
KEYSTONE_CLIENT: KeystoneClient.KeyStoneClientRuntime,
},
}
@ -133,13 +138,16 @@ def print_cfgs(cfg, action):
LOG.info("Passwords:")
map_print(passwords_gotten)
if(len(full_cfgs)):
#TOD
#better way to do this?? (ie a list difference?)
filtered_mp = dict()
for key in full_cfgs.keys():
if(key in passwords_gotten):
continue
filtered_mp[key] = full_cfgs.get(key)
LOG.info("Configs:")
map_print(filtered_mp)
if(len(filtered_mp)):
LOG.info("Configs:")
map_print(filtered_mp)
if(len(db_dsns)):
LOG.info("Data source names:")
map_print(db_dsns)
@ -161,9 +169,11 @@ def runner(action_name, component_set, distro, root_dir, program_args):
instance = klass(components=component_set, distro=distro, pkg=pkg_manager, cfg=config, root=root_dir)
if(action_name == INSTALL):
LOG.info("Downloading %s." % (c))
instance.download()
am_downloaded = instance.download()
LOG.info("Performed %s downloads." % (str(am_downloaded)))
LOG.info("Configuring %s." % (c))
instance.configure()
am_configured = instance.configure()
LOG.info("Configuring %s files." % (str(am_configured)))
LOG.info("Pre-installing %s." % (c))
instance.pre_install()
LOG.info("Installing %s." % (c))
@ -178,7 +188,8 @@ def runner(action_name, component_set, distro, root_dir, program_args):
elif(action_name == STOP):
try:
LOG.info("Stopping %s." % (c))
instance.stop()
stop_am = instance.stop()
LOG.info("Stopped %s applications." % (str(stop_am)))
LOG.info("Finished stop of %s" % (c))
except NoTraceException, e:
if(force):
@ -187,10 +198,13 @@ def runner(action_name, component_set, distro, root_dir, program_args):
raise
elif(action_name == START):
LOG.info("Starting %s." % (c))
trace_locs = instance.start() or list()
LOG.info("Finished start of %s - check [%s] for traces of what happened." % (c, ", ".join(trace_locs)))
if(trace_locs):
results = results + trace_locs
start_info = instance.start()
if(type(start_info) == list):
LOG.info("Check [%s] for traces of what happened." % (", ".join(start_info)))
results = results + start_info
elif(type(start_info) == int):
LOG.info("Started %s applications." % (str(start_info)))
LOG.info("Finished start of %s." % (c))
elif(action_name == UNINSTALL):
try:
LOG.info("Unconfiguring %s." % (c))