コード例 #1
0
def createFiberChannelHbaObjects(fiberChannelHbas, globalZoneOsh, resultsVector):
    for fchba in fiberChannelHbas:
        try:
            hbatype_ = None
            ports = []
            nodewwn = str(wwn.parse_from_str(fchba.nodeWwn, 16))
            fchbapdo = fc_hba_topology.Pdo(fchba.name,
                                           nodewwn,
                                           fchba.model,
                                           fchba.vendor,
                                           hbatype_,
                                           fchba.serialNumber,
                                           fchba.driverVersion,
                                           None)
            portwwn = str(wwn.parse_from_str(fchba.portWwn, 16))
            ports.append(fc_hba_topology.PortPdo(portwwn,
                                                  name=None,
                                                  portindex=None,
                                                  type=fchba.type,
                                                  trunkedstate=None,
                                                  symbolicname=None,
                                                  status=None,
                                                  state=None,
                                                  speed=None,
                                                  scsiport=None,
                                                  id=None,
                                                  maxspeed=None,
                                                  fibertype=fchba.type,
                                                  domainid=None,
                                                  connectedtowwn=None))

            _, _, oshs = fc_hba_topology.Reporter().report((fchbapdo, ports), globalZoneOsh)
            resultsVector.addAll(oshs)
        except ValueError, e:
            logger.debugException('Failed to create fchba/fcport pdo object')
コード例 #2
0
    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')
コード例 #3
0
    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')
コード例 #4
0
 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)
コード例 #5
0
    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')
コード例 #6
0
ファイル: smis.py プロジェクト: deezeesms/dd-git
    def build(self, fcPort):
        '''
        @param fcPort: fcPort DO
        @return: fcport OSH
        '''
        if not fcPort:
            raise ValueError("fcPort object is None")
        fcPortOsh = ObjectStateHolder("fcport")
        if fcPort.id is not None:
            fcPortOsh.setIntegerAttribute("fcport_portid", fcPort.id)
        if fcPort.index is not None:
            fcPortOsh.setIntegerAttribute("port_index", fcPort.index)

        wwnFormated = ''
        try:
            wwnFormated = str(wwn.parse_from_str(fcPort.wwn))
        except:
            logger.debug('error about fcPort.wwn: %s' % fcPort.wwn)

        fcPort.wwn and fcPortOsh.setStringAttribute("fcport_wwn", wwnFormated)
        fcPort.name and fcPortOsh.setStringAttribute("fcport_symbolicname", fcPort.name)
        fcPort.status and fcPortOsh.setStringAttribute("fcport_status", fcPort.status)
        fcPort.state and fcPortOsh.setStringAttribute("fcport_state", fcPort.state)
        fcPort.portType and fcPortOsh.setStringAttribute("fcport_type", fcPort.portType)
        if fcPort.maxSpeedGbps is not None:
            fcPortOsh.setAttribute("fcport_maxspeed", fcPort.maxSpeedGbps)
        if fcPort.speedGbps is not None:
            fcPortOsh.setAttribute("fcport_speed", fcPort.speedGbps)
        return fcPortOsh
コード例 #7
0
ファイル: ECC_Discovery.py プロジェクト: deezeesms/dd-git
def buildFCConnectLinks(localOracleClient, portOshDictWWN):
    try:
        resultVector = ObjectStateHolderVector()

        # # FC CONNECT links between STORAGE ARRAY and FC SWITCH
        fccQuery = 'SELECT port.port_wwn, port.conn_port_wwn FROM stssys.sts_array_port_connection port WHERE port.port_wwn IS NOT NULL AND port.conn_port_wwn IS NOT NULL'
        fccResultSet = doQuery(localOracleClient, fccQuery)

        # # Return if query returns no results
        if fccResultSet == None:
            logger.debug('[buildFCConnectLinks] No FC CONNECT links found between STORAGE ARRAY and FC SWITCH')
        else:
            # # We have query results!
            while fccResultSet.next():
                portwwn = wwn.parse_from_str(fccResultSet.getString(1), 16)
                conn_portwwn = wwn.parse_from_str(fccResultSet.getString(2), 16)
                if portOshDictWWN.has_key(portwwn) and portOshDictWWN.has_key(conn_portwwn):
                    debugPrint(3, '[buildFCConnectLinks:ARRAY] Got FC CONNECT link between <%s> and <%s>' % (portwwn, conn_portwwn))
                    resultVector.add(modeling.createLinkOSH('fcconnect', portOshDictWWN[portwwn], portOshDictWWN[conn_portwwn]))
            fccResultSet.close()

        # # FC CONNECT links between FC SWITCH and HOST
        fccQuery = 'SELECT port.port_wwn, port.conn_port_wwn FROM stssys.sts_switch_port port WHERE port.port_wwn IS NOT NULL AND port.conn_port_wwn IS NOT NULL'
        fccResultSet = doQuery(localOracleClient, fccQuery)

        # # Return if query returns no results
        if fccResultSet == None:
            logger.debug('[buildFCConnectLinks] No FC CONNECT links found between FC SWITCH and HOST')
        else:
            # # We have query results!
            while fccResultSet.next():
                portwwn = wwn.parse_from_str(fccResultSet.getString(1), 16)
                conn_portwwn = wwn.parse_from_str(fccResultSet.getString(2), 16)
                if portOshDictWWN.has_key(portwwn) and portOshDictWWN.has_key(conn_portwwn):
                    debugPrint(3, '[buildFCConnectLinks:HOST] Got FC CONNECT link between <%s> and <%s>' % (conn_portwwn, portwwn))
                    resultVector.add(modeling.createLinkOSH('fcconnect', portOshDictWWN[conn_portwwn], portOshDictWWN[portwwn]))
            fccResultSet.close()

        return resultVector
    except:
        excInfo = logger.prepareJythonStackTrace('')
        logger.warn('[' + SCRIPT_NAME + ':buildFCConnectLinks] Exception: <%s>' % excInfo)
        pass
コード例 #8
0
    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')
コード例 #9
0
    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')
コード例 #10
0
ファイル: smis.py プロジェクト: deezeesms/dd-git
 def build(self, fcHba):
     '''
     @param fcHba: instance of FcHba DO
     @raise ValueError: fcHba is not set
     @return: fchba Osh
     '''
     if not fcHba:
         raise ValueError("fcHba is not specified")
     fcHbaOsh = ObjectStateHolder("fchba")
     fcHbaOsh.setStringAttribute('name', fcHba.name)
     wwnFormated = str(wwn.parse_from_str(fcHba.wwn))
     fcHbaOsh.setStringAttribute('fchba_wwn', wwnFormated)
     fcHbaOsh.setStringAttribute('fchba_targetportwwn', wwnFormated)
     return fcHbaOsh
コード例 #11
0
ファイル: ECC_Discovery.py プロジェクト: deezeesms/dd-git
def _query_switch_ports(client, switch_id):
    '''Query Fiber Channel Port
    Each FC Switch has one (zero?) or more ports

    @types: Client, str -> list[Port]
    '''

    columns = (('port_id', types.IntType),
               ('port_number', types.StringType),
               ('port_type', types.StringType),
               ('adport_alias', types.StringType),
               ('port_wwn', types.StringType),
               ('port_status', types.StringType),
               ('conn_port_wwn', types.StringType))

    table = 'stssys.sts_switch_port'
    ports = _select(columns, table, where='st_id = %s' % switch_id)(client)
    ports = [Port(p.port_id, p.port_number, p.port_type,
                              p.adport_alias, p.port_status,
                              wwn.parse_from_str(p.port_wwn, 16) if p.port_wwn else None,
                              wwn.parse_from_str(p.conn_port_wwn, 16) if p.conn_port_wwn else None)
             for p in ports]
    logger.info("Found %s ports" % len(ports))
    return ports
コード例 #12
0
ファイル: ECC_Discovery.py プロジェクト: deezeesms/dd-git
def _query_host_ports(client, host_id):
    '@types: Client, str -> list[Port]'
    columns = (('port_id', types.IntType),
               ('port_number', types.StringType),
               ('adport_alias', types.StringType),
               ('port_wwn', types.StringType))

    table = 'stssys.sts_host_hba'
    ports = _select(columns, table, where='host_id = %s' % host_id)(client)
    type_, status, conn_port_wwn = None, None, None
    ports = [Port(p.port_id, p.port_number, type_,
                  p.adport_alias, status,
                  wwn.parse_from_str(p.port_wwn, 16) if p.port_wwn else None,
                  conn_port_wwn)
             for p in ports]
    logger.info("Found %s ports" % len(ports))
    return ports
コード例 #13
0
ファイル: ECC_Discovery.py プロジェクト: deezeesms/dd-git
def _query_storage_array_ports(client, id_):
    '''Query Storage Array Ports
    @types: Client, str -> list[Port]
    '''
    columns = (('port_id', types.IntType),
               ('port_number', types.StringType),
               ('port_type', types.StringType),
               ('adport_alias', types.StringType),
               ('port_wwn', types.StringType),
               ('port_status', types.StringType))

    table = 'stssys.sts_array_port'
    ports = _select(columns, table, where='st_id = %s' % id_)(client)
    ports = [Port(p.port_id, p.port_number, p.port_type,
                                  p.adport_alias, p.port_status,
                              wwn.parse_from_str(p.port_wwn, 16) if p.port_wwn else None, None)
             for p in ports]
    logger.info("Found %s ports" % len(ports))
    return ports
コード例 #14
0
ファイル: ECC_Discovery.py プロジェクト: deezeesms/dd-git
def _query_host_hbas(client, host_id):
    '@types: Client, str -> list[HostHba]'
    columns = (('ad_id', types.StringType),
               ('ad_name', types.StringType),
               ('fibread_nodewwn', types.StringType),
               ('ad_vendor', types.StringType),
               ('ad_revision', types.StringType),
               ('ad_model', types.StringType),
               ('port_id', types.StringType),
               ('ad_driver_rev', types.StringType))
    table = 'stssys.sts_host_hba'
    hbas = []
    for h in _select(columns, table, where='host_id = %s' % host_id)(client):
        hba = Hba(h.port_id, h.ad_id, h.ad_name)
        fibread_nodewwn = None
        if h.fibread_nodewwn:
            fibread_nodewwn = wwn.parse_from_str(h.fibread_nodewwn, 16)
        host_hba = HostHba(h.port_id, hba, h.ad_vendor, h.ad_revision,
                           h.ad_model, h.ad_driver_rev, fibread_nodewwn)
        hbas.append(host_hba)
    logger.info("Found %s Host HBAs" % len(hbas))
    return hbas
コード例 #15
0
 def _decompose_adapter_identifier(self, identifier):
     m = re.match('fc\.(.+):(.+)', identifier)
     if m:
         return [wwn.parse_from_str(wwn_, 16) for wwn_ in m.groups()]
コード例 #16
0
    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')
コード例 #17
0
ファイル: smis.py プロジェクト: deezeesms/dd-git
class TopologyBuilder:
    '''
    General SMI-S topolofy builder
    '''
    def buildHost(self, node):
        '''
        @param node: instance of Host DO
        @return: node Osh
        '''
        if node.ip is not None:
            return modeling.createHostOSH(ipAddress = node.ip, machineName=node.name)
        else:
            hostOsh = modeling.ObjectStateHolder('node')
            if node.name is not None:
                hostOsh.setStringAttribute('name', node.name)
            if node.serial is not None:
                hostOsh.setStringAttribute('serial_number', node.serial)
            if node.model is not None:
                hostOsh.setStringAttribute('discovered_model', node.model)
            if node.description is not None:
                hostOsh.setStringAttribute('os_description', node.description)
            if node.vendor is not None:
                hostOsh.setStringAttribute('vendor', node.vendor)
            return hostOsh

    def buildStorageArray(self, node):
        '''
        @param node: instance of Host DO
        @return: Storage Array Osh
        '''
        if node.ip is not None:
            hostOsh = modeling.createHostOSH(hostClassName='storagearray', ipAddress = node.ip)
        else:
            hostOsh = modeling.ObjectStateHolder('storagearray')
        if node.name is not None:
            hostOsh.setStringAttribute('name', node.name)
        if node.serial is not None:
            hostOsh.setStringAttribute('serial_number', node.serial)
        if node.version is not None:
            hostOsh.setStringAttribute('hardware_version', node.version)
        if node.model is not None:
            hostOsh.setStringAttribute('discovered_model', node.model)
        if node.description is not None:
            hostOsh.setStringAttribute('os_description', node.description)
        if node.vendor is not None:
            hostOsh.setStringAttribute('vendor', node.vendor)
        if node.status is not None:
            hostOsh.setStringAttribute('storagearray_status', node.status)
        return hostOsh

    def reportFcSwitchTopolopy(self, fabrics, switches, hosts, fcPorts, switch2FabricLinks={}, portlinks={}):
        resultVector = ObjectStateHolderVector()
        fabricOshIdMap = {}
        switchOshIdMap = {}
        hostOshIdMap = {}
        portOshIdMap = {}
        for fabric in fabrics:
            fabricBuilder = StorageFabricBuilder()
            fabricReporter = StorageFabricReporter(fabricBuilder)
            fabricOsh = fabricReporter.report(fabric)
            fabricOshIdMap[fabric.name] = fabricOsh
            resultVector.add(fabricOsh)

        builder = FcSwitchBuilder()
        reporter = FcSwitchReporter(builder)
        for switch in switches:
            fabricId = switch2FabricLinks.get(switch.wwn)
            fabricOsh = fabricId and fabricOshIdMap.get(fabricId)
            (switchOsh,vector)  = reporter.report(switch, fabricOsh)
            switchOshIdMap[switch.wwn] = switchOsh
            resultVector.addAll(vector)

        for host in hosts:
            hostOsh = ObjectStateHolder('node')
            if host.name:
                hostOsh.setStringAttribute('name', host.name)
                hostOshIdMap[host.name] = hostOsh
                resultVector.add(hostOsh)

        portBuilder = FibreChanelPortBuilder()
        portReporter = FibreChannelPortReporter(portBuilder)
        for fc in fcPorts:
            if fc.parentReference:
                containerOsh = fabricOshIdMap.get(fc.parentReference) or \
                                switchOshIdMap.get(fc.parentReference) or \
                                hostOshIdMap.get(fc.parentReference)
                (portOsh, vector) = portReporter.report(fc, containerOsh)
                resultVector.addAll(vector)
                portOshIdMap[fc.wwn] = portOsh

        for link in portlinks.keys():
            end1Osh = portOshIdMap.get(link)
            end2Osh = portOshIdMap.get(portlinks.get(link))
            if end1Osh and end2Osh:
                linkOsh = modeling.createLinkOSH('fcconnect', end1Osh, end2Osh)
                resultVector.add(linkOsh)

        return resultVector

    def reportTopology(self, storageSystems, ports, pools, lvs, endPoints, fcHbas = None, storageProcessors = None,
                       pvs = None, endpointLinks = None, lunMappings = None, pv2poolLinks = None):
        '''
        @param ports: collection of FcPort DO instances
        @param pools: collection of StoragePool DO instances
        @param lvs: collection of LogicaVolumes DO instances
        @param fcHbas: collection of FcHba DO instances
        @return: OSHV
        '''
        resultVector = ObjectStateHolderVector()
        if not storageSystems:
            raise ValueError('No storage system discovered.')
        idToHostOshMap = {}
        storageSystemIdToOshMap = {}
        for storageSystem in storageSystems:
            storageSystemOsh = self.buildStorageArray(storageSystem)
            resultVector.add(storageSystemOsh)
            storageSystemIdToOshMap[storageSystem.id] = storageSystemOsh
            resultVector.add(storageSystemOsh)
            idToHostOshMap[storageSystem.id] = storageSystemOsh

        storageSystem = storageSystems[0]
        storageSystemOsh = storageSystemIdToOshMap.get(storageSystem.id)

        storageProcessorIdToOshMap = {}
        if storageProcessors:
            for storageProcessor in storageProcessors:
                processorBuilder = StorageProcessorBuilder()
                processorReporter = StorageProcessorReporter(processorBuilder)
                if storageProcessor.parent:
                    parentOsh = storageSystemIdToOshMap.get(storageProcessor.parent)
                else:
                    parentOsh = storageSystemOsh
                (processorOsh, vector) = processorReporter.report(storageProcessor, parentOsh)
                storageProcessorIdToOshMap[storageProcessor.id] = processorOsh
                resultVector.addAll(vector)

        portRemotePeerToPortOshMap = {}
        portBuilder = FibreChanelPortBuilder()
        portReporter = FibreChannelPortReporter(portBuilder)

        endpointIdToHostOshMap = {}
        reporter = RemoteEndPointReporter()
        for endpoint in endPoints:
            try:
                hostOsh = storageSystemIdToOshMap.get(endpoint.name) or storageProcessorIdToOshMap.get(endpoint.name)
                (remotePortOsh, remoteNodeOsh, vector) = reporter.report(endpoint, hostOsh)
                resultVector.addAll(vector)
                portRemotePeerToPortOshMap[endpoint.name] = remotePortOsh
                endpointIdToHostOshMap[endpoint.objId] = remoteNodeOsh
            except ValueError, e:
                logger.debugException('Failed to report fc port')

        for port in ports:
            containerOsh = idToHostOshMap.get(port.parentReference, None)
            if not containerOsh:
                containerOsh = storageProcessorIdToOshMap.get(port.parentReference, None)
            if containerOsh:
                (portOsh, vector) = portReporter.report(port, containerOsh)
                resultVector.addAll(vector)
                remotePortOsh = portRemotePeerToPortOshMap.get(port.remotePeer)
                if remotePortOsh and portOsh:
                    linkOsh = modeling.createLinkOSH('fcconnect', portOsh, remotePortOsh)
                    resultVector.add(linkOsh)
                if port.storageProcessorId:
                    processorOsh = storageProcessorIdToOshMap.get(port.storageProcessorId)
                    if processorOsh:
                        linkOsh = modeling.createLinkOSH('containment' , processorOsh, portOsh)
                        resultVector.add(linkOsh)

        fcHbaBuilder = FcHbaBuilder()
        fcHbaReporter = FcHbaReporter(fcHbaBuilder)
        if fcHbas:
            for fcHba in fcHbas:
                hostOsh = idToHostOshMap.get(fcHba.parentReference)
                if hostOsh:
                    (fcHbaOsh, vector) = fcHbaReporter.report(fcHba, hostOsh)
                    resultVector.addAll(vector)

        pvIdMap = {}
        pvBuilder = PhysicalVolumeBuilder()
        pvReporter = PhysicalVolumeReporter(pvBuilder)
        for pv in pvs:
            hostOsh = idToHostOshMap.get(pv.parentReference)
            if hostOsh:
                (pvOsh, vector) = pvReporter.report(pv, hostOsh)
                resultVector.addAll(vector)
                pv.Osh = pvOsh
                pvIdMap[pv.parentReference+pv.systemObjId] = pv

        poolBuilder = StoragePoolBuilder()
        poolReporter = StoragePoolReporter(poolBuilder)
        poolIdToPoolOsh = {}
        for pool in pools:
            if pool.parentReference:
                parentOsh = storageSystemIdToOshMap.get(pool.parentReference)
            else:
                parentOsh = storageSystemOsh
            (poolOsh, vector) = poolReporter.report(pool, parentOsh)
            if pool.cimId:
                poolIdToPoolOsh[pool.cimId] = poolOsh
            resultVector.addAll(vector)

        for poolId in pv2poolLinks.keys():
            poolOsh = poolIdToPoolOsh.get(poolId)
            if poolOsh:
                pvs = pv2poolLinks[poolId]
                for pvId in pvs:
                    pv = pvIdMap.get(pvId)
                    if pv.Osh:
                        linkOsh = modeling.createLinkOSH('usage', poolOsh, pv.Osh)
                        resultVector.add(linkOsh)

        lvmBuilder = LogicalVolumeBuilder()
        lvmReporter = LogicalVolumeReporter(lvmBuilder)
        lvmIdToLvmOshMap = {}
        lvSystemNameAndIdToLvmOshMap = {}
        for lv in lvs:
            hostOsh = idToHostOshMap.get(lv.parentReference)
            if hostOsh:
                (lvmOsh, vector) = lvmReporter.report(lv, hostOsh)
                lvmIdToLvmOshMap[lv.systemObjId] = lvmOsh
                lvSystemNameAndIdToLvmOshMap[lv.parentReference+lv.systemObjId] = lvmOsh
                resultVector.addAll(vector)
                if lv.poolId:
                    poolOsh = poolIdToPoolOsh.get(lv.poolId)
                    if poolOsh:
                        linkOsh = modeling.createLinkOSH('membership', poolOsh, lvmOsh)
                        resultVector.add(linkOsh)

        #building member links
        for pool in pools:
            (poolOsh, vector) = poolReporter.report(pool, storageSystemOsh)
            if pool.lvmIds:
                for lvmId in pool.lvmIds:
                    lvOsh = lvmIdToLvmOshMap.get(lvmId)
                    if lvOsh:
                        linkOsh = modeling.createLinkOSH('membership', poolOsh, lvOsh)
                        resultVector.add(linkOsh)
            if pool.childPoolIds:
                for poolId in pool.childPoolIds:
                    plOsh = poolIdToPoolOsh.get(poolId)
                    if plOsh:
                        linkOsh = modeling.createLinkOSH('membership', poolOsh, plOsh)
                        resultVector.add(linkOsh)


        if endpointLinks:
            lvmIdToLvmMap = {}
            for lv in lvs:
                lvmIdToLvmMap[lv.systemObjId] = lv
            for endpointLink in endpointLinks:
                localVolumeOsh = lvmIdToLvmOshMap.get(endpointLink.volume_id)
                remoteNodeOsh = endpointIdToHostOshMap.get(endpointLink.host_id)
                logVolume = lvmIdToLvmMap.get(endpointLink.volume_id)
                if localVolumeOsh and remoteNodeOsh and logVolume:
                    (remoteLvmOsh, vector) = lvmReporter.report(logVolume, remoteNodeOsh)
                    resultVector.addAll(vector)
                    linkOsh = modeling.createLinkOSH('dependency', remoteLvmOsh, localVolumeOsh)
                    resultVector.add(linkOsh)

        for lunMap in lunMappings:
            lvOsh = lvSystemNameAndIdToLvmOshMap[lunMap.volume_parent_ref + lunMap.volume_id]
            localFcPortOsh = ObjectStateHolder("fcport")
            wwnFormated = str(wwn.parse_from_str(lunMap.local_wwn))
            localFcPortOsh.setStringAttribute("fcport_wwn", wwnFormated)
            resultVector.add(localFcPortOsh)

            linkOsh = modeling.createLinkOSH('dependency', lvOsh, localFcPortOsh)
            resultVector.add(linkOsh)

            remoteFcPortOsh = ObjectStateHolder("fcport")
            wwnFormated = str(wwn.parse_from_str(lunMap.remote_wwn))
            remoteFcPortOsh.setStringAttribute("fcport_wwn", wwnFormated)
            resultVector.add(remoteFcPortOsh)

            linkOsh = modeling.createLinkOSH('fcconnect', remoteFcPortOsh, localFcPortOsh)
            resultVector.add(linkOsh)

        return resultVector