예제 #1
0
	def getVMVcpuMapping(self, vm):
		try:
			libvirt_instance_name = getattr(vm, 'OS-EXT-SRV-ATTR:instance_name')
			with libvirt_client.LibVirtConnection(self.hostname, "qemu+ssh") as libvconn:
				libvinstance = libvirt_client.LibVirtInstance(libvconn, str(libvirt_instance_name))
				return list(libvinstance.get_instance_mapping()[0])
		except:
			self.logger.info("=================> Could not get vcpu mapping of VM %s", vm.id)
			return None
예제 #2
0
	def pin_vcpu(self, vm, vcpu, pcpus):
		self.logger.debug("======> Pinning vcpu %d in pcpus %s", vcpu, pcpus)
		try:
			libvirt_instance_name = getattr(vm, 'OS-EXT-SRV-ATTR:instance_name')
			with libvirt_client.LibVirtConnection(self.hostname, "qemu+ssh") as libvconn:
				libvinstance = libvirt_client.LibVirtInstance(libvconn, str(libvirt_instance_name))
				libvinstance.map_instance_vcpu(vcpu, pcpus)
			return True
		except:
			self.logger.info("=================> Could not pin vcpu %d in pcpus %s", vcpu, pcpus)
			return False
예제 #3
0
def pin_vcpus(vm, vcpus, node):
    try:
        libvirt_instance_name = getattr(vm, 'OS-EXT-SRV-ATTR:instance_name')
        with libvirt_client.LibVirtConnection(node, 'qemu+ssh') as libvconn:
            libvinstance = libvirt_client.LibVirtInstance(
                libvconn, str(libvirt_instance_name))
            for vcpu in range(vcpus):
                libvinstance.map_instance_vcpu(vcpu, [vcpu])
        return True
    except:
        logger.info("======> Failed to pin vcpu in pcpus")
        return False