dell_storagecenter_driver/dell_storagecenter_blockdevice.py
def attach_volume(self, blockdevice_id, attach_to):
        """Attach an existing volume to an initiator.

        :param blockdevice_id: The unique identifier for the volume.
        :param attach_to: An identifier like the one returned by the
            ``compute_instance_id`` method indicating the node to which to
            attach the volume.

        :raises UnknownVolume: If the supplied ``blockdevice_id`` does not
            exist.
        :returns: A ``BlockDeviceVolume`` with a ``attached_to`` attribute set
            to ``attach_to``.
        """
        LOG.info('Attaching %s to %s', blockdevice_id, attach_to)

        # Functional tests expect a failure if it's already
        # attached, even if we're being asked to attach to
        # the same host.
        # not_local = attach_to != self.compute_instance_id()
        not_local = True

        with self._client.open_connection() as api:
            # Check that we have that volume
            scvolume = api.find_volume(blockdevice_id)
            if not scvolume:
                raise blockdevice.UnknownVolume(blockdevice_id)

            # Make sure we have a server defined for this host
            iqn = iscsi_utils.get_initiator_name()
            host = api.find_server(iqn)
            LOG.info("Search for server returned: %s", host)
            if not host:
                # Try to create a new host
                host = api.create_server(attach_to, iqn)
                LOG.info("Created server %s", host)
            # Make sure the server is logged in to the array
            ports = api.get_iscsi_ports()
            for port in ports:
                iscsi_utils.iscsi_login(port[0], port[1])

            # Make sure we were able to find something
            if not host:
                raise BlockDriverAPIException()

            # First check if we are already mapped
            mappings = api.find_mapping_profiles(scvolume)
            if mappings:
                # See if it is to this server
                if not_local:
                    raise blockdevice.AlreadyAttachedVolume(blockdevice_id)
                for mapping in mappings:
                    if (mapping['server']['instanceName'] !=
                            host['instanceName']):
                        raise blockdevice.AlreadyAttachedVolume(blockdevice_id)

            mapping = api.map_volume(scvolume, host)
            if not mapping:
                raise BlockDriverAPIException(
                    'Unable to map volume to server.')

            self._do_rescan('attach')

            return self._to_blockdevicevolume(scvolume, attach_to)
Attach an existing volume to an initiator.

        :param blockdevice_id: The unique identifier for the volume.
        :param attach_to: An identifier like the one returned by the
            ``compute_instance_id`` method indicating the node to which to
            attach the volume.

        :raises UnknownVolume: If the supplied ``blockdevice_id`` does not
            exist.
        :returns: A ``BlockDeviceVolume`` with a ``attached_to`` attribute set
            to ``attach_to``.
        
Attach an existing volume to an initiator.
Attach an existing volume to an initiator .
def attach_volume(self, blockdevice_id, attach_to):
        LOG.info('Attaching %s to %s', blockdevice_id, attach_to)
        not_local = True
        with self._client.open_connection() as api:
            scvolume = api.find_volume(blockdevice_id)
            if not scvolume:
                raise blockdevice.UnknownVolume(blockdevice_id)
            iqn = iscsi_utils.get_initiator_name()
            host = api.find_server(iqn)
            LOG.info("Search for server returned: %s", host)
            if not host:
                host = api.create_server(attach_to, iqn)
                LOG.info("Created server %s", host)
            ports = api.get_iscsi_ports()
            for port in ports:
                iscsi_utils.iscsi_login(port[0], port[1])
            if not host:
                raise BlockDriverAPIException()
            mappings = api.find_mapping_profiles(scvolume)
            if mappings:
                if not_local:
                    raise blockdevice.AlreadyAttachedVolume(blockdevice_id)
                for mapping in mappings:
                    if (mapping['server']['instanceName'] !=
                            host['instanceName']):
                        raise blockdevice.AlreadyAttachedVolume(blockdevice_id)
            mapping = api.map_volume(scvolume, host)
            if not mapping:
                raise BlockDriverAPIException(
                    'Unable to map volume to server.')
            self._do_rescan('attach')
            return self._to_blockdevicevolume(scvolume, attach_to)
def attach_volume ( self , blockdevice_id , attach_to ) : LOG . info ( 'Attaching %s to %s' , blockdevice_id , attach_to ) not_local = True with self . _client . open_connection ( ) as api : scvolume = api . find_volume ( blockdevice_id ) if not scvolume : raise blockdevice . UnknownVolume ( blockdevice_id ) iqn = iscsi_utils . get_initiator_name ( ) host = api . find_server ( iqn ) LOG . info ( "Search for server returned: %s" , host ) if not host : host = api . create_server ( attach_to , iqn ) LOG . info ( "Created server %s" , host ) ports = api . get_iscsi_ports ( ) for port in ports : iscsi_utils . iscsi_login ( port [ 0 ] , port [ 1 ] ) if not host : raise BlockDriverAPIException ( ) mappings = api . find_mapping_profiles ( scvolume ) if mappings : if not_local : raise blockdevice . AlreadyAttachedVolume ( blockdevice_id ) for mapping in mappings : if ( mapping [ 'server' ] [ 'instanceName' ] != host [ 'instanceName' ] ) : raise blockdevice . AlreadyAttachedVolume ( blockdevice_id ) mapping = api . map_volume ( scvolume , host ) if not mapping : raise BlockDriverAPIException ( 'Unable to map volume to server.' ) self . _do_rescan ( 'attach' ) return self . _to_blockdevicevolume ( scvolume , attach_to )
Attach an existing volume to an initiator.
Attach an existing volume to an initiator .
"""Attach an existing volume to an initiator.

        :param blockdevice_id: The unique identifier for the volume.
        :param attach_to: An identifier like the one returned by the
            ``compute_instance_id`` method indicating the node to which to
            attach the volume.

        :raises UnknownVolume: If the supplied ``blockdevice_id`` does not
            exist.
        :returns: A ``BlockDeviceVolume`` with a ``attached_to`` attribute set
            to ``attach_to``.
        """ # Functional tests expect a failure if it's already # attached, even if we're being asked to attach to # the same host. # not_local = attach_to != self.compute_instance_id() # Check that we have that volume # Make sure we have a server defined for this host # Try to create a new host # Make sure the server is logged in to the array # Make sure we were able to find something # First check if we are already mapped # See if it is to this server
A ``BlockDeviceVolume`` with a ``attached_to`` attribute set
to ``attach_to``.
A ` ` BlockDeviceVolume ` ` with a ` ` attached_to ` ` attribute set to ` ` attach_to ` ` .
If the supplied ``blockdevice_id`` does not
exist.
If the supplied ` ` blockdevice_id ` ` does not exist .
UnknownVolume
self
blockdevice_id
The unique identifier for the volume.
The unique identifier for the volume .
attach_to
An identifier like the one returned by the
``compute_instance_id`` method indicating the node to which to
attach the volume.
An identifier like the one returned by the ` ` compute_instance_id ` ` method indicating the node to which to attach the volume .