Renamed constants to settings which is more appropriate.
Had a little fun with figlet :-)
This commit is contained in:
		| @@ -13,17 +13,16 @@ | |||||||
| #    License for the specific language governing permissions and limitations | #    License for the specific language governing permissions and limitations | ||||||
| #    under the License. | #    under the License. | ||||||
|  |  | ||||||
| import os |  | ||||||
|  |  | ||||||
| from devstack import constants as c |  | ||||||
| from devstack import downloader as down | from devstack import downloader as down | ||||||
| from devstack import exceptions as excp | from devstack import exceptions as excp | ||||||
| from devstack import log as logging | from devstack import log as logging | ||||||
| from devstack import pip | from devstack import pip | ||||||
| from devstack import runner | from devstack import runner | ||||||
|  | from devstack import settings | ||||||
| from devstack import shell as sh | from devstack import shell as sh | ||||||
| from devstack import trace as tr | from devstack import trace as tr | ||||||
| from devstack import utils | from devstack import utils | ||||||
|  |  | ||||||
| from devstack.runners import fork | from devstack.runners import fork | ||||||
| from devstack.runners import screen | from devstack.runners import screen | ||||||
|  |  | ||||||
| @@ -175,7 +174,7 @@ class PkgInstallComponent(ComponentBase, InstallComponent): | |||||||
|         return sh.joinpths(self.cfgdir, name) |         return sh.joinpths(self.cfgdir, name) | ||||||
|  |  | ||||||
|     def _get_source_config_name(self, name): |     def _get_source_config_name(self, name): | ||||||
|         return sh.joinpths(c.STACK_CONFIG_DIR, self.component_name, name) |         return sh.joinpths(settings.STACK_CONFIG_DIR, self.component_name, name) | ||||||
|  |  | ||||||
|     def _configure_files(self): |     def _configure_files(self): | ||||||
|         configs = self._get_config_files() |         configs = self._get_config_files() | ||||||
| @@ -187,7 +186,7 @@ class PkgInstallComponent(ComponentBase, InstallComponent): | |||||||
|                 sourcefn = self._get_source_config_name(fn) |                 sourcefn = self._get_source_config_name(fn) | ||||||
|                 tgtfn = self._get_target_config_name(fn) |                 tgtfn = self._get_target_config_name(fn) | ||||||
|                 #ensure directory is there (if not created previously) |                 #ensure directory is there (if not created previously) | ||||||
|                 self.tracewriter.make_dir(os.path.dirname(tgtfn)) |                 self.tracewriter.make_dir(sh.dirname(tgtfn)) | ||||||
|                 #now configure it |                 #now configure it | ||||||
|                 LOG.info("Configuring template file %s" % (sourcefn)) |                 LOG.info("Configuring template file %s" % (sourcefn)) | ||||||
|                 contents = sh.load_file(sourcefn) |                 contents = sh.load_file(sourcefn) | ||||||
| @@ -234,11 +233,8 @@ class PythonInstallComponent(PkgInstallComponent): | |||||||
|             stdout = '' |             stdout = '' | ||||||
|         if(stderr == None): |         if(stderr == None): | ||||||
|             stderr = '' |             stderr = '' | ||||||
|         combined_output = "===STDOUT===" + os.linesep |         combined = ["===STDOUT===", str(stdout), "===STDERR===", str(stderr)] | ||||||
|         combined_output += stdout + os.linesep |         return utils.joinlinesep(*combined) | ||||||
|         combined_output += "===STDERR===" + os.linesep |  | ||||||
|         combined_output += stderr + os.linesep |  | ||||||
|         return combined_output |  | ||||||
|  |  | ||||||
|     def _format_trace_name(self, name): |     def _format_trace_name(self, name): | ||||||
|         return "%s-%s" % (tr.PY_TRACE, name) |         return "%s-%s" % (tr.PY_TRACE, name) | ||||||
|   | |||||||
| @@ -14,7 +14,7 @@ | |||||||
| #    under the License. | #    under the License. | ||||||
|  |  | ||||||
| from devstack import component as comp | from devstack import component as comp | ||||||
| from devstack import constants | from devstack import settings | ||||||
| from devstack import exceptions as excp | from devstack import exceptions as excp | ||||||
| from devstack import log as logging | from devstack import log as logging | ||||||
| from devstack import shell as sh | from devstack import shell as sh | ||||||
| @@ -23,7 +23,7 @@ from devstack import utils | |||||||
|  |  | ||||||
|  |  | ||||||
| LOG = logging.getLogger("devstack.components.db") | LOG = logging.getLogger("devstack.components.db") | ||||||
| TYPE = constants.DB | TYPE = settings.DB | ||||||
| MYSQL = 'mysql' | MYSQL = 'mysql' | ||||||
| DB_ACTIONS = { | DB_ACTIONS = { | ||||||
|     MYSQL: { |     MYSQL: { | ||||||
|   | |||||||
| @@ -17,7 +17,7 @@ import io | |||||||
|  |  | ||||||
| from devstack import cfg | from devstack import cfg | ||||||
| from devstack import component as comp | from devstack import component as comp | ||||||
| from devstack import constants | from devstack import settings | ||||||
| from devstack import log as logging | from devstack import log as logging | ||||||
| from devstack import shell as sh | from devstack import shell as sh | ||||||
| from devstack.components import db | from devstack.components import db | ||||||
| @@ -26,7 +26,7 @@ from devstack.image import creator | |||||||
| LOG = logging.getLogger("devstack.components.glance") | LOG = logging.getLogger("devstack.components.glance") | ||||||
|  |  | ||||||
| #naming + config files | #naming + config files | ||||||
| TYPE = constants.GLANCE | TYPE = settings.GLANCE | ||||||
| API_CONF = "glance-api.conf" | API_CONF = "glance-api.conf" | ||||||
| REG_CONF = "glance-registry.conf" | REG_CONF = "glance-registry.conf" | ||||||
| CONFIGS = [API_CONF, REG_CONF] | CONFIGS = [API_CONF, REG_CONF] | ||||||
|   | |||||||
| @@ -15,11 +15,11 @@ | |||||||
|  |  | ||||||
|  |  | ||||||
| from devstack import component as comp | from devstack import component as comp | ||||||
| from devstack import constants |  | ||||||
| from devstack import log as logging | from devstack import log as logging | ||||||
|  | from devstack import settings | ||||||
| from devstack import shell as sh | from devstack import shell as sh | ||||||
|  |  | ||||||
| TYPE = constants.HORIZON | TYPE = settings.HORIZON | ||||||
|  |  | ||||||
| ROOT_HORIZON = 'horizon' | ROOT_HORIZON = 'horizon' | ||||||
| HORIZON_NAME = 'horizon' | HORIZON_NAME = 'horizon' | ||||||
| @@ -100,7 +100,7 @@ class HorizonInstaller(comp.PythonInstallComponent): | |||||||
|         #Horizon currently imports quantum even if you aren't using it. |         #Horizon currently imports quantum even if you aren't using it. | ||||||
|         #Instead of installing quantum we can create a simple module |         #Instead of installing quantum we can create a simple module | ||||||
|         #that will pass the initial imports. |         #that will pass the initial imports. | ||||||
|         if(constants.QUANTUM in self.all_components): |         if(settings.QUANTUM in self.all_components): | ||||||
|             return |             return | ||||||
|         else: |         else: | ||||||
|             #Make the fake quantum |             #Make the fake quantum | ||||||
| @@ -132,7 +132,7 @@ class HorizonInstaller(comp.PythonInstallComponent): | |||||||
|             mp['HORIZON_DIR'] = self.appdir |             mp['HORIZON_DIR'] = self.appdir | ||||||
|         else: |         else: | ||||||
|             #Enable quantum in dashboard, if requested |             #Enable quantum in dashboard, if requested | ||||||
|             mp['QUANTUM_ENABLED'] = "%s" % (constants.QUANTUM in self.all_components) |             mp['QUANTUM_ENABLED'] = "%s" % (settings.QUANTUM in self.all_components) | ||||||
|             mp['OPENSTACK_HOST'] = self.cfg.get('host', 'ip') |             mp['OPENSTACK_HOST'] = self.cfg.get('host', 'ip') | ||||||
|         return mp |         return mp | ||||||
|  |  | ||||||
|   | |||||||
| @@ -17,15 +17,15 @@ import io | |||||||
|  |  | ||||||
| from devstack import cfg | from devstack import cfg | ||||||
| from devstack import component as comp | from devstack import component as comp | ||||||
| from devstack import constants |  | ||||||
| from devstack import log as logging | from devstack import log as logging | ||||||
|  | from devstack import settings | ||||||
| from devstack import shell as sh | from devstack import shell as sh | ||||||
| from devstack import utils | from devstack import utils | ||||||
| from devstack.components import db | from devstack.components import db | ||||||
|  |  | ||||||
| LOG = logging.getLogger("devstack.components.keystone") | LOG = logging.getLogger("devstack.components.keystone") | ||||||
|  |  | ||||||
| TYPE = constants.KEYSTONE | TYPE = settings.KEYSTONE | ||||||
| ROOT_CONF = "keystone.conf" | ROOT_CONF = "keystone.conf" | ||||||
| CONFIGS = [ROOT_CONF] | CONFIGS = [ROOT_CONF] | ||||||
| BIN_DIR = "bin" | BIN_DIR = "bin" | ||||||
| @@ -81,7 +81,7 @@ class KeystoneInstaller(comp.PythonInstallComponent): | |||||||
|  |  | ||||||
|     def _setup_data(self): |     def _setup_data(self): | ||||||
|         #load the json file which has the keystone setup commands |         #load the json file which has the keystone setup commands | ||||||
|         cmds_pth = sh.joinpths(constants.STACK_CONFIG_DIR, TYPE, MANAGE_JSON_CONF) |         cmds_pth = sh.joinpths(settings.STACK_CONFIG_DIR, TYPE, MANAGE_JSON_CONF) | ||||||
|         cmd_map = utils.load_json(cmds_pth) |         cmd_map = utils.load_json(cmds_pth) | ||||||
|  |  | ||||||
|         #order matters here |         #order matters here | ||||||
| @@ -105,13 +105,13 @@ class KeystoneInstaller(comp.PythonInstallComponent): | |||||||
|         endpoint_cmds = cmd_map.get('endpoints', list()) |         endpoint_cmds = cmd_map.get('endpoints', list()) | ||||||
|         base_cmds.extend(endpoint_cmds) |         base_cmds.extend(endpoint_cmds) | ||||||
|  |  | ||||||
|         if(constants.GLANCE in self.all_components): |         if(settings.GLANCE in self.all_components): | ||||||
|             glance_cmds = cmd_map.get('glance', list()) |             glance_cmds = cmd_map.get('glance', list()) | ||||||
|             base_cmds.extend(glance_cmds) |             base_cmds.extend(glance_cmds) | ||||||
|         if(constants.NOVA in self.all_components): |         if(settings.NOVA in self.all_components): | ||||||
|             nova_cmds = cmd_map.get('nova', list()) |             nova_cmds = cmd_map.get('nova', list()) | ||||||
|             base_cmds.extend(nova_cmds) |             base_cmds.extend(nova_cmds) | ||||||
|         if(constants.SWIFT in self.all_components): |         if(settings.SWIFT in self.all_components): | ||||||
|             swift_cmds = cmd_map.get('swift', list()) |             swift_cmds = cmd_map.get('swift', list()) | ||||||
|             base_cmds.extend(swift_cmds) |             base_cmds.extend(swift_cmds) | ||||||
|  |  | ||||||
|   | |||||||
| @@ -15,10 +15,10 @@ | |||||||
|  |  | ||||||
|  |  | ||||||
| from devstack import component as comp | from devstack import component as comp | ||||||
| from devstack import constants |  | ||||||
| from devstack import log as logging | from devstack import log as logging | ||||||
|  | from devstack import settings | ||||||
|  |  | ||||||
| TYPE = constants.KEYSTONE_CLIENT | TYPE = settings.KEYSTONE_CLIENT | ||||||
| LOG = logging.getLogger("devstack.components.keystone_client") | LOG = logging.getLogger("devstack.components.keystone_client") | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
| @@ -14,8 +14,8 @@ | |||||||
| #    under the License. | #    under the License. | ||||||
|  |  | ||||||
| from devstack import component as comp | from devstack import component as comp | ||||||
| from devstack import constants as co |  | ||||||
| from devstack import log as logging | from devstack import log as logging | ||||||
|  | from devstack import settings | ||||||
| from devstack import shell as sh | from devstack import shell as sh | ||||||
| from devstack.components import nova_conf as nc | from devstack.components import nova_conf as nc | ||||||
|  |  | ||||||
| @@ -27,7 +27,7 @@ CONFIGS = [API_CONF] | |||||||
|  |  | ||||||
| DB_NAME = "nova" | DB_NAME = "nova" | ||||||
| BIN_DIR = 'bin' | BIN_DIR = 'bin' | ||||||
| TYPE = co.NOVA | TYPE = settings.NOVA | ||||||
|  |  | ||||||
|  |  | ||||||
| class NovaUninstaller(comp.PythonUninstallComponent): | class NovaUninstaller(comp.PythonUninstallComponent): | ||||||
|   | |||||||
| @@ -14,11 +14,11 @@ | |||||||
| #    under the License. | #    under the License. | ||||||
|  |  | ||||||
| from devstack import component as comp | from devstack import component as comp | ||||||
| from devstack import constants |  | ||||||
| from devstack import log as logging | from devstack import log as logging | ||||||
|  | from devstack import settings | ||||||
|  |  | ||||||
| LOG = logging.getLogger("devstack.components.nova_client") | LOG = logging.getLogger("devstack.components.nova_client") | ||||||
| TYPE = constants.NOVA_CLIENT | TYPE = settings.NOVA_CLIENT | ||||||
|  |  | ||||||
|  |  | ||||||
| class NovaClientUninstaller(comp.PythonUninstallComponent): | class NovaClientUninstaller(comp.PythonUninstallComponent): | ||||||
|   | |||||||
| @@ -13,13 +13,12 @@ | |||||||
| #    under the License. | #    under the License. | ||||||
|  |  | ||||||
| from devstack import component as comp | from devstack import component as comp | ||||||
| from devstack import constants as co |  | ||||||
| from devstack import log as logging | from devstack import log as logging | ||||||
|  | from devstack import settings | ||||||
| from devstack import shell as sh | from devstack import shell as sh | ||||||
| from devstack import utils | from devstack import utils | ||||||
|  |  | ||||||
| LOG = logging.getLogger("devstack.components.nova_conf") | LOG = logging.getLogger("devstack.components.nova_conf") | ||||||
|  |  | ||||||
| QUANTUM_MANAGER = 'nova.network.quantum.manager.QuantumManager' | QUANTUM_MANAGER = 'nova.network.quantum.manager.QuantumManager' | ||||||
| NET_MANAGER_TEMPLATE = 'nova.network.manager.%s' | NET_MANAGER_TEMPLATE = 'nova.network.manager.%s' | ||||||
| DEF_IMAGE_SERVICE = 'nova.image.glance.GlanceImageService' | DEF_IMAGE_SERVICE = 'nova.image.glance.GlanceImageService' | ||||||
| @@ -79,7 +78,7 @@ class NovaConfigurator(): | |||||||
|         #whats the network fixed range? |         #whats the network fixed range? | ||||||
|         nova_conf.add('fixed_range', self._getstr('fixed_range')) |         nova_conf.add('fixed_range', self._getstr('fixed_range')) | ||||||
|  |  | ||||||
|         if(co.QUANTUM in self.active_components): |         if(settings.QUANTUM in self.active_components): | ||||||
|             #setup quantum config |             #setup quantum config | ||||||
|             nova_conf.add('network_manager', QUANTUM_MANAGER) |             nova_conf.add('network_manager', QUANTUM_MANAGER) | ||||||
|             nova_conf.add('quantum_connection_host', self.cfg.get('quantum', 'q_host')) |             nova_conf.add('quantum_connection_host', self.cfg.get('quantum', 'q_host')) | ||||||
| @@ -120,7 +119,7 @@ class NovaConfigurator(): | |||||||
|                                 self._getstr('instance_name_postfix')) |                                 self._getstr('instance_name_postfix')) | ||||||
|         nova_conf.add('instance_name_template', instance_template) |         nova_conf.add('instance_name_template', instance_template) | ||||||
|  |  | ||||||
|         if(co.OPENSTACK_X in self.active_components): |         if(settings.OPENSTACK_X in self.active_components): | ||||||
|             nova_conf.add('osapi_compute_extension', 'nova.api.openstack.compute.contrib.standard_extensions') |             nova_conf.add('osapi_compute_extension', 'nova.api.openstack.compute.contrib.standard_extensions') | ||||||
|             nova_conf.add('osapi_compute_extension', 'extensions.admin.Admin') |             nova_conf.add('osapi_compute_extension', 'extensions.admin.Admin') | ||||||
|  |  | ||||||
|   | |||||||
| @@ -14,13 +14,13 @@ | |||||||
| #    under the License. | #    under the License. | ||||||
|  |  | ||||||
| from devstack import component as comp | from devstack import component as comp | ||||||
| from devstack import constants |  | ||||||
| from devstack import log as logging | from devstack import log as logging | ||||||
|  | from devstack import settings | ||||||
| from devstack import shell as sh | from devstack import shell as sh | ||||||
| from devstack import utils | from devstack import utils | ||||||
|  |  | ||||||
| LOG = logging.getLogger("devstack.components.openstackx") | LOG = logging.getLogger("devstack.components.openstackx") | ||||||
| TYPE = constants.OPENSTACK_X | TYPE = settings.OPENSTACK_X | ||||||
|  |  | ||||||
|  |  | ||||||
| class OpenstackXUninstaller(comp.PythonUninstallComponent): | class OpenstackXUninstaller(comp.PythonUninstallComponent): | ||||||
|   | |||||||
| @@ -14,13 +14,13 @@ | |||||||
| #    under the License. | #    under the License. | ||||||
|  |  | ||||||
| from devstack import component as comp | from devstack import component as comp | ||||||
| from devstack import constants |  | ||||||
| from devstack import log as logging | from devstack import log as logging | ||||||
|  | from devstack import settings | ||||||
| from devstack import shell as sh | from devstack import shell as sh | ||||||
| from devstack import utils | from devstack import utils | ||||||
|  |  | ||||||
| LOG = logging.getLogger("devstack.components.quantum") | LOG = logging.getLogger("devstack.components.quantum") | ||||||
| TYPE = constants.QUANTUM | TYPE = settings.QUANTUM | ||||||
|  |  | ||||||
|  |  | ||||||
| class QuantumUninstaller(comp.UninstallComponent): | class QuantumUninstaller(comp.UninstallComponent): | ||||||
|   | |||||||
| @@ -17,14 +17,14 @@ | |||||||
| from tempfile import TemporaryFile | from tempfile import TemporaryFile | ||||||
|  |  | ||||||
| from devstack import component as comp | from devstack import component as comp | ||||||
| from devstack import constants |  | ||||||
| from devstack import exceptions as excp | from devstack import exceptions as excp | ||||||
| from devstack import log as logging | from devstack import log as logging | ||||||
|  | from devstack import settings | ||||||
| from devstack import shell as sh | from devstack import shell as sh | ||||||
| from devstack import trace as tr | from devstack import trace as tr | ||||||
|  |  | ||||||
| LOG = logging.getLogger("devstack.components.rabbit") | LOG = logging.getLogger("devstack.components.rabbit") | ||||||
| TYPE = constants.RABBIT | TYPE = settings.RABBIT | ||||||
|  |  | ||||||
| #hopefully these are distro independent.. | #hopefully these are distro independent.. | ||||||
| START_CMD = ['service', "rabbitmq-server", "start"] | START_CMD = ['service', "rabbitmq-server", "start"] | ||||||
| @@ -79,7 +79,7 @@ class RabbitRuntime(comp.NullRuntime): | |||||||
|         return sysout.strip().lower() |         return sysout.strip().lower() | ||||||
|  |  | ||||||
|     def _run_cmd(self, cmd): |     def _run_cmd(self, cmd): | ||||||
|         if(self.distro == constants.UBUNTU11): |         if(self.distro == settings.UBUNTU11): | ||||||
|             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) | ||||||
|   | |||||||
| @@ -15,12 +15,13 @@ | |||||||
|  |  | ||||||
|  |  | ||||||
| from devstack import component as comp | from devstack import component as comp | ||||||
| from devstack import constants |  | ||||||
| from devstack import log as logging | from devstack import log as logging | ||||||
|  | from devstack import settings | ||||||
| from devstack import shell as sh | from devstack import shell as sh | ||||||
| from devstack import utils | from devstack import utils | ||||||
|  |  | ||||||
| LOG = logging.getLogger("devstack.components.swift") | LOG = logging.getLogger("devstack.components.swift") | ||||||
|  | TYPE = settings.SWIFT | ||||||
|  |  | ||||||
|  |  | ||||||
| class SwiftUninstaller(comp.UninstallComponent): | class SwiftUninstaller(comp.UninstallComponent): | ||||||
|   | |||||||
| @@ -209,7 +209,7 @@ class ImageCreationService: | |||||||
|                 if(len(url)): |                 if(len(url)): | ||||||
|                     Image(url, self.token).install() |                     Image(url, self.token).install() | ||||||
|             except (IOError, tarfile.TarError): |             except (IOError, tarfile.TarError): | ||||||
|                 #these are the known exceptions we will catch and all that  |                 #these are the known exceptions we will catch and all that | ||||||
|                 #should be emitted (except core python errors, catching all |                 #should be emitted (except core python errors, catching all | ||||||
|                 #exceptions is not good...), since this service is not critical |                 #exceptions is not good...), since this service is not critical | ||||||
|                 #just log them and carry on. |                 #just log them and carry on. | ||||||
|   | |||||||
| @@ -13,14 +13,16 @@ | |||||||
| #    License for the specific language governing permissions and limitations | #    License for the specific language governing permissions and limitations | ||||||
| #    under the License. | #    under the License. | ||||||
|  |  | ||||||
| from optparse import OptionParser, OptionGroup |  | ||||||
| from optparse import IndentedHelpFormatter | from optparse import IndentedHelpFormatter | ||||||
|  | from optparse import OptionParser, OptionGroup | ||||||
|  |  | ||||||
| from devstack import constants | from devstack import log as logging | ||||||
|  | from devstack import settings | ||||||
| from devstack import utils | from devstack import utils | ||||||
| from devstack import version | from devstack import version | ||||||
|  |  | ||||||
| HELP_WIDTH = 80 | HELP_WIDTH = 80 | ||||||
|  | LOG = logging.getLogger("devstack.opts") | ||||||
|  |  | ||||||
|  |  | ||||||
| def parse(): | def parse(): | ||||||
| @@ -31,7 +33,7 @@ def parse(): | |||||||
|     parser = OptionParser(version=version_str, formatter=help_formatter) |     parser = OptionParser(version=version_str, formatter=help_formatter) | ||||||
|  |  | ||||||
|     base_group = OptionGroup(parser, "Install/uninstall/start/stop options") |     base_group = OptionGroup(parser, "Install/uninstall/start/stop options") | ||||||
|     known_actions = sorted(constants.ACTIONS) |     known_actions = sorted(settings.ACTIONS) | ||||||
|     actions = "(" + ", ".join(known_actions) + ")" |     actions = "(" + ", ".join(known_actions) + ")" | ||||||
|     base_group.add_option("-a", "--action", |     base_group.add_option("-a", "--action", | ||||||
|             action="store", |             action="store", | ||||||
| @@ -46,7 +48,7 @@ def parse(): | |||||||
|         metavar="DIR", |         metavar="DIR", | ||||||
|         help="empty root DIR for install or "\ |         help="empty root DIR for install or "\ | ||||||
|              "DIR with existing components for start/stop/uninstall") |              "DIR with existing components for start/stop/uninstall") | ||||||
|     known_components = sorted(constants.COMPONENT_NAMES) |     known_components = sorted(settings.COMPONENT_NAMES) | ||||||
|     components = "(" + ", ".join(known_components) + ")" |     components = "(" + ", ".join(known_components) + ")" | ||||||
|     base_group.add_option("-c", "--component", |     base_group.add_option("-c", "--component", | ||||||
|         action="append", |         action="append", | ||||||
|   | |||||||
| @@ -13,8 +13,8 @@ | |||||||
| #    License for the specific language governing permissions and limitations | #    License for the specific language governing permissions and limitations | ||||||
| #    under the License. | #    under the License. | ||||||
|  |  | ||||||
| from devstack import constants |  | ||||||
| from devstack import log as logging | from devstack import log as logging | ||||||
|  | from devstack import settings | ||||||
| from devstack import utils | from devstack import utils | ||||||
|  |  | ||||||
| LOG = logging.getLogger("devstack.packager") | LOG = logging.getLogger("devstack.packager") | ||||||
| @@ -34,7 +34,7 @@ class Packager(): | |||||||
|         pkgnames = sorted(pkgs.keys()) |         pkgnames = sorted(pkgs.keys()) | ||||||
|         for name in pkgnames: |         for name in pkgnames: | ||||||
|             packageinfo = pkgs.get(name) |             packageinfo = pkgs.get(name) | ||||||
|             preinstallcmds = packageinfo.get(constants.PRE_INSTALL) |             preinstallcmds = packageinfo.get(settings.PRE_INSTALL) | ||||||
|             if(preinstallcmds and len(preinstallcmds)): |             if(preinstallcmds and len(preinstallcmds)): | ||||||
|                 LOG.info("Running pre-install commands for package %s." % (name)) |                 LOG.info("Running pre-install commands for package %s." % (name)) | ||||||
|                 utils.execute_template(*preinstallcmds, params=installparams) |                 utils.execute_template(*preinstallcmds, params=installparams) | ||||||
| @@ -43,7 +43,7 @@ class Packager(): | |||||||
|         pkgnames = sorted(pkgs.keys()) |         pkgnames = sorted(pkgs.keys()) | ||||||
|         for name in pkgnames: |         for name in pkgnames: | ||||||
|             packageinfo = pkgs.get(name) |             packageinfo = pkgs.get(name) | ||||||
|             postinstallcmds = packageinfo.get(constants.POST_INSTALL) |             postinstallcmds = packageinfo.get(settings.POST_INSTALL) | ||||||
|             if(postinstallcmds and len(postinstallcmds)): |             if(postinstallcmds and len(postinstallcmds)): | ||||||
|                 LOG.info("Running post-install commands for package %s." % (name)) |                 LOG.info("Running post-install commands for package %s." % (name)) | ||||||
|                 utils.execute_template(*postinstallcmds, params=installparams) |                 utils.execute_template(*postinstallcmds, params=installparams) | ||||||
|   | |||||||
| @@ -16,9 +16,9 @@ | |||||||
| from tempfile import TemporaryFile | from tempfile import TemporaryFile | ||||||
| import time | import time | ||||||
|  |  | ||||||
| from devstack import constants as co |  | ||||||
| from devstack import log as logging | from devstack import log as logging | ||||||
| from devstack import packager as pack | from devstack import packager as pack | ||||||
|  | from devstack import settings | ||||||
| from devstack import shell as sh | from devstack import shell as sh | ||||||
|  |  | ||||||
| LOG = logging.getLogger("devstack.packaging.apt") | LOG = logging.getLogger("devstack.packaging.apt") | ||||||
| @@ -100,7 +100,7 @@ class AptPackager(pack.Packager): | |||||||
|             self._execute_apt(cmd) |             self._execute_apt(cmd) | ||||||
|  |  | ||||||
|     def _pkg_remove_special(self, name, pkginfo): |     def _pkg_remove_special(self, name, pkginfo): | ||||||
|         if(name == 'rabbitmq-server' and self.distro == co.UBUNTU11): |         if(name == 'rabbitmq-server' and self.distro == settings.UBUNTU11): | ||||||
|             #https://bugs.launchpad.net/ubuntu/+source/rabbitmq-server/+bug/878597 |             #https://bugs.launchpad.net/ubuntu/+source/rabbitmq-server/+bug/878597 | ||||||
|             #https://bugs.launchpad.net/ubuntu/+source/rabbitmq-server/+bug/878600 |             #https://bugs.launchpad.net/ubuntu/+source/rabbitmq-server/+bug/878600 | ||||||
|             LOG.info("Handling special remove of %s." % (name)) |             LOG.info("Handling special remove of %s." % (name)) | ||||||
| @@ -116,7 +116,7 @@ class AptPackager(pack.Packager): | |||||||
|         return False |         return False | ||||||
|  |  | ||||||
|     def _pkg_install_special(self, name, pkginfo): |     def _pkg_install_special(self, name, pkginfo): | ||||||
|         if(name == 'rabbitmq-server' and self.distro == co.UBUNTU11): |         if(name == 'rabbitmq-server' and self.distro == settings.UBUNTU11): | ||||||
|             #https://bugs.launchpad.net/ubuntu/+source/rabbitmq-server/+bug/878597 |             #https://bugs.launchpad.net/ubuntu/+source/rabbitmq-server/+bug/878597 | ||||||
|             #https://bugs.launchpad.net/ubuntu/+source/rabbitmq-server/+bug/878600 |             #https://bugs.launchpad.net/ubuntu/+source/rabbitmq-server/+bug/878600 | ||||||
|             LOG.info("Handling special install of %s." % (name)) |             LOG.info("Handling special install of %s." % (name)) | ||||||
|   | |||||||
| @@ -13,9 +13,9 @@ | |||||||
| #    License for the specific language governing permissions and limitations | #    License for the specific language governing permissions and limitations | ||||||
| #    under the License. | #    under the License. | ||||||
|  |  | ||||||
|  | from devstack import log as logging | ||||||
| from devstack import packager as pack | from devstack import packager as pack | ||||||
| from devstack import shell as sh | from devstack import shell as sh | ||||||
| from devstack import log as logging |  | ||||||
|  |  | ||||||
| LOG = logging.getLogger("devstack.packaging.yum") | LOG = logging.getLogger("devstack.packaging.yum") | ||||||
| YUM_CMD = ['yum'] | YUM_CMD = ['yum'] | ||||||
|   | |||||||
| @@ -13,12 +13,13 @@ | |||||||
| #    License for the specific language governing permissions and limitations | #    License for the specific language governing permissions and limitations | ||||||
| #    under the License. | #    under the License. | ||||||
|  |  | ||||||
| from devstack import constants as c | from devstack import cfg | ||||||
| from devstack import utils |  | ||||||
| from devstack import shell as sh |  | ||||||
| from devstack import log as logging |  | ||||||
| from devstack import exceptions as excp |  | ||||||
| from devstack import date | from devstack import date | ||||||
|  | from devstack import exceptions as excp | ||||||
|  | from devstack import log as logging | ||||||
|  | from devstack import settings | ||||||
|  | from devstack import shell as sh | ||||||
|  | from devstack import utils | ||||||
|  |  | ||||||
| from devstack.components import db | from devstack.components import db | ||||||
| from devstack.components import glance | from devstack.components import glance | ||||||
| @@ -32,61 +33,71 @@ from devstack.components import quantum | |||||||
| from devstack.components import rabbit | from devstack.components import rabbit | ||||||
| from devstack.components import swift | from devstack.components import swift | ||||||
|  |  | ||||||
|  | from devstack.packaging import apt | ||||||
|  | from devstack.packaging import yum | ||||||
|  |  | ||||||
| LOG = logging.getLogger("devstack.progs.actions") | LOG = logging.getLogger("devstack.progs.actions") | ||||||
|  |  | ||||||
|  | #this map controls which distro has | ||||||
|  | #which package management class | ||||||
|  | _PKGR_MAP = { | ||||||
|  |     settings.UBUNTU11: apt.AptPackager, | ||||||
|  |     settings.RHEL6: yum.YumPackager, | ||||||
|  | } | ||||||
|  |  | ||||||
| # This determines what classes to use to install/uninstall/... | # This determines what classes to use to install/uninstall/... | ||||||
| _ACTION_CLASSES = { | _ACTION_CLASSES = { | ||||||
|     c.INSTALL: { |     settings.INSTALL: { | ||||||
|         c.NOVA: nova.NovaInstaller, |         settings.NOVA: nova.NovaInstaller, | ||||||
|         c.GLANCE: glance.GlanceInstaller, |         settings.GLANCE: glance.GlanceInstaller, | ||||||
|         c.QUANTUM: quantum.QuantumInstaller, |         settings.QUANTUM: quantum.QuantumInstaller, | ||||||
|         c.SWIFT: swift.SwiftInstaller, |         settings.SWIFT: swift.SwiftInstaller, | ||||||
|         c.HORIZON: horizon.HorizonInstaller, |         settings.HORIZON: horizon.HorizonInstaller, | ||||||
|         c.KEYSTONE: keystone.KeystoneInstaller, |         settings.KEYSTONE: keystone.KeystoneInstaller, | ||||||
|         c.DB: db.DBInstaller, |         settings.DB: db.DBInstaller, | ||||||
|         c.RABBIT: rabbit.RabbitInstaller, |         settings.RABBIT: rabbit.RabbitInstaller, | ||||||
|         c.KEYSTONE_CLIENT: keystone_client.KeyStoneClientInstaller, |         settings.KEYSTONE_CLIENT: keystone_client.KeyStoneClientInstaller, | ||||||
|         c.NOVA_CLIENT: nova_client.NovaClientInstaller, |         settings.NOVA_CLIENT: nova_client.NovaClientInstaller, | ||||||
|         c.OPENSTACK_X: openstack_x.OpenstackXInstaller, |         settings.OPENSTACK_X: openstack_x.OpenstackXInstaller, | ||||||
|     }, |     }, | ||||||
|     c.UNINSTALL: { |     settings.UNINSTALL: { | ||||||
|         c.NOVA: nova.NovaUninstaller, |         settings.NOVA: nova.NovaUninstaller, | ||||||
|         c.GLANCE: glance.GlanceUninstaller, |         settings.GLANCE: glance.GlanceUninstaller, | ||||||
|         c.QUANTUM: quantum.QuantumUninstaller, |         settings.QUANTUM: quantum.QuantumUninstaller, | ||||||
|         c.SWIFT: swift.SwiftUninstaller, |         settings.SWIFT: swift.SwiftUninstaller, | ||||||
|         c.HORIZON: horizon.HorizonUninstaller, |         settings.HORIZON: horizon.HorizonUninstaller, | ||||||
|         c.KEYSTONE: keystone.KeystoneUninstaller, |         settings.KEYSTONE: keystone.KeystoneUninstaller, | ||||||
|         c.DB: db.DBUninstaller, |         settings.DB: db.DBUninstaller, | ||||||
|         c.RABBIT: rabbit.RabbitUninstaller, |         settings.RABBIT: rabbit.RabbitUninstaller, | ||||||
|         c.KEYSTONE_CLIENT: keystone_client.KeyStoneClientUninstaller, |         settings.KEYSTONE_CLIENT: keystone_client.KeyStoneClientUninstaller, | ||||||
|         c.NOVA_CLIENT: nova_client.NovaClientUninstaller, |         settings.NOVA_CLIENT: nova_client.NovaClientUninstaller, | ||||||
|         c.OPENSTACK_X: openstack_x.OpenstackXUninstaller, |         settings.OPENSTACK_X: openstack_x.OpenstackXUninstaller, | ||||||
|     }, |     }, | ||||||
|     c.START: { |     settings.START: { | ||||||
|         c.NOVA: nova.NovaRuntime, |         settings.NOVA: nova.NovaRuntime, | ||||||
|         c.GLANCE: glance.GlanceRuntime, |         settings.GLANCE: glance.GlanceRuntime, | ||||||
|         c.QUANTUM: quantum.QuantumRuntime, |         settings.QUANTUM: quantum.QuantumRuntime, | ||||||
|         c.SWIFT: swift.SwiftRuntime, |         settings.SWIFT: swift.SwiftRuntime, | ||||||
|         c.HORIZON: horizon.HorizonRuntime, |         settings.HORIZON: horizon.HorizonRuntime, | ||||||
|         c.KEYSTONE: keystone.KeystoneRuntime, |         settings.KEYSTONE: keystone.KeystoneRuntime, | ||||||
|         c.DB: db.DBRuntime, |         settings.DB: db.DBRuntime, | ||||||
|         c.RABBIT: rabbit.RabbitRuntime, |         settings.RABBIT: rabbit.RabbitRuntime, | ||||||
|         c.KEYSTONE_CLIENT: keystone_client.KeyStoneClientRuntime, |         settings.KEYSTONE_CLIENT: keystone_client.KeyStoneClientRuntime, | ||||||
|         c.NOVA_CLIENT: nova_client.NovaClientRuntime, |         settings.NOVA_CLIENT: nova_client.NovaClientRuntime, | ||||||
|         c.OPENSTACK_X: openstack_x.OpenstackXRuntime, |         settings.OPENSTACK_X: openstack_x.OpenstackXRuntime, | ||||||
|     }, |     }, | ||||||
|     c.STOP: { |     settings.STOP: { | ||||||
|         c.NOVA: nova.NovaRuntime, |         settings.NOVA: nova.NovaRuntime, | ||||||
|         c.GLANCE: glance.GlanceRuntime, |         settings.GLANCE: glance.GlanceRuntime, | ||||||
|         c.QUANTUM: quantum.QuantumRuntime, |         settings.QUANTUM: quantum.QuantumRuntime, | ||||||
|         c.SWIFT: swift.SwiftRuntime, |         settings.SWIFT: swift.SwiftRuntime, | ||||||
|         c.HORIZON: horizon.HorizonRuntime, |         settings.HORIZON: horizon.HorizonRuntime, | ||||||
|         c.KEYSTONE: keystone.KeystoneRuntime, |         settings.KEYSTONE: keystone.KeystoneRuntime, | ||||||
|         c.DB: db.DBRuntime, |         settings.DB: db.DBRuntime, | ||||||
|         c.RABBIT: rabbit.RabbitRuntime, |         settings.RABBIT: rabbit.RabbitRuntime, | ||||||
|         c.KEYSTONE_CLIENT: keystone_client.KeyStoneClientRuntime, |         settings.KEYSTONE_CLIENT: keystone_client.KeyStoneClientRuntime, | ||||||
|         c.NOVA_CLIENT: nova_client.NovaClientRuntime, |         settings.NOVA_CLIENT: nova_client.NovaClientRuntime, | ||||||
|         c.OPENSTACK_X: openstack_x.OpenstackXRuntime, |         settings.OPENSTACK_X: openstack_x.OpenstackXRuntime, | ||||||
|     }, |     }, | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -95,11 +106,16 @@ def _clean_action(action): | |||||||
|     if(action == None): |     if(action == None): | ||||||
|         return None |         return None | ||||||
|     action = action.strip().lower() |     action = action.strip().lower() | ||||||
|     if(not (action in c.ACTIONS)): |     if(not (action in settings.ACTIONS)): | ||||||
|         return None |         return None | ||||||
|     return action |     return action | ||||||
|  |  | ||||||
|  |  | ||||||
|  | def _get_pkg_manager(distro): | ||||||
|  |     cls = _PKGR_MAP.get(distro) | ||||||
|  |     return cls(distro) | ||||||
|  |  | ||||||
|  |  | ||||||
| def _get_action_cls(action_name, component_name): | def _get_action_cls(action_name, component_name): | ||||||
|     action_cls_map = _ACTION_CLASSES.get(action_name) |     action_cls_map = _ACTION_CLASSES.get(action_name) | ||||||
|     if(not action_cls_map): |     if(not action_cls_map): | ||||||
| @@ -110,23 +126,25 @@ def _get_action_cls(action_name, component_name): | |||||||
| def _check_root(action, rootdir): | def _check_root(action, rootdir): | ||||||
|     if(rootdir == None or len(rootdir) == 0): |     if(rootdir == None or len(rootdir) == 0): | ||||||
|         return False |         return False | ||||||
|     if(action == c.INSTALL): |     if(action == settings.INSTALL): | ||||||
|         if(sh.isdir(rootdir) and len(sh.listdir(rootdir)) != 0): |         if(sh.isdir(rootdir)): | ||||||
|             LOG.error("Root directory [%s] already exists (and it's not empty)! "\ |             dir_list = sh.listdir(rootdir) | ||||||
|                       "Please remove it or uninstall components!" % (rootdir)) |             if(len(dir_list) > 0): | ||||||
|             return False |                 LOG.error("Root directory [%s] already exists (and it's not empty)! "\ | ||||||
|  |                           "Please remove it or uninstall components!" % (rootdir)) | ||||||
|  |                 return False | ||||||
|     return True |     return True | ||||||
|  |  | ||||||
|  |  | ||||||
| def _pre_run(action_name, **kargs): | def _pre_run(action_name, **kargs): | ||||||
|     if(action_name == c.INSTALL): |     if(action_name == settings.INSTALL): | ||||||
|         root_dir = kargs.get("root_dir") |         root_dir = kargs.get("root_dir") | ||||||
|         if(root_dir): |         if(root_dir): | ||||||
|             sh.mkdir(root_dir) |             sh.mkdir(root_dir) | ||||||
|  |  | ||||||
|  |  | ||||||
| def _post_run(action_name, **kargs): | def _post_run(action_name, **kargs): | ||||||
|     if(action_name == c.UNINSTALL): |     if(action_name == settings.UNINSTALL): | ||||||
|         root_dir = kargs.get("root_dir") |         root_dir = kargs.get("root_dir") | ||||||
|         if(root_dir): |         if(root_dir): | ||||||
|             sh.rmdir(root_dir) |             sh.rmdir(root_dir) | ||||||
| @@ -230,10 +248,18 @@ def _uninstall(component_name, instance, skip_notrace): | |||||||
|             raise |             raise | ||||||
|  |  | ||||||
|  |  | ||||||
|  | def _get_config(): | ||||||
|  |     cfg_fn = sh.canon_path(settings.STACK_CONFIG_LOCATION) | ||||||
|  |     LOG.info("Loading config from [%s]" % (cfg_fn)) | ||||||
|  |     config_instance = cfg.EnvConfigParser() | ||||||
|  |     config_instance.read(cfg_fn) | ||||||
|  |     return config_instance | ||||||
|  |  | ||||||
|  |  | ||||||
| def _run_components(action_name, component_order, components_info, distro, root_dir, program_args): | def _run_components(action_name, component_order, components_info, distro, root_dir, program_args): | ||||||
|     LOG.info("Will %s [%s] (in that order) using root directory \"%s\"" % (action_name, ", ".join(component_order), root_dir)) |     LOG.info("Will %s [%s] (in that order) using root directory \"%s\"" % (action_name, ", ".join(component_order), root_dir)) | ||||||
|     pkg_manager = utils.get_pkg_manager(distro) |     pkg_manager = _get_pkg_manager(distro) | ||||||
|     config = utils.get_config() |     config = _get_config() | ||||||
|     results = list() |     results = list() | ||||||
|     #this key list may be different than the order due to reference components |     #this key list may be different than the order due to reference components | ||||||
|     active_components = components_info.keys() |     active_components = components_info.keys() | ||||||
| @@ -247,24 +273,28 @@ def _run_components(action_name, component_order, components_info, distro, root_ | |||||||
|                             cfg=config, |                             cfg=config, | ||||||
|                             root=root_dir, |                             root=root_dir, | ||||||
|                             component_opts=components_info.get(component, list())) |                             component_opts=components_info.get(component, list())) | ||||||
|         if(action_name == c.INSTALL): |         #activate the correct function for the given action | ||||||
|  |         if(action_name == settings.INSTALL): | ||||||
|             install_result = _install(component, instance) |             install_result = _install(component, instance) | ||||||
|             if install_result: |             if install_result: | ||||||
|                 if type(install_result) == list: |                 if type(install_result) == list: | ||||||
|                     results += install_result |                     results += install_result | ||||||
|                 else: |                 else: | ||||||
|                     results.append(str(install_result)) |                     results.append(str(install_result)) | ||||||
|         elif(action_name == c.STOP): |         elif(action_name == settings.STOP): | ||||||
|             _stop(component, instance, program_args.get('force', False)) |             _stop(component, instance, program_args.get('force', False)) | ||||||
|         elif(action_name == c.START): |         elif(action_name == settings.START): | ||||||
|             start_result = _start(component, instance) |             start_result = _start(component, instance) | ||||||
|             if start_result: |             if start_result: | ||||||
|                 if type(start_result) == list: |                 if type(start_result) == list: | ||||||
|                     results += start_result |                     results += start_result | ||||||
|                 else: |                 else: | ||||||
|                     results.append(str(start_result)) |                     results.append(str(start_result)) | ||||||
|         elif(action_name == c.UNINSTALL): |         elif(action_name == settings.UNINSTALL): | ||||||
|             _uninstall(component, instance, program_args.get('force', False)) |             _uninstall(component, instance, program_args.get('force', False)) | ||||||
|  |         else: | ||||||
|  |             #TODO throw? | ||||||
|  |             pass | ||||||
|     #display any configs touched... |     #display any configs touched... | ||||||
|     _print_cfgs(config, action_name) |     _print_cfgs(config, action_name) | ||||||
|     #any post run actions go now |     #any post run actions go now | ||||||
| @@ -273,7 +303,7 @@ def _run_components(action_name, component_order, components_info, distro, root_ | |||||||
|  |  | ||||||
|  |  | ||||||
| def _run_action(args): | def _run_action(args): | ||||||
|     components = utils.parse_components(args.pop("components")) |     components = settings.parse_components(args.pop("components")) | ||||||
|     if(len(components) == 0): |     if(len(components) == 0): | ||||||
|         LOG.error("No components specified!") |         LOG.error("No components specified!") | ||||||
|         return False |         return False | ||||||
| @@ -295,18 +325,18 @@ def _run_action(args): | |||||||
|     #need to figure out dependencies for components (if any) |     #need to figure out dependencies for components (if any) | ||||||
|     ignore_deps = args.pop('ignore_deps', False) |     ignore_deps = args.pop('ignore_deps', False) | ||||||
|     if(not ignore_deps): |     if(not ignore_deps): | ||||||
|         new_components = utils.resolve_dependencies(components.keys()) |         new_components = settings.resolve_dependencies(components.keys()) | ||||||
|         component_diff = new_components.difference(components.keys()) |         component_diff = new_components.difference(components.keys()) | ||||||
|         if(len(component_diff)): |         if(len(component_diff)): | ||||||
|             LOG.info("Having to activate dependent components: [%s]" % (", ".join(component_diff))) |             LOG.info("Having to activate dependent components: [%s]" % (", ".join(component_diff))) | ||||||
|             for new_component in component_diff: |             for new_component in component_diff: | ||||||
|                 components[new_component] = list() |                 components[new_component] = list() | ||||||
|     #get the right component order (by priority) |     #get the right component order (by priority) | ||||||
|     component_order = utils.prioritize_components(components.keys()) |     component_order = settings.prioritize_components(components.keys()) | ||||||
|     #now do it! |     #now do it! | ||||||
|     LOG.info("Starting action [%s] on %s for distro [%s]" % (action, date.rcf8222date(), distro)) |     LOG.info("Starting action [%s] on %s for distro [%s]" % (action, date.rcf8222date(), distro)) | ||||||
|     #add in any that will just be referenced but which will not actually do anything |     #add in any that will just be referenced but which will not actually do anything | ||||||
|     ref_components = utils.parse_components(args.pop("ref_components")) |     ref_components = settings.parse_components(args.pop("ref_components")) | ||||||
|     for c in ref_components.keys(): |     for c in ref_components.keys(): | ||||||
|         if(c not in components): |         if(c not in components): | ||||||
|             components[c] = ref_components.get(c) |             components[c] = ref_components.get(c) | ||||||
|   | |||||||
| @@ -13,8 +13,8 @@ | |||||||
| #    License for the specific language governing permissions and limitations | #    License for the specific language governing permissions and limitations | ||||||
| #    under the License. | #    under the License. | ||||||
|  |  | ||||||
| from devstack import utils |  | ||||||
| from devstack import log as logging | from devstack import log as logging | ||||||
|  | from devstack import settings | ||||||
|  |  | ||||||
| LOG = logging.getLogger("devstack.progs.deps") | LOG = logging.getLogger("devstack.progs.deps") | ||||||
|  |  | ||||||
| @@ -24,7 +24,7 @@ def log_deps(components): | |||||||
|     left_show = list(components) |     left_show = list(components) | ||||||
|     while(len(left_show) != 0): |     while(len(left_show) != 0): | ||||||
|         c = left_show.pop() |         c = left_show.pop() | ||||||
|         deps = utils.get_dependencies(c) |         deps = settings.get_dependencies(c) | ||||||
|         dep_str = "" |         dep_str = "" | ||||||
|         dep_len = len(deps) |         dep_len = len(deps) | ||||||
|         if(dep_len >= 1): |         if(dep_len >= 1): | ||||||
| @@ -45,7 +45,7 @@ def log_deps(components): | |||||||
|  |  | ||||||
|  |  | ||||||
| def _run_list_deps(args): | def _run_list_deps(args): | ||||||
|     components = utils.parse_components(args.pop("components"), True).keys() |     components = settings.parse_components(args.pop("components"), True).keys() | ||||||
|     components = sorted(components) |     components = sorted(components) | ||||||
|     components.reverse() |     components.reverse() | ||||||
|     return log_deps(components) |     return log_deps(components) | ||||||
|   | |||||||
| @@ -13,9 +13,14 @@ | |||||||
| #    License for the specific language governing permissions and limitations | #    License for the specific language governing permissions and limitations | ||||||
| #    under the License. | #    under the License. | ||||||
| 
 | 
 | ||||||
|  | import operator | ||||||
| import os.path | import os.path | ||||||
| import re | import re | ||||||
| 
 | 
 | ||||||
|  | from devstack import log as logging | ||||||
|  | 
 | ||||||
|  | LOG = logging.getLogger("devstack.settings") | ||||||
|  | 
 | ||||||
| # These also have meaning outside python, | # These also have meaning outside python, | ||||||
| # ie in the pkg/pip listings so update there also! | # ie in the pkg/pip listings so update there also! | ||||||
| UBUNTU11 = "ubuntu-oneiric" | UBUNTU11 = "ubuntu-oneiric" | ||||||
| @@ -93,6 +98,9 @@ COMPONENT_TRACE_DIR = "traces" | |||||||
| COMPONENT_APP_DIR = "app" | COMPONENT_APP_DIR = "app" | ||||||
| COMPONENT_CONFIG_DIR = "config" | COMPONENT_CONFIG_DIR = "config" | ||||||
| 
 | 
 | ||||||
|  | # This regex is used to extract a components options (if any) and its name | ||||||
|  | EXT_COMPONENT = re.compile(r"^\s*([\w-]+)(?:\((.*)\))?\s*$") | ||||||
|  | 
 | ||||||
| # Program | # Program | ||||||
| # actions | # actions | ||||||
| INSTALL = "install" | INSTALL = "install" | ||||||
| @@ -201,3 +209,71 @@ PKG_MAP = { | |||||||
|             os.path.join(STACK_PKG_DIR, 'openstackx.json'), |             os.path.join(STACK_PKG_DIR, 'openstackx.json'), | ||||||
|         ], |         ], | ||||||
| } | } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | def get_dependencies(component): | ||||||
|  |     return sorted(COMPONENT_DEPENDENCIES.get(component, list())) | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | def resolve_dependencies(components): | ||||||
|  |     active_components = list(components) | ||||||
|  |     new_components = set() | ||||||
|  |     while(len(active_components)): | ||||||
|  |         curr_comp = active_components.pop() | ||||||
|  |         component_deps = get_dependencies(curr_comp) | ||||||
|  |         new_components.add(curr_comp) | ||||||
|  |         for c in component_deps: | ||||||
|  |             if(c in new_components or c in active_components): | ||||||
|  |                 pass | ||||||
|  |             else: | ||||||
|  |                 active_components.append(c) | ||||||
|  |     return new_components | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | def prioritize_components(components): | ||||||
|  |     #get the right component order (by priority) | ||||||
|  |     mporder = dict() | ||||||
|  |     for c in components: | ||||||
|  |         priority = COMPONENT_NAMES_PRIORITY.get(c) | ||||||
|  |         if(priority == None): | ||||||
|  |             priority = sys.maxint | ||||||
|  |         mporder[c] = priority | ||||||
|  |     #sort by priority value | ||||||
|  |     priority_order = sorted(mporder.iteritems(), key=operator.itemgetter(1)) | ||||||
|  |     #extract the final list ordering | ||||||
|  |     component_order = [x[0] for x in priority_order] | ||||||
|  |     return component_order | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | def parse_components(components, assume_all=False): | ||||||
|  |     #none provided, init it | ||||||
|  |     if(not components): | ||||||
|  |         components = list() | ||||||
|  |     adjusted_components = dict() | ||||||
|  |     for c in components: | ||||||
|  |         mtch = EXT_COMPONENT.match(c) | ||||||
|  |         if(mtch): | ||||||
|  |             component_name = mtch.group(1).lower().strip() | ||||||
|  |             if(component_name not in COMPONENT_NAMES): | ||||||
|  |                 LOG.warn("Unknown component named %s" % (component_name)) | ||||||
|  |             else: | ||||||
|  |                 component_opts = mtch.group(2) | ||||||
|  |                 components_opts_cleaned = list() | ||||||
|  |                 if(component_opts == None or len(component_opts) == 0): | ||||||
|  |                     pass | ||||||
|  |                 else: | ||||||
|  |                     sp_component_opts = component_opts.split(",") | ||||||
|  |                     for co in sp_component_opts: | ||||||
|  |                         cleaned_opt = co.strip() | ||||||
|  |                         if(len(cleaned_opt)): | ||||||
|  |                             components_opts_cleaned.append(cleaned_opt) | ||||||
|  |                 adjusted_components[component_name] = components_opts_cleaned | ||||||
|  |         else: | ||||||
|  |             LOG.warn("Unparseable component %s" % (c)) | ||||||
|  |     #should we adjust them to be all the components? | ||||||
|  |     if(len(adjusted_components) == 0 and assume_all): | ||||||
|  |         all_components = dict() | ||||||
|  |         for c in COMPONENT_NAMES: | ||||||
|  |             all_components[c] = list() | ||||||
|  |         adjusted_components = all_components | ||||||
|  |     return adjusted_components | ||||||
| @@ -19,9 +19,9 @@ import os.path | |||||||
| import shutil | import shutil | ||||||
| import subprocess | import subprocess | ||||||
|  |  | ||||||
| from devstack import log as logging |  | ||||||
| from devstack import exceptions as excp |  | ||||||
| from devstack import env | from devstack import env | ||||||
|  | from devstack import exceptions as excp | ||||||
|  | from devstack import log as logging | ||||||
|  |  | ||||||
| ROOT_HELPER = ["sudo"] | ROOT_HELPER = ["sudo"] | ||||||
| MKPW_CMD = ["openssl", 'rand', '-hex'] | MKPW_CMD = ["openssl", 'rand', '-hex'] | ||||||
|   | |||||||
| @@ -15,9 +15,9 @@ | |||||||
|  |  | ||||||
| import json | import json | ||||||
|  |  | ||||||
|  | from devstack import date | ||||||
| from devstack import exceptions as excp | from devstack import exceptions as excp | ||||||
| from devstack import shell as sh | from devstack import shell as sh | ||||||
| from devstack import date |  | ||||||
|  |  | ||||||
| #trace per line output and file extension formats | #trace per line output and file extension formats | ||||||
| TRACE_FMT = "%s - %s\n" | TRACE_FMT = "%s - %s\n" | ||||||
|   | |||||||
| @@ -15,17 +15,18 @@ | |||||||
|  |  | ||||||
| import json | import json | ||||||
| import netifaces | import netifaces | ||||||
| import operator |  | ||||||
| import os | import os | ||||||
| import platform | import platform | ||||||
|  | import random | ||||||
| import re | import re | ||||||
| import sys |  | ||||||
|  |  | ||||||
|  | #requires http://pypi.python.org/pypi/termcolor | ||||||
|  | #but the colors make it worth it :-) | ||||||
| from termcolor import colored | from termcolor import colored | ||||||
|  |  | ||||||
| from devstack import constants |  | ||||||
| from devstack import exceptions as excp | from devstack import exceptions as excp | ||||||
| from devstack import log as logging | from devstack import log as logging | ||||||
|  | from devstack import settings | ||||||
| from devstack import shell as sh | from devstack import shell as sh | ||||||
| from devstack import version | from devstack import version | ||||||
|  |  | ||||||
| @@ -34,52 +35,8 @@ PARAM_SUB_REGEX = re.compile(r"%([\w\d]+?)%") | |||||||
| LOG = logging.getLogger("devstack.util") | LOG = logging.getLogger("devstack.util") | ||||||
|  |  | ||||||
|  |  | ||||||
| def get_pkg_manager(distro): |  | ||||||
|     from devstack.packaging import apt |  | ||||||
|     from devstack.packaging import yum |  | ||||||
|     #this map controls which distro has |  | ||||||
|     #which package management class |  | ||||||
|     PKGR_MAP = { |  | ||||||
|         constants.UBUNTU11: apt.AptPackager, |  | ||||||
|         constants.RHEL6: yum.YumPackager, |  | ||||||
|     } |  | ||||||
|     cls = PKGR_MAP.get(distro) |  | ||||||
|     return cls(distro) |  | ||||||
|  |  | ||||||
|  |  | ||||||
| def get_config(): |  | ||||||
|     from devstack import cfg |  | ||||||
|     cfg_fn = sh.canon_path(constants.STACK_CONFIG_LOCATION) |  | ||||||
|     LOG.info("Loading config from [%s]" % (cfg_fn)) |  | ||||||
|     config_instance = cfg.EnvConfigParser() |  | ||||||
|     config_instance.read(cfg_fn) |  | ||||||
|     return config_instance |  | ||||||
|  |  | ||||||
|  |  | ||||||
| def get_dependencies(component): |  | ||||||
|     deps = constants.COMPONENT_DEPENDENCIES.get(component, list()) |  | ||||||
|     return sorted(deps) |  | ||||||
|  |  | ||||||
|  |  | ||||||
| def resolve_dependencies(components): |  | ||||||
|     active_components = list(components) |  | ||||||
|     new_components = set() |  | ||||||
|     while(len(active_components)): |  | ||||||
|         curr_comp = active_components.pop() |  | ||||||
|         component_deps = get_dependencies(curr_comp) |  | ||||||
|         new_components.add(curr_comp) |  | ||||||
|         for c in component_deps: |  | ||||||
|             if(c in new_components or c in active_components): |  | ||||||
|                 pass |  | ||||||
|             else: |  | ||||||
|                 active_components.append(c) |  | ||||||
|     return new_components |  | ||||||
|  |  | ||||||
|  |  | ||||||
| def execute_template(*cmds, **kargs): | def execute_template(*cmds, **kargs): | ||||||
|     if(not cmds or len(cmds) == 0): |     params_replacements = kargs.pop('params', None) | ||||||
|         return |  | ||||||
|     params_replacements = kargs.pop('params') |  | ||||||
|     ignore_missing = kargs.pop('ignore_missing', False) |     ignore_missing = kargs.pop('ignore_missing', False) | ||||||
|     cmd_results = list() |     cmd_results = list() | ||||||
|     for cmdinfo in cmds: |     for cmdinfo in cmds: | ||||||
| @@ -108,63 +65,11 @@ def execute_template(*cmds, **kargs): | |||||||
|     return cmd_results |     return cmd_results | ||||||
|  |  | ||||||
|  |  | ||||||
| def parse_components(components, assume_all=False): |  | ||||||
|     #none provided, init it |  | ||||||
|     if(components == None): |  | ||||||
|         components = list() |  | ||||||
|     #this regex is used to extract a components options (if any) and its name |  | ||||||
|     EXT_COMPONENT = re.compile(r"^\s*([\w-]+)(?:\((.*)\))?\s*$") |  | ||||||
|     adjusted_components = dict() |  | ||||||
|     for c in components: |  | ||||||
|         mtch = EXT_COMPONENT.match(c) |  | ||||||
|         if(mtch): |  | ||||||
|             component_name = mtch.group(1).lower().strip() |  | ||||||
|             if(component_name not in constants.COMPONENT_NAMES): |  | ||||||
|                 LOG.warn("Unknown component named %s" % (component_name)) |  | ||||||
|             else: |  | ||||||
|                 component_opts = mtch.group(2) |  | ||||||
|                 components_opts_cleaned = list() |  | ||||||
|                 if(component_opts == None or len(component_opts) == 0): |  | ||||||
|                     pass |  | ||||||
|                 else: |  | ||||||
|                     sp_component_opts = component_opts.split(",") |  | ||||||
|                     for co in sp_component_opts: |  | ||||||
|                         cleaned_opt = co.strip() |  | ||||||
|                         if(len(cleaned_opt)): |  | ||||||
|                             components_opts_cleaned.append(cleaned_opt) |  | ||||||
|                 adjusted_components[component_name] = components_opts_cleaned |  | ||||||
|         else: |  | ||||||
|             LOG.warn("Unparseable component %s" % (c)) |  | ||||||
|     #should we adjust them to be all the components? |  | ||||||
|     if(len(adjusted_components) == 0 and assume_all): |  | ||||||
|         all_components = dict() |  | ||||||
|         for c in constants.COMPONENT_NAMES: |  | ||||||
|             all_components[c] = list() |  | ||||||
|         adjusted_components = all_components |  | ||||||
|     return adjusted_components |  | ||||||
|  |  | ||||||
|  |  | ||||||
| def prioritize_components(components): |  | ||||||
|     #get the right component order (by priority) |  | ||||||
|     mporder = dict() |  | ||||||
|     priorities = constants.COMPONENT_NAMES_PRIORITY |  | ||||||
|     for c in components: |  | ||||||
|         priority = priorities.get(c) |  | ||||||
|         if(priority == None): |  | ||||||
|             priority = sys.maxint |  | ||||||
|         mporder[c] = priority |  | ||||||
|     #sort by priority value |  | ||||||
|     priority_order = sorted(mporder.iteritems(), key=operator.itemgetter(1)) |  | ||||||
|     #extract the right order |  | ||||||
|     component_order = [x[0] for x in priority_order] |  | ||||||
|     return component_order |  | ||||||
|  |  | ||||||
|  |  | ||||||
| def component_paths(root, component_name): | def component_paths(root, component_name): | ||||||
|     component_root = sh.joinpths(root, component_name) |     component_root = sh.joinpths(root, component_name) | ||||||
|     tracedir = sh.joinpths(component_root, constants.COMPONENT_TRACE_DIR) |     tracedir = sh.joinpths(component_root, settings.COMPONENT_TRACE_DIR) | ||||||
|     appdir = sh.joinpths(component_root, constants.COMPONENT_APP_DIR) |     appdir = sh.joinpths(component_root, settings.COMPONENT_APP_DIR) | ||||||
|     cfgdir = sh.joinpths(component_root, constants.COMPONENT_CONFIG_DIR) |     cfgdir = sh.joinpths(component_root, settings.COMPONENT_CONFIG_DIR) | ||||||
|     return (component_root, tracedir, appdir, cfgdir) |     return (component_root, tracedir, appdir, cfgdir) | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -183,9 +88,9 @@ def load_json(fn): | |||||||
| def get_host_ip(): | def get_host_ip(): | ||||||
|     ip = None |     ip = None | ||||||
|     interfaces = get_interfaces() |     interfaces = get_interfaces() | ||||||
|     def_info = interfaces.get(constants.DEFAULT_NET_INTERFACE) |     def_info = interfaces.get(settings.DEFAULT_NET_INTERFACE) | ||||||
|     if(def_info): |     if(def_info): | ||||||
|         ipinfo = def_info.get(constants.DEFAULT_NET_INTERFACE_IP_VERSION) |         ipinfo = def_info.get(settings.DEFAULT_NET_INTERFACE_IP_VERSION) | ||||||
|         if(ipinfo): |         if(ipinfo): | ||||||
|             ip = ipinfo.get('addr') |             ip = ipinfo.get('addr') | ||||||
|     if(ip == None): |     if(ip == None): | ||||||
| @@ -202,11 +107,11 @@ def get_interfaces(): | |||||||
|         ip6 = interface_addresses.get(netifaces.AF_INET6) |         ip6 = interface_addresses.get(netifaces.AF_INET6) | ||||||
|         if(ip6 and len(ip6)): |         if(ip6 and len(ip6)): | ||||||
|             #just take the first |             #just take the first | ||||||
|             interface_info[constants.IPV6] = ip6[0] |             interface_info[settings.IPV6] = ip6[0] | ||||||
|         ip4 = interface_addresses.get(netifaces.AF_INET) |         ip4 = interface_addresses.get(netifaces.AF_INET) | ||||||
|         if(ip4 and len(ip4)): |         if(ip4 and len(ip4)): | ||||||
|             #just take the first |             #just take the first | ||||||
|             interface_info[constants.IPV4] = ip4[0] |             interface_info[settings.IPV4] = ip4[0] | ||||||
|         #there are others but this is good for now |         #there are others but this is good for now | ||||||
|         interfaces[intfc] = interface_info |         interfaces[intfc] = interface_info | ||||||
|     return interfaces |     return interfaces | ||||||
| @@ -220,7 +125,7 @@ def determine_distro(): | |||||||
|         return (None, plt) |         return (None, plt) | ||||||
|     #attempt to match it to our platforms |     #attempt to match it to our platforms | ||||||
|     found_os = None |     found_os = None | ||||||
|     for (known_os, pattern) in constants.KNOWN_DISTROS.items(): |     for (known_os, pattern) in settings.KNOWN_DISTROS.items(): | ||||||
|         if(pattern.search(plt)): |         if(pattern.search(plt)): | ||||||
|             found_os = known_os |             found_os = known_os | ||||||
|             break |             break | ||||||
| @@ -230,7 +135,7 @@ def determine_distro(): | |||||||
| def get_pip_list(distro, component): | def get_pip_list(distro, component): | ||||||
|     LOG.info("Getting pip packages for distro %s and component %s." % (distro, component)) |     LOG.info("Getting pip packages for distro %s and component %s." % (distro, component)) | ||||||
|     all_pkgs = dict() |     all_pkgs = dict() | ||||||
|     fns = constants.PIP_MAP.get(component) |     fns = settings.PIP_MAP.get(component) | ||||||
|     if(fns == None): |     if(fns == None): | ||||||
|         return all_pkgs |         return all_pkgs | ||||||
|     #load + merge them |     #load + merge them | ||||||
| @@ -249,7 +154,7 @@ def get_pip_list(distro, component): | |||||||
| def get_pkg_list(distro, component): | def get_pkg_list(distro, component): | ||||||
|     LOG.info("Getting packages for distro %s and component %s." % (distro, component)) |     LOG.info("Getting packages for distro %s and component %s." % (distro, component)) | ||||||
|     all_pkgs = dict() |     all_pkgs = dict() | ||||||
|     fns = constants.PKG_MAP.get(component) |     fns = settings.PKG_MAP.get(component) | ||||||
|     if(fns == None): |     if(fns == None): | ||||||
|         return all_pkgs |         return all_pkgs | ||||||
|     #load + merge them |     #load + merge them | ||||||
| @@ -265,7 +170,7 @@ def get_pkg_list(distro, component): | |||||||
|                     for (infokey, infovalue) in pkginfo.items(): |                     for (infokey, infovalue) in pkginfo.items(): | ||||||
|                         #this is expected to be a list of cmd actions |                         #this is expected to be a list of cmd actions | ||||||
|                         #so merge that accordingly |                         #so merge that accordingly | ||||||
|                         if(infokey == constants.PRE_INSTALL or infokey == constants.POST_INSTALL): |                         if(infokey == settings.PRE_INSTALL or infokey == settings.POST_INSTALL): | ||||||
|                             oldinstalllist = oldpkginfo.get(infokey) or [] |                             oldinstalllist = oldpkginfo.get(infokey) or [] | ||||||
|                             infovalue = oldinstalllist + infovalue |                             infovalue = oldinstalllist + infovalue | ||||||
|                         newpkginfo[infokey] = infovalue |                         newpkginfo[infokey] = infovalue | ||||||
| @@ -309,8 +214,58 @@ def param_replace(text, replacements, ignore_missing=False): | |||||||
|     return PARAM_SUB_REGEX.sub(replacer, text) |     return PARAM_SUB_REGEX.sub(replacer, text) | ||||||
|  |  | ||||||
|  |  | ||||||
|  | def _get_welcome_stack(): | ||||||
|  |     possibles = list() | ||||||
|  |     #thank you figlet ;) | ||||||
|  |     possibles.append(r''' | ||||||
|  |   ___  ____  _____ _   _ ____ _____  _    ____ _  __ | ||||||
|  |  / _ \|  _ \| ____| \ | / ___|_   _|/ \  / ___| |/ / | ||||||
|  | | | | | |_) |  _| |  \| \___ \ | | / _ \| |   | ' / | ||||||
|  | | |_| |  __/| |___| |\  |___) || |/ ___ \ |___| . \ | ||||||
|  |  \___/|_|   |_____|_| \_|____/ |_/_/   \_\____|_|\_\ | ||||||
|  |  | ||||||
|  | ''') | ||||||
|  |     possibles.append(r''' | ||||||
|  |   ___  ___ ___ _  _ ___ _____ _   ___ _  __ | ||||||
|  |  / _ \| _ \ __| \| / __|_   _/_\ / __| |/ / | ||||||
|  | | (_) |  _/ _|| .` \__ \ | |/ _ \ (__| ' <  | ||||||
|  |  \___/|_| |___|_|\_|___/ |_/_/ \_\___|_|\_\ | ||||||
|  |  | ||||||
|  | ''')             | ||||||
|  |     possibles.append(r''' | ||||||
|  | ____ ___  ____ _  _ ____ ___ ____ ____ _  _  | ||||||
|  | |  | |__] |___ |\ | [__   |  |__| |    |_/   | ||||||
|  | |__| |    |___ | \| ___]  |  |  | |___ | \_  | ||||||
|  |  | ||||||
|  | ''') | ||||||
|  |     possibles.append(r''' | ||||||
|  |   _  ___ ___  _  _  __  ___  _   __  _  _ | ||||||
|  |  / \| o \ __|| \| |/ _||_ _|/ \ / _|| |// | ||||||
|  | ( o )  _/ _| | \\ |\_ \ | || o ( (_ |  (  | ||||||
|  |  \_/|_| |___||_|\_||__/ |_||_n_|\__||_|\\ | ||||||
|  |  | ||||||
|  | ''') | ||||||
|  |     possibles.append(r''' | ||||||
|  |    _   ___  ___  _  __  ___ _____  _    __  _    | ||||||
|  |  ,' \ / o |/ _/ / |/ /,' _//_  _/.' \ ,'_/ / //7 | ||||||
|  | / o |/ _,'/ _/ / || /_\ `.  / / / o // /_ /  ,'  | ||||||
|  | |_,'/_/  /___//_/|_//___,' /_/ /_n_/ |__//_/\\   | ||||||
|  |  | ||||||
|  | ''') | ||||||
|  |     possibles.append(r''' | ||||||
|  |  _____  ___    ___    _   _  ___   _____  _____  ___    _   _  | ||||||
|  | (  _  )(  _`\ (  _`\ ( ) ( )(  _`\(_   _)(  _  )(  _`\ ( ) ( ) | ||||||
|  | | ( ) || |_) )| (_(_)| `\| || (_(_) | |  | (_) || ( (_)| |/'/' | ||||||
|  | | | | || ,__/'|  _)_ | , ` |`\__ \  | |  |  _  || |  _ | , <   | ||||||
|  | | (_) || |    | (_( )| |`\ |( )_) | | |  | | | || (_( )| |\`\  | ||||||
|  | (_____)(_)    (____/'(_) (_)`\____) (_)  (_) (_)(____/'(_) (_) | ||||||
|  |  | ||||||
|  | ''') | ||||||
|  |     return random.choice(possibles) | ||||||
|  |  | ||||||
|  |  | ||||||
| def welcome(action): | def welcome(action): | ||||||
|     formatted_action = constants.WELCOME_MAP.get(action, "") |     formatted_action = settings.WELCOME_MAP.get(action, "") | ||||||
|     ver_str = version.version_string() |     ver_str = version.version_string() | ||||||
|     lower = "|" |     lower = "|" | ||||||
|     if(formatted_action): |     if(formatted_action): | ||||||
| @@ -318,19 +273,16 @@ def welcome(action): | |||||||
|         lower += " " |         lower += " " | ||||||
|     lower += ver_str |     lower += ver_str | ||||||
|     lower += "|" |     lower += "|" | ||||||
|     welcome_ = r''' |     welcome_ = _get_welcome_stack() | ||||||
|   ___  ____  _____ _   _ ____ _____  _    ____ _  __ |  | ||||||
|  / _ \|  _ \| ____| \ | / ___|_   _|/ \  / ___| |/ / |  | ||||||
| | | | | |_) |  _| |  \| \___ \ | | / _ \| |   | ' / |  | ||||||
| | |_| |  __/| |___| |\  |___) || |/ ___ \ |___| . \ |  | ||||||
|  \___/|_|   |_____|_| \_|____/ |_/_/   \_\____|_|\_\ |  | ||||||
|  |  | ||||||
| ''' |  | ||||||
|     welcome_ = welcome_.strip("\n\r") |     welcome_ = welcome_.strip("\n\r") | ||||||
|     max_len = len(max(welcome_.splitlines(), key=len)) |     max_line_len = len(max(welcome_.splitlines(), key=len)) | ||||||
|     lower_out = colored(constants.PROG_NICE_NAME, 'green') + \ |     lower_out = colored(settings.PROG_NICE_NAME, 'green') + \ | ||||||
|                 ": " + colored(lower, 'blue') |                 ": " + colored(lower, 'blue') | ||||||
|     uncolored_lower_len = (len(constants.PROG_NICE_NAME + ": " + lower)) |     uncolored_lower = (settings.PROG_NICE_NAME + ": " + lower) | ||||||
|     center_len = max_len + (max_len - uncolored_lower_len) |     if(max_line_len - len(uncolored_lower) > 0): | ||||||
|     lower_out = lower_out.center(center_len) |         #this format string wil center the uncolored text which | ||||||
|  |         #we will then replace | ||||||
|  |         #with the color text equivalent | ||||||
|  |         centered_str = '{0:{fill}{align}{size}}'.format(uncolored_lower, fill=" ", align="^", size=max_line_len) | ||||||
|  |         lower_out = centered_str.replace(uncolored_lower, lower_out) | ||||||
|     print((welcome_ + os.linesep + lower_out)) |     print((welcome_ + os.linesep + lower_out)) | ||||||
|   | |||||||
							
								
								
									
										1
									
								
								stack
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								stack
									
									
									
									
									
								
							| @@ -23,7 +23,6 @@ logging.setup() | |||||||
|  |  | ||||||
| #this handles our option parsing | #this handles our option parsing | ||||||
| from devstack import opts | from devstack import opts | ||||||
| from devstack import constants |  | ||||||
|  |  | ||||||
| #these are the program runtimes that actually do the running | #these are the program runtimes that actually do the running | ||||||
| from devstack.progs import actions | from devstack.progs import actions | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Joshua Harlow
					Joshua Harlow