Updated null runtime to be renamed empty runtime (which is more appropriate)
Adjusted the changes from that and added in runtime constants for runtimes to use to know if stopped/started/??
This commit is contained in:
@@ -27,9 +27,16 @@ from devstack.runners import screen
|
|||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger("devstack.component")
|
LOG = logging.getLogger("devstack.component")
|
||||||
|
|
||||||
|
#how we actually setup and unsetup python
|
||||||
PY_INSTALL = ['python', 'setup.py', 'develop']
|
PY_INSTALL = ['python', 'setup.py', 'develop']
|
||||||
PY_UNINSTALL = ['python', 'setup.py', 'develop', '--uninstall']
|
PY_UNINSTALL = ['python', 'setup.py', 'develop', '--uninstall']
|
||||||
|
|
||||||
|
#runtime status constants (return by runtime status)
|
||||||
|
STATUS_UNKNOWN = "unknown"
|
||||||
|
STATUS_STARTED = "started"
|
||||||
|
STATUS_STOPPED = "stopped"
|
||||||
|
|
||||||
|
|
||||||
class ComponentBase(object):
|
class ComponentBase(object):
|
||||||
def __init__(self, component_name, **kargs):
|
def __init__(self, component_name, **kargs):
|
||||||
@@ -428,7 +435,7 @@ class ProgramRuntime(ComponentBase):
|
|||||||
return killedam
|
return killedam
|
||||||
|
|
||||||
def status(self):
|
def status(self):
|
||||||
return None
|
return STATUS_UNKNOWN
|
||||||
|
|
||||||
def restart(self):
|
def restart(self):
|
||||||
return 0
|
return 0
|
||||||
@@ -439,7 +446,7 @@ class PythonRuntime(ProgramRuntime):
|
|||||||
ProgramRuntime.__init__(self, component_name, *args, **kargs)
|
ProgramRuntime.__init__(self, component_name, *args, **kargs)
|
||||||
|
|
||||||
def status(self):
|
def status(self):
|
||||||
return None
|
return STATUS_UNKNOWN
|
||||||
|
|
||||||
def restart(self):
|
def restart(self):
|
||||||
return 0
|
return 0
|
||||||
@@ -455,7 +462,7 @@ class PythonRuntime(ProgramRuntime):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
class NullRuntime(ComponentBase):
|
class EmptyRuntime(ComponentBase):
|
||||||
def __init__(self, component_name, *args, **kargs):
|
def __init__(self, component_name, *args, **kargs):
|
||||||
ComponentBase.__init__(self, component_name, *args, **kargs)
|
ComponentBase.__init__(self, component_name, *args, **kargs)
|
||||||
|
|
||||||
@@ -472,7 +479,7 @@ class NullRuntime(ComponentBase):
|
|||||||
return 0
|
return 0
|
||||||
|
|
||||||
def status(self):
|
def status(self):
|
||||||
return None
|
return STATUS_UNKNOWN
|
||||||
|
|
||||||
def restart(self):
|
def restart(self):
|
||||||
return 0
|
return 0
|
||||||
|
|||||||
@@ -103,9 +103,9 @@ class DBInstaller(comp.PkgInstallComponent):
|
|||||||
return parent_result
|
return parent_result
|
||||||
|
|
||||||
|
|
||||||
class DBRuntime(comp.NullRuntime):
|
class DBRuntime(comp.EmptyRuntime):
|
||||||
def __init__(self, *args, **kargs):
|
def __init__(self, *args, **kargs):
|
||||||
comp.NullRuntime.__init__(self, TYPE, *args, **kargs)
|
comp.EmptyRuntime.__init__(self, TYPE, *args, **kargs)
|
||||||
self.tracereader = tr.TraceReader(self.tracedir, tr.IN_TRACE)
|
self.tracereader = tr.TraceReader(self.tracedir, tr.IN_TRACE)
|
||||||
|
|
||||||
def _gettypeactions(self, act, exception_cls):
|
def _gettypeactions(self, act, exception_cls):
|
||||||
@@ -122,17 +122,20 @@ class DBRuntime(comp.NullRuntime):
|
|||||||
return typeactions.get(act)
|
return typeactions.get(act)
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
if(self.status().find('start') == -1):
|
if(self.status() == comp.STATUS_STOPPED):
|
||||||
startcmd = self._gettypeactions('start', excp.StartException)
|
startcmd = self._gettypeactions('start', excp.StartException)
|
||||||
sh.execute(*startcmd, run_as_root=True)
|
sh.execute(*startcmd, run_as_root=True)
|
||||||
return None
|
return 1
|
||||||
|
else:
|
||||||
|
return 0
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
if(self.status().find('stop') == -1):
|
if(self.status() == comp.STATUS_STARTED):
|
||||||
stopcmd = self._gettypeactions('stop', excp.StopException)
|
stopcmd = self._gettypeactions('stop', excp.StopException)
|
||||||
sh.execute(*stopcmd, run_as_root=True)
|
sh.execute(*stopcmd, run_as_root=True)
|
||||||
return 1
|
return 1
|
||||||
return 0
|
else:
|
||||||
|
return 0
|
||||||
|
|
||||||
def restart(self):
|
def restart(self):
|
||||||
restartcmd = self._gettypeactions('restart', excp.RestartException)
|
restartcmd = self._gettypeactions('restart', excp.RestartException)
|
||||||
@@ -141,8 +144,13 @@ class DBRuntime(comp.NullRuntime):
|
|||||||
|
|
||||||
def status(self):
|
def status(self):
|
||||||
statuscmd = self._gettypeactions('status', excp.StatusException)
|
statuscmd = self._gettypeactions('status', excp.StatusException)
|
||||||
(sysout, _) = sh.execute(*statuscmd, run_as_root=True)
|
(sysout, _) = sh.execute(*statuscmd)
|
||||||
return sysout.strip()
|
if(sysout.find("start/running") != -1):
|
||||||
|
return comp.STATUS_STARTED
|
||||||
|
elif(sysout.find("stop/waiting") != -1):
|
||||||
|
return comp.STATUS_STOPPED
|
||||||
|
else:
|
||||||
|
return comp.STATUS_UNKNOWN
|
||||||
|
|
||||||
|
|
||||||
def drop_db(cfg, dbname):
|
def drop_db(cfg, dbname):
|
||||||
|
|||||||
@@ -49,21 +49,21 @@ APP_OPTIONS = {
|
|||||||
'glance-registry': ['--config-file', sh.joinpths('%ROOT%', "etc", REG_CONF)]
|
'glance-registry': ['--config-file', sh.joinpths('%ROOT%', "etc", REG_CONF)]
|
||||||
}
|
}
|
||||||
|
|
||||||
#subdirs of the checkout
|
#subdirs of the downloaded
|
||||||
CONFIG_ACTUAL_DIR = 'etc'
|
CONFIG_DIR = 'etc'
|
||||||
BIN_DIR = 'bin'
|
BIN_DIR = 'bin'
|
||||||
|
|
||||||
|
|
||||||
class GlanceUninstaller(comp.PythonUninstallComponent):
|
class GlanceUninstaller(comp.PythonUninstallComponent):
|
||||||
def __init__(self, *args, **kargs):
|
def __init__(self, *args, **kargs):
|
||||||
comp.PythonUninstallComponent.__init__(self, TYPE, *args, **kargs)
|
comp.PythonUninstallComponent.__init__(self, TYPE, *args, **kargs)
|
||||||
self.cfgdir = sh.joinpths(self.appdir, CONFIG_ACTUAL_DIR)
|
self.cfgdir = sh.joinpths(self.appdir, CONFIG_DIR)
|
||||||
|
|
||||||
|
|
||||||
class GlanceRuntime(comp.PythonRuntime):
|
class GlanceRuntime(comp.PythonRuntime):
|
||||||
def __init__(self, *args, **kargs):
|
def __init__(self, *args, **kargs):
|
||||||
comp.PythonRuntime.__init__(self, TYPE, *args, **kargs)
|
comp.PythonRuntime.__init__(self, TYPE, *args, **kargs)
|
||||||
self.cfgdir = sh.joinpths(self.appdir, CONFIG_ACTUAL_DIR)
|
self.cfgdir = sh.joinpths(self.appdir, CONFIG_DIR)
|
||||||
|
|
||||||
def _get_apps_to_start(self):
|
def _get_apps_to_start(self):
|
||||||
apps = list()
|
apps = list()
|
||||||
@@ -89,7 +89,7 @@ class GlanceInstaller(comp.PythonInstallComponent):
|
|||||||
comp.PythonInstallComponent.__init__(self, TYPE, *args, **kargs)
|
comp.PythonInstallComponent.__init__(self, TYPE, *args, **kargs)
|
||||||
self.git_loc = self.cfg.get("git", "glance_repo")
|
self.git_loc = self.cfg.get("git", "glance_repo")
|
||||||
self.git_branch = self.cfg.get("git", "glance_branch")
|
self.git_branch = self.cfg.get("git", "glance_branch")
|
||||||
self.cfgdir = sh.joinpths(self.appdir, CONFIG_ACTUAL_DIR)
|
self.cfgdir = sh.joinpths(self.appdir, CONFIG_DIR)
|
||||||
|
|
||||||
def _get_download_locations(self):
|
def _get_download_locations(self):
|
||||||
places = comp.PythonInstallComponent._get_download_locations(self)
|
places = comp.PythonInstallComponent._get_download_locations(self)
|
||||||
|
|||||||
@@ -35,6 +35,8 @@ HORIZON_APACHE_TGT = ['/', 'etc', 'apache2', 'sites-enabled', '000-default']
|
|||||||
CONFIGS = [HORIZON_PY_CONF, HORIZON_APACHE_CONF]
|
CONFIGS = [HORIZON_PY_CONF, HORIZON_APACHE_CONF]
|
||||||
DB_SYNC_CMD = ['python', 'manage.py', 'syncdb']
|
DB_SYNC_CMD = ['python', 'manage.py', 'syncdb']
|
||||||
BLACKHOLE_DIR = '.blackhole'
|
BLACKHOLE_DIR = '.blackhole'
|
||||||
|
|
||||||
|
#hopefully this will be distro independent ??
|
||||||
APACHE_RESTART_CMD = ['service', 'apache2', 'restart']
|
APACHE_RESTART_CMD = ['service', 'apache2', 'restart']
|
||||||
|
|
||||||
LOG = logging.getLogger("devstack.components.horizon")
|
LOG = logging.getLogger("devstack.components.horizon")
|
||||||
@@ -111,11 +113,11 @@ class HorizonInstaller(comp.PythonInstallComponent):
|
|||||||
self.tracewriter.touch_file(sh.joinpths(quantum_dir, 'client.py'))
|
self.tracewriter.touch_file(sh.joinpths(quantum_dir, 'client.py'))
|
||||||
|
|
||||||
def post_install(self):
|
def post_install(self):
|
||||||
parent_res = comp.PythonInstallComponent.post_install(self)
|
parent_result = comp.PythonInstallComponent.post_install(self)
|
||||||
self._fake_quantum()
|
self._fake_quantum()
|
||||||
self._sync_db()
|
self._sync_db()
|
||||||
self._setup_blackhole()
|
self._setup_blackhole()
|
||||||
return parent_res
|
return parent_result
|
||||||
|
|
||||||
def _get_apache_user(self):
|
def _get_apache_user(self):
|
||||||
#TODO will this be the right user?
|
#TODO will this be the right user?
|
||||||
@@ -138,6 +140,6 @@ class HorizonInstaller(comp.PythonInstallComponent):
|
|||||||
return mp
|
return mp
|
||||||
|
|
||||||
|
|
||||||
class HorizonRuntime(comp.NullRuntime):
|
class HorizonRuntime(comp.EmptyRuntime):
|
||||||
def __init__(self, *args, **kargs):
|
def __init__(self, *args, **kargs):
|
||||||
comp.NullRuntime.__init__(self, TYPE, *args, **kargs)
|
comp.EmptyRuntime.__init__(self, TYPE, *args, **kargs)
|
||||||
|
|||||||
@@ -44,6 +44,6 @@ class KeyStoneClientInstaller(comp.PythonInstallComponent):
|
|||||||
return places
|
return places
|
||||||
|
|
||||||
|
|
||||||
class KeyStoneClientRuntime(comp.NullRuntime):
|
class KeyStoneClientRuntime(comp.EmptyRuntime):
|
||||||
def __init__(self, *args, **kargs):
|
def __init__(self, *args, **kargs):
|
||||||
comp.NullRuntime.__init__(self, TYPE, *args, **kargs)
|
comp.EmptyRuntime.__init__(self, TYPE, *args, **kargs)
|
||||||
|
|||||||
@@ -51,6 +51,6 @@ class NovaClientInstaller(comp.PythonInstallComponent):
|
|||||||
return mp
|
return mp
|
||||||
|
|
||||||
|
|
||||||
class NovaClientRuntime(comp.NullRuntime):
|
class NovaClientRuntime(comp.EmptyRuntime):
|
||||||
def __init__(self, *args, **kargs):
|
def __init__(self, *args, **kargs):
|
||||||
comp.NullRuntime.__init__(self, TYPE, *args, **kargs)
|
comp.EmptyRuntime.__init__(self, TYPE, *args, **kargs)
|
||||||
|
|||||||
@@ -43,6 +43,6 @@ class OpenstackXInstaller(comp.PythonInstallComponent):
|
|||||||
return places
|
return places
|
||||||
|
|
||||||
|
|
||||||
class OpenstackXRuntime(comp.NullRuntime):
|
class OpenstackXRuntime(comp.EmptyRuntime):
|
||||||
def __init__(self, *args, **kargs):
|
def __init__(self, *args, **kargs):
|
||||||
comp.NullRuntime.__init__(self, TYPE, *args, **kargs)
|
comp.EmptyRuntime.__init__(self, TYPE, *args, **kargs)
|
||||||
|
|||||||
@@ -56,6 +56,6 @@ class QuantumInstaller(object):
|
|||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
|
|
||||||
class QuantumRuntime(comp.NullRuntime):
|
class QuantumRuntime(comp.EmptyRuntime):
|
||||||
def __init__(self, *args, **kargs):
|
def __init__(self, *args, **kargs):
|
||||||
comp.NullRuntime.__init__(self, TYPE, *args, **kargs)
|
comp.EmptyRuntime.__init__(self, TYPE, *args, **kargs)
|
||||||
|
|||||||
@@ -58,49 +58,57 @@ class RabbitInstaller(comp.PkgInstallComponent):
|
|||||||
return parent_result
|
return parent_result
|
||||||
|
|
||||||
|
|
||||||
class RabbitRuntime(comp.NullRuntime):
|
class RabbitRuntime(comp.EmptyRuntime):
|
||||||
def __init__(self, *args, **kargs):
|
def __init__(self, *args, **kargs):
|
||||||
comp.NullRuntime.__init__(self, TYPE, *args, **kargs)
|
comp.EmptyRuntime.__init__(self, TYPE, *args, **kargs)
|
||||||
self.tracereader = tr.TraceReader(self.tracedir, tr.IN_TRACE)
|
self.tracereader = tr.TraceReader(self.tracedir, tr.IN_TRACE)
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
pkgsinstalled = self.tracereader.packages_installed()
|
if(self.status() == comp.STATUS_STOPPED):
|
||||||
if(len(pkgsinstalled) == 0):
|
|
||||||
msg = "Can not start %s since it was not installed" % (TYPE)
|
|
||||||
raise excp.StartException(msg)
|
|
||||||
if(self.status().find('start') == -1):
|
|
||||||
self._run_cmd(START_CMD)
|
self._run_cmd(START_CMD)
|
||||||
return None
|
return 1
|
||||||
|
else:
|
||||||
|
return 0
|
||||||
|
|
||||||
def status(self):
|
def status(self):
|
||||||
pkgsinstalled = self.tracereader.packages_installed()
|
pkgsinstalled = self.tracereader.packages_installed()
|
||||||
if(len(pkgsinstalled) == 0):
|
if(len(pkgsinstalled) == 0):
|
||||||
msg = "Can not check the status of %s since it was not installed" % (TYPE)
|
msg = "Can not check the status of %s since it was not installed" % (TYPE)
|
||||||
raise excp.StatusException(msg)
|
raise excp.StatusException(msg)
|
||||||
(sysout, _) = sh.execute(*STATUS_CMD, run_as_root=True)
|
#this has got to be the worst status output
|
||||||
return sysout.strip().lower()
|
#i have ever seen (its like a weird mix json)
|
||||||
|
(sysout, _) = sh.execute(*STATUS_CMD,
|
||||||
|
run_as_root=True,
|
||||||
|
check_exit_code=False)
|
||||||
|
if(sysout.find('nodedown') != -1 or sysout.find("unable to connect to node") != -1):
|
||||||
|
return comp.STATUS_STOPPED
|
||||||
|
elif(sysout.find('running_applications') != -1):
|
||||||
|
return comp.STATUS_STARTED
|
||||||
|
else:
|
||||||
|
return comp.STATUS_UNKNOWN
|
||||||
|
|
||||||
def _run_cmd(self, cmd):
|
def _run_cmd(self, cmd):
|
||||||
if(self.distro == settings.UBUNTU11):
|
if(self.distro == settings.UBUNTU11):
|
||||||
|
#this seems to fix one of the bugs with rabbit mq starting and stopping
|
||||||
|
#not cool, possibly connected to the following bugs:
|
||||||
|
#https://bugs.launchpad.net/ubuntu/+source/rabbitmq-server/+bug/878597
|
||||||
|
#https://bugs.launchpad.net/ubuntu/+source/rabbitmq-server/+bug/878600
|
||||||
with TemporaryFile() as f:
|
with TemporaryFile() as f:
|
||||||
sh.execute(*cmd, run_as_root=True,
|
sh.execute(*cmd, run_as_root=True,
|
||||||
stdout_fh=f, stderr_fh=f)
|
stdout_fh=f, stderr_fh=f)
|
||||||
else:
|
else:
|
||||||
sh.execute(*cmd, run_as_root=True)
|
sh.execute(*cmd, run_as_root=True)
|
||||||
|
|
||||||
|
return sh.execute(*cmd, run_as_root=True)
|
||||||
|
|
||||||
|
|
||||||
def restart(self):
|
def restart(self):
|
||||||
pkgsinstalled = self.tracereader.packages_installed()
|
|
||||||
if(len(pkgsinstalled) == 0):
|
|
||||||
msg = "Can not check the status of %s since it was not installed" % (TYPE)
|
|
||||||
raise excp.RestartException(msg)
|
|
||||||
self._run_cmd(RESTART_CMD)
|
self._run_cmd(RESTART_CMD)
|
||||||
return None
|
return 1
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
pkgsinstalled = self.tracereader.packages_installed()
|
if(self.status() == comp.STATUS_STARTED):
|
||||||
if(len(pkgsinstalled) == 0):
|
|
||||||
msg = "Can not stop %s since it was not installed" % (TYPE)
|
|
||||||
raise excp.StopException(msg)
|
|
||||||
if(self.status().find('stop') == -1):
|
|
||||||
self._run_cmd(STOP_CMD)
|
self._run_cmd(STOP_CMD)
|
||||||
return None
|
return 1
|
||||||
|
else:
|
||||||
|
return 0
|
||||||
|
|||||||
@@ -57,6 +57,6 @@ class SwiftInstaller(object):
|
|||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
|
|
||||||
class SwiftRuntime(comp.NullRuntime):
|
class SwiftRuntime(comp.EmptyRuntime):
|
||||||
def __init__(self, *args, **kargs):
|
def __init__(self, *args, **kargs):
|
||||||
comp.NullRuntime.__init__(self, TYPE, *args, **kargs)
|
comp.EmptyRuntime.__init__(self, TYPE, *args, **kargs)
|
||||||
|
|||||||
@@ -145,6 +145,8 @@ class Image(object):
|
|||||||
self._register()
|
self._register()
|
||||||
finally:
|
finally:
|
||||||
self._cleanup()
|
self._cleanup()
|
||||||
|
else:
|
||||||
|
LOG.warn("You already seem to have image named %s, skipping" % (possible_name))
|
||||||
|
|
||||||
|
|
||||||
class ImageRegistry:
|
class ImageRegistry:
|
||||||
@@ -212,10 +214,12 @@ class ImageCreationService:
|
|||||||
|
|
||||||
#install them in glance
|
#install them in glance
|
||||||
am_installed = 0
|
am_installed = 0
|
||||||
for url in urls:
|
if(urls):
|
||||||
try:
|
LOG.info("Attempting to download & extract and upload (%s) images." % (", ".join(urls)))
|
||||||
Image(url, token).install()
|
for url in urls:
|
||||||
am_installed += 1
|
try:
|
||||||
except (IOError, tarfile.TarError):
|
Image(url, token).install()
|
||||||
LOG.exception('Installing "%s" failed', url)
|
am_installed += 1
|
||||||
|
except (IOError, tarfile.TarError):
|
||||||
|
LOG.exception('Installing "%s" failed', url)
|
||||||
return am_installed
|
return am_installed
|
||||||
|
|||||||
Reference in New Issue
Block a user