dell_storagecenter_driver/dell_storagecenter_api.py
def find_iscsi_properties(self, scvolume, ip=None, port=None):
        """Finds target information for a given Dell scvolume object mapping.

        The data coming back is both the preferred path and all the paths.

        :param scvolume: The dell sc volume object.
        :param ip: The preferred target portal ip.
        :param port: The preferred target portal port.
        :returns: iSCSI property dictionary.
        :raises: VolumeBackendAPIException
        """
        LOG.debug('enter find_iscsi_properties')
        LOG.debug('scvolume: %s', scvolume)
        # Our mutable process object.
        pdata = {'active': -1,
                 'up': -1,
                 'access_mode': 'rw',
                 'ip': ip,
                 'port': port}
        # Our output lists.
        portals = []
        luns = []
        iqns = []

        # Process just looks for the best port to return.
        def process(lun, iqn, address, port, readonly, status, active):
            """Process this mapping information.

            :param lun: SCSI Lun.
            :param iqn: iSCSI IQN address.
            :param address: IP address.
            :param port: IP Port number
            :param readonly: Boolean indicating mapping is readonly.
            :param status: String indicating mapping status.  (Up is what we
                           are looking for.)
            :param active: Boolean indicating whether this is on the active
                           controller or not.
            :return: Nothing
            """
            portals.append(address + ':' +
                           six.text_type(port))
            iqns.append(iqn)
            luns.append(lun)

            # We've all the information.  We need to find
            # the best single portal to return.  So check
            # this one if it is on the right IP, port and
            # if the access and status are correct.
            if ((pdata['ip'] is None or pdata['ip'] == address) and
                    (pdata['port'] is None or pdata['port'] == port)):

                # We need to point to the best link.
                # So state active and status up is preferred
                # but we don't actually need the state to be
                # up at this point.
                if pdata['up'] == -1:
                    pdata['access_mode'] = 'rw' if readonly is False else 'ro'
                    if active:
                        pdata['active'] = len(iqns) - 1
                        if status == 'Up':
                            pdata['up'] = pdata['active']

        # Start by getting our mappings.
        mappings = self._find_mappings(scvolume)

        # We should have mappings at the time of this call but do check.
        if len(mappings) > 0:
            # In multipath (per Liberty) we will return all paths.  But
            # if multipath is not set (ip and port are None) then we need
            # to return a mapping from the controller on which the volume
            # is active.  So find that controller.
            actvctrl = self._find_active_controller(scvolume)
            # Two different methods are used to find our luns and portals
            # depending on whether we are in virtual or legacy port mode.
            isvpmode = self._is_virtualport_mode()
            # Trundle through our mappings.
            for mapping in mappings:
                # The lun, ro mode and status are in the mapping.
                LOG.debug('mapping: %s', mapping)
                lun = mapping.get('lun')
                ro = mapping.get('readOnly', False)
                status = mapping.get('status')
                # Get our IQN from our mapping.
                iqn = self._get_iqn(mapping)
                # Check if our controller ID matches our active controller ID.
                isactive = True if (self._get_controller_id(mapping) ==
                                    actvctrl) else False
                # If we have an IQN and are in virtual port mode.
                if isvpmode and iqn:
                    domains = self._get_domains(mapping)
                    if domains:
                        for dom in domains:
                            LOG.debug('domain: %s', dom)
                            ipaddress = dom.get('targetIpv4Address',
                                                dom.get('wellKnownIpAddress'))
                            portnumber = dom.get('portNumber')
                            # We have all our information. Process this portal.
                            process(lun, iqn, ipaddress, portnumber,
                                    ro, status, isactive)
                # Else we are in legacy mode.
                elif iqn:
                    # Need to get individual ports
                    cportid = self._get_id(mapping.get('controllerPort'))
                    # Legacy mode stuff is in the ISCSI configuration object.
                    cpconfig = self._find_controller_port_iscsi_config(cportid)
                    # This should really never fail. Things happen so if it
                    # does just keep moving. Return what we can.
                    if cpconfig:
                        ipaddress = cpconfig.get('ipAddress')
                        portnumber = cpconfig.get('portNumber')
                        # We have all our information.  Process this portal.
                        process(lun, iqn, ipaddress, portnumber,
                                ro, status, isactive)

        # We've gone through all our mappings.
        # Make sure we found something to return.
        if len(luns) == 0:
            # Since we just mapped this and can't find that mapping the world
            # is wrong so we raise exception.
            raise Exception('Unable to find iSCSI mappings.')

        # Make sure we point to the best portal we can.  This means it is
        # on the active controller and, preferably, up.  If it isn't return
        # what we have.
        if pdata['up'] != -1:
            # We found a connection that is already up.  Return that.
            pdata['active'] = pdata['up']
        elif pdata['active'] == -1:
            # This shouldn't be able to happen.  Maybe a controller went
            # down in the middle of this so just return the first one and
            # hope the ports are up by the time the connection is attempted.
            LOG.debug('Volume is not yet active on any controller.')
            pdata['active'] = 0

        data = {'target_discovered': False,
                'target_iqn': iqns[pdata['active']],
                'target_iqns': iqns,
                'target_portal': portals[pdata['active']],
                'target_portals': portals,
                'target_lun': luns[pdata['active']],
                'target_luns': luns,
                'access_mode': pdata['access_mode']
                }
        LOG.debug('find_iscsi_properties return: %s',
                  data)

        return data
Finds target information for a given Dell scvolume object mapping.

        The data coming back is both the preferred path and all the paths.

        :param scvolume: The dell sc volume object.
        :param ip: The preferred target portal ip.
        :param port: The preferred target portal port.
        :returns: iSCSI property dictionary.
        :raises: VolumeBackendAPIException
        
Finds target information for a given Dell scvolume object mapping.
The data coming back is both the preferred path and all the paths.
Finds target information for a given Dell scvolume object mapping . The data coming back is both the preferred path and all the paths .
def find_iscsi_properties(self, scvolume, ip=None, port=None):
        LOG.debug('enter find_iscsi_properties')
        LOG.debug('scvolume: %s', scvolume)
        pdata = {'active': -1,
                 'up': -1,
                 'access_mode': 'rw',
                 'ip': ip,
                 'port': port}
        portals = []
        luns = []
        iqns = []
        def process(lun, iqn, address, port, readonly, status, active):
            portals.append(address + ':' +
                           six.text_type(port))
            iqns.append(iqn)
            luns.append(lun)
            if ((pdata['ip'] is None or pdata['ip'] == address) and
                    (pdata['port'] is None or pdata['port'] == port)):
                if pdata['up'] == -1:
                    pdata['access_mode'] = 'rw' if readonly is False else 'ro'
                    if active:
                        pdata['active'] = len(iqns) - 1
                        if status == 'Up':
                            pdata['up'] = pdata['active']
        mappings = self._find_mappings(scvolume)
        if len(mappings) > 0:
            actvctrl = self._find_active_controller(scvolume)
            isvpmode = self._is_virtualport_mode()
            for mapping in mappings:
                LOG.debug('mapping: %s', mapping)
                lun = mapping.get('lun')
                ro = mapping.get('readOnly', False)
                status = mapping.get('status')
                iqn = self._get_iqn(mapping)
                isactive = True if (self._get_controller_id(mapping) ==
                                    actvctrl) else False
                if isvpmode and iqn:
                    domains = self._get_domains(mapping)
                    if domains:
                        for dom in domains:
                            LOG.debug('domain: %s', dom)
                            ipaddress = dom.get('targetIpv4Address',
                                                dom.get('wellKnownIpAddress'))
                            portnumber = dom.get('portNumber')
                            process(lun, iqn, ipaddress, portnumber,
                                    ro, status, isactive)
                elif iqn:
                    cportid = self._get_id(mapping.get('controllerPort'))
                    cpconfig = self._find_controller_port_iscsi_config(cportid)
                    if cpconfig:
                        ipaddress = cpconfig.get('ipAddress')
                        portnumber = cpconfig.get('portNumber')
                        process(lun, iqn, ipaddress, portnumber,
                                ro, status, isactive)
        if len(luns) == 0:
            raise Exception('Unable to find iSCSI mappings.')
        if pdata['up'] != -1:
            pdata['active'] = pdata['up']
        elif pdata['active'] == -1:
            LOG.debug('Volume is not yet active on any controller.')
            pdata['active'] = 0
        data = {'target_discovered': False,
                'target_iqn': iqns[pdata['active']],
                'target_iqns': iqns,
                'target_portal': portals[pdata['active']],
                'target_portals': portals,
                'target_lun': luns[pdata['active']],
                'target_luns': luns,
                'access_mode': pdata['access_mode']
                }
        LOG.debug('find_iscsi_properties return: %s',
                  data)
        return data
def find_iscsi_properties ( self , scvolume , ip = None , port = None ) : LOG . debug ( 'enter find_iscsi_properties' ) LOG . debug ( 'scvolume: %s' , scvolume ) pdata = { 'active' : - 1 , 'up' : - 1 , 'access_mode' : 'rw' , 'ip' : ip , 'port' : port } portals = [ ] luns = [ ] iqns = [ ] def process ( lun , iqn , address , port , readonly , status , active ) : """Process this mapping information.

            :param lun: SCSI Lun.
            :param iqn: iSCSI IQN address.
            :param address: IP address.
            :param port: IP Port number
            :param readonly: Boolean indicating mapping is readonly.
            :param status: String indicating mapping status.  (Up is what we
                           are looking for.)
            :param active: Boolean indicating whether this is on the active
                           controller or not.
            :return: Nothing
            """ portals . append ( address + ':' + six . text_type ( port ) ) iqns . append ( iqn ) luns . append ( lun ) if ( ( pdata [ 'ip' ] is None or pdata [ 'ip' ] == address ) and ( pdata [ 'port' ] is None or pdata [ 'port' ] == port ) ) : if pdata [ 'up' ] == - 1 : pdata [ 'access_mode' ] = 'rw' if readonly is False else 'ro' if active : pdata [ 'active' ] = len ( iqns ) - 1 if status == 'Up' : pdata [ 'up' ] = pdata [ 'active' ] mappings = self . _find_mappings ( scvolume ) if len ( mappings ) > 0 : actvctrl = self . _find_active_controller ( scvolume ) isvpmode = self . _is_virtualport_mode ( ) for mapping in mappings : LOG . debug ( 'mapping: %s' , mapping ) lun = mapping . get ( 'lun' ) ro = mapping . get ( 'readOnly' , False ) status = mapping . get ( 'status' ) iqn = self . _get_iqn ( mapping ) isactive = True if ( self . _get_controller_id ( mapping ) == actvctrl ) else False if isvpmode and iqn : domains = self . _get_domains ( mapping ) if domains : for dom in domains : LOG . debug ( 'domain: %s' , dom ) ipaddress = dom . get ( 'targetIpv4Address' , dom . get ( 'wellKnownIpAddress' ) ) portnumber = dom . get ( 'portNumber' ) process ( lun , iqn , ipaddress , portnumber , ro , status , isactive ) elif iqn : cportid = self . _get_id ( mapping . get ( 'controllerPort' ) ) cpconfig = self . _find_controller_port_iscsi_config ( cportid ) if cpconfig : ipaddress = cpconfig . get ( 'ipAddress' ) portnumber = cpconfig . get ( 'portNumber' ) process ( lun , iqn , ipaddress , portnumber , ro , status , isactive ) if len ( luns ) == 0 : raise Exception ( 'Unable to find iSCSI mappings.' ) if pdata [ 'up' ] != - 1 : pdata [ 'active' ] = pdata [ 'up' ] elif pdata [ 'active' ] == - 1 : LOG . debug ( 'Volume is not yet active on any controller.' ) pdata [ 'active' ] = 0 data = { 'target_discovered' : False , 'target_iqn' : iqns [ pdata [ 'active' ] ] , 'target_iqns' : iqns , 'target_portal' : portals [ pdata [ 'active' ] ] , 'target_portals' : portals , 'target_lun' : luns [ pdata [ 'active' ] ] , 'target_luns' : luns , 'access_mode' : pdata [ 'access_mode' ] } LOG . debug ( 'find_iscsi_properties return: %s' , data ) return data
Finds target information for a given Dell scvolume object mapping.
Finds target information for a given Dell scvolume object mapping .
"""Finds target information for a given Dell scvolume object mapping.

        The data coming back is both the preferred path and all the paths.

        :param scvolume: The dell sc volume object.
        :param ip: The preferred target portal ip.
        :param port: The preferred target portal port.
        :returns: iSCSI property dictionary.
        :raises: VolumeBackendAPIException
        """ # Our mutable process object. # Our output lists. # Process just looks for the best port to return. """Process this mapping information.

            :param lun: SCSI Lun.
            :param iqn: iSCSI IQN address.
            :param address: IP address.
            :param port: IP Port number
            :param readonly: Boolean indicating mapping is readonly.
            :param status: String indicating mapping status.  (Up is what we
                           are looking for.)
            :param active: Boolean indicating whether this is on the active
                           controller or not.
            :return: Nothing
            """ # We've all the information.  We need to find # the best single portal to return.  So check # this one if it is on the right IP, port and # if the access and status are correct. # We need to point to the best link. # So state active and status up is preferred # but we don't actually need the state to be # up at this point. # Start by getting our mappings. # We should have mappings at the time of this call but do check. # In multipath (per Liberty) we will return all paths.  But # if multipath is not set (ip and port are None) then we need # to return a mapping from the controller on which the volume # is active.  So find that controller. # Two different methods are used to find our luns and portals # depending on whether we are in virtual or legacy port mode. # Trundle through our mappings. # The lun, ro mode and status are in the mapping. # Get our IQN from our mapping. # Check if our controller ID matches our active controller ID. # If we have an IQN and are in virtual port mode. # We have all our information. Process this portal. # Else we are in legacy mode. # Need to get individual ports # Legacy mode stuff is in the ISCSI configuration object. # This should really never fail. Things happen so if it # does just keep moving. Return what we can. # We have all our information.  Process this portal. # We've gone through all our mappings. # Make sure we found something to return. # Since we just mapped this and can't find that mapping the world # is wrong so we raise exception. # Make sure we point to the best portal we can.  This means it is # on the active controller and, preferably, up.  If it isn't return # what we have. # We found a connection that is already up.  Return that. # This shouldn't be able to happen.  Maybe a controller went # down in the middle of this so just return the first one and # hope the ports are up by the time the connection is attempted.
iSCSI property dictionary.
iSCSI property dictionary .
None
self
scvolume
The dell sc volume object.
The dell sc volume object .
ip
The preferred target portal ip.
The preferred target portal ip .
port
The preferred target portal port.
The preferred target portal port .