def start_domain(uuid): """ Boots the domain for the first time after installation is complete. """ # Load the configuration file for this UUID. domain = DomainDirectory() config = domain.load_config(uuid) # Connect to the hypervisor. connection = libvirt.open(None) # We will attempt to determine if the domain is configured to use a # bootloader. If not, we'll have to explicitly use the kernel and initrd # data provided in the config to start the domain. try: config.getConfigItem(DomainConfig.BOOTLOADER) except DomainConfigError: dce = sys.exc_info()[1] # No bootloader tag present. Use pygrub to extract the kernel from # the disk image if its Xen. For fully virt we dont have pygrub, it # directly emulates the BIOS loading the first sector of the boot disk. if connection.getType() == 'Xen': # This uses pygrub which comes only with xen _prepare_guest_kernel_and_ramdisk(config) # Now, we'll restart the instance, this time using the re-create XML. try: domain = connection.createLinux(config.toXML(), 0) except Exception: e = sys.exc_info()[1] raise_with_tb( VirtualizationException( "Error occurred while attempting to recreate domain %s: %s" % (uuid, str(e))), sys.exc_info()[2])
def start_domain(uuid): """ Boots the domain for the first time after installation is complete. """ # Load the configuration file for this UUID. domain = DomainDirectory() config = domain.load_config(uuid) # Connect to the hypervisor. connection = libvirt.open(None) # We will attempt to determine if the domain is configured to use a # bootloader. If not, we'll have to explicitly use the kernel and initrd # data provided in the config to start the domain. try: config.getConfigItem(DomainConfig.BOOTLOADER) except DomainConfigError: dce = sys.exc_info()[1] # No bootloader tag present. Use pygrub to extract the kernel from # the disk image if its Xen. For fully virt we dont have pygrub, it # directly emulates the BIOS loading the first sector of the boot disk. if connection.getType() == 'Xen': # This uses pygrub which comes only with xen _prepare_guest_kernel_and_ramdisk(config) # Now, we'll restart the instance, this time using the re-create XML. try: domain = connection.createLinux(config.toXML(), 0) except Exception: e = sys.exc_info()[1] raise_with_tb(VirtualizationException("Error occurred while attempting to recreate domain %s: %s" % (uuid, str(e))), sys.exc_info()[2])
def setVCPUs(uuid, vcpus): """ Sets the number of vcpus for the domain with the given UUID. """ domain_dir = DomainDirectory() config = domain_dir.load_config(uuid) config.setConfigItem(DomainConfig.VCPU, vcpus) config.save() domain_control.setVCPUs(uuid, vcpus)
def setMemory(uuid, memory): """ Sets the max memory usage for the domain with the given UUID. """ domain_dir = DomainDirectory() config = domain_dir.load_config(uuid) config.setConfigItem(DomainConfig.MEMORY, memory) config.save() domain_control.setMemory(uuid, memory)
def start_domain(uuid): """ Boots the domain for the first time after installation is complete. """ # Load the configuration file for this UUID. domain = DomainDirectory() config = domain.load_config(uuid) # Connect to the hypervisor. connection = libvirt.open(None) # We will attempt to determine if the domain is configured to use a # bootloader. If not, we'll have to explicitly use the kernel and initrd # data provided in the config to start the domain. try: config.getConfigItem(DomainConfig.BOOTLOADER) except DomainConfigError, dce: # No bootloader tag present. Use pygrub to extract the kernel from # the disk image if its Xen. For fully virt we dont have pygrub, it # directly emulates the BIOS loading the first sector of the boot disk. if connection.getType() == 'Xen': # This uses pygrub which comes only with xen _prepare_guest_kernel_and_ramdisk(config)