'Creates a CG snapshot.'

def _create_cgsnapshot(self, context, cgsnapshot, snapshots):

    model_update = {'status': fields.GroupSnapshotStatus.AVAILABLE}
    cgname = self._cg_name_from_cgsnapshot(cgsnapshot)
    groupname = self._group_name_from_cgsnapshot_id(cgsnapshot['id'])
    LOG.info('Creating    snapshot    %(group)s    for    CG    %(cg)s.', {'group': groupname, 'cg': cgname})
    try:
        self._call_xiv_xcli('cg_snapshots_create', cg=cgname, snap_group=groupname).as_list
    except errors.CgDoesNotExistError as e:
        error = (_('Consistency    group    %s    does    not    exist    on    backend') % cgname)
        LOG.error(error)
        raise self._get_exception()(error)
    except errors.CgBadNameError as e:
        error = (_('Consistency    group    %s    has    an    illegal    name') % cgname)
        LOG.error(error)
        raise self._get_exception()(error)
    except errors.SnapshotGroupDoesNotExistError as e:
        error = (_('Snapshot    group    %s    has    an    illegal    name') % cgname)
        LOG.error(error)
        raise self._get_exception()(error)
    except errors.PoolSnapshotLimitReachedError as e:
        error = _('Reached    maximum    snapshots    allocation    size')
        LOG.error(error)
        raise self._get_exception()(error)
    except errors.CgEmptyError as e:
        error = (_('Consistency    group    %s    is    empty') % cgname)
        LOG.error(error)
        raise self._get_exception()(error)
    except (errors.MaxVolumesReachedError, errors.DomainMaxVolumesReachedError) as e:
        error = _('Reached    Maximum    number    of    volumes')
        LOG.error(error)
        raise self._get_exception()(error)
    except errors.SnapshotGroupIsReservedError as e:
        error = (_('Consistency    group    %s    name    is    reserved') % cgname)
        LOG.error(error)
        raise self._get_exception()(error)
    except errors.SnapshotGroupAlreadyExistsError as e:
        error = (_('Snapshot    group    %s    already    exists') % groupname)
        LOG.error(error)
        raise self._get_exception()(error)
    except errors.XCLIError as e:
        error = (_('Fatal:    CG    %(cg)s,    Group    %(group)s.    %(err)s') % {'cg': cgname, 'group': groupname, 'err': self._get_code_and_status_or_message(e)})
        LOG.error(error)
        raise self._get_exception()(error)
    snapshots_model_update = []
    for snapshot in snapshots:
        snapshots_model_update.append({'id': snapshot['id'], 'status': fields.SnapshotStatus.AVAILABLE})
    return (model_update, snapshots_model_update)
