'Selects a datastore satisfying the given requirements.
A datastore which is connected to maximum number of hosts is
selected. Ties if any are broken based on space utilization--
datastore with least space utilization is preferred. It returns
the selected datastore\'s summary along with a host and resource
pool where the volume can be created.
:param req: selection requirements
:param hosts: list of hosts to consider
:return: (host, resourcePool, summary)'

def select_datastore(self, req, hosts=None):

    LOG.debug('Using    requirements:    %s    for    datastore    selection.', req)
    hard_affinity_ds_types = req.get(DatastoreSelector.HARD_AFFINITY_DS_TYPE)
    hard_anti_affinity_datastores = req.get(DatastoreSelector.HARD_ANTI_AFFINITY_DS)
    size_bytes = req[DatastoreSelector.SIZE_BYTES]
    profile_name = req.get(DatastoreSelector.PROFILE_NAME)
    profile_id = None
    if (profile_name is not None):
        profile_id = self.get_profile_id(profile_name)
    datastores = self._get_datastores()
    datastores = self._filter_datastores(datastores, size_bytes, profile_id, hard_anti_affinity_datastores, hard_affinity_ds_types, valid_host_refs=hosts)
    res = self._select_best_datastore(datastores, valid_host_refs=hosts)
    LOG.debug('Selected    (host,    resourcepool,    datastore):    %s', res)
    return res
