def _config_adjust(self, contents, config_fn): if config_fn == ROOT_CONF: with io.BytesIO(contents) as stream: config = cfg.RewritableConfigParser() config.readfp(stream) config.set('DEFAULT', 'sql_connection', dbhelper.fetch_dbdsn(self.cfg, DB_NAME, utf8=True)) config.set('DEFAULT', 'verbose', True) config.set('DEFAULT', 'debug', True) contents = config.stringify(config_fn) return contents
def _config_adjust_registry(self, contents, fn): params = ghelper.get_shared_params(self.cfg) with io.BytesIO(contents) as stream: config = cfg.RewritableConfigParser() config.readfp(stream) config.set('DEFAULT', 'debug', True) config.set('DEFAULT', 'verbose', True) config.set('DEFAULT', 'bind_port', params['endpoints']['registry']['port']) config.set('DEFAULT', 'sql_connection', dbhelper.fetch_dbdsn(self.cfg, DB_NAME, utf8=True)) config.remove_option('DEFAULT', 'log_file') config.set('paste_deploy', 'flavor', 'keystone') return config.stringify(fn) return contents
def _config_adjust(self, contents, config_fn): if config_fn == PLUGIN_CONF and self.q_vswitch_service: # Need to fix the "Quantum plugin provider module" with io.BytesIO(contents) as stream: config = cfg.RewritableConfigParser() config.readfp(stream) config.set("plugin", "provider", "quantum.plugins.openvswitch.ovs_quantum_plugin.OVSQuantumPlugin") contents = config.stringify(config_fn) return contents elif config_fn == AGENT_CONF and self.q_vswitch_agent: # Need to adjust the sql connection with io.BytesIO(contents) as stream: config = cfg.RewritableConfigParser() config.readfp(stream) config.set("database", "sql_connection", dbhelper.fetch_dbdsn(self.cfg, DB_NAME, utf8=True)) contents = config.stringify(config_fn) return contents else: return comp.PkgInstallComponent._config_adjust(self, contents, config_fn)
def _config_adjust_root(self, contents, fn): params = khelper.get_shared_params(self.cfg) with io.BytesIO(contents) as stream: config = cfg.RewritableConfigParser() config.readfp(stream) config.set('DEFAULT', 'admin_token', params['service_token']) config.set('DEFAULT', 'admin_port', params['endpoints']['admin']['port']) config.set('DEFAULT', 'public_port', params['endpoints']['public']['port']) config.set('DEFAULT', 'verbose', True) config.set('DEFAULT', 'debug', True) config.set('catalog', 'driver', 'keystone.catalog.backends.sql.Catalog') config.remove_option('DEFAULT', 'log_config') config.set('sql', 'connection', dbhelper.fetch_dbdsn(self.cfg, DB_NAME, utf8=True)) config.set('ec2', 'driver', "keystone.contrib.ec2.backends.sql.Ec2") config.set('filter:s3_extension', 'paste.filter_factory', "keystone.contrib.s3:S3Extension.factory") config.set('pipeline:admin_api', 'pipeline', ('token_auth admin_token_auth xml_body ' 'json_body debug ec2_extension s3_extension crud_extension admin_service')) contents = config.stringify(fn) return contents
def _config_adjust_api(self, contents, fn): params = ghelper.get_shared_params(self.cfg) 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', True) config.set('DEFAULT', 'verbose', True) 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(self.cfg, DB_NAME, utf8=True)) config.remove_option('DEFAULT', 'log_file') config.set('paste_deploy', 'flavor', 'keystone') LOG.info("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 configure(self, fn=API_CONF, root_wrapped=False): # Everything built goes in here nova_conf = Conf(fn) # Used more than once so we calculate it ahead of time hostip = self.cfg.get('host', 'ip') if self._getbool('verbose'): nova_conf.add('verbose', True) # Allow the admin api? if self._getbool('allow_admin_api'): nova_conf.add('allow_admin_api', True) # FIXME: ?? nova_conf.add('allow_resize_to_same_host', True) # Which scheduler do u want? nova_conf.add('compute_scheduler_driver', self._getstr('scheduler', DEF_SCHEDULER)) # Rate limit the api?? nova_conf.add('api_rate_limit', self._getbool('api_rate_limit')) # Setup any network settings self._configure_network_settings(nova_conf) # Setup nova volume settings if self.volumes_enabled: self._configure_vols(nova_conf) # The ip of where we are running nova_conf.add('my_ip', hostip) # Setup your sql connection nova_conf.add('sql_connection', dbhelper.fetch_dbdsn(self.cfg, DB_NAME)) # Configure anything libvirt related? virt_driver = canon_virt_driver(self._getstr('virt_driver')) if virt_driver == 'libvirt': libvirt_type = lv.canon_libvirt_type(self._getstr('libvirt_type')) self._configure_libvirt(libvirt_type, nova_conf) # How instances will be presented instance_template = self._getstr('instance_name_prefix') + self._getstr('instance_name_postfix') if not instance_template: instance_template = DEF_INSTANCE_TEMPL nova_conf.add('instance_name_template', instance_template) # Enable the standard extensions nova_conf.add('osapi_compute_extension', STD_COMPUTE_EXTS) # Auth will be using keystone nova_conf.add('auth_strategy', 'keystone') # Don't always force images to raw nova_conf.add('force_raw_images', self._getbool('force_raw_images')) # Add a checksum for images fetched to a hypervisor nova_conf.add('checksum_base_images', self._getbool('checksum_base_images')) # Vnc settings setup self._configure_vnc(nova_conf) # Where our paste config is nova_conf.add('api_paste_config', self.paste_conf_fn) # What our imaging service will be self._configure_image_service(nova_conf, hostip) # Configs for ec2 / s3 stuff nova_conf.add('ec2_dmz_host', self._getstr('ec2_dmz_host', hostip)) nova_conf.add('s3_host', hostip) # How is your mq setup? mq_type = canon_mq_type(self.installer.get_option('mq')) if mq_type == 'rabbit': nova_conf.add('rabbit_host', self.cfg.getdefaulted('rabbit', 'rabbit_host', hostip)) nova_conf.add('rabbit_password', self.cfg.get("passwords", "rabbit")) nova_conf.add('rabbit_userid', self.cfg.get('rabbit', 'rabbit_userid')) nova_conf.add('rpc_backend', 'nova.rpc.impl_kombu') elif mq_type == 'qpid': nova_conf.add('rpc_backend', 'nova.rpc.impl_qpid') nova_conf.add('qpid_hostname', self.cfg.getdefaulted('qpid', 'qpid_hostname', hostip)) qpid_user = self.cfg.get('qpid', 'qpid_username') if qpid_user: nova_conf.add('qpid_username', qpid_user) elif mq_type == 'zeromq': # TODO more needed??? nova_conf.add('rpc_backend', 'nova.rpc.impl_kombu') # Where instances will be stored instances_path = self._getstr('instances_path', sh.joinpths(self.installer.get_option('component_dir'), 'instances')) self._configure_instances_path(instances_path, nova_conf) # Is this a multihost setup? self._configure_multihost(nova_conf) # Handle any virt driver specifics self._configure_virt_driver(nova_conf) # Setup our root wrap helper that will limit our sudo ability if root_wrapped: self._configure_root_wrap(nova_conf) # Annnnnd extract to finish return self._get_content(nova_conf)