def list_nodes(): parse_collection_request(_SCHEMA) host_mgr = g.client_set.compute.hosts names = [h._info['host_name'] for h in host_mgr.list_all() if h._info['service'] == 'compute'] result = [] for name in names: try: result.append(_node_to_view(name, host_mgr.get(name))) except osc_exc.NotFound: pass return make_collection_response('nodes', result)
def list_nodes(): parse_collection_request(_SCHEMA) host_mgr = g.client_set.compute.hosts names = [ h._info['host_name'] for h in host_mgr.list_all() if h._info['service'] == 'compute' ] result = [] for name in names: try: result.append(_node_to_view(name, host_mgr.get(name))) except osc_exc.NotFound: pass return make_collection_response('nodes', result)
def list_stats_by_project(): parse_collection_request(_SCHEMA) cs = auth.admin_client_set() if g.my_projects: tenants = g.client_set.identity_public.tenants.list() else: tenants = cs.identity_admin.tenants.list() result = {} for tenant in tenants: if tenant.id != auth.default_tenant_id(): users = cs.identity_admin.tenants.list_users(tenant.id) result[tenant.id] = { 'project': link_for_tenant(tenant), 'members': len(users), 'instances': 0, 'local-images': 0, 'total-images': 0, 'href': url_for('stats.get_project_stats', project_id=tenant.id) } for server in cs.compute.servers.list(search_opts={'all_tenants': 1}): try: result[server.tenant_id]['instances'] += 1 except KeyError: pass global_images = 0 for image in list_all_images(cs.image.images): if image.is_public: global_images += 1 if image.owner in result: result[image.owner]['local-images'] += 1 if not image.is_public: result[image.owner]['total-images'] += 1 for value in result.itervalues(): value['total-images'] += global_images data = sorted(result.itervalues(), key=lambda s: s['href']) return make_collection_response(u'stats', data, parent_href=url_for('stats.altai_stats'))
def list_all_records(): parse_collection_request(_SCHEMA) result = [record_to_view(record) for record in AuditDAO.list_all()] return make_collection_response(u'audit-log', result)