def create_cgsnapshot(ctxt, consistencygroup_id, name='test_cgsnapshot', description='this is a test cgsnapshot', status='creating', recursive_create_if_needed=True, return_vo=True, **kwargs):
 values = {'user_id': (ctxt.user_id or fake.USER_ID), 'project_id': (ctxt.project_id or fake.PROJECT_ID), 'status': status, 'name': name, 'description': description, 'consistencygroup_id': consistencygroup_id}
 values.update(kwargs)
 if (recursive_create_if_needed and consistencygroup_id):
  create_cg = False
  try:
   objects.ConsistencyGroup.get_by_id(ctxt, consistencygroup_id)
   create_vol = (not db.volume_get_all_by_group(ctxt, consistencygroup_id))
  except exception.ConsistencyGroupNotFound:
   create_cg = True
   create_vol = True
  if create_cg:
   create_consistencygroup(ctxt, id=consistencygroup_id)
  if create_vol:
   create_volume(ctxt, consistencygroup_id=consistencygroup_id)
 cgsnap = db.cgsnapshot_create(ctxt, values)
 if (not return_vo):
  return cgsnap
 return objects.CGSnapshot.get_by_id(ctxt, cgsnap.id)

def create_cgsnapshot ( ctxt , consistencygroup_id , name = 'test_cgsnapshot' , description = 'this is a test cgsnapshot' , status = 'creating' , recursive_create_if_needed = True , return_vo = True , ** kwargs ) : values = { 'user_id' : ( ctxt . user_id or fake . USER_ID ) , 'project_id' : ( ctxt . project_id or fake . PROJECT_ID ) , 'status' : status , 'name' : name , 'description' : description , 'consistencygroup_id' : consistencygroup_id } values . update ( kwargs ) if ( recursive_create_if_needed and consistencygroup_id ) : create_cg = False try : objects . ConsistencyGroup . get_by_id ( ctxt , consistencygroup_id ) create_vol = ( not db . volume_get_all_by_group ( ctxt , consistencygroup_id ) ) except exception . ConsistencyGroupNotFound : create_cg = True create_vol = True if create_cg : create_consistencygroup ( ctxt , id = consistencygroup_id ) if create_vol : create_volume ( ctxt , consistencygroup_id = consistencygroup_id ) cgsnap = db . cgsnapshot_create ( ctxt , values ) if ( not return_vo ) : return cgsnap return objects . CGSnapshot . get_by_id ( ctxt , cgsnap . id )
create a cgsnapshot object in the db .