'Generates the hashed name for the space from the name.
This must be called in a locked context as there are race conditions
where 2 contexts could both pick what they think is an unallocated
space name, and fail later on due to that conflict.'

def _make_space_name(self, name):

    valid_chars = ('-_.%s%s' % (string.ascii_letters, string.digits))
    name = ''.join((c for c in name if (c in valid_chars)))
    name = name.strip('.')
    name = (name or 'space')
    outname = name[0:13]
    params = [self.VGCCLUSTER, 'space-list', '--name-only']
    try:
        (out, unused) = self._execute(run_as_root=True, *params)
    except processutils.ProcessExecutionError as err:
        self._log_cli_err(err)
        msg = _('Unable    to    get    list    of    spaces    to    make    new    name.        Please    verify    the    cluster    is    running.')
        raise exception.VolumeDriverException(message=msg)
    names = out.splitlines()
    names += os.listdir('/dev')
    names += ['.', '..']
    itr = 0
    while (outname in names):
        itrstr = six.text_type(itr)
        outname = (outname[0:(13 - len(itrstr))] + itrstr)
        itr += 1
    return outname
