def _attach_volume(self, ctxt, volume, properties, remote=False):
    status = volume['status']
    if remote:
        rpcapi = volume_rpcapi.VolumeAPI()
        try:
            conn = rpcapi.initialize_connection(ctxt, volume, properties)
        except Exception:
            with excutils.save_and_reraise_exception():
                LOG.error(_LE('Failed to attach volume %(vol)s.'), {'vol': volume['id']})
                self.db.volume_update(ctxt, volume['id'], {'status': status})
    else:
        conn = self.initialize_connection(ctxt, volume['id'], properties)
    return self._connect_device(conn)
def _attach_volume(self, ctxt, volume, properties, remote=False):
    status = volume['status']
    if remote:
        rpcapi = volume_rpcapi.VolumeAPI()
        try:
            conn = rpcapi.initialize_connection(ctxt, volume, properties)
        except Exception:
            with excutils.save_and_reraise_exception():
                LOG.error(_LE('Failed to attach volume %(vol)s.'), {'vol': volume['id']})
                self.db.volume_update(ctxt, volume['id'], {'status': status})
    else:
        conn = self.initialize_connection(ctxt, volume['id'], properties)
    return self._connect_device(conn)