'Manage an existing nimble volume (import to cinder)'

def manage_existing(self, volume, external_ref):

    target_vol_name = self._get_existing_volume_ref_name(external_ref)
    LOG.debug('Entering    manage_existing.    Target_volume_name    =%s', target_vol_name)
    vol_info = self.APIExecutor.get_vol_info(target_vol_name)
    if ((vol_info['agent_type'] == AGENT_TYPE_OPENSTACK) or (vol_info['agent_type'] == AGENT_TYPE_OPENSTACK_GST)):
        raise exception.ManageExistingAlreadyManaged(volume_ref=volume['id'])
    if (vol_info['agent_type'] != AGENT_TYPE_NONE):
        msg = _('Volume    should    have    agent-type    set    as    None.')
        raise exception.InvalidVolume(reason=msg)
    new_vol_name = volume['name']
    LOG.info('Volume    status    before    managing    it    :    %(status)s', {'status': vol_info['online']})
    if (vol_info['online'] is True):
        msg = (_('Volume    %s    is    online.    Set    volume    to    offline    for    managing    using    OpenStack.') % target_vol_name)
        raise exception.InvalidVolume(reason=msg)
    data = {'data': {'name': new_vol_name}}
    if (self._group_target_enabled is True):
        if (('access_control_records' in vol_info) and (vol_info['access_control_records'] is not None)):
            msg = (_('Volume    %s    has    ACL    associated    with    it.    Remove    ACL    for    managing    using    OpenStack') % target_vol_name)
            raise exception.InvalidVolume(reason=msg)
        data['data']['agent_type'] = AGENT_TYPE_OPENSTACK_GST
    else:
        data['data']['agent_type'] = AGENT_TYPE_OPENSTACK
    LOG.debug('Data    for    edit    %(data)s', {'data': data})
    self.APIExecutor.edit_vol(target_vol_name, data)
    self.APIExecutor.online_vol(new_vol_name, True)
    return self._get_model_info(new_vol_name)
