def cg_creating_from_src(cg_id=None, cgsnapshot_id=None):
 subq = sql.select([models.ConsistencyGroup]).where(and_((~ models.ConsistencyGroup.deleted), (models.ConsistencyGroup.status == 'creating'))).alias('cg2')
 if cg_id:
  match_id = (subq.c.source_cgid == cg_id)
 elif cgsnapshot_id:
  match_id = (subq.c.cgsnapshot_id == cgsnapshot_id)
 else:
  msg = _('cg_creating_from_src must be called with cg_id or cgsnapshot_id parameter.')
  raise exception.ProgrammingError(reason=msg)
 return sql.exists([subq]).where(match_id)

def cg_creating_from_src ( cg_id = None , cgsnapshot_id = None ) : subq = sql . select ( [ models . ConsistencyGroup ] ) . where ( and_ ( ( ~ models . ConsistencyGroup . deleted ) , ( models . ConsistencyGroup . status == 'creating' ) ) ) . alias ( 'cg2' ) if cg_id : match_id = ( subq . c . source_cgid == cg_id ) elif cgsnapshot_id : match_id = ( subq . c . cgsnapshot_id == cgsnapshot_id ) else : msg = _ ( 'cg_creating_from_src must be called with cg_id or cgsnapshot_id parameter.' ) raise exception . ProgrammingError ( reason = msg ) return sql . exists ( [ subq ] ) . where ( match_id )
return a filter to check if a cg is being used as creation source .