'Creates a group snapshot.'

@cinder_utils.trace
def create_group_snapshot(self, context, group_snapshot, snapshots):

    if (not utils.is_group_a_cg_snapshot_type(group_snapshot)):
        raise NotImplementedError()
    client = self._login()
    try:
        snap_set = []
        snapshot_base_name = ('snapshot-' + group_snapshot.id)
        snapshot_model_updates = []
        for (i, snapshot) in enumerate(snapshots):
            volume = snapshot.volume
            volume_name = volume['name']
            try:
                volume_info = client.getVolumeByName(volume_name)
            except Exception as ex:
                error = six.text_type(ex)
                LOG.error('Could    not    find    volume    with    name    %(name)s.    Error:    %(error)s', {'name': volume_name, 'error': error})
                raise exception.VolumeBackendAPIException(data=error)
            volume_id = volume_info['id']
            snapshot_name = ((snapshot_base_name + '-') + six.text_type(i))
            snap_set_member = {'volumeName': volume_name, 'volumeId': volume_id, 'snapshotName': snapshot_name}
            snap_set.append(snap_set_member)
            snapshot_update = {'id': snapshot['id'], 'status': fields.SnapshotStatus.AVAILABLE}
            snapshot_model_updates.append(snapshot_update)
        source_volume_id = snap_set[0]['volumeId']
        optional = {'inheritAccess': True}
        description = group_snapshot.description
        if description:
            optional['description'] = description
        try:
            client.createSnapshotSet(source_volume_id, snap_set, optional)
        except Exception as ex:
            error = six.text_type(ex)
            LOG.error("Could    not    create    snapshot    set.    Error:    '%s'", error)
            raise exception.VolumeBackendAPIException(data=error)
    except Exception as ex:
        raise exception.VolumeBackendAPIException(data=six.text_type(ex))
    finally:
        self._logout(client)
    model_update = {'status': 'available'}
    return (model_update, snapshot_model_updates)
