def create_consistencygroup(ctxt, host='test_host@fakedrv#fakepool', name='test_cg', description='this is a test cg', status=fields.ConsistencyGroupStatus.AVAILABLE, availability_zone='fake_az', volume_type_id=None, cgsnapshot_id=None, source_cgid=None, **kwargs):
 cg = objects.ConsistencyGroup(ctxt)
 cg.host = host
 cg.user_id = (ctxt.user_id or fake.USER_ID)
 cg.project_id = (ctxt.project_id or fake.PROJECT_ID)
 cg.status = status
 cg.name = name
 cg.description = description
 cg.availability_zone = availability_zone
 if volume_type_id:
  cg.volume_type_id = volume_type_id
 cg.cgsnapshot_id = cgsnapshot_id
 cg.source_cgid = source_cgid
 new_id = kwargs.pop('id', None)
 cg.update(kwargs)
 cg.create()
 if (new_id and (new_id != cg.id)):
  db.consistencygroup_update(ctxt, cg.id, {'id': new_id})
  cg = objects.ConsistencyGroup.get_by_id(ctxt, new_id)
 return cg

def create_consistencygroup ( ctxt , host = 'test_host@fakedrv#fakepool' , name = 'test_cg' , description = 'this is a test cg' , status = fields . ConsistencyGroupStatus . AVAILABLE , availability_zone = 'fake_az' , volume_type_id = None , cgsnapshot_id = None , source_cgid = None , ** kwargs ) : cg = objects . ConsistencyGroup ( ctxt ) cg . host = host cg . user_id = ( ctxt . user_id or fake . USER_ID ) cg . project_id = ( ctxt . project_id or fake . PROJECT_ID ) cg . status = status cg . name = name cg . description = description cg . availability_zone = availability_zone if volume_type_id : cg . volume_type_id = volume_type_id cg . cgsnapshot_id = cgsnapshot_id cg . source_cgid = source_cgid new_id = kwargs . pop ( 'id' , None ) cg . update ( kwargs ) cg . create ( ) if ( new_id and ( new_id != cg . id ) ) : db . consistencygroup_update ( ctxt , cg . id , { 'id' : new_id } ) cg = objects . ConsistencyGroup . get_by_id ( ctxt , new_id ) return cg
create a consistencygroup object in the db .