async def cpcluster_search(ns={}): center_id = ns['center_id'] if ns.get('center_id') else '' cluster_name = ns['cluster_name'] if ns.get('center_name') else '' if not center_id: return { 'status': False, 'msg': '请传递算力中心center_id' } db = DBPools() async with db.sqlorContext('kboss') as sor: try: if cluster_name: search_sql = """ SELECT * from cpcluster WHERE center_id = '%s' and cluster_name = '%s' and del_flg = '0'; """ % (center_id, cluster_name) res = await sor.sqlExe(search_sql, {}) else: search_sql = """ SELECT * from cpcluster WHERE center_id = '%s' and del_flg = '0'; """ % center_id res = await sor.sqlExe(search_sql, {}) return { 'status': True, 'msg': '算力集群查找成功', 'data': res } except Exception as e: return { 'status': False, 'msg': '算力集群查找错误, %s' % str(e) } ret = await cpcluster_search(params_kw) return ret