示例#1
0
 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_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
示例#3
0
 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 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
示例#5
0
 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()
示例#6
0
 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()
示例#7
0
 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
示例#8
0
 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()
示例#9
0
 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()
示例#10
0
 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
示例#11
0
    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")
示例#12
0
    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")
示例#13
0
 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]
示例#14
0
 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]
示例#15
0
 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
示例#16
0
 def get_all_records(cls):
     return dict([(inst.get_uuid(), inst.get_record())
                  for inst in XendAPIStore.get_all(cls.getClass())])
示例#17
0
 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]
示例#19
0
 def get_all_records(cls):
     return dict([(inst.get_uuid(), inst.get_record())
                  for inst in XendAPIStore.get_all(cls.getClass())])
 def get_PIFs(self):
     pifs = XendAPIStore.get_all("PIF")
     return [pif.get_uuid() for pif in pifs
             if pif.get_network() == self.get_uuid()]
示例#21
0
 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
     ]
示例#22
0
 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
示例#23
0
 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