コード例 #1
0
 def connector(self):
     if not self._connector:
         if not self.conn_info:
             return None
         self._connector = volume_utils.brick_get_connector(
             self.protocol,
             use_multipath=self.use_multipath,
             device_scan_attempts=self.scan_attempts,
             # NOTE(geguileo): afaik only remotefs uses the connection info
             conn=self.conn_info,
             do_local_attach=True)
     return self._connector
コード例 #2
0
ファイル: manager.py プロジェクト: lj361588364/cinder
    def _connect_device(self, conn):
        """Establish connection to device."""
        use_multipath = CONF.use_multipath_for_image_xfer
        device_scan_attempts = CONF.num_volume_device_scan_tries
        protocol = conn['driver_volume_type']
        connector = volume_utils.brick_get_connector(
            protocol,
            use_multipath=use_multipath,
            device_scan_attempts=device_scan_attempts,
            conn=conn,
            expect_raw_disk=True)
        vol_handle = connector.connect_volume(conn['data'])

        return {'conn': conn, 'device': vol_handle, 'connector': connector}
コード例 #3
0
    def _remove_device(self, properties, device):
        LOG.debug('enter: _remove_device')

        if not properties or not device:
            LOG.warning('_remove_device: invalid properties or device.')
            return

        use_multipath = self.configuration.use_multipath_for_image_xfer
        device_scan_attempts = self.configuration.num_volume_device_scan_tries
        protocol = properties['driver_volume_type']
        connector = volume_utils.brick_get_connector(
            protocol,
            use_multipath=use_multipath,
            device_scan_attempts=device_scan_attempts,
            conn=properties)

        connector.disconnect_volume(properties['data'], device)

        LOG.debug('leave: _remove_device')
コード例 #4
0
 def _attach_context(self, connection):
     use_multipath = self.configuration.use_multipath_for_image_xfer
     device_scan_attempts = self.configuration.num_volume_device_scan_tries
     protocol = connection['driver_volume_type']
     connector = volume_utils.brick_get_connector(
         protocol,
         use_multipath=use_multipath,
         device_scan_attempts=device_scan_attempts,
         conn=connection)
     attach_info = None
     try:
         attach_info = self._connect_device(connection)
         yield attach_info
     except exception.DeviceUnavailable as exc:
         attach_info = exc.kwargs.get('attach_info', None)
         raise
     finally:
         if attach_info:
             connector.disconnect_volume(attach_info['conn']['data'],
                                         attach_info['device'])
コード例 #5
0
ファイル: datera_api21.py プロジェクト: lj361588364/cinder
 def _connect_vol(self, context, vol):
     connector = None
     try:
         # Start connection, get the connector object and create the
         # export (ACL, IP-Pools, etc)
         conn = self._initialize_connection_2_1(
             vol, {'multipath': False})
         connector = volutils.brick_get_connector(
             conn['driver_volume_type'],
             use_multipath=False,
             device_scan_attempts=10,
             conn=conn)
         connector_info = {'initiator': connector.get_initiator()}
         self._create_export_2_1(None, vol, connector_info)
         retries = 10
         attach_info = conn['data']
         while True:
             try:
                 attach_info.update(
                     connector.connect_volume(conn['data']))
                 break
             except brick_exception.FailedISCSITargetPortalLogin:
                 retries -= 1
                 if not retries:
                     LOG.error("Could not log into portal before end of "
                               "polling period")
                     raise
                 LOG.debug("Failed to login to portal, retrying")
                 eventlet.sleep(2)
         device_path = attach_info['path']
         yield device_path
     finally:
         # Close target connection
         if connector:
             # Best effort disconnection
             try:
                 connector.disconnect_volume(attach_info, attach_info)
             except Exception:
                 pass
コード例 #6
0
    def _scan_device(self, properties):
        LOG.debug('enter: _scan_device')

        use_multipath = self.configuration.use_multipath_for_image_xfer
        device_scan_attempts = self.configuration.num_volume_device_scan_tries
        protocol = properties['driver_volume_type']
        connector = volume_utils.brick_get_connector(
            protocol,
            use_multipath=use_multipath,
            device_scan_attempts=device_scan_attempts,
            conn=properties)
        device = connector.connect_volume(properties['data'])
        host_device = device['path']

        if not connector.check_valid_device(host_device):
            msg = (_('Unable to access the backend storage '
                     'via the path %(path)s.') % {
                         'path': host_device
                     })
            raise exception.VolumeBackendAPIException(data=msg)

        LOG.debug('leave: _scan_device')
        return device