'List volumes on the backend available for management by Cinder.
Rule out volumes that are attached to a Purity host or that
are already in the list of cinder_volumes. We return references
of the volume names for any others.'

def get_manageable_volumes(self, cinder_volumes, marker, limit, offset, sort_keys, sort_dirs):

    array = self._get_current_array()
    pure_vols = array.list_volumes()
    hosts_with_connections = array.list_hosts(all=True)
    connected_vols = {}
    for host in hosts_with_connections:
        vol = host.get('vol')
        if vol:
            connected_vols[vol] = host['name']
    existing_vols = {}
    for cinder_vol in cinder_volumes:
        existing_vols[self._get_vol_name(cinder_vol)] = cinder_vol.name_id
    manageable_vols = []
    for pure_vol in pure_vols:
        vol_name = pure_vol['name']
        cinder_id = existing_vols.get(vol_name)
        is_safe = True
        reason_not_safe = None
        host = connected_vols.get(vol_name)
        if host:
            is_safe = False
            reason_not_safe = (_('Volume    connected    to    host    %s.') % host)
        if cinder_id:
            is_safe = False
            reason_not_safe = _('Volume    already    managed.')
        manageable_vols.append({'reference': {'name': vol_name}, 'size': self._round_bytes_to_gib(pure_vol['size']), 'safe_to_manage': is_safe, 'reason_not_safe': reason_not_safe, 'cinder_id': cinder_id, 'extra_info': None})
    return volume_utils.paginate_entries_list(manageable_vols, marker, limit, offset, sort_keys, sort_dirs)
