def _init_PSCSIs(self): # Initialise PSCSIs saved_pscsis = self.state_store.load_state('pscsi') saved_pscsi_table = {} if saved_pscsis: for pscsi_uuid, pscsi_record in saved_pscsis.items(): try: saved_pscsi_table[pscsi_record['scsi_id']] = pscsi_uuid except KeyError: pass for pscsi_record in vscsi_util.get_all_scsi_devices(): if pscsi_record['scsi_id']: # If saved uuid exists, use it. Otherwise create one. pscsi_uuid = saved_pscsi_table.get(pscsi_record['scsi_id'], uuid.createString()) XendPSCSI(pscsi_uuid, pscsi_record)
def _init_PSCSIs(self): # Initialise PSCSIs and PSCSI_HBAs saved_pscsis = self.state_store.load_state('pscsi') saved_pscsi_table = {} if saved_pscsis: for pscsi_uuid, pscsi_record in saved_pscsis.items(): try: saved_pscsi_table[pscsi_record['scsi_id']] = pscsi_uuid except KeyError: pass saved_pscsi_HBAs = self.state_store.load_state('pscsi_HBA') saved_pscsi_HBA_table = {} if saved_pscsi_HBAs: for pscsi_HBA_uuid, pscsi_HBA_record in saved_pscsi_HBAs.items(): try: physical_host = int(pscsi_HBA_record['physical_host']) saved_pscsi_HBA_table[physical_host] = pscsi_HBA_uuid except (KeyError, ValueError): pass pscsi_table = {} pscsi_HBA_table = {} pscsi_records = [] for pscsi_mask in xendoptions().get_pscsi_device_mask(): pscsi_records += vscsi_util.get_all_scsi_devices(pscsi_mask) log.debug("pscsi record count: %s" % len(pscsi_records)) for pscsi_record in pscsi_records: scsi_id = pscsi_record['scsi_id'] if scsi_id: saved_HBA_uuid = None pscsi_uuid = saved_pscsi_table.get(scsi_id, None) if pscsi_uuid is None: pscsi_uuid = uuid.createString() saved_pscsi_table[scsi_id] = pscsi_uuid else: try: saved_HBA_uuid = saved_pscsis[pscsi_uuid].get('HBA', None) except KeyError: log.warn("Multi-path SCSI devices are not supported for XenAPI") return physical_host = int(pscsi_record['physical_HCTL'].split(':')[0]) if pscsi_HBA_table.has_key(physical_host): pscsi_HBA_uuid = pscsi_HBA_table[physical_host] elif saved_pscsi_HBA_table.has_key(physical_host): pscsi_HBA_uuid = saved_pscsi_HBA_table[physical_host] pscsi_HBA_table[physical_host] = pscsi_HBA_uuid else: pscsi_HBA_uuid = uuid.createString() pscsi_HBA_table[physical_host] = pscsi_HBA_uuid if saved_HBA_uuid is not None and \ saved_HBA_uuid != pscsi_HBA_uuid: log.debug('The PSCSI(%s) host number was changed', scsi_id) pscsi_record['HBA'] = pscsi_HBA_uuid pscsi_table[pscsi_uuid] = pscsi_record for pscsi_uuid, pscsi_record in pscsi_table.items(): XendPSCSI(pscsi_uuid, pscsi_record) for physical_host, pscsi_HBA_uuid in pscsi_HBA_table.items(): XendPSCSI_HBA(pscsi_HBA_uuid, {'physical_host': physical_host})
def _init_PSCSIs(self): # Initialise PSCSIs and PSCSI_HBAs saved_pscsis = self.state_store.load_state('pscsi') saved_pscsi_table = {} if saved_pscsis: for pscsi_uuid, pscsi_record in saved_pscsis.items(): try: saved_pscsi_table[pscsi_record['scsi_id']] = pscsi_uuid except KeyError: pass saved_pscsi_HBAs = self.state_store.load_state('pscsi_HBA') saved_pscsi_HBA_table = {} if saved_pscsi_HBAs: for pscsi_HBA_uuid, pscsi_HBA_record in saved_pscsi_HBAs.items(): try: physical_host = int(pscsi_HBA_record['physical_host']) saved_pscsi_HBA_table[physical_host] = pscsi_HBA_uuid except (KeyError, ValueError): pass pscsi_table = {} pscsi_HBA_table = {} pscsi_records = [] for pscsi_mask in xendoptions().get_pscsi_device_mask(): pscsi_records += vscsi_util.get_all_scsi_devices(pscsi_mask) log.debug("pscsi record count: %s" % len(pscsi_records)) for pscsi_record in pscsi_records: scsi_id = pscsi_record['scsi_id'] if scsi_id: saved_HBA_uuid = None pscsi_uuid = saved_pscsi_table.get(scsi_id, None) if pscsi_uuid is None: pscsi_uuid = uuid.createString() saved_pscsi_table[scsi_id] = pscsi_uuid else: try: saved_HBA_uuid = saved_pscsis[pscsi_uuid].get( 'HBA', None) except KeyError: log.warn( "Multi-path SCSI devices are not supported for XenAPI" ) return physical_host = int( pscsi_record['physical_HCTL'].split(':')[0]) if pscsi_HBA_table.has_key(physical_host): pscsi_HBA_uuid = pscsi_HBA_table[physical_host] elif saved_pscsi_HBA_table.has_key(physical_host): pscsi_HBA_uuid = saved_pscsi_HBA_table[physical_host] pscsi_HBA_table[physical_host] = pscsi_HBA_uuid else: pscsi_HBA_uuid = uuid.createString() pscsi_HBA_table[physical_host] = pscsi_HBA_uuid if saved_HBA_uuid is not None and \ saved_HBA_uuid != pscsi_HBA_uuid: log.debug('The PSCSI(%s) host number was changed', scsi_id) pscsi_record['HBA'] = pscsi_HBA_uuid pscsi_table[pscsi_uuid] = pscsi_record for pscsi_uuid, pscsi_record in pscsi_table.items(): XendPSCSI(pscsi_uuid, pscsi_record) for physical_host, pscsi_HBA_uuid in pscsi_HBA_table.items(): XendPSCSI_HBA(pscsi_HBA_uuid, {'physical_host': physical_host})