def _create_target_fchba_details(self, remote_descriptors): result = [] if remote_descriptors: for remote_descriptor in remote_descriptors: try: port_id = Sfn(int)(remote_descriptor.target_n_port_id, 16) wwpn = wwn.normalize(remote_descriptor.target_port_wwn) wwnn = wwn.normalize(remote_descriptor.target_node_wwn) port_type = remote_descriptor.port_type port_name = '' node_name = '' if remote_descriptor.symbolic_port_name and remote_descriptor.symbolic_port_name.lower( ) != 'none': port_name = remote_descriptor.symbolic_port_name if remote_descriptor.symbolic_node_name and remote_descriptor.symbolic_node_name.lower( ) != 'none': node_name = remote_descriptor.symbolic_node_name fchba = fc_hba_model.FcHba('', node_name, wwn=wwnn) fcport = fc_hba_model.FcPort(port_id, wwpn, type=port_type, name=port_name) result.append((fchba, fcport, None)) except (TypeError, ValueError): logger.debugException( 'Failed to create target fchba/fcport data object') return tuple(result)
def get_fc_hbas(self, shell): result = [] executor = command.cmdlet.executeCommand(shell) lsdev = lsdev_aix.find(executor) vpd_discoverer = vital_product_data.Discoverer.find_impl(executor) exec_ = Sfn(self.__get_produce_result_executor(shell).process) fcadapters = self.list_fc_adapter_names(lsdev, exec_) for fcs in fcadapters: try: descriptor = vpd_discoverer.get_fc_vpd_by_devicename( fcs, executor) id_ = descriptor.hardware_location_code nodewwn = descriptor.device_specific.get('Z8') fw_version = None if 'Z9' in descriptor.device_specific: fw_version = descriptor.device_specific.get('Z9') _, fw_version = fw_version.split('.') nodewwn = wwn.parse_from_str(nodewwn) portwwn = descriptor.network_address serialnum = descriptor.serial_number model = descriptor.platform_specific.model driverid = descriptor.driverid vendor = Sfn(self.parse_vendor_from_driverid)(driverid) driver_version = self.get_driver_version(driverid, exec_) fchba = fc_hba_model.FcHba(id_, fcs, wwn=nodewwn, vendor=vendor, model=model, serial_number=serialnum, driver_version=driver_version, firmware_version=fw_version) ports = [] try: port_wwn = wwn.parse_from_str(portwwn) fcstat = Sfn(fcstat_aix.find)(executor) port_id = None type_ = None if fcstat: fcstat_descriptor = exec_(fcstat(fcs)) if fcstat_descriptor: port_id = Sfn(int)(fcstat_descriptor.port_fc_id, 16) type_ = fcstat_descriptor.port_type port_speed = fcstat_descriptor.running_port_speed ports.append((fc_hba_model.FcPort(port_id, port_wwn, type_, None, port_speed), ())) except (command.ExecuteException, TypeError, ValueError), ex: logger.debugException( 'Failed to create fcport data object') result.append((fchba, ports)) except (command.ExecuteException, TypeError, ValueError), ex: logger.debugException('Failed to create fchba data object')
def _create_target_fchba_details(self, scsi_paths): result = [] if scsi_paths: for path in scsi_paths: try: identifier = path.get('TargetIdentifier') wwnn, wwpn = self._decompose_adapter_identifier(identifier) fchba = fc_hba_model.FcHba('', '', wwn=wwnn) fcport = fc_hba_model.FcPort(None, wwpn) result.append((fchba, fcport, None)) except (TypeError, ValueError): logger.debugException('Failed to create target fchba/fcport data object') return tuple(result)
def _create_target_fchba_details(self, remote_port_descriptors): result = [] if remote_port_descriptors: for descriptor in remote_port_descriptors: try: wwpn = wwn.parse_from_str(descriptor.remote_port_wwn) wwnn = wwn.parse_from_str(descriptor.node_wwn) fchba = fc_hba_model.FcHba('', '', wwn=wwnn) fcport = fc_hba_model.FcPort(None, wwpn) result.append((fchba, fcport, None)) except (TypeError, ValueError): logger.debugException('Failed to create target fchba/fcport data object') return tuple(result)
def get_fc_hbas(self, shell): executor = self.__get_produce_result_executor(shell) list_file_names_fn = self._get_list_dir_fullnames_fn(shell) get_content_fn = self._get_file_content_fn(shell) result = defaultdict(list) for path in self.list_fc_host_instances(list_file_names_fn): try: name = path.basename driver_version = Sfn(self.get_driver_version)(get_content_fn, name) fw_version = Sfn(self.get_fw_version)(get_content_fn, name) model = Sfn(self.get_model_name)(get_content_fn, name) portwwn = self.get_port_name(get_content_fn, name) nodewwn = self.get_node_name(get_content_fn, name) nodewwn = wwn.parse_from_str(nodewwn) serialnum = Sfn(self.get_serial_num)(get_content_fn, name) vendor = Sfn(self.get_vendor_by_device_path)(path, executor) fchba = fc_hba_model.FcHba(name, unicode(path), wwn=nodewwn, vendor=vendor, model=model, serial_number=serialnum, driver_version=driver_version, firmware_version=fw_version) remote_ports = self.get_remote_port_descriptors( list_file_names_fn, get_content_fn, name) ports = [] try: port_id = self.get_port_id(get_content_fn, name) port_id = Sfn(int)(port_id, 16) port_wwn = wwn.parse_from_str(portwwn) type_ = self.get_port_type(get_content_fn, name) port_speed = _parse_port_speed( self.get_port_speed(get_content_fn, name)) ports.append( (fc_hba_model.FcPort(port_id, port_wwn, type_, None, port_speed), self._create_target_fchba_details(remote_ports))) except (command.ExecuteException, TypeError, ValueError), ex: logger.debugException( 'Failed to create fcport data object') result[fchba].extend(ports) except (command.ExecuteException, TypeError, ValueError), ex: logger.debugException('Failed to create fchba data object')
def get_fc_hbas(self, shell): result = [] descriptors = fc_hba_descriptors_by_hpux_fcmsutil.get_fc_hba_descriptors( shell) find_name_by_id_in_hex = Sfn(vendors.find_name_by_id_in_hex) for ioscan_dscriptor, fc_descriptor, fc_vpd_descriptor in descriptors: try: hba_id = ioscan_dscriptor.device_filename name = ioscan_dscriptor.device_filename node_wwn = fc_descriptor.n_port_node_world_wide_name node_wwn = wwn.normalize(node_wwn) vendor = find_name_by_id_in_hex(fc_descriptor.vendor_id) model = fc_vpd_descriptor.part_number serial_number = fc_vpd_descriptor.part_serial_number driver_version = fc_descriptor.driver_version firmware_version = fc_vpd_descriptor.rom_firmware_version port_speed = fc_descriptor.link_speed fchba = fc_hba_model.FcHba(hba_id, name, wwn=node_wwn, vendor=vendor, model=model, serial_number=serial_number, driver_version=driver_version, firmware_version=firmware_version) port_id = fc_descriptor.local_n_port_id port_wwn = wwn.normalize( fc_descriptor.n_port_port_world_wide_name) type_ = fc_descriptor.topology ports = [] port_id = Sfn(int)(port_id, 16) speed = _parse_port_speed(port_speed) remote_descriptors = Sfn(fc_hba_descriptors_by_hpux_fcmsutil. get_remote_fc_hba_descriptors)( shell, ioscan_dscriptor.device_filename) target_fchbas = self._create_target_fchba_details( remote_descriptors) ports.append((fc_hba_model.FcPort(port_id, port_wwn, type_, None, speed), target_fchbas)) result.append((fchba, tuple(ports))) except (TypeError, ValueError), ex: logger.debugException('Failed to create fchba data object')
def get_fc_hbas(self, shell): executor = command.cmdlet.executeCommand(shell) fcinfo_impl = find_fcinfo_impl(executor)() exec_ = command.get_exec_fn(executor) safe_exec_ = command.get_safe_exec_fn(executor) descriptors = exec_(fcinfo_impl.hba_port()) result = [] for fchba_descriptor in descriptors: try: name = fchba_descriptor.name nodewwn = wwn.parse_from_str(fchba_descriptor.node_wwn) portwwn = fchba_descriptor.port_wwn model = fchba_descriptor.model vendor = fchba_descriptor.vendor type_ = fchba_descriptor.type serialnum = fchba_descriptor.serial_number driver_version = fchba_descriptor.driver_version fw_version = fchba_descriptor.firmware_version port_speed = fchba_descriptor.port_speed fchba = fc_hba_model.FcHba(name, name, wwn=nodewwn, vendor=vendor, model=model, serial_number=serialnum, driver_version=driver_version, firmware_version=fw_version) ports = [] try: port_id = None port_wwn = wwn.parse_from_str(portwwn) speed = _parse_port_speed(port_speed) remote_port_descriptors = safe_exec_(fcinfo_impl.remote_port.p(portwwn)) target_fchbas = self._create_target_fchba_details(remote_port_descriptors) ports.append((fc_hba_model.FcPort(port_id, port_wwn, type_, None, speed), target_fchbas)) except (command.ExecuteException, TypeError, ValueError), ex: logger.debugException('Failed to create fcport data object') result.append((fchba, ports)) except (command.ExecuteException, TypeError, ValueError), ex: logger.debugException('Failed to create fchba data object')
def get_fc_hbas(self, shell): result = [] executor = self.get_executor(shell) pairs = get_fc_hba_descriptors(executor) parse_wwn_ = Sfn(parse_wwn) for adapter_descriptor, port_descriptors in pairs: hba_id = adapter_descriptor.UniqueAdapterId name = adapter_descriptor.InstanceName node_wwn = adapter_descriptor.NodeWWN node_wwn = node_wwn and parse_wwn_(node_wwn) vendor = adapter_descriptor.Manufacturer model = adapter_descriptor.Model serial_number = adapter_descriptor.SerialNumber driver_version = adapter_descriptor.DriverVersion firmware_version = adapter_descriptor.FirmwareVersion fchba = fc_hba_model.FcHba(hba_id, name, wwn=node_wwn, vendor=vendor, model=model, serial_number=serial_number, driver_version=driver_version, firmware_version=firmware_version) ports = [] for port_descriptor in port_descriptors: try: port_id = port_descriptor.UniquePortId portname = port_descriptor.InstanceName port_wwn = parse_wwn_(port_descriptor.Attributes.PortWWN) type_ = Sfn(parse_port_type)( port_descriptor.Attributes.PortType) port_speed = float(port_descriptor.Attributes.PortSpeed) ports.append((fc_hba_model.FcPort(port_id, port_wwn, type_, portname, speed=port_speed), ())) except (TypeError, ValueError), ex: logger.debugException('Failed to create fchba data object') result.append((fchba, tuple(ports)))
def _create_target_fchba_details(self, remote_descriptors): result = [] if remote_descriptors: for nodewwn, port_descriptors in remote_descriptors.items(): for port_descriptor in port_descriptors: portid, portwwn = port_descriptor try: port_id = Sfn(int)(portid, 16) wwpn = wwn.normalize(portwwn) wwnn = wwn.normalize(nodewwn) port_name = '' node_name = '' fchba = fc_hba_model.FcHba('', node_name, wwn=wwnn) fcport = fc_hba_model.FcPort(port_id, wwpn, type=None, name=port_name) result.append((fchba, fcport, None)) except (TypeError, ValueError): logger.debugException( 'Failed to create target fchba/fcport data object') return tuple(result)
def get_fc_hbas(self, shell): result = defaultdict(list) executor = command.cmdlet.executeCommand(shell) esxcli = find_esxcli_impl(executor)() esxcli = esxcli.formatter('csv') esxcli_exec = command.get_exec_fn(esxcli, executor) storage = EsxcliStorageNamespace(esxcli) software = EsxcliSoftwareNamespace(esxcli) scsi_path_by_adapter_identifier = fptools.groupby(methodcaller('get', 'AdapterIdentifier'), esxcli_exec(storage.core.path.list())) adapters = esxcli_exec(storage.core.adapter.list()) grouped_adapters = dict((adapter.get('HBAName'), adapter) for adapter in adapters) grouped = defaultdict(list) for descriptor in esxcli_exec(storage.san.fc.list()): grouped[(descriptor.get('Adapter'), descriptor.get('NodeName'))].append(descriptor) get_vendor = Sfn(self.get_vendor) get_fchba_descriptor = Sfn(self._get_fchba_descriptor) for key, descriptors in grouped.iteritems(): try: vmhba, nodewwn = key nodewwn = wwn.parse_from_str(nodewwn) name = vmhba id_ = vmhba adapter_descriptor = grouped_adapters.get(vmhba) driverversion = None vendor = get_vendor(vmhba, executor) model = None fwversion = None serialnum = None if adapter_descriptor: id_ = adapter_descriptor.get('UID') driver = adapter_descriptor.get('Driver') vib_descriptor = esxcli_exec(software.vib.get(vibname=driver)) driverversion = vib_descriptor.get('Version') fchabdescriptor = get_fchba_descriptor(driver, vmhba, executor) if fchabdescriptor: model = fchabdescriptor.model fwversion = fchabdescriptor.firmwareversion serialnum = fchabdescriptor.serialnumber driverversion = fchabdescriptor.driverversion fchba = fc_hba_model.FcHba(id_, name, wwn=nodewwn, vendor=vendor, model=model, serial_number=serialnum, driver_version=driverversion, firmware_version=fwversion) ports = [] for fcdescriptor in descriptors: try: portwwn = fcdescriptor.get('PortName') porttype = fcdescriptor.get('PortType') portwwn = wwn.parse_from_str(portwwn) portid = fcdescriptor.get('PortID') port_speed = _parse_port_speed(fcdescriptor.get('Speed')) portid = Sfn(int)(portid, 16) adapter_identifier = self._compose_adapter_identifier(nodewwn, portwwn) scsi_paths = scsi_path_by_adapter_identifier.get(adapter_identifier) target_fcdescriptors = self._create_target_fchba_details(scsi_paths) ports.append((fc_hba_model.FcPort(portid, portwwn, porttype, None, port_speed), target_fcdescriptors)) except (command.ExecuteException, TypeError, ValueError), ex: logger.debugException('Failed to create fcport data object') result[fchba].extend(ports) except (command.ExecuteException, TypeError, ValueError), ex: logger.debugException('Failed to create fchba data object')