body stringlengths 26 98.2k | body_hash int64 -9,222,864,604,528,158,000 9,221,803,474B | docstring stringlengths 1 16.8k | path stringlengths 5 230 | name stringlengths 1 96 | repository_name stringlengths 7 89 | lang stringclasses 1
value | body_without_docstring stringlengths 20 98.2k |
|---|---|---|---|---|---|---|---|
def plug_vifs(self, instance, network_info):
'Plug VIFs into networks.'
for vif in network_info:
self.vif_driver.plug(instance, vif) | 6,357,100,223,343,190,000 | Plug VIFs into networks. | nova/virt/libvirt/driver.py | plug_vifs | srajag/nova | python | def plug_vifs(self, instance, network_info):
for vif in network_info:
self.vif_driver.plug(instance, vif) |
def _unplug_vifs(self, instance, network_info, ignore_errors):
'Unplug VIFs from networks.'
for vif in network_info:
try:
self.vif_driver.unplug(instance, vif)
except exception.NovaException:
if (not ignore_errors):
raise | -7,604,990,297,459,410,000 | Unplug VIFs from networks. | nova/virt/libvirt/driver.py | _unplug_vifs | srajag/nova | python | def _unplug_vifs(self, instance, network_info, ignore_errors):
for vif in network_info:
try:
self.vif_driver.unplug(instance, vif)
except exception.NovaException:
if (not ignore_errors):
raise |
def _cleanup_lvm(self, instance):
'Delete all LVM disks for given instance object.'
disks = self._lvm_disks(instance)
if disks:
lvm.remove_volumes(disks) | 6,992,421,263,557,911,000 | Delete all LVM disks for given instance object. | nova/virt/libvirt/driver.py | _cleanup_lvm | srajag/nova | python | def _cleanup_lvm(self, instance):
disks = self._lvm_disks(instance)
if disks:
lvm.remove_volumes(disks) |
def _lvm_disks(self, instance):
'Returns all LVM disks for given instance object.'
if CONF.libvirt.images_volume_group:
vg = os.path.join('/dev', CONF.libvirt.images_volume_group)
if (not os.path.exists(vg)):
return []
pattern = ('%s_' % instance['uuid'])
def belongs... | 8,662,966,914,996,749,000 | Returns all LVM disks for given instance object. | nova/virt/libvirt/driver.py | _lvm_disks | srajag/nova | python | def _lvm_disks(self, instance):
if CONF.libvirt.images_volume_group:
vg = os.path.join('/dev', CONF.libvirt.images_volume_group)
if (not os.path.exists(vg)):
return []
pattern = ('%s_' % instance['uuid'])
def belongs_to_instance_legacy(disk):
pattern = (... |
def _swap_volume(self, domain, disk_path, new_path, resize_to):
'Swap existing disk with a new block device.'
xml = domain.XMLDesc((libvirt.VIR_DOMAIN_XML_INACTIVE | libvirt.VIR_DOMAIN_XML_SECURE))
try:
domain.blockJobAbort(disk_path, 0)
except Exception:
pass
try:
if domain.... | 1,421,798,263,718,253,300 | Swap existing disk with a new block device. | nova/virt/libvirt/driver.py | _swap_volume | srajag/nova | python | def _swap_volume(self, domain, disk_path, new_path, resize_to):
xml = domain.XMLDesc((libvirt.VIR_DOMAIN_XML_INACTIVE | libvirt.VIR_DOMAIN_XML_SECURE))
try:
domain.blockJobAbort(disk_path, 0)
except Exception:
pass
try:
if domain.isPersistent():
domain.undefine()... |
@staticmethod
def _get_disk_xml(xml, device):
'Returns the xml for the disk mounted at device.'
try:
doc = etree.fromstring(xml)
except Exception:
return None
ret = doc.findall('./devices/disk')
for node in ret:
for child in node.getchildren():
if (child.tag == 't... | 8,606,600,322,234,641,000 | Returns the xml for the disk mounted at device. | nova/virt/libvirt/driver.py | _get_disk_xml | srajag/nova | python | @staticmethod
def _get_disk_xml(xml, device):
try:
doc = etree.fromstring(xml)
except Exception:
return None
ret = doc.findall('./devices/disk')
for node in ret:
for child in node.getchildren():
if (child.tag == 'target'):
if (child.get('dev') == ... |
def snapshot(self, context, instance, image_id, update_task_state):
'Create snapshot from a running VM instance.\n\n This command only works with qemu 0.14+\n '
try:
virt_dom = self._lookup_by_name(instance['name'])
except exception.InstanceNotFound:
raise exception.InstanceNot... | -1,372,859,029,786,314,000 | Create snapshot from a running VM instance.
This command only works with qemu 0.14+ | nova/virt/libvirt/driver.py | snapshot | srajag/nova | python | def snapshot(self, context, instance, image_id, update_task_state):
'Create snapshot from a running VM instance.\n\n This command only works with qemu 0.14+\n '
try:
virt_dom = self._lookup_by_name(instance['name'])
except exception.InstanceNotFound:
raise exception.InstanceNot... |
@staticmethod
def _wait_for_block_job(domain, disk_path, abort_on_error=False, wait_for_job_clean=False):
'Wait for libvirt block job to complete.\n\n Libvirt may return either cur==end or an empty dict when\n the job is complete, depending on whether the job has been\n cleaned up by libvirt ye... | 1,692,038,503,507,733,000 | Wait for libvirt block job to complete.
Libvirt may return either cur==end or an empty dict when
the job is complete, depending on whether the job has been
cleaned up by libvirt yet, or not.
:returns: True if still in progress
False if completed | nova/virt/libvirt/driver.py | _wait_for_block_job | srajag/nova | python | @staticmethod
def _wait_for_block_job(domain, disk_path, abort_on_error=False, wait_for_job_clean=False):
'Wait for libvirt block job to complete.\n\n Libvirt may return either cur==end or an empty dict when\n the job is complete, depending on whether the job has been\n cleaned up by libvirt ye... |
def _live_snapshot(self, domain, disk_path, out_path, image_format):
'Snapshot an instance without downtime.'
xml = domain.XMLDesc((libvirt.VIR_DOMAIN_XML_INACTIVE | libvirt.VIR_DOMAIN_XML_SECURE))
try:
domain.blockJobAbort(disk_path, 0)
except Exception:
pass
src_disk_size = libvirt... | 3,208,218,799,842,274,300 | Snapshot an instance without downtime. | nova/virt/libvirt/driver.py | _live_snapshot | srajag/nova | python | def _live_snapshot(self, domain, disk_path, out_path, image_format):
xml = domain.XMLDesc((libvirt.VIR_DOMAIN_XML_INACTIVE | libvirt.VIR_DOMAIN_XML_SECURE))
try:
domain.blockJobAbort(disk_path, 0)
except Exception:
pass
src_disk_size = libvirt_utils.get_disk_size(disk_path)
src_... |
def _volume_snapshot_update_status(self, context, snapshot_id, status):
'Send a snapshot status update to Cinder.\n\n This method captures and logs exceptions that occur\n since callers cannot do anything useful with these exceptions.\n\n Operations on the Cinder side waiting for this will time... | 8,066,054,957,183,952,000 | Send a snapshot status update to Cinder.
This method captures and logs exceptions that occur
since callers cannot do anything useful with these exceptions.
Operations on the Cinder side waiting for this will time out if
a failure occurs sending the update.
:param context: security context
:param snapshot_id: id of s... | nova/virt/libvirt/driver.py | _volume_snapshot_update_status | srajag/nova | python | def _volume_snapshot_update_status(self, context, snapshot_id, status):
'Send a snapshot status update to Cinder.\n\n This method captures and logs exceptions that occur\n since callers cannot do anything useful with these exceptions.\n\n Operations on the Cinder side waiting for this will time... |
def _volume_snapshot_create(self, context, instance, domain, volume_id, snapshot_id, new_file):
'Perform volume snapshot.\n\n :param domain: VM that volume is attached to\n :param volume_id: volume UUID to snapshot\n :param snapshot_id: UUID of snapshot being created\n :param... | -5,064,008,524,797,116,000 | Perform volume snapshot.
:param domain: VM that volume is attached to
:param volume_id: volume UUID to snapshot
:param snapshot_id: UUID of snapshot being created
:param new_file: relative path to new qcow2 file present on share | nova/virt/libvirt/driver.py | _volume_snapshot_create | srajag/nova | python | def _volume_snapshot_create(self, context, instance, domain, volume_id, snapshot_id, new_file):
'Perform volume snapshot.\n\n :param domain: VM that volume is attached to\n :param volume_id: volume UUID to snapshot\n :param snapshot_id: UUID of snapshot being created\n :param... |
def volume_snapshot_create(self, context, instance, volume_id, create_info):
"Create snapshots of a Cinder volume via libvirt.\n\n :param instance: VM instance object reference\n :param volume_id: id of volume being snapshotted\n :param create_info: dict of information used to create snapshots\... | -7,727,998,743,351,326,000 | Create snapshots of a Cinder volume via libvirt.
:param instance: VM instance object reference
:param volume_id: id of volume being snapshotted
:param create_info: dict of information used to create snapshots
- snapshot_id : ID of snapshot
- type : qcow2 / <other>
- new_file : qc... | nova/virt/libvirt/driver.py | volume_snapshot_create | srajag/nova | python | def volume_snapshot_create(self, context, instance, volume_id, create_info):
"Create snapshots of a Cinder volume via libvirt.\n\n :param instance: VM instance object reference\n :param volume_id: id of volume being snapshotted\n :param create_info: dict of information used to create snapshots\... |
def _volume_snapshot_delete(self, context, instance, volume_id, snapshot_id, delete_info=None):
"Note:\n if file being merged into == active image:\n do a blockRebase (pull) operation\n else:\n do a blockCommit operation\n Files must be adjacent in snap... | -8,897,284,408,874,923,000 | Note:
if file being merged into == active image:
do a blockRebase (pull) operation
else:
do a blockCommit operation
Files must be adjacent in snap chain.
:param instance: instance object reference
:param volume_id: volume UUID
:param snapshot_id: snapshot UUID (unused currently)
:param dele... | nova/virt/libvirt/driver.py | _volume_snapshot_delete | srajag/nova | python | def _volume_snapshot_delete(self, context, instance, volume_id, snapshot_id, delete_info=None):
"Note:\n if file being merged into == active image:\n do a blockRebase (pull) operation\n else:\n do a blockCommit operation\n Files must be adjacent in snap... |
def reboot(self, context, instance, network_info, reboot_type, block_device_info=None, bad_volumes_callback=None):
'Reboot a virtual machine, given an instance reference.'
if (reboot_type == 'SOFT'):
try:
soft_reboot_success = self._soft_reboot(instance)
except libvirt.libvirtError a... | 3,548,329,928,541,850,600 | Reboot a virtual machine, given an instance reference. | nova/virt/libvirt/driver.py | reboot | srajag/nova | python | def reboot(self, context, instance, network_info, reboot_type, block_device_info=None, bad_volumes_callback=None):
if (reboot_type == 'SOFT'):
try:
soft_reboot_success = self._soft_reboot(instance)
except libvirt.libvirtError as e:
LOG.debug('Instance soft reboot failed:... |
def _soft_reboot(self, instance):
'Attempt to shutdown and restart the instance gracefully.\n\n We use shutdown and create here so we can return if the guest\n responded and actually rebooted. Note that this method only\n succeeds if the guest responds to acpi. Therefore we return\n succ... | -4,453,278,297,860,923,400 | Attempt to shutdown and restart the instance gracefully.
We use shutdown and create here so we can return if the guest
responded and actually rebooted. Note that this method only
succeeds if the guest responds to acpi. Therefore we return
success or failure so we can fall back to a hard reboot if
necessary.
:returns:... | nova/virt/libvirt/driver.py | _soft_reboot | srajag/nova | python | def _soft_reboot(self, instance):
'Attempt to shutdown and restart the instance gracefully.\n\n We use shutdown and create here so we can return if the guest\n responded and actually rebooted. Note that this method only\n succeeds if the guest responds to acpi. Therefore we return\n succ... |
def _hard_reboot(self, context, instance, network_info, block_device_info=None):
'Reboot a virtual machine, given an instance reference.\n\n Performs a Libvirt reset (if supported) on the domain.\n\n If Libvirt reset is unavailable this method actually destroys and\n re-creates the domain to en... | 2,541,477,673,550,523,000 | Reboot a virtual machine, given an instance reference.
Performs a Libvirt reset (if supported) on the domain.
If Libvirt reset is unavailable this method actually destroys and
re-creates the domain to ensure the reboot happens, as the guest
OS cannot ignore this action.
If xml is set, it uses the passed in xml in pl... | nova/virt/libvirt/driver.py | _hard_reboot | srajag/nova | python | def _hard_reboot(self, context, instance, network_info, block_device_info=None):
'Reboot a virtual machine, given an instance reference.\n\n Performs a Libvirt reset (if supported) on the domain.\n\n If Libvirt reset is unavailable this method actually destroys and\n re-creates the domain to en... |
def pause(self, instance):
'Pause VM instance.'
dom = self._lookup_by_name(instance['name'])
dom.suspend() | -1,065,690,872,297,552,300 | Pause VM instance. | nova/virt/libvirt/driver.py | pause | srajag/nova | python | def pause(self, instance):
dom = self._lookup_by_name(instance['name'])
dom.suspend() |
def unpause(self, instance):
'Unpause paused VM instance.'
dom = self._lookup_by_name(instance['name'])
dom.resume() | 1,876,379,601,638,167,000 | Unpause paused VM instance. | nova/virt/libvirt/driver.py | unpause | srajag/nova | python | def unpause(self, instance):
dom = self._lookup_by_name(instance['name'])
dom.resume() |
def power_off(self, instance):
'Power off the specified instance.'
self._destroy(instance) | 5,946,449,247,883,757,000 | Power off the specified instance. | nova/virt/libvirt/driver.py | power_off | srajag/nova | python | def power_off(self, instance):
self._destroy(instance) |
def power_on(self, context, instance, network_info, block_device_info=None):
'Power on the specified instance.'
self._hard_reboot(context, instance, network_info, block_device_info) | -6,413,646,608,397,868,000 | Power on the specified instance. | nova/virt/libvirt/driver.py | power_on | srajag/nova | python | def power_on(self, context, instance, network_info, block_device_info=None):
self._hard_reboot(context, instance, network_info, block_device_info) |
def suspend(self, instance):
'Suspend the specified instance.'
dom = self._lookup_by_name(instance['name'])
self._detach_pci_devices(dom, pci_manager.get_instance_pci_devs(instance))
dom.managedSave(0) | -4,455,299,906,648,574,500 | Suspend the specified instance. | nova/virt/libvirt/driver.py | suspend | srajag/nova | python | def suspend(self, instance):
dom = self._lookup_by_name(instance['name'])
self._detach_pci_devices(dom, pci_manager.get_instance_pci_devs(instance))
dom.managedSave(0) |
def resume(self, context, instance, network_info, block_device_info=None):
'resume the specified instance.'
xml = self._get_existing_domain_xml(instance, network_info, block_device_info)
dom = self._create_domain_and_network(context, xml, instance, network_info, block_device_info=block_device_info, vifs_alr... | 6,518,967,721,012,617,000 | resume the specified instance. | nova/virt/libvirt/driver.py | resume | srajag/nova | python | def resume(self, context, instance, network_info, block_device_info=None):
xml = self._get_existing_domain_xml(instance, network_info, block_device_info)
dom = self._create_domain_and_network(context, xml, instance, network_info, block_device_info=block_device_info, vifs_already_plugged=True)
self._att... |
def resume_state_on_host_boot(self, context, instance, network_info, block_device_info=None):
'resume guest state when a host is booted.'
try:
domain = self._lookup_by_name(instance['name'])
state = LIBVIRT_POWER_STATE[domain.info()[0]]
ignored_states = (power_state.RUNNING, power_state.... | 1,156,686,891,336,810,000 | resume guest state when a host is booted. | nova/virt/libvirt/driver.py | resume_state_on_host_boot | srajag/nova | python | def resume_state_on_host_boot(self, context, instance, network_info, block_device_info=None):
try:
domain = self._lookup_by_name(instance['name'])
state = LIBVIRT_POWER_STATE[domain.info()[0]]
ignored_states = (power_state.RUNNING, power_state.SUSPENDED, power_state.NOSTATE, power_state... |
def rescue(self, context, instance, network_info, image_meta, rescue_password):
'Loads a VM using rescue images.\n\n A rescue is normally performed when something goes wrong with the\n primary images and data needs to be corrected/recovered. Rescuing\n should not edit or over-ride the original ... | -1,001,450,618,260,863,000 | Loads a VM using rescue images.
A rescue is normally performed when something goes wrong with the
primary images and data needs to be corrected/recovered. Rescuing
should not edit or over-ride the original image, only allow for
data recovery. | nova/virt/libvirt/driver.py | rescue | srajag/nova | python | def rescue(self, context, instance, network_info, image_meta, rescue_password):
'Loads a VM using rescue images.\n\n A rescue is normally performed when something goes wrong with the\n primary images and data needs to be corrected/recovered. Rescuing\n should not edit or over-ride the original ... |
def unrescue(self, instance, network_info):
'Reboot the VM which is being rescued back into primary images.\n '
instance_dir = libvirt_utils.get_instance_path(instance)
unrescue_xml_path = os.path.join(instance_dir, 'unrescue.xml')
xml = libvirt_utils.load_file(unrescue_xml_path)
virt_dom = s... | 1,013,918,113,273,256,200 | Reboot the VM which is being rescued back into primary images. | nova/virt/libvirt/driver.py | unrescue | srajag/nova | python | def unrescue(self, instance, network_info):
'\n '
instance_dir = libvirt_utils.get_instance_path(instance)
unrescue_xml_path = os.path.join(instance_dir, 'unrescue.xml')
xml = libvirt_utils.load_file(unrescue_xml_path)
virt_dom = self._lookup_by_name(instance.name)
self._destroy(instance)... |
@staticmethod
def _create_local(target, local_size, unit='G', fs_format=None, label=None):
'Create a blank image of specified size.'
libvirt_utils.create_image('raw', target, ('%d%c' % (local_size, unit))) | -9,215,295,529,502,526,000 | Create a blank image of specified size. | nova/virt/libvirt/driver.py | _create_local | srajag/nova | python | @staticmethod
def _create_local(target, local_size, unit='G', fs_format=None, label=None):
libvirt_utils.create_image('raw', target, ('%d%c' % (local_size, unit))) |
@staticmethod
def _create_swap(target, swap_mb, max_size=None):
'Create a swap file of specified size.'
libvirt_utils.create_image('raw', target, ('%dM' % swap_mb))
utils.mkfs('swap', target) | 4,355,613,304,691,187,000 | Create a swap file of specified size. | nova/virt/libvirt/driver.py | _create_swap | srajag/nova | python | @staticmethod
def _create_swap(target, swap_mb, max_size=None):
libvirt_utils.create_image('raw', target, ('%dM' % swap_mb))
utils.mkfs('swap', target) |
@staticmethod
def _is_booted_from_volume(instance, disk_mapping):
'Determines whether the VM is booting from volume\n\n Determines whether the disk mapping indicates that the VM\n is booting from a volume.\n '
return ((not bool(instance.get('image_ref'))) or ('disk' not in disk_mapping)) | -1,955,707,853,542,445,300 | Determines whether the VM is booting from volume
Determines whether the disk mapping indicates that the VM
is booting from a volume. | nova/virt/libvirt/driver.py | _is_booted_from_volume | srajag/nova | python | @staticmethod
def _is_booted_from_volume(instance, disk_mapping):
'Determines whether the VM is booting from volume\n\n Determines whether the disk mapping indicates that the VM\n is booting from a volume.\n '
return ((not bool(instance.get('image_ref'))) or ('disk' not in disk_mapping)) |
def _inject_data(self, instance, network_info, admin_pass, files, suffix):
'Injects data in a disk image\n\n Helper used for injecting data in a disk image file system.\n\n Keyword arguments:\n instance -- a dict that refers instance specifications\n network_info -- a dict that refer... | 7,476,893,220,072,604,000 | Injects data in a disk image
Helper used for injecting data in a disk image file system.
Keyword arguments:
instance -- a dict that refers instance specifications
network_info -- a dict that refers network speficications
admin_pass -- a string used to set an admin password
files -- a list of files needs to be... | nova/virt/libvirt/driver.py | _inject_data | srajag/nova | python | def _inject_data(self, instance, network_info, admin_pass, files, suffix):
'Injects data in a disk image\n\n Helper used for injecting data in a disk image file system.\n\n Keyword arguments:\n instance -- a dict that refers instance specifications\n network_info -- a dict that refer... |
def _set_host_enabled(self, enabled, disable_reason=DISABLE_REASON_UNDEFINED):
"Enables / Disables the compute service on this host.\n\n This doesn't override non-automatic disablement with an automatic\n setting; thereby permitting operators to keep otherwise\n healthy hosts out of ro... | -4,019,735,877,820,524,500 | Enables / Disables the compute service on this host.
This doesn't override non-automatic disablement with an automatic
setting; thereby permitting operators to keep otherwise
healthy hosts out of rotation. | nova/virt/libvirt/driver.py | _set_host_enabled | srajag/nova | python | def _set_host_enabled(self, enabled, disable_reason=DISABLE_REASON_UNDEFINED):
"Enables / Disables the compute service on this host.\n\n This doesn't override non-automatic disablement with an automatic\n setting; thereby permitting operators to keep otherwise\n healthy hosts out of ro... |
def _get_host_capabilities(self):
'Returns an instance of config.LibvirtConfigCaps representing\n the capabilities of the host.\n '
if (not self._caps):
xmlstr = self._conn.getCapabilities()
self._caps = vconfig.LibvirtConfigCaps()
self._caps.parse_str(xmlstr)
if... | -7,659,002,948,757,558,000 | Returns an instance of config.LibvirtConfigCaps representing
the capabilities of the host. | nova/virt/libvirt/driver.py | _get_host_capabilities | srajag/nova | python | def _get_host_capabilities(self):
'Returns an instance of config.LibvirtConfigCaps representing\n the capabilities of the host.\n '
if (not self._caps):
xmlstr = self._conn.getCapabilities()
self._caps = vconfig.LibvirtConfigCaps()
self._caps.parse_str(xmlstr)
if... |
def _get_host_uuid(self):
'Returns a UUID representing the host.'
caps = self._get_host_capabilities()
return caps.host.uuid | -8,148,530,765,576,642,000 | Returns a UUID representing the host. | nova/virt/libvirt/driver.py | _get_host_uuid | srajag/nova | python | def _get_host_uuid(self):
caps = self._get_host_capabilities()
return caps.host.uuid |
def _get_guest_config_meta(self, context, instance, flavor):
'Get metadata config for guest.'
meta = vconfig.LibvirtConfigGuestMetaNovaInstance()
meta.package = version.version_string_with_package()
meta.name = instance['display_name']
meta.creationTime = time.time()
if (instance['image_ref'] no... | 8,349,429,409,947,018,000 | Get metadata config for guest. | nova/virt/libvirt/driver.py | _get_guest_config_meta | srajag/nova | python | def _get_guest_config_meta(self, context, instance, flavor):
meta = vconfig.LibvirtConfigGuestMetaNovaInstance()
meta.package = version.version_string_with_package()
meta.name = instance['display_name']
meta.creationTime = time.time()
if (instance['image_ref'] not in (, None)):
meta.roo... |
def _get_guest_config(self, instance, network_info, image_meta, disk_info, rescue=None, block_device_info=None, context=None):
"Get config data for parameters.\n\n :param rescue: optional dictionary that should contain the key\n 'ramdisk_id' if a ramdisk is needed for the rescue image and\n ... | 1,053,936,662,492,052,500 | Get config data for parameters.
:param rescue: optional dictionary that should contain the key
'ramdisk_id' if a ramdisk is needed for the rescue image and
'kernel_id' if a kernel is needed for the rescue image. | nova/virt/libvirt/driver.py | _get_guest_config | srajag/nova | python | def _get_guest_config(self, instance, network_info, image_meta, disk_info, rescue=None, block_device_info=None, context=None):
"Get config data for parameters.\n\n :param rescue: optional dictionary that should contain the key\n 'ramdisk_id' if a ramdisk is needed for the rescue image and\n ... |
def _lookup_by_id(self, instance_id):
'Retrieve libvirt domain object given an instance id.\n\n All libvirt error handling should be handled in this method and\n relevant nova exceptions should be raised in response.\n\n '
try:
return self._conn.lookupByID(instance_id)
except li... | 7,288,528,978,716,452,000 | Retrieve libvirt domain object given an instance id.
All libvirt error handling should be handled in this method and
relevant nova exceptions should be raised in response. | nova/virt/libvirt/driver.py | _lookup_by_id | srajag/nova | python | def _lookup_by_id(self, instance_id):
'Retrieve libvirt domain object given an instance id.\n\n All libvirt error handling should be handled in this method and\n relevant nova exceptions should be raised in response.\n\n '
try:
return self._conn.lookupByID(instance_id)
except li... |
def _lookup_by_name(self, instance_name):
'Retrieve libvirt domain object given an instance name.\n\n All libvirt error handling should be handled in this method and\n relevant nova exceptions should be raised in response.\n\n '
try:
return self._conn.lookupByName(instance_name)
... | -8,928,353,716,722,507,000 | Retrieve libvirt domain object given an instance name.
All libvirt error handling should be handled in this method and
relevant nova exceptions should be raised in response. | nova/virt/libvirt/driver.py | _lookup_by_name | srajag/nova | python | def _lookup_by_name(self, instance_name):
'Retrieve libvirt domain object given an instance name.\n\n All libvirt error handling should be handled in this method and\n relevant nova exceptions should be raised in response.\n\n '
try:
return self._conn.lookupByName(instance_name)
... |
def get_info(self, instance):
'Retrieve information from libvirt for a specific instance name.\n\n If a libvirt error is encountered during lookup, we might raise a\n NotFound exception or Error exception depending on how severe the\n libvirt error is.\n\n '
virt_dom = self._lookup_b... | -168,255,364,237,726,800 | Retrieve information from libvirt for a specific instance name.
If a libvirt error is encountered during lookup, we might raise a
NotFound exception or Error exception depending on how severe the
libvirt error is. | nova/virt/libvirt/driver.py | get_info | srajag/nova | python | def get_info(self, instance):
'Retrieve information from libvirt for a specific instance name.\n\n If a libvirt error is encountered during lookup, we might raise a\n NotFound exception or Error exception depending on how severe the\n libvirt error is.\n\n '
virt_dom = self._lookup_b... |
def _create_domain(self, xml=None, domain=None, instance=None, launch_flags=0, power_on=True):
'Create a domain.\n\n Either domain or xml must be passed in. If both are passed, then\n the domain definition is overwritten from the xml.\n '
err = None
if (instance and (CONF.libvirt.virt_t... | -3,845,477,721,825,623,000 | Create a domain.
Either domain or xml must be passed in. If both are passed, then
the domain definition is overwritten from the xml. | nova/virt/libvirt/driver.py | _create_domain | srajag/nova | python | def _create_domain(self, xml=None, domain=None, instance=None, launch_flags=0, power_on=True):
'Create a domain.\n\n Either domain or xml must be passed in. If both are passed, then\n the domain definition is overwritten from the xml.\n '
err = None
if (instance and (CONF.libvirt.virt_t... |
def _create_domain_and_network(self, context, xml, instance, network_info, block_device_info=None, power_on=True, reboot=False, vifs_already_plugged=False):
'Do required network setup and create domain.'
block_device_mapping = driver.block_device_info_get_mapping(block_device_info)
for vol in block_device_m... | -3,292,688,747,660,380,000 | Do required network setup and create domain. | nova/virt/libvirt/driver.py | _create_domain_and_network | srajag/nova | python | def _create_domain_and_network(self, context, xml, instance, network_info, block_device_info=None, power_on=True, reboot=False, vifs_already_plugged=False):
block_device_mapping = driver.block_device_info_get_mapping(block_device_info)
for vol in block_device_mapping:
connection_info = vol['connect... |
def _get_all_block_devices(self):
'Return all block devices in use on this node.'
devices = []
for dom in self._list_instance_domains():
try:
doc = etree.fromstring(dom.XMLDesc(0))
except libvirt.libvirtError as e:
LOG.warn((_LW("couldn't obtain the XML from domain: %... | -7,571,256,240,773,195,000 | Return all block devices in use on this node. | nova/virt/libvirt/driver.py | _get_all_block_devices | srajag/nova | python | def _get_all_block_devices(self):
devices = []
for dom in self._list_instance_domains():
try:
doc = etree.fromstring(dom.XMLDesc(0))
except libvirt.libvirtError as e:
LOG.warn((_LW("couldn't obtain the XML from domain: %(uuid)s, exception: %(ex)s") % {'uuid': dom.UUI... |
def _get_interfaces(self, xml):
'Note that this function takes a domain xml.\n\n Returns a list of all network interfaces for this instance.\n '
doc = None
try:
doc = etree.fromstring(xml)
except Exception:
return []
interfaces = []
ret = doc.findall('./devices/inte... | 1,829,918,215,923,531,000 | Note that this function takes a domain xml.
Returns a list of all network interfaces for this instance. | nova/virt/libvirt/driver.py | _get_interfaces | srajag/nova | python | def _get_interfaces(self, xml):
'Note that this function takes a domain xml.\n\n Returns a list of all network interfaces for this instance.\n '
doc = None
try:
doc = etree.fromstring(xml)
except Exception:
return []
interfaces = []
ret = doc.findall('./devices/inte... |
def _get_vcpu_total(self):
'Get available vcpu number of physical computer.\n\n :returns: the number of cpu core instances can be used.\n\n '
if (self._vcpu_total != 0):
return self._vcpu_total
try:
total_pcpus = self._conn.getInfo()[2]
except libvirt.libvirtError:
... | 4,877,681,997,652,236,000 | Get available vcpu number of physical computer.
:returns: the number of cpu core instances can be used. | nova/virt/libvirt/driver.py | _get_vcpu_total | srajag/nova | python | def _get_vcpu_total(self):
'Get available vcpu number of physical computer.\n\n :returns: the number of cpu core instances can be used.\n\n '
if (self._vcpu_total != 0):
return self._vcpu_total
try:
total_pcpus = self._conn.getInfo()[2]
except libvirt.libvirtError:
... |
def _get_memory_mb_total(self):
'Get the total memory size(MB) of physical computer.\n\n :returns: the total amount of memory(MB).\n\n '
return self._conn.getInfo()[1] | -6,204,214,114,700,270,000 | Get the total memory size(MB) of physical computer.
:returns: the total amount of memory(MB). | nova/virt/libvirt/driver.py | _get_memory_mb_total | srajag/nova | python | def _get_memory_mb_total(self):
'Get the total memory size(MB) of physical computer.\n\n :returns: the total amount of memory(MB).\n\n '
return self._conn.getInfo()[1] |
@staticmethod
def _get_local_gb_info():
'Get local storage info of the compute node in GB.\n\n :returns: A dict containing:\n :total: How big the overall usable filesystem is (in gigabytes)\n :free: How much space is free (in gigabytes)\n :used: How much space is used (in ... | 6,157,551,686,383,488,000 | Get local storage info of the compute node in GB.
:returns: A dict containing:
:total: How big the overall usable filesystem is (in gigabytes)
:free: How much space is free (in gigabytes)
:used: How much space is used (in gigabytes) | nova/virt/libvirt/driver.py | _get_local_gb_info | srajag/nova | python | @staticmethod
def _get_local_gb_info():
'Get local storage info of the compute node in GB.\n\n :returns: A dict containing:\n :total: How big the overall usable filesystem is (in gigabytes)\n :free: How much space is free (in gigabytes)\n :used: How much space is used (in ... |
def _get_vcpu_used(self):
'Get vcpu usage number of physical computer.\n\n :returns: The total number of vcpu(s) that are currently being used.\n\n '
total = 0
if (CONF.libvirt.virt_type == 'lxc'):
return (total + 1)
for dom in self._list_instance_domains():
try:
... | -3,860,857,789,327,115,300 | Get vcpu usage number of physical computer.
:returns: The total number of vcpu(s) that are currently being used. | nova/virt/libvirt/driver.py | _get_vcpu_used | srajag/nova | python | def _get_vcpu_used(self):
'Get vcpu usage number of physical computer.\n\n :returns: The total number of vcpu(s) that are currently being used.\n\n '
total = 0
if (CONF.libvirt.virt_type == 'lxc'):
return (total + 1)
for dom in self._list_instance_domains():
try:
... |
def _get_memory_mb_used(self):
'Get the used memory size(MB) of physical computer.\n\n :returns: the total usage of memory(MB).\n\n '
if (sys.platform.upper() not in ['LINUX2', 'LINUX3']):
return 0
with open('/proc/meminfo') as fp:
m = fp.read().split()
idx1 = m.index('MemF... | -1,535,954,299,046,830,000 | Get the used memory size(MB) of physical computer.
:returns: the total usage of memory(MB). | nova/virt/libvirt/driver.py | _get_memory_mb_used | srajag/nova | python | def _get_memory_mb_used(self):
'Get the used memory size(MB) of physical computer.\n\n :returns: the total usage of memory(MB).\n\n '
if (sys.platform.upper() not in ['LINUX2', 'LINUX3']):
return 0
with open('/proc/meminfo') as fp:
m = fp.read().split()
idx1 = m.index('MemF... |
def _get_hypervisor_type(self):
'Get hypervisor type.\n\n :returns: hypervisor type (ex. qemu)\n\n '
return self._conn.getType() | 5,286,859,397,592,172,000 | Get hypervisor type.
:returns: hypervisor type (ex. qemu) | nova/virt/libvirt/driver.py | _get_hypervisor_type | srajag/nova | python | def _get_hypervisor_type(self):
'Get hypervisor type.\n\n :returns: hypervisor type (ex. qemu)\n\n '
return self._conn.getType() |
def _get_hypervisor_version(self):
'Get hypervisor version.\n\n :returns: hypervisor version (ex. 12003)\n\n '
method = getattr(self._conn, 'getVersion', None)
if (method is None):
raise exception.NovaException(_('libvirt version is too old (does not support getVersion)'))
return m... | -7,621,861,062,212,571,000 | Get hypervisor version.
:returns: hypervisor version (ex. 12003) | nova/virt/libvirt/driver.py | _get_hypervisor_version | srajag/nova | python | def _get_hypervisor_version(self):
'Get hypervisor version.\n\n :returns: hypervisor version (ex. 12003)\n\n '
method = getattr(self._conn, 'getVersion', None)
if (method is None):
raise exception.NovaException(_('libvirt version is too old (does not support getVersion)'))
return m... |
def _get_hypervisor_hostname(self):
'Returns the hostname of the hypervisor.'
hostname = self._conn.getHostname()
if (not hasattr(self, '_hypervisor_hostname')):
self._hypervisor_hostname = hostname
elif (hostname != self._hypervisor_hostname):
LOG.error(_LE('Hostname has changed from %(... | 375,618,949,531,053,760 | Returns the hostname of the hypervisor. | nova/virt/libvirt/driver.py | _get_hypervisor_hostname | srajag/nova | python | def _get_hypervisor_hostname(self):
hostname = self._conn.getHostname()
if (not hasattr(self, '_hypervisor_hostname')):
self._hypervisor_hostname = hostname
elif (hostname != self._hypervisor_hostname):
LOG.error(_LE('Hostname has changed from %(old)s to %(new)s. A restart is required t... |
def _get_instance_capabilities(self):
'Get hypervisor instance capabilities\n\n Returns a list of tuples that describe instances the\n hypervisor is capable of hosting. Each tuple consists\n of the triplet (arch, hypervisor_type, vm_mode).\n\n :returns: List of tuples describing instanc... | -8,739,905,543,423,807,000 | Get hypervisor instance capabilities
Returns a list of tuples that describe instances the
hypervisor is capable of hosting. Each tuple consists
of the triplet (arch, hypervisor_type, vm_mode).
:returns: List of tuples describing instance capabilities | nova/virt/libvirt/driver.py | _get_instance_capabilities | srajag/nova | python | def _get_instance_capabilities(self):
'Get hypervisor instance capabilities\n\n Returns a list of tuples that describe instances the\n hypervisor is capable of hosting. Each tuple consists\n of the triplet (arch, hypervisor_type, vm_mode).\n\n :returns: List of tuples describing instanc... |
def _get_cpu_info(self):
'Get cpuinfo information.\n\n Obtains cpu feature from virConnect.getCapabilities,\n and returns as a json string.\n\n :return: see above description\n\n '
caps = self._get_host_capabilities()
cpu_info = dict()
cpu_info['arch'] = caps.host.cpu.arch
... | 3,019,756,992,942,653,000 | Get cpuinfo information.
Obtains cpu feature from virConnect.getCapabilities,
and returns as a json string.
:return: see above description | nova/virt/libvirt/driver.py | _get_cpu_info | srajag/nova | python | def _get_cpu_info(self):
'Get cpuinfo information.\n\n Obtains cpu feature from virConnect.getCapabilities,\n and returns as a json string.\n\n :return: see above description\n\n '
caps = self._get_host_capabilities()
cpu_info = dict()
cpu_info['arch'] = caps.host.cpu.arch
... |
def _get_pcidev_info(self, devname):
'Returns a dict of PCI device.'
def _get_device_type(cfgdev):
"Get a PCI device's device type.\n\n An assignable PCI device can be a normal PCI device,\n a SR-IOV Physical Function (PF), or a SR-IOV Virtual\n Function (VF). Only norm... | -7,456,508,015,902,004,000 | Returns a dict of PCI device. | nova/virt/libvirt/driver.py | _get_pcidev_info | srajag/nova | python | def _get_pcidev_info(self, devname):
def _get_device_type(cfgdev):
"Get a PCI device's device type.\n\n An assignable PCI device can be a normal PCI device,\n a SR-IOV Physical Function (PF), or a SR-IOV Virtual\n Function (VF). Only normal PCI devices or SR-IOV VFs\n ... |
def _get_pci_passthrough_devices(self):
"Get host PCI devices information.\n\n Obtains pci devices information from libvirt, and returns\n as a JSON string.\n\n Each device information is a dictionary, with mandatory keys\n of 'address', 'vendor_id', 'product_id', 'dev_type', 'dev_id',\n... | 5,520,751,107,575,842,000 | Get host PCI devices information.
Obtains pci devices information from libvirt, and returns
as a JSON string.
Each device information is a dictionary, with mandatory keys
of 'address', 'vendor_id', 'product_id', 'dev_type', 'dev_id',
'label' and other optional device specific information.
Refer to the objects/pci_de... | nova/virt/libvirt/driver.py | _get_pci_passthrough_devices | srajag/nova | python | def _get_pci_passthrough_devices(self):
"Get host PCI devices information.\n\n Obtains pci devices information from libvirt, and returns\n as a JSON string.\n\n Each device information is a dictionary, with mandatory keys\n of 'address', 'vendor_id', 'product_id', 'dev_type', 'dev_id',\n... |
def get_all_volume_usage(self, context, compute_host_bdms):
'Return usage info for volumes attached to vms on\n a given host.\n '
vol_usage = []
for instance_bdms in compute_host_bdms:
instance = instance_bdms['instance']
for bdm in instance_bdms['instance_bdms']:
... | 7,337,256,096,335,965,000 | Return usage info for volumes attached to vms on
a given host. | nova/virt/libvirt/driver.py | get_all_volume_usage | srajag/nova | python | def get_all_volume_usage(self, context, compute_host_bdms):
'Return usage info for volumes attached to vms on\n a given host.\n '
vol_usage = []
for instance_bdms in compute_host_bdms:
instance = instance_bdms['instance']
for bdm in instance_bdms['instance_bdms']:
... |
def block_stats(self, instance_name, disk_id):
'Note that this function takes an instance name.'
try:
domain = self._lookup_by_name(instance_name)
return domain.blockStats(disk_id)
except libvirt.libvirtError as e:
errcode = e.get_error_code()
LOG.info(_LI('Getting block stat... | -682,258,597,712,542,700 | Note that this function takes an instance name. | nova/virt/libvirt/driver.py | block_stats | srajag/nova | python | def block_stats(self, instance_name, disk_id):
try:
domain = self._lookup_by_name(instance_name)
return domain.blockStats(disk_id)
except libvirt.libvirtError as e:
errcode = e.get_error_code()
LOG.info(_LI('Getting block stats failed, device might have been detached. Instan... |
def interface_stats(self, instance_name, iface_id):
'Note that this function takes an instance name.'
domain = self._lookup_by_name(instance_name)
return domain.interfaceStats(iface_id) | -8,352,032,843,542,878,000 | Note that this function takes an instance name. | nova/virt/libvirt/driver.py | interface_stats | srajag/nova | python | def interface_stats(self, instance_name, iface_id):
domain = self._lookup_by_name(instance_name)
return domain.interfaceStats(iface_id) |
def get_available_resource(self, nodename):
'Retrieve resource information.\n\n This method is called when nova-compute launches, and\n as part of a periodic task that records the results in the DB.\n\n :param nodename: will be put in PCI device\n :returns: dictionary containing resource... | -6,399,908,168,104,497,000 | Retrieve resource information.
This method is called when nova-compute launches, and
as part of a periodic task that records the results in the DB.
:param nodename: will be put in PCI device
:returns: dictionary containing resource info | nova/virt/libvirt/driver.py | get_available_resource | srajag/nova | python | def get_available_resource(self, nodename):
'Retrieve resource information.\n\n This method is called when nova-compute launches, and\n as part of a periodic task that records the results in the DB.\n\n :param nodename: will be put in PCI device\n :returns: dictionary containing resource... |
def check_can_live_migrate_destination(self, context, instance, src_compute_info, dst_compute_info, block_migration=False, disk_over_commit=False):
'Check if it is possible to execute live migration.\n\n This runs checks on the destination host, and then calls\n back to the source host to check the re... | 3,491,805,781,014,162,400 | Check if it is possible to execute live migration.
This runs checks on the destination host, and then calls
back to the source host to check the results.
:param context: security context
:param instance: nova.db.sqlalchemy.models.Instance
:param block_migration: if true, prepare for block migration
:param disk_over_c... | nova/virt/libvirt/driver.py | check_can_live_migrate_destination | srajag/nova | python | def check_can_live_migrate_destination(self, context, instance, src_compute_info, dst_compute_info, block_migration=False, disk_over_commit=False):
'Check if it is possible to execute live migration.\n\n This runs checks on the destination host, and then calls\n back to the source host to check the re... |
def check_can_live_migrate_destination_cleanup(self, context, dest_check_data):
'Do required cleanup on dest host after check_can_live_migrate calls\n\n :param context: security context\n '
filename = dest_check_data['filename']
self._cleanup_shared_storage_test_file(filename) | 3,965,159,367,356,769,000 | Do required cleanup on dest host after check_can_live_migrate calls
:param context: security context | nova/virt/libvirt/driver.py | check_can_live_migrate_destination_cleanup | srajag/nova | python | def check_can_live_migrate_destination_cleanup(self, context, dest_check_data):
'Do required cleanup on dest host after check_can_live_migrate calls\n\n :param context: security context\n '
filename = dest_check_data['filename']
self._cleanup_shared_storage_test_file(filename) |
def check_can_live_migrate_source(self, context, instance, dest_check_data):
'Check if it is possible to execute live migration.\n\n This checks if the live migration can succeed, based on the\n results from check_can_live_migrate_destination.\n\n :param context: security context\n :para... | -5,361,551,892,567,386,000 | Check if it is possible to execute live migration.
This checks if the live migration can succeed, based on the
results from check_can_live_migrate_destination.
:param context: security context
:param instance: nova.db.sqlalchemy.models.Instance
:param dest_check_data: result of check_can_live_migrate_destination
:ret... | nova/virt/libvirt/driver.py | check_can_live_migrate_source | srajag/nova | python | def check_can_live_migrate_source(self, context, instance, dest_check_data):
'Check if it is possible to execute live migration.\n\n This checks if the live migration can succeed, based on the\n results from check_can_live_migrate_destination.\n\n :param context: security context\n :para... |
def _is_shared_block_storage(self, instance, dest_check_data):
'Check if all block storage of an instance can be shared\n between source and destination of a live migration.\n\n Returns true if the instance is volume backed and has no local disks,\n or if the image backend is the same on source... | -5,988,698,175,857,207,000 | Check if all block storage of an instance can be shared
between source and destination of a live migration.
Returns true if the instance is volume backed and has no local disks,
or if the image backend is the same on source and destination and the
backend shares block storage between compute nodes. | nova/virt/libvirt/driver.py | _is_shared_block_storage | srajag/nova | python | def _is_shared_block_storage(self, instance, dest_check_data):
'Check if all block storage of an instance can be shared\n between source and destination of a live migration.\n\n Returns true if the instance is volume backed and has no local disks,\n or if the image backend is the same on source... |
def _is_shared_instance_path(self, dest_check_data):
'Check if instance path is shared between source and\n destination of a live migration.\n '
return self._check_shared_storage_test_file(dest_check_data['filename']) | 6,241,452,415,291,556,000 | Check if instance path is shared between source and
destination of a live migration. | nova/virt/libvirt/driver.py | _is_shared_instance_path | srajag/nova | python | def _is_shared_instance_path(self, dest_check_data):
'Check if instance path is shared between source and\n destination of a live migration.\n '
return self._check_shared_storage_test_file(dest_check_data['filename']) |
def _assert_dest_node_has_enough_disk(self, context, instance, available_mb, disk_over_commit):
'Checks if destination has enough disk for block migration.'
available = 0
if available_mb:
available = (available_mb * units.Mi)
ret = self.get_instance_disk_info(instance['name'])
disk_infos = j... | -3,717,422,254,881,443,000 | Checks if destination has enough disk for block migration. | nova/virt/libvirt/driver.py | _assert_dest_node_has_enough_disk | srajag/nova | python | def _assert_dest_node_has_enough_disk(self, context, instance, available_mb, disk_over_commit):
available = 0
if available_mb:
available = (available_mb * units.Mi)
ret = self.get_instance_disk_info(instance['name'])
disk_infos = jsonutils.loads(ret)
necessary = 0
if disk_over_commi... |
def _compare_cpu(self, cpu_info):
'Checks the host cpu is compatible to a cpu given by xml.\n "xml" must be a part of libvirt.openAuth(...).getCapabilities().\n return values follows by virCPUCompareResult.\n if 0 > return value, do live migration.\n \'http://libvirt.org/html/libvirt-lib... | 6,895,970,308,596,628,000 | Checks the host cpu is compatible to a cpu given by xml.
"xml" must be a part of libvirt.openAuth(...).getCapabilities().
return values follows by virCPUCompareResult.
if 0 > return value, do live migration.
'http://libvirt.org/html/libvirt-libvirt.html#virCPUCompareResult'
:param cpu_info: json string of cpu feature ... | nova/virt/libvirt/driver.py | _compare_cpu | srajag/nova | python | def _compare_cpu(self, cpu_info):
'Checks the host cpu is compatible to a cpu given by xml.\n "xml" must be a part of libvirt.openAuth(...).getCapabilities().\n return values follows by virCPUCompareResult.\n if 0 > return value, do live migration.\n \'http://libvirt.org/html/libvirt-lib... |
def _create_shared_storage_test_file(self):
'Makes tmpfile under CONF.instances_path.'
dirpath = CONF.instances_path
(fd, tmp_file) = tempfile.mkstemp(dir=dirpath)
LOG.debug('Creating tmpfile %s to notify to other compute nodes that they should mount the same storage.', tmp_file)
os.close(fd)
re... | 5,045,898,907,620,860,000 | Makes tmpfile under CONF.instances_path. | nova/virt/libvirt/driver.py | _create_shared_storage_test_file | srajag/nova | python | def _create_shared_storage_test_file(self):
dirpath = CONF.instances_path
(fd, tmp_file) = tempfile.mkstemp(dir=dirpath)
LOG.debug('Creating tmpfile %s to notify to other compute nodes that they should mount the same storage.', tmp_file)
os.close(fd)
return os.path.basename(tmp_file) |
def _check_shared_storage_test_file(self, filename):
'Confirms existence of the tmpfile under CONF.instances_path.\n\n Cannot confirm tmpfile return False.\n '
tmp_file = os.path.join(CONF.instances_path, filename)
if (not os.path.exists(tmp_file)):
return False
else:
retur... | 834,513,234,792,377,700 | Confirms existence of the tmpfile under CONF.instances_path.
Cannot confirm tmpfile return False. | nova/virt/libvirt/driver.py | _check_shared_storage_test_file | srajag/nova | python | def _check_shared_storage_test_file(self, filename):
'Confirms existence of the tmpfile under CONF.instances_path.\n\n Cannot confirm tmpfile return False.\n '
tmp_file = os.path.join(CONF.instances_path, filename)
if (not os.path.exists(tmp_file)):
return False
else:
retur... |
def _cleanup_shared_storage_test_file(self, filename):
'Removes existence of the tmpfile under CONF.instances_path.'
tmp_file = os.path.join(CONF.instances_path, filename)
os.remove(tmp_file) | 2,424,444,300,822,148,000 | Removes existence of the tmpfile under CONF.instances_path. | nova/virt/libvirt/driver.py | _cleanup_shared_storage_test_file | srajag/nova | python | def _cleanup_shared_storage_test_file(self, filename):
tmp_file = os.path.join(CONF.instances_path, filename)
os.remove(tmp_file) |
def ensure_filtering_rules_for_instance(self, instance, network_info):
"Ensure that an instance's filtering rules are enabled.\n\n When migrating an instance, we need the filtering rules to\n be configured on the destination host before starting the\n migration.\n\n Also, when restarting... | -1,945,658,079,477,859,800 | Ensure that an instance's filtering rules are enabled.
When migrating an instance, we need the filtering rules to
be configured on the destination host before starting the
migration.
Also, when restarting the compute service, we need to ensure
that filtering rules exist for all running services. | nova/virt/libvirt/driver.py | ensure_filtering_rules_for_instance | srajag/nova | python | def ensure_filtering_rules_for_instance(self, instance, network_info):
"Ensure that an instance's filtering rules are enabled.\n\n When migrating an instance, we need the filtering rules to\n be configured on the destination host before starting the\n migration.\n\n Also, when restarting... |
def live_migration(self, context, instance, dest, post_method, recover_method, block_migration=False, migrate_data=None):
'Spawning live_migration operation for distributing high-load.\n\n :param context: security context\n :param instance:\n nova.db.sqlalchemy.models.Instance object\n ... | 7,227,832,000,531,877,000 | Spawning live_migration operation for distributing high-load.
:param context: security context
:param instance:
nova.db.sqlalchemy.models.Instance object
instance object that is migrated.
:param dest: destination host
:param post_method:
post operation method.
expected nova.compute.manager._post_live_m... | nova/virt/libvirt/driver.py | live_migration | srajag/nova | python | def live_migration(self, context, instance, dest, post_method, recover_method, block_migration=False, migrate_data=None):
'Spawning live_migration operation for distributing high-load.\n\n :param context: security context\n :param instance:\n nova.db.sqlalchemy.models.Instance object\n ... |
def _live_migration(self, context, instance, dest, post_method, recover_method, block_migration=False, migrate_data=None):
'Do live migration.\n\n :param context: security context\n :param instance:\n nova.db.sqlalchemy.models.Instance object\n instance object that is migrated.\n... | 5,170,598,127,086,826,000 | Do live migration.
:param context: security context
:param instance:
nova.db.sqlalchemy.models.Instance object
instance object that is migrated.
:param dest: destination host
:param post_method:
post operation method.
expected nova.compute.manager._post_live_migration.
:param recover_method:
recove... | nova/virt/libvirt/driver.py | _live_migration | srajag/nova | python | def _live_migration(self, context, instance, dest, post_method, recover_method, block_migration=False, migrate_data=None):
'Do live migration.\n\n :param context: security context\n :param instance:\n nova.db.sqlalchemy.models.Instance object\n instance object that is migrated.\n... |
def _fetch_instance_kernel_ramdisk(self, context, instance):
'Download kernel and ramdisk for instance in instance directory.'
instance_dir = libvirt_utils.get_instance_path(instance)
if instance['kernel_id']:
libvirt_utils.fetch_image(context, os.path.join(instance_dir, 'kernel'), instance['kernel_... | 6,271,825,693,192,430,000 | Download kernel and ramdisk for instance in instance directory. | nova/virt/libvirt/driver.py | _fetch_instance_kernel_ramdisk | srajag/nova | python | def _fetch_instance_kernel_ramdisk(self, context, instance):
instance_dir = libvirt_utils.get_instance_path(instance)
if instance['kernel_id']:
libvirt_utils.fetch_image(context, os.path.join(instance_dir, 'kernel'), instance['kernel_id'], instance['user_id'], instance['project_id'])
if ins... |
def rollback_live_migration_at_destination(self, context, instance, network_info, block_device_info, destroy_disks=True, migrate_data=None):
'Clean up destination node after a failed live migration.'
self.destroy(context, instance, network_info, block_device_info, destroy_disks, migrate_data) | -8,457,260,677,069,410,000 | Clean up destination node after a failed live migration. | nova/virt/libvirt/driver.py | rollback_live_migration_at_destination | srajag/nova | python | def rollback_live_migration_at_destination(self, context, instance, network_info, block_device_info, destroy_disks=True, migrate_data=None):
self.destroy(context, instance, network_info, block_device_info, destroy_disks, migrate_data) |
def pre_live_migration(self, context, instance, block_device_info, network_info, disk_info, migrate_data=None):
'Preparation live migration.'
is_shared_block_storage = True
is_shared_instance_path = True
is_block_migration = True
instance_relative_path = None
if migrate_data:
is_shared_b... | 5,580,733,104,593,865,000 | Preparation live migration. | nova/virt/libvirt/driver.py | pre_live_migration | srajag/nova | python | def pre_live_migration(self, context, instance, block_device_info, network_info, disk_info, migrate_data=None):
is_shared_block_storage = True
is_shared_instance_path = True
is_block_migration = True
instance_relative_path = None
if migrate_data:
is_shared_block_storage = migrate_data.g... |
def _create_images_and_backing(self, context, instance, instance_dir, disk_info_json):
':param context: security context\n :param instance:\n nova.db.sqlalchemy.models.Instance object\n instance object that is migrated.\n :param instance_dir:\n instance ... | 7,238,436,511,716,076,000 | :param context: security context
:param instance:
nova.db.sqlalchemy.models.Instance object
instance object that is migrated.
:param instance_dir:
instance path to use, calculated externally to handle block
migrating an instance with an old style instance path
:param disk_info_json:
json strings spe... | nova/virt/libvirt/driver.py | _create_images_and_backing | srajag/nova | python | def _create_images_and_backing(self, context, instance, instance_dir, disk_info_json):
':param context: security context\n :param instance:\n nova.db.sqlalchemy.models.Instance object\n instance object that is migrated.\n :param instance_dir:\n instance ... |
def post_live_migration_at_source(self, context, instance, network_info):
'Unplug VIFs from networks at source.\n\n :param context: security context\n :param instance: instance object reference\n :param network_info: instance network information\n '
self.unplug_vifs(instance, network... | -5,631,838,636,930,248,000 | Unplug VIFs from networks at source.
:param context: security context
:param instance: instance object reference
:param network_info: instance network information | nova/virt/libvirt/driver.py | post_live_migration_at_source | srajag/nova | python | def post_live_migration_at_source(self, context, instance, network_info):
'Unplug VIFs from networks at source.\n\n :param context: security context\n :param instance: instance object reference\n :param network_info: instance network information\n '
self.unplug_vifs(instance, network... |
def post_live_migration_at_destination(self, context, instance, network_info, block_migration=False, block_device_info=None):
'Post operation of live migration at destination host.\n\n :param context: security context\n :param instance:\n nova.db.sqlalchemy.models.Instance object\n ... | 6,864,859,203,662,335,000 | Post operation of live migration at destination host.
:param context: security context
:param instance:
nova.db.sqlalchemy.models.Instance object
instance object that is migrated.
:param network_info: instance network information
:param block_migration: if true, post operation of block_migration. | nova/virt/libvirt/driver.py | post_live_migration_at_destination | srajag/nova | python | def post_live_migration_at_destination(self, context, instance, network_info, block_migration=False, block_device_info=None):
'Post operation of live migration at destination host.\n\n :param context: security context\n :param instance:\n nova.db.sqlalchemy.models.Instance object\n ... |
def _get_disk_over_committed_size_total(self):
'Return total over committed disk size for all instances.'
disk_over_committed_size = 0
for dom in self._list_instance_domains():
try:
xml = dom.XMLDesc(0)
disk_infos = jsonutils.loads(self._get_instance_disk_info(dom.name(), xml... | 3,580,466,839,921,161,000 | Return total over committed disk size for all instances. | nova/virt/libvirt/driver.py | _get_disk_over_committed_size_total | srajag/nova | python | def _get_disk_over_committed_size_total(self):
disk_over_committed_size = 0
for dom in self._list_instance_domains():
try:
xml = dom.XMLDesc(0)
disk_infos = jsonutils.loads(self._get_instance_disk_info(dom.name(), xml))
for info in disk_infos:
dis... |
def unfilter_instance(self, instance, network_info):
'See comments of same method in firewall_driver.'
self.firewall_driver.unfilter_instance(instance, network_info=network_info) | -4,260,456,343,576,868,000 | See comments of same method in firewall_driver. | nova/virt/libvirt/driver.py | unfilter_instance | srajag/nova | python | def unfilter_instance(self, instance, network_info):
self.firewall_driver.unfilter_instance(instance, network_info=network_info) |
def get_host_stats(self, refresh=False):
"Return the current state of the host.\n\n If 'refresh' is True, run update the stats first.\n "
return self.host_state.get_host_stats(refresh=refresh) | -4,014,127,448,018,930,700 | Return the current state of the host.
If 'refresh' is True, run update the stats first. | nova/virt/libvirt/driver.py | get_host_stats | srajag/nova | python | def get_host_stats(self, refresh=False):
"Return the current state of the host.\n\n If 'refresh' is True, run update the stats first.\n "
return self.host_state.get_host_stats(refresh=refresh) |
def get_host_cpu_stats(self):
'Return the current CPU state of the host.'
stats = self._conn.getCPUStats(libvirt.VIR_NODE_CPU_STATS_ALL_CPUS, 0)
stats['frequency'] = self._conn.getInfo()[3]
return stats | 3,507,474,525,421,915,600 | Return the current CPU state of the host. | nova/virt/libvirt/driver.py | get_host_cpu_stats | srajag/nova | python | def get_host_cpu_stats(self):
stats = self._conn.getCPUStats(libvirt.VIR_NODE_CPU_STATS_ALL_CPUS, 0)
stats['frequency'] = self._conn.getInfo()[3]
return stats |
def get_host_uptime(self, host):
'Returns the result of calling "uptime".'
(out, err) = utils.execute('env', 'LANG=C', 'uptime')
return out | 9,065,312,545,126,296,000 | Returns the result of calling "uptime". | nova/virt/libvirt/driver.py | get_host_uptime | srajag/nova | python | def get_host_uptime(self, host):
(out, err) = utils.execute('env', 'LANG=C', 'uptime')
return out |
def manage_image_cache(self, context, all_instances):
'Manage the local cache of images.'
self.image_cache_manager.update(context, all_instances) | 6,971,867,045,383,601,000 | Manage the local cache of images. | nova/virt/libvirt/driver.py | manage_image_cache | srajag/nova | python | def manage_image_cache(self, context, all_instances):
self.image_cache_manager.update(context, all_instances) |
def _cleanup_remote_migration(self, dest, inst_base, inst_base_resize, shared_storage=False):
'Used only for cleanup in case migrate_disk_and_power_off fails.'
try:
if os.path.exists(inst_base_resize):
utils.execute('rm', '-rf', inst_base)
utils.execute('mv', inst_base_resize, in... | -7,738,954,416,765,412,000 | Used only for cleanup in case migrate_disk_and_power_off fails. | nova/virt/libvirt/driver.py | _cleanup_remote_migration | srajag/nova | python | def _cleanup_remote_migration(self, dest, inst_base, inst_base_resize, shared_storage=False):
try:
if os.path.exists(inst_base_resize):
utils.execute('rm', '-rf', inst_base)
utils.execute('mv', inst_base_resize, inst_base)
if (not shared_storage):
uti... |
@staticmethod
def _disk_size_from_instance(instance, info):
'Determines the disk size from instance properties\n\n Returns the disk size by using the disk name to determine whether it\n is a root or an ephemeral disk, then by checking properties of the\n instance returns the size converted to b... | -3,037,090,758,507,430,000 | Determines the disk size from instance properties
Returns the disk size by using the disk name to determine whether it
is a root or an ephemeral disk, then by checking properties of the
instance returns the size converted to bytes.
Returns 0 if the disk name not match (disk, disk.local). | nova/virt/libvirt/driver.py | _disk_size_from_instance | srajag/nova | python | @staticmethod
def _disk_size_from_instance(instance, info):
'Determines the disk size from instance properties\n\n Returns the disk size by using the disk name to determine whether it\n is a root or an ephemeral disk, then by checking properties of the\n instance returns the size converted to b... |
@staticmethod
def _disk_raw_to_qcow2(path):
'Converts a raw disk to qcow2.'
path_qcow = (path + '_qcow')
utils.execute('qemu-img', 'convert', '-f', 'raw', '-O', 'qcow2', path, path_qcow)
utils.execute('mv', path_qcow, path) | 5,152,713,984,113,876,000 | Converts a raw disk to qcow2. | nova/virt/libvirt/driver.py | _disk_raw_to_qcow2 | srajag/nova | python | @staticmethod
def _disk_raw_to_qcow2(path):
path_qcow = (path + '_qcow')
utils.execute('qemu-img', 'convert', '-f', 'raw', '-O', 'qcow2', path, path_qcow)
utils.execute('mv', path_qcow, path) |
@staticmethod
def _disk_qcow2_to_raw(path):
'Converts a qcow2 disk to raw.'
path_raw = (path + '_raw')
utils.execute('qemu-img', 'convert', '-f', 'qcow2', '-O', 'raw', path, path_raw)
utils.execute('mv', path_raw, path) | -5,464,065,104,567,348,000 | Converts a qcow2 disk to raw. | nova/virt/libvirt/driver.py | _disk_qcow2_to_raw | srajag/nova | python | @staticmethod
def _disk_qcow2_to_raw(path):
path_raw = (path + '_raw')
utils.execute('qemu-img', 'convert', '-f', 'qcow2', '-O', 'raw', path, path_raw)
utils.execute('mv', path_raw, path) |
def _disk_resize(self, info, size):
'Attempts to resize a disk to size\n\n Attempts to resize a disk by checking the capabilities and\n preparing the format, then calling disk.api.extend.\n\n Note: Currently only support disk extend.\n '
fmt = info['type']
pth = info['path']
... | 4,721,868,778,200,022,000 | Attempts to resize a disk to size
Attempts to resize a disk by checking the capabilities and
preparing the format, then calling disk.api.extend.
Note: Currently only support disk extend. | nova/virt/libvirt/driver.py | _disk_resize | srajag/nova | python | def _disk_resize(self, info, size):
'Attempts to resize a disk to size\n\n Attempts to resize a disk by checking the capabilities and\n preparing the format, then calling disk.api.extend.\n\n Note: Currently only support disk extend.\n '
fmt = info['type']
pth = info['path']
... |
def _cleanup_failed_migration(self, inst_base):
"Make sure that a failed migrate doesn't prevent us from rolling\n back in a revert.\n "
try:
shutil.rmtree(inst_base)
except OSError as e:
if (e.errno != errno.ENOENT):
raise | 7,264,325,835,884,052,000 | Make sure that a failed migrate doesn't prevent us from rolling
back in a revert. | nova/virt/libvirt/driver.py | _cleanup_failed_migration | srajag/nova | python | def _cleanup_failed_migration(self, inst_base):
"Make sure that a failed migrate doesn't prevent us from rolling\n back in a revert.\n "
try:
shutil.rmtree(inst_base)
except OSError as e:
if (e.errno != errno.ENOENT):
raise |
def confirm_migration(self, migration, instance, network_info):
'Confirms a resize, destroying the source VM.'
self._cleanup_resize(instance, network_info) | -2,616,171,590,583,491,600 | Confirms a resize, destroying the source VM. | nova/virt/libvirt/driver.py | confirm_migration | srajag/nova | python | def confirm_migration(self, migration, instance, network_info):
self._cleanup_resize(instance, network_info) |
def get_host_stats(self, refresh=False):
"Return the current state of the host.\n\n If 'refresh' is True, run update the stats first.\n "
if (refresh or (not self._stats)):
self.update_status()
return self._stats | 6,806,025,530,485,851,000 | Return the current state of the host.
If 'refresh' is True, run update the stats first. | nova/virt/libvirt/driver.py | get_host_stats | srajag/nova | python | def get_host_stats(self, refresh=False):
"Return the current state of the host.\n\n If 'refresh' is True, run update the stats first.\n "
if (refresh or (not self._stats)):
self.update_status()
return self._stats |
def update_status(self):
'Retrieve status info from libvirt.'
def _get_disk_available_least():
'Return total real disk available least size.\n\n The size of available disk, when block_migration command given\n disk_over_commit param is FALSE.\n\n The size that deducted ... | -4,228,633,569,821,032,400 | Retrieve status info from libvirt. | nova/virt/libvirt/driver.py | update_status | srajag/nova | python | def update_status(self):
def _get_disk_available_least():
'Return total real disk available least size.\n\n The size of available disk, when block_migration command given\n disk_over_commit param is FALSE.\n\n The size that deducted real instance disk size from the tot... |
def _wait_for_destroy(expected_domid):
'Called at an interval until the VM is gone.'
try:
dom_info = self.get_info(instance)
state = dom_info['state']
new_domid = dom_info['id']
except exception.InstanceNotFound:
LOG.warning(_LW('During wait destroy, instance disappeared.'), ... | 5,439,729,913,305,656,000 | Called at an interval until the VM is gone. | nova/virt/libvirt/driver.py | _wait_for_destroy | srajag/nova | python | def _wait_for_destroy(expected_domid):
try:
dom_info = self.get_info(instance)
state = dom_info['state']
new_domid = dom_info['id']
except exception.InstanceNotFound:
LOG.warning(_LW('During wait destroy, instance disappeared.'), instance=instance)
raise loopingcall.... |
def _wait_for_reboot():
'Called at an interval until the VM is running again.'
state = self.get_info(instance)['state']
if (state == power_state.RUNNING):
LOG.info(_LI('Instance rebooted successfully.'), instance=instance)
raise loopingcall.LoopingCallDone() | -6,929,160,274,796,647,000 | Called at an interval until the VM is running again. | nova/virt/libvirt/driver.py | _wait_for_reboot | srajag/nova | python | def _wait_for_reboot():
state = self.get_info(instance)['state']
if (state == power_state.RUNNING):
LOG.info(_LI('Instance rebooted successfully.'), instance=instance)
raise loopingcall.LoopingCallDone() |
def _wait_for_boot():
'Called at an interval until the VM is running.'
state = self.get_info(instance)['state']
if (state == power_state.RUNNING):
LOG.info(_LI('Instance spawned successfully.'), instance=instance)
raise loopingcall.LoopingCallDone() | -3,637,270,590,012,610,000 | Called at an interval until the VM is running. | nova/virt/libvirt/driver.py | _wait_for_boot | srajag/nova | python | def _wait_for_boot():
state = self.get_info(instance)['state']
if (state == power_state.RUNNING):
LOG.info(_LI('Instance spawned successfully.'), instance=instance)
raise loopingcall.LoopingCallDone() |
def _get_device_type(cfgdev):
"Get a PCI device's device type.\n\n An assignable PCI device can be a normal PCI device,\n a SR-IOV Physical Function (PF), or a SR-IOV Virtual\n Function (VF). Only normal PCI devices or SR-IOV VFs\n are assignable, while SR-IOV PFs are alw... | 993,374,100,423,534,300 | Get a PCI device's device type.
An assignable PCI device can be a normal PCI device,
a SR-IOV Physical Function (PF), or a SR-IOV Virtual
Function (VF). Only normal PCI devices or SR-IOV VFs
are assignable, while SR-IOV PFs are always owned by
hypervisor.
Please notice that a PCI device with SR-IOV
capability but not... | nova/virt/libvirt/driver.py | _get_device_type | srajag/nova | python | def _get_device_type(cfgdev):
"Get a PCI device's device type.\n\n An assignable PCI device can be a normal PCI device,\n a SR-IOV Physical Function (PF), or a SR-IOV Virtual\n Function (VF). Only normal PCI devices or SR-IOV VFs\n are assignable, while SR-IOV PFs are alw... |
def wait_for_live_migration():
'waiting for live migration completion.'
try:
self.get_info(instance)['state']
except exception.InstanceNotFound:
timer.stop()
post_method(context, instance, dest, block_migration, migrate_data) | -3,174,638,724,439,251,000 | waiting for live migration completion. | nova/virt/libvirt/driver.py | wait_for_live_migration | srajag/nova | python | def wait_for_live_migration():
try:
self.get_info(instance)['state']
except exception.InstanceNotFound:
timer.stop()
post_method(context, instance, dest, block_migration, migrate_data) |
def get_io_devices(xml_doc):
'get the list of io devices from the xml document.'
result = {'volumes': [], 'ifaces': []}
try:
doc = etree.fromstring(xml_doc)
except Exception:
return result
blocks = [('./devices/disk', 'volumes'), ('./devices/interface', 'ifaces')]
for (block, key... | 6,174,880,537,626,591,000 | get the list of io devices from the xml document. | nova/virt/libvirt/driver.py | get_io_devices | srajag/nova | python | def get_io_devices(xml_doc):
result = {'volumes': [], 'ifaces': []}
try:
doc = etree.fromstring(xml_doc)
except Exception:
return result
blocks = [('./devices/disk', 'volumes'), ('./devices/interface', 'ifaces')]
for (block, key) in blocks:
section = doc.findall(block)
... |
def _get_disk_available_least():
'Return total real disk available least size.\n\n The size of available disk, when block_migration command given\n disk_over_commit param is FALSE.\n\n The size that deducted real instance disk size from the total size\n of the virtual dis... | -3,710,712,168,234,871,300 | Return total real disk available least size.
The size of available disk, when block_migration command given
disk_over_commit param is FALSE.
The size that deducted real instance disk size from the total size
of the virtual disk of all instances. | nova/virt/libvirt/driver.py | _get_disk_available_least | srajag/nova | python | def _get_disk_available_least():
'Return total real disk available least size.\n\n The size of available disk, when block_migration command given\n disk_over_commit param is FALSE.\n\n The size that deducted real instance disk size from the total size\n of the virtual dis... |
@staticmethod
def configureFromCommandline(db, serviceObject, args):
'Subclasses should take the remaining args from the commandline and configure using them'
pass | 6,080,763,618,851,087,000 | Subclasses should take the remaining args from the commandline and configure using them | object_database/service_manager/ServiceBase.py | configureFromCommandline | braxtonmckee/nativepython | python | @staticmethod
def configureFromCommandline(db, serviceObject, args):
pass |
@pre_load
def set_kubernetes_job_timeout(self, in_data, **kwargs):
'Set kubernetes_job_timeout to a default value if not provided and validate the value.\n\n Method receives the whole data dictionary but operates *only* on kubernetes_job_timeout.\n Updated dictionary is returned.\n '
if ('k... | 883,647,504,958,752,000 | Set kubernetes_job_timeout to a default value if not provided and validate the value.
Method receives the whole data dictionary but operates *only* on kubernetes_job_timeout.
Updated dictionary is returned. | reana_job_controller/schemas.py | set_kubernetes_job_timeout | focilo/focilo-job-controller | python | @pre_load
def set_kubernetes_job_timeout(self, in_data, **kwargs):
'Set kubernetes_job_timeout to a default value if not provided and validate the value.\n\n Method receives the whole data dictionary but operates *only* on kubernetes_job_timeout.\n Updated dictionary is returned.\n '
if ('k... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.