def post_start(self): if not sh.isfile(self.init_fn) and self.get_bool_option('do-init'): self.wait_active() LOG.info("Running commands to initialize keystone.") (fn, contents) = utils.load_template(self.name, INIT_WHAT_FN) LOG.debug("Initializing with contents of %s", fn) params = {} params['keystone'] = khelper.get_shared_params(**utils.merge_dicts(self.options, khelper.get_shared_passwords(self))) params['glance'] = ghelper.get_shared_params(ip=self.get_option('ip'), **self.get_option('glance')) params['nova'] = nhelper.get_shared_params(ip=self.get_option('ip'), **self.get_option('nova')) params['neutron'] = net_helper.get_shared_params(ip=self.get_option('ip'), **self.get_option('neutron')) params['cinder'] = chelper.get_shared_params(ip=self.get_option('ip'), **self.get_option('cinder')) wait_urls = [ params['keystone']['endpoints']['admin']['uri'], params['keystone']['endpoints']['public']['uri'], ] for url in wait_urls: utils.wait_for_url(url) init_what = utils.load_yaml_text(contents) init_what = utils.expand_template_deep(init_what, params) try: init_how = khelper.Initializer(params['keystone']['service_token'], params['keystone']['endpoints']['admin']['uri']) init_how.initialize(**init_what) except RuntimeError: LOG.exception("Failed to initialize keystone, is the keystone client library available?") else: # Writing this makes sure that we don't init again sh.write_file(self.init_fn, utils.prettify_yaml(init_what)) LOG.info("If you wish to re-run initialization, delete %s", colorizer.quote(self.init_fn))
def post_start(self): if not sh.isfile(self.init_fn) and self.get_bool_option('do-init'): self.wait_active() LOG.info("Running commands to initialize keystone.") (fn, contents) = utils.load_template(self.name, INIT_WHAT_FN) LOG.debug("Initializing with contents of %s", fn) params = {} params['keystone'] = khelper.get_shared_params(**utils.merge_dicts(self.options, khelper.get_shared_passwords(self))) params['glance'] = ghelper.get_shared_params(ip=self.get_option('ip'), **self.get_option('glance')) params['nova'] = nhelper.get_shared_params(ip=self.get_option('ip'), **self.get_option('nova')) params['quantum'] = qhelper.get_shared_params(ip=self.get_option('ip'), **self.get_option('quantum')) params['cinder'] = chelper.get_shared_params(ip=self.get_option('ip'), **self.get_option('cinder')) wait_urls = [ params['keystone']['endpoints']['admin']['uri'], params['keystone']['endpoints']['public']['uri'], ] for url in wait_urls: utils.wait_for_url(url) init_what = utils.load_yaml_text(contents) init_what = utils.expand_template_deep(self._filter_init(init_what), params) khelper.Initializer(params['keystone']['service_token'], params['keystone']['endpoints']['admin']['uri']).initialize(**init_what) # Writing this makes sure that we don't init again sh.write_file(self.init_fn, utils.prettify_yaml(init_what)) LOG.info("If you wish to re-run initialization, delete %s", colorizer.quote(self.init_fn))
def _add_bridge(self, name): cmd_template = self.distro.get_command('openvswitch', 'add_bridge') cmd = utils.expand_template_deep(cmd_template, {'NAME': name}) try: sh.execute(cmd) except excp.ProcessExecutionError: LOG.warn("Failed to create '%s' openvswitch bridge." % name)
def post_start(self): if not sh.isfile(self.init_fn) and self.get_bool_option("do-init"): self.wait_active() LOG.info("Running commands to initialize keystone.") (fn, contents) = utils.load_template(self.name, INIT_WHAT_FN) LOG.debug("Initializing with contents of %s", fn) params = {} params["keystone"] = khelper.get_shared_params( **utils.merge_dicts(self.options, khelper.get_shared_passwords(self)) ) params["glance"] = ghelper.get_shared_params(ip=self.get_option("ip"), **self.get_option("glance")) params["nova"] = nhelper.get_shared_params(ip=self.get_option("ip"), **self.get_option("nova")) wait_urls = [ params["keystone"]["endpoints"]["admin"]["uri"], params["keystone"]["endpoints"]["public"]["uri"], ] for url in wait_urls: utils.wait_for_url(url) init_what = utils.load_yaml_text(contents) init_what = utils.expand_template_deep(self._filter_init(init_what), params) khelper.Initializer( params["keystone"]["service_token"], params["keystone"]["endpoints"]["admin"]["uri"] ).initialize(**init_what) # Writing this makes sure that we don't init again sh.write_file(self.init_fn, utils.prettify_yaml(init_what)) LOG.info("If you wish to re-run initialization, delete %s", colorizer.quote(self.init_fn))
def post_install(self): binstall.PkgInstallComponent.post_install(self) user_name = self.get_option('user_id') try: LOG.debug("Attempting to create the qpid user '%s' and their associated password.", user_name) cmd_template = self.distro.get_command('qpid', 'create_user') cmd = utils.expand_template_deep(cmd_template, {'USER': user_name}) if cmd: sh.execute(cmd, process_input=self.get_password('qpid')) except IOError: LOG.warn(("Could not create the user/password. You might have to manually " "create the user/password before running."))
def post_uninstall(self): binstall.PkgUninstallComponent.post_uninstall(self) user_name = self.get_option('user_id') if user_name in NO_DELETE: return try: LOG.debug("Attempting to delete the qpid user '%s' and their associated password.", user_name) cmd_template = self.distro.get_command('qpid', 'delete_user') cmd = utils.expand_template_deep(cmd_template, {'USER': user_name}) if cmd: sh.execute(cmd) except IOError: LOG.warn(("Could not delete the user/password. You might have to manually " "reset the user/password before the next install."))
def post_install(self): binstall.PkgInstallComponent.post_install(self) user_name = self.get_option('user_id') try: LOG.debug( "Attempting to create the qpid user '%s' and their associated password.", user_name) cmd_template = self.distro.get_command('qpid', 'create_user') cmd = utils.expand_template_deep(cmd_template, {'USER': user_name}) if cmd: sh.execute(cmd, process_input=self.get_password('qpid')) except IOError: LOG.warn(( "Could not create the user/password. You might have to manually " "create the user/password before running."))
def post_uninstall(self): binstall.PkgUninstallComponent.post_uninstall(self) user_name = self.get_option('user_id') if user_name in NO_DELETE: return try: LOG.debug( "Attempting to delete the qpid user '%s' and their associated password.", user_name) cmd_template = self.distro.get_command('qpid', 'delete_user') cmd = utils.expand_template_deep(cmd_template, {'USER': user_name}) if cmd: sh.execute(cmd) except IOError: LOG.warn(( "Could not delete the user/password. You might have to manually " "reset the user/password before the next install."))
def get_command(self, command, program): program = self.daemon_name(program) cmd_template = self.distro.get_command("service", command) return utils.expand_template_deep(cmd_template, {'NAME': program})