def _config_adjust_api(self, contents, fn): params = ghelper.get_shared_params(**self.options) with io.BytesIO(contents) as stream: config = cfg.create_parser(cfg.RewritableConfigParser, self) config.readfp(stream) img_store_dir = sh.joinpths(self.get_option('component_dir'), 'images') config.set('DEFAULT', 'debug', self.get_bool_option('verbose', )) config.set('DEFAULT', 'verbose', self.get_bool_option('verbose')) config.set('DEFAULT', 'default_store', 'file') config.set('DEFAULT', 'filesystem_store_datadir', img_store_dir) config.set('DEFAULT', 'bind_port', params['endpoints']['public']['port']) config.set( 'DEFAULT', 'sql_connection', dbhelper.fetch_dbdsn(dbname=DB_NAME, utf8=True, dbtype=self.get_option('db', 'type'), **utils.merge_dicts( self.get_option('db'), dbhelper.get_shared_passwords(self)))) config.remove_option('DEFAULT', 'log_file') config.set('paste_deploy', 'flavor', self.get_option('paste_flavor')) LOG.debug( "Ensuring file system store directory %r exists and is empty." % (img_store_dir)) sh.deldir(img_store_dir) self.tracewriter.dirs_made(*sh.mkdirslist(img_store_dir)) return config.stringify(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['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 _config_adjust_api_reg(self, contents, fn): gparams = ghelper.get_shared_params(**self.options) with io.BytesIO(contents) as stream: config = cfg.create_parser(cfg.RewritableConfigParser, self) config.readfp(stream) config.set('DEFAULT', 'debug', self.get_bool_option('verbose')) config.set('DEFAULT', 'verbose', self.get_bool_option('verbose')) if fn in [REG_CONF]: config.set('DEFAULT', 'bind_port', gparams['endpoints']['registry']['port']) else: config.set('DEFAULT', 'bind_port', gparams['endpoints']['public']['port']) config.set('DEFAULT', 'sql_connection', dbhelper.fetch_dbdsn(dbname=DB_NAME, utf8=True, dbtype=self.get_option('db', 'type'), **utils.merge_dicts(self.get_option('db'), dbhelper.get_shared_passwords(self)))) config.remove_option('DEFAULT', 'log_file') config.set('paste_deploy', 'flavor', self.get_option('paste_flavor')) for (k, v) in self._fetch_keystone_params().items(): config.set('keystone_authtoken', k, v) if fn in [API_CONF]: config.set('DEFAULT', 'default_store', 'file') img_store_dir = sh.joinpths(self.get_option('component_dir'), 'images') config.set('DEFAULT', 'filesystem_store_datadir', img_store_dir) LOG.debug("Ensuring file system store directory %r exists and is empty." % (img_store_dir)) if sh.isdir(img_store_dir): sh.deldir(img_store_dir) sh.mkdirslist(img_store_dir, tracewriter=self.tracewriter, adjust_suids=True) return config.stringify(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")) 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 _config_adjust_api(self, config): self._config_adjust_api_reg(config) gparams = ghelper.get_shared_params(**self.installer.options) config.add('bind_port', gparams['endpoints']['public']['port']) config.add( 'default_store', 'file') img_store_dir = sh.joinpths(self.installer.get_option('component_dir'), 'images') config.add('filesystem_store_datadir', img_store_dir) LOG.debug("Ensuring file system store directory %r exists and is empty." % (img_store_dir)) if sh.isdir(img_store_dir): sh.deldir(img_store_dir) sh.mkdirslist(img_store_dir, tracewriter=self.installer.tracewriter)
def post_start(self): comp.PythonRuntime.post_start(self) if self.get_bool_option('load-images'): # Install any images that need activating... self.wait_active() params = {} params['glance'] = ghelper.get_shared_params(**self.options) params['keystone'] = khelper.get_shared_params(ip=self.get_option('ip'), service_user='******', **utils.merge_dicts(self.get_option('keystone'), khelper.get_shared_passwords(self))) ghelper.UploadService(params).install(self._get_image_urls())
def post_start(self): comp.PythonRuntime.post_start(self) if self.get_bool_option('load-images'): # Install any images that need activating... self.wait_active() params = {} params['glance'] = ghelper.get_shared_params(**self.options) params['keystone'] = khelper.get_shared_params( ip=self.get_option('ip'), service_user='******', **utils.merge_dicts(self.get_option('keystone'), khelper.get_shared_passwords(self))) ghelper.UploadService(params).install(self._get_image_urls())
def _config_adjust_api(self, config): self._config_adjust_api_reg(config) gparams = ghelper.get_shared_params(**self.installer.options) config.add('bind_port', gparams['endpoints']['public']['port']) config.add('default_store', 'file') img_store_dir = sh.joinpths(self.installer.get_option('component_dir'), 'images') config.add('filesystem_store_datadir', img_store_dir) LOG.debug( "Ensuring file system store directory %r exists and is empty." % (img_store_dir)) if sh.isdir(img_store_dir): sh.deldir(img_store_dir) sh.mkdirslist(img_store_dir, tracewriter=self.installer.tracewriter)
def _config_adjust_api(self, config): self._config_adjust_api_reg(config) gparams = ghelper.get_shared_params(**self.installer.options) config.add('bind_port', gparams['endpoints']['public']['port']) def ensure_image_storage(img_store_dir): if sh.isdir(img_store_dir): return LOG.debug("Ensuring file system store directory %r exists.", img_store_dir) sh.mkdirslist(img_store_dir, tracewriter=self.installer.tracewriter) config.add('default_store', 'file') config.add('filesystem_store_datadir', self.img_dir) ensure_image_storage(self.img_dir)
def _config_adjust_registry(self, contents, fn): params = ghelper.get_shared_params(**self.options) with io.BytesIO(contents) as stream: config = cfg.RewritableConfigParser() config.readfp(stream) config.set('DEFAULT', 'debug', self.get_bool_option('verbose')) config.set('DEFAULT', 'verbose', self.get_bool_option('verbose')) config.set('DEFAULT', 'bind_port', params['endpoints']['registry']['port']) config.set('DEFAULT', 'sql_connection', dbhelper.fetch_dbdsn(dbname=DB_NAME, utf8=True, dbtype=self.get_option('db', 'type'), **utils.merge_dicts(self.get_option('db'), dbhelper.get_shared_passwords(self)))) config.remove_option('DEFAULT', 'log_file') config.set('paste_deploy', 'flavor', self.get_option('paste_flavor')) return config.stringify(fn) return contents
def _config_adjust_registry(self, contents, fn): params = ghelper.get_shared_params(**self.options) with io.BytesIO(contents) as stream: config = cfg.create_parser(cfg.RewritableConfigParser, self) config.readfp(stream) config.set('DEFAULT', 'debug', self.get_bool_option('verbose')) config.set('DEFAULT', 'verbose', self.get_bool_option('verbose')) config.set('DEFAULT', 'bind_port', params['endpoints']['registry']['port']) config.set( 'DEFAULT', 'sql_connection', dbhelper.fetch_dbdsn(dbname=DB_NAME, utf8=True, dbtype=self.get_option('db', 'type'), **utils.merge_dicts( self.get_option('db'), dbhelper.get_shared_passwords(self)))) config.remove_option('DEFAULT', 'log_file') config.set('paste_deploy', 'flavor', self.get_option('paste_flavor')) return config.stringify(fn) return contents
def _config_adjust_api(self, contents, fn): params = ghelper.get_shared_params(**self.options) with io.BytesIO(contents) as stream: config = cfg.RewritableConfigParser() config.readfp(stream) img_store_dir = sh.joinpths(self.get_option('component_dir'), 'images') config.set('DEFAULT', 'debug', self.get_bool_option('verbose',)) config.set('DEFAULT', 'verbose', self.get_bool_option('verbose')) config.set('DEFAULT', 'default_store', 'file') config.set('DEFAULT', 'filesystem_store_datadir', img_store_dir) config.set('DEFAULT', 'bind_port', params['endpoints']['public']['port']) config.set('DEFAULT', 'sql_connection', dbhelper.fetch_dbdsn(dbname=DB_NAME, utf8=True, dbtype=self.get_option('db', 'type'), **utils.merge_dicts(self.get_option('db'), dbhelper.get_shared_passwords(self)))) config.remove_option('DEFAULT', 'log_file') config.set('paste_deploy', 'flavor', self.get_option('paste_flavor')) LOG.debug("Ensuring file system store directory %r exists and is empty." % (img_store_dir)) sh.deldir(img_store_dir) self.tracewriter.dirs_made(*sh.mkdirslist(img_store_dir)) return config.stringify(fn)
def env_exports(self): to_set = OrderedDict() params = ghelper.get_shared_params(**self.options) for (endpoint, details) in params['endpoints'].items(): to_set[("GLANCE_%s_URI" % (endpoint.upper()))] = details['uri'] return to_set
def _config_adjust_reg(self, config): self._config_adjust_api_reg(config) gparams = ghelper.get_shared_params(**self.installer.options) config.add('bind_port', gparams['endpoints']['registry']['port'])