def get_DSCSIs(self): DSCSIs = [] uuid = self.get_uuid() for dscsi in XendAPIStore.get_all('DSCSI'): if dscsi.get_VM() == self.VM and dscsi.get_HBA() == uuid: DSCSIs.append(dscsi.get_uuid()) return DSCSIs
def get_PSCSI_HBAs(self): PSCSIs = [] uuid = self.get_uuid() for dscsi in XendAPIStore.get_all('DSCSI'): if dscsi.get_VM() == self.VM and dscsi.get_HBA() == uuid: PSCSIs.append(dscsi.get_PSCSI()) PSCSI_HBAs = [] for pscsi_uuid in PSCSIs: pscsi_HBA_uuid = XendAPIStore.get(pscsi_uuid, 'PSCSI').get_HBA() if not pscsi_HBA_uuid in PSCSI_HBAs: PSCSI_HBAs.append(pscsi_HBA_uuid) return PSCSI_HBAs
def autostart_pools(cls): """ Start managed pools that are marked as autostart pools. Function is called after recreation of managed domains while xend restart. """ cls.pool_lock.acquire() try: for inst in XendAPIStore.get_all(cls.getClass()): if inst.is_managed() and inst.auto_power_on and \ inst.query_pool_id() == None: inst.activate() finally: cls.pool_lock.release()
def get_by_name_label(cls, name_label): """ Query a Pool(ref) by its name. @return: ref of pool @rtype: str """ cls.pool_lock.acquire() try: return [ inst.get_uuid() for inst in XendAPIStore.get_all(cls.getClass()) if inst.name_label == name_label ] finally: cls.pool_lock.release()
def get_all_managed(cls): """ Query all managed pools. @return: uuids of all managed pools @rtype: list of str """ cls.pool_lock.acquire() try: managed_pools = [ inst.get_uuid() for inst in XendAPIStore.get_all(cls.getClass()) if inst.is_managed() ] finally: cls.pool_lock.release() return managed_pools
def create(self, dpci_struct): # Check if VM is valid xendom = XendDomain.instance() if not xendom.is_valid_vm(dpci_struct['VM']): raise InvalidHandleError('VM', dpci_struct['VM']) dom = xendom.get_vm_by_uuid(dpci_struct['VM']) # Check if PPCI is valid xennode = XendNode.instance() ppci_uuid = xennode.get_ppci_by_uuid(dpci_struct['PPCI']) if not ppci_uuid: raise InvalidHandleError('PPCI', dpci_struct['PPCI']) for existing_dpci in XendAPIStore.get_all('DPCI'): if ppci_uuid == existing_dpci.get_PPCI(): raise DirectPCIError("Device is in use") # Assign PPCI to VM try: dpci_ref = XendTask.log_progress(0, 100, dom.create_dpci, dpci_struct) except XendError, e: raise DirectPCIError("Failed to assign device")
def get_by_SR(cls, sr_ref): pbds = XendAPIStore.get_all("PBD") return [pbd.get_uuid() for pbd in pbds if pbd.get_SR() == sr_ref]
def get_by_VM(cls, VM_ref): result = [] for dpci in XendAPIStore.get_all("DPCI"): if dpci.get_VM() == VM_ref: result.append(dpci.get_uuid()) return result
def get_all_records(cls): return dict([(inst.get_uuid(), inst.get_record()) for inst in XendAPIStore.get_all(cls.getClass())])
def get_by_VM(cls, VM_ref): result = [] for dscsi in XendAPIStore.get_all("DSCSI"): if dscsi.get_VM() == VM_ref: result.append(dscsi.get_uuid()) return result
def get_by_name_label(cls, name): return [inst.get_uuid() for inst in XendAPIStore.get_all(cls.getClass()) if inst.get_name_label() == name]
def get_PIFs(self): pifs = XendAPIStore.get_all("PIF") return [pif.get_uuid() for pif in pifs if pif.get_network() == self.get_uuid()]
def get_by_name_label(cls, name): return [ inst.get_uuid() for inst in XendAPIStore.get_all(cls.getClass()) if inst.get_name_label() == name ]
def get_PIFs(self): pifs = XendAPIStore.get_all("PIF") return [ pif.get_uuid() for pif in pifs if pif.get_network() == self.get_uuid() ]
def get_by_VM(cls, VM_ref): result = [] for dscsi_HBA in XendAPIStore.get_all("DSCSI_HBA"): if dscsi_HBA.get_VM() == VM_ref: result.append(dscsi_HBA.get_uuid()) return result