def pre_start(self): # Let the parent class do its thing comp.PythonRuntime.pre_start(self) virt_driver = nhelper.canon_virt_driver(self.cfg.get("nova", "virt_driver")) if virt_driver == "libvirt": # FIXME: The configuration for the virtualization-type # should come from the persona. virt_type = lv.canon_libvirt_type(self.cfg.get("nova", "libvirt_type")) LOG.info( "Checking that your selected libvirt virtualization type %s is working and running.", colorizer.quote(virt_type), ) try: self.virsh.check_virt(virt_type) self.virsh.restart_service() LOG.info("Libvirt virtualization type %s seems to be working and running.", colorizer.quote(virt_type)) except exceptions.ProcessExecutionError as e: msg = ( "Libvirt type %r does not seem to be active or configured correctly, " "perhaps you should be using %r instead: %s" % (virt_type, lv.DEF_VIRT_TYPE, e) ) raise exceptions.StartException(msg)
def _clear_libvirt_domains(self): virt_driver = nhelper.canon_virt_driver(self.cfg.get("nova", "virt_driver")) if virt_driver == "libvirt": inst_prefix = self.cfg.getdefaulted("nova", "instance_name_prefix", DEF_INSTANCE_PREFIX) libvirt_type = lv.canon_libvirt_type(self.cfg.get("nova", "libvirt_type")) self.virsh.clear_domains(libvirt_type, inst_prefix)
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)