def pre_start(self): virt_driver = self.cfg.get('nova', 'virt_driver') if virt_driver == virsh.VIRT_TYPE: virt_type = virsh.default(self.cfg.get('nova', 'libvirt_type')) LOG.info("Checking that your selected libvirt virtualization type [%s] is working and running." % (virt_type)) if not virsh.virt_ok(virt_type, self.distro): msg = ("Libvirt type %s for distro %s does not seem to be active or configured correctly, " "perhaps you should be using %s instead." % (virt_type, self.distro, virsh.DEFAULT_VIRT)) raise exceptions.StartException(msg) virsh.restart(self.distro)
def configure(self, component_dirs): nova_conf = NovaConf() #use more than once hostip = self.cfg.get('host', 'ip') #verbose on? if self._getbool('verbose'): nova_conf.add_simple('verbose') #allow the admin api? if self._getbool('allow_admin_api'): nova_conf.add_simple('allow_admin_api') #which scheduler do u want? scheduler = self._getstr('scheduler') if not scheduler: scheduler = DEF_SCHEDULER nova_conf.add('scheduler_driver', scheduler) #setup network settings self._configure_network_settings(nova_conf, component_dirs) #setup nova volume settings if self.volumes_enabled: self._configure_vols(nova_conf) #where we are running nova_conf.add('my_ip', hostip) #setup your sql connection nova_conf.add('sql_connection', self.cfg.get_dbdsn('nova')) #configure anything libvirt releated? virt_driver = self._getstr('virt_driver') if virt_driver == virsh.VIRT_TYPE: libvirt_type = virsh.default(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') nova_conf.add('instance_name_template', instance_template) #??? nova_conf.add('osapi_compute_extension', 'nova.api.openstack.compute.contrib.standard_extensions') #vnc settings 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) #ec2 / s3 stuff ec2_dmz_host = self._getstr('ec2_dmz_host') if not ec2_dmz_host: ec2_dmz_host = hostip nova_conf.add('ec2_dmz_host', ec2_dmz_host) nova_conf.add('s3_host', hostip) #how is your rabbit setup? nova_conf.add('rabbit_host', self.cfg.get('default', 'rabbit_host')) nova_conf.add('rabbit_password', self.cfg.get("passwords", "rabbit")) #where instances will be stored instances_path = self._getstr('instances_path') if not instances_path: instances_path = sh.joinpths(self.component_root, 'instances') self._configure_instances_path(instances_path, nova_conf) #is this a multihost setup? self._configure_multihost(nova_conf) #enable syslog?? self._configure_syslog(nova_conf) #handle any virt driver specifics self._configure_virt_driver(nova_conf) #now make it conf_lines = sorted(nova_conf.generate()) complete_file = utils.joinlinesep(*conf_lines) #add any extra flags in? extra_flags = self._getstr('extra_flags') if extra_flags: full_file = [complete_file, extra_flags] complete_file = utils.joinlinesep(*full_file) return complete_file
def _clear_libvirt_domains(self): virt_driver = self.cfg.get('nova', 'virt_driver') if virt_driver == virsh.VIRT_TYPE: inst_prefix = self.cfg.get('nova', 'instance_name_prefix') libvirt_type = virsh.default(self.cfg.get('nova', 'libvirt_type')) virsh.clear_libvirt_domains(libvirt_type, inst_prefix)