def clean(self): virsh = lv.Virsh(self.uninstaller.get_int_option('service_wait_seconds'), self.uninstaller.distro) virt_driver = utils.canon_virt_driver(self.uninstaller.get_option('virt_driver')) if virt_driver == 'libvirt': inst_prefix = self.uninstaller.get_option('instance_name_prefix', default_value='instance-') libvirt_type = lv.canon_libvirt_type(self.uninstaller.get_option('libvirt_type')) virsh.clear_domains(libvirt_type, inst_prefix)
def _configure_virt_driver(self, nova_conf): drive_canon = utils.canon_virt_driver(self.installer.get_option('virt_driver')) nova_conf.add('compute_driver', utils.VIRT_DRIVER_MAP.get(drive_canon, drive_canon)) if drive_canon == 'libvirt': nova_conf.add('firewall_driver', self.installer.get_option('libvirt_firewall_driver')) else: nova_conf.add('firewall_driver', self.installer.get_option('basic_firewall_driver'))
def verify(self): # Do a little check to make sure actually have that interface/s public_interface = self.installer.get_option("public_interface") vlan_interface = self.installer.get_option("vlan_interface", default_value=public_interface) known_interfaces = utils.get_interfaces() if not public_interface in known_interfaces: msg = "Public interface %r is not a known interface (is it one of %s??)" % ( public_interface, ", ".join(known_interfaces), ) raise exceptions.ConfigException(msg) if not vlan_interface in known_interfaces: msg = "VLAN interface %r is not a known interface (is it one of %s??)" % ( vlan_interface, ", ".join(known_interfaces), ) raise exceptions.ConfigException(msg) # Driver specific interface checks drive_canon = utils.canon_virt_driver(self.installer.get_option("virt_driver")) if drive_canon == "libvirt": flat_interface = self.installer.get_option("flat_interface") if flat_interface and not flat_interface in known_interfaces: msg = "Libvirt flat interface %s is not a known interface (is it one of %s??)" % ( flat_interface, ", ".join(known_interfaces), ) raise exceptions.ConfigException(msg)
def clean(self): virsh = lv.Virsh(self.uninstaller.get_int_option("service_wait_seconds"), self.uninstaller.distro) virt_driver = utils.canon_virt_driver(self.uninstaller.get_option("virt_driver")) if virt_driver == "libvirt": inst_prefix = self.uninstaller.get_option("instance_name_prefix", default_value="instance-") libvirt_type = lv.canon_libvirt_type(self.uninstaller.get_option("libvirt_type")) virsh.clear_domains(libvirt_type, inst_prefix)
def _configure_virt_driver(self, nova_conf): drive_canon = utils.canon_virt_driver(self.installer.get_option("virt_driver")) nova_conf.add("compute_driver", utils.VIRT_DRIVER_MAP.get(drive_canon, drive_canon)) if drive_canon == "libvirt": nova_conf.add("firewall_driver", self.installer.get_option("libvirt_firewall_driver")) else: nova_conf.add("firewall_driver", self.installer.get_option("basic_firewall_driver"))
def clean(self): virsh = lv.Virsh( self.uninstaller.get_int_option('service_wait_seconds'), self.uninstaller.distro) virt_driver = utils.canon_virt_driver( self.uninstaller.get_option('virt_driver')) if virt_driver == 'libvirt': inst_prefix = self.uninstaller.get_option( 'instance_name_prefix', default_value='instance-') libvirt_type = lv.canon_libvirt_type( self.uninstaller.get_option('libvirt_type')) virsh.clear_domains(libvirt_type, inst_prefix)
def _fix_virt(self): virt_driver = utils.canon_virt_driver(self.get_option('virt_driver')) if virt_driver == 'libvirt': virt_type = lv.canon_libvirt_type(self.get_option('libvirt_type')) if virt_type == 'qemu': # On RHEL it appears a sym-link needs to be created # to enable qemu to actually work, apparently fixed # in RHEL 6.4. # # See: http://fedoraproject.org/wiki/Getting_started_with_OpenStack_EPEL if not sh.isfile('/usr/bin/qemu-system-x86_64'): sh.symlink('/usr/libexec/qemu-kvm', '/usr/bin/qemu-system-x86_64', tracewriter=self.tracewriter)
def configure(self): configs_made = nova.NovaInstaller.configure(self) driver_canon = utils.canon_virt_driver(self.get_option('virt_driver')) if driver_canon == 'libvirt': # Create a libvirtd user group if not sh.group_exists('libvirtd'): cmd = ['groupadd', 'libvirtd'] sh.execute(cmd) if not sh.isfile(LIBVIRT_POLICY_FN): contents = self._get_policy(self._get_policy_users()) sh.mkdirslist(sh.dirname(LIBVIRT_POLICY_FN)) sh.write_file(LIBVIRT_POLICY_FN, contents) configs_made += 1 return configs_made
def pre_start(self): # Let the parent class do its thing bruntime.OpenStackRuntime.pre_start(self) virt_driver = utils.canon_virt_driver(self.get_option('virt_driver')) if virt_driver == 'libvirt': virt_type = lv.canon_libvirt_type(self.get_option('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 excp.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 excp.StartException(msg)
def verify(self): # Do a little check to make sure actually have that interface/s public_interface = self.installer.get_option('public_interface') vlan_interface = self.installer.get_option('vlan_interface', default_value=public_interface) known_interfaces = utils.get_interfaces() if public_interface not in known_interfaces: msg = "Public interface %r is not a known interface (is it one of %s??)" % (public_interface, ", ".join(known_interfaces)) raise exceptions.ConfigException(msg) if vlan_interface not in known_interfaces: msg = "VLAN interface %r is not a known interface (is it one of %s??)" % (vlan_interface, ", ".join(known_interfaces)) raise exceptions.ConfigException(msg) # Driver specific interface checks drive_canon = utils.canon_virt_driver(self.installer.get_option('virt_driver')) if drive_canon == 'libvirt': flat_interface = self.installer.get_option('flat_interface') if flat_interface and flat_interface not in known_interfaces: msg = "Libvirt flat interface %s is not a known interface (is it one of %s??)" % (flat_interface, ", ".join(known_interfaces)) raise exceptions.ConfigException(msg)
def pre_start(self): # Let the parent class do its thing bruntime.PythonRuntime.pre_start(self) virt_driver = utils.canon_virt_driver(self.get_option('virt_driver')) if virt_driver == 'libvirt': virt_type = lv.canon_libvirt_type(self.get_option('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 excp.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 excp.StartException(msg)
def _config_adjust_api(self, nova_conf): '''This method has the smarts to build the configuration file based on various runtime values. A useful reference for figuring out this is at http://docs.openstack.org/diablo/openstack-compute/admin/content/ch_configuring-openstack-compute.html See also: https://github.com/openstack/nova/blob/master/etc/nova/nova.conf.sample ''' # Used more than once so we calculate it ahead of time hostip = self.installer.get_option('ip') nova_conf.add('verbose', self.installer.get_bool_option('log_verbose')) nova_conf.add('state_path', '/var/lib/nova') nova_conf.add('log_dir', '/var/log/nova') nova_conf.add('bindir', '/usr/bin') # Allow destination machine to match source for resize. nova_conf.add('allow_resize_to_same_host', True) # Which scheduler do u want? nova_conf.add('compute_scheduler_driver', self.installer.get_option('scheduler', default_value='nova.scheduler.filter_scheduler.FilterScheduler')) # Rate limit the api?? nova_conf.add('api_rate_limit', self.installer.get_bool_option('api_rate_limit')) # Ensure the policy.json is referenced correctly nova_conf.add('policy_file', '/etc/nova/policy.json') # Setup nova network/settings self._configure_network_settings(nova_conf) # The ip of where we are running nova_conf.add('my_ip', hostip) # Setup how the database will be connected. nova_conf.add('sql_connection', self.fetch_dbdsn()) # Configure anything libvirt related? virt_driver = utils.canon_virt_driver(self.installer.get_option('virt_driver')) if virt_driver == 'libvirt': self._configure_libvirt(lv.canon_libvirt_type(self.installer.get_option('libvirt_type')), nova_conf) # How instances will be presented instance_template = "%s%s" % (self.installer.get_option('instance_name_prefix'), self.installer.get_option('instance_name_postfix')) if not instance_template: instance_template = 'instance-%08x' nova_conf.add('instance_name_template', instance_template) # Enable the standard extensions nova_conf.add('osapi_compute_extension', 'nova.api.openstack.compute.contrib.standard_extensions') # Auth will be using keystone nova_conf.add('auth_strategy', 'keystone') # Is config drive being forced on? if self.installer.get_bool_option('force_cfg_drive'): nova_conf.add('force_config_drive', 'always') # Don't always force images to raw, which makes things take time to get to raw... nova_conf.add('force_raw_images', self.installer.get_bool_option('force_raw_images')) # Add a checksum for images fetched for each hypervisor? # This check absorbs cpu cycles, warning.... nova_conf.add('checksum_base_images', self.installer.get_bool_option('checksum_base_images')) # Setup the interprocess locking directory (don't put me on shared storage) nova_conf.add('lock_path', '/var/lock/nova') # Vnc settings setup self._configure_vnc(nova_conf) # Where our paste config is nova_conf.add('api_paste_config', self.target_config(PASTE_CONF)) # 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.installer.get_option('ec2_dmz_host', default_value=hostip)) nova_conf.add('s3_host', hostip) # How is your message queue setup? self.setup_rpc(nova_conf, rpc_backends=MQ_BACKENDS) # The USB tablet device is meant to improve mouse behavior in # the VNC console, but it has the side effect of increasing # the CPU usage of an idle VM tenfold. nova_conf.add('use_usb_tablet', False) # Is this a multihost setup? self._configure_multihost(nova_conf) # Handle any virt driver specifics self._configure_virt_driver(nova_conf) # Handle configuring the conductor service self._configure_conductor(nova_conf)
def _config_adjust_api(self, nova_conf): ''' This method has the smarts to build the configuration file based on various runtime values. A useful reference for figuring out this is at http://docs.openstack.org/diablo/openstack-compute/admin/content/ch_configuring-openstack-compute.html See also: https://github.com/openstack/nova/blob/master/etc/nova/nova.conf.sample ''' # Used more than once so we calculate it ahead of time hostip = self.installer.get_option('ip') nova_conf.add('verbose', self.installer.get_bool_option('log_verbose')) # Allow destination machine to match source for resize. nova_conf.add('allow_resize_to_same_host', True) # Which scheduler do u want? nova_conf.add( 'compute_scheduler_driver', self.installer.get_option( 'scheduler', default_value='nova.scheduler.filter_scheduler.FilterScheduler' )) # Rate limit the api?? nova_conf.add('api_rate_limit', self.installer.get_bool_option('api_rate_limit')) # Ensure the policy.json is referenced correctly nova_conf.add('policy_file', '/etc/nova/policy.json') # Setup nova network/settings self._configure_network_settings(nova_conf) # The ip of where we are running nova_conf.add('my_ip', hostip) nova_conf.add('sql_connection', self.fetch_dbdsn()) # Configure anything libvirt related? virt_driver = utils.canon_virt_driver( self.installer.get_option('virt_driver')) if virt_driver == 'libvirt': self._configure_libvirt( lv.canon_libvirt_type( self.installer.get_option('libvirt_type')), nova_conf) # How instances will be presented instance_template = "%s%s" % ( self.installer.get_option('instance_name_prefix'), self.installer.get_option('instance_name_postfix')) if not instance_template: instance_template = 'instance-%08x' nova_conf.add('instance_name_template', instance_template) # Enable the standard extensions nova_conf.add( 'osapi_compute_extension', 'nova.api.openstack.compute.contrib.standard_extensions') # Auth will be using keystone nova_conf.add('auth_strategy', 'keystone') # Is config drive being forced on? if self.installer.get_bool_option('force_cfg_drive'): nova_conf.add('force_config_drive', 'always') # Don't always force images to raw, which makes things take time to get to raw... nova_conf.add('force_raw_images', self.installer.get_bool_option('force_raw_images')) # Add a checksum for images fetched for each hypervisor? # This check absorbs cpu cycles, warning.... nova_conf.add('checksum_base_images', self.installer.get_bool_option('checksum_base_images')) # Setup the interprocess locking directory (don't put me on shared storage) lock_path = self.installer.get_option('lock_path') if not lock_path: lock_path = sh.joinpths(self.installer.get_option('component_dir'), 'locks') sh.mkdirslist(lock_path, tracewriter=self.tracewriter) nova_conf.add('lock_path', lock_path) # Vnc settings setup self._configure_vnc(nova_conf) # Where our paste config is nova_conf.add('api_paste_config', self.target_config(PASTE_CONF)) # 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.installer.get_option('ec2_dmz_host', default_value=hostip)) nova_conf.add('s3_host', hostip) # How is your message queue setup? self.setup_rpc(nova_conf, 'nova.rpc.impl_kombu') # The USB tablet device is meant to improve mouse behavior in # the VNC console, but it has the side effect of increasing # the CPU usage of an idle VM tenfold. nova_conf.add('use_usb_tablet', False) # Where instances will be stored instances_path = self.installer.get_option('instances_path') if not instances_path: 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) # Handle configuring the conductor service self._configure_conductor(nova_conf)