Ejemplo n.º 1
0
    def rcd_get_diskName(self, vmName, vmID):
        """
        """

        cmd = 'cat /var/run/libvirt/qemu/%s.xml' % vmName
        srcDomXML = self.rcd_call_backendCmd(cmd, vmID)

        parsedSrcDomXML = _domParseStr(srcDomXML)

        domainXmlElements = parsedSrcDomXML.getElementsByTagName('domain')[0]

        #domainXmlElements = parsedSrcDomXML.childNodes[0].getElementsByTagName('domain')[0]

        allDiskDeviceXmlElements = domainXmlElements.getElementsByTagName(
            'devices')[0].getElementsByTagName('disk')

        snappableDiskDeviceXmlElements = \
            self._filterSnappableDiskDevices(allDiskDeviceXmlElements)

        disk = {}
        for snappableDiskDeviceXmlElement in snappableDiskDeviceXmlElements:
            diskType = snappableDiskDeviceXmlElement.getAttribute('type')
            if diskType not in ['file', 'block']:
                continue
            devname = snappableDiskDeviceXmlElement.getElementsByTagName('target')[0].\
                        getAttribute('dev')
            source = snappableDiskDeviceXmlElement.getElementsByTagName('source')[0].\
                        getAttribute('dev')

            imageID = os.path.basename(os.path.dirname(source))
            disk[imageID] = devname

        return disk
Ejemplo n.º 2
0
    def rcd_get_diskName(self, vmName, vmID):
        """
        """
        
        cmd = 'cat /var/run/libvirt/qemu/%s.xml' % vmName
        srcDomXML = self.rcd_call_backendCmd(cmd, vmID)

        parsedSrcDomXML = _domParseStr(srcDomXML)
       
        domainXmlElements = parsedSrcDomXML.getElementsByTagName('domain')[0]
  
        #domainXmlElements = parsedSrcDomXML.childNodes[0].getElementsByTagName('domain')[0]

        allDiskDeviceXmlElements = domainXmlElements.getElementsByTagName('devices')[0].getElementsByTagName('disk')

        snappableDiskDeviceXmlElements = \
            self._filterSnappableDiskDevices(allDiskDeviceXmlElements)
 
        disk = {}
        for snappableDiskDeviceXmlElement in snappableDiskDeviceXmlElements:
            diskType = snappableDiskDeviceXmlElement.getAttribute('type')
            if diskType not in ['file', 'block']:
                continue
            devname = snappableDiskDeviceXmlElement.getElementsByTagName('target')[0].\
                        getAttribute('dev')
            source = snappableDiskDeviceXmlElement.getElementsByTagName('source')[0].\
                        getAttribute('dev')
            
            imageID = os.path.basename(os.path.dirname(source))
            disk[imageID] = devname

        return disk
Ejemplo n.º 3
0
    def getVmCpuTuneInfo(self, uuid):
        ret = {}
        domain = self._getDomainFromUUID(uuid)

        # Get the user selection for vcpuLimit from the metadata
        metadataCpuLimit = None
        try:
            metadataCpuLimit = domain.metadata(
                libvirt.VIR_DOMAIN_METADATA_ELEMENT, _METADATA_VM_TUNE_URI, 0)
        except libvirt.libvirtError as e:
            if e.get_error_code() != libvirt.VIR_ERR_NO_DOMAIN_METADATA:
                self.logger.error("Failed to retrieve QoS metadata")

        if metadataCpuLimit:
            metadataCpuLimitXML = _domParseStr(metadataCpuLimit)
            nodeList = \
                metadataCpuLimitXML.getElementsByTagName('vcpuLimit')
            ret['vcpu_user_limit'] = nodeList[0].childNodes[0].data
        else:
            ret['vcpu_user_limit'] = 100

        # Retrieve the current cpu tuning params
        ret.update(domain.schedulerParameters())

        if ret['vcpu_quota'] == None:
            ret['vcpu_quota'] = 0

        if ret['vcpu_period'] == None:
            ret['vcpu_period'] = 0

        # Get the number of vcpus
        vcpuCount = domain.vcpusFlags(libvirt.VIR_DOMAIN_VCPU_CURRENT)
        if vcpuCount != -1:
            ret['vcpu_count'] = vcpuCount
        else:
            self.logger.error('Failed to get VM cpu count')
            return None

        return ret
Ejemplo n.º 4
0
    def getVmCpuTuneInfo(self, uuid):
        ret = {}
        domain = self._getDomainFromUUID(uuid)

        # Get the user selection for vcpuLimit from the metadata
        metadataCpuLimit = None
        try:
            metadataCpuLimit = domain.metadata(
                libvirt.VIR_DOMAIN_METADATA_ELEMENT, _METADATA_VM_TUNE_URI, 0)
        except libvirt.libvirtError as e:
            if e.get_error_code() != libvirt.VIR_ERR_NO_DOMAIN_METADATA:
                self.logger.error("Failed to retrieve QoS metadata")

        if metadataCpuLimit:
            metadataCpuLimitXML = _domParseStr(metadataCpuLimit)
            nodeList = \
                metadataCpuLimitXML.getElementsByTagName('vcpuLimit')
            ret['vcpu_user_limit'] = nodeList[0].childNodes[0].data
        else:
            ret['vcpu_user_limit'] = 100

        # Retrieve the current cpu tuning params
        ret.update(domain.schedulerParameters())

        if ret['vcpu_quota'] == None:
            ret['vcpu_quota'] = 0

        if ret['vcpu_period'] == None:
            ret['vcpu_period'] = 0

        # Get the number of vcpus
        vcpuCount = domain.vcpusFlags(libvirt.VIR_DOMAIN_VCPU_CURRENT)
        if vcpuCount != -1:
            ret['vcpu_count'] =  vcpuCount
        else:
            self.logger.error('Failed to get VM cpu count')
            return None

        return ret