summaryrefslogtreecommitdiff
path: root/openstack_dashboard
diff options
context:
space:
mode:
authorBradley Jones <jones.bradley@me.com>2013-06-05 15:21:10 -0700
committerBradley Jones <jones.bradley@me.com>2013-06-17 11:40:13 -0700
commitfb5df6bbc4ac9bebde1fce23be8f321c0234fca1 (patch)
tree99501bba0faf2b06bbefb0d24fd1ad7dbf850283 /openstack_dashboard
parentd17fd51359ef915e59e053401dec0e8a952dfbe8 (diff)
downloadtuskar-ui-fb5df6bbc4ac9bebde1fce23be8f321c0234fca1.tar.gz
Only display tenant resources in network topology when admin
Change how the JSON renders so that it checks for tenant IDs but still allows shared and external networks to be shown for each project, no longer directly accesses the python clients instead uses the api class. Change-Id: I1c4c97cf0bc6df3c13be2b1b97fe621817425c09 Fixes: bug #1151101
Diffstat (limited to 'openstack_dashboard')
-rw-r--r--openstack_dashboard/dashboards/project/network_topology/views.py69
1 files changed, 56 insertions, 13 deletions
diff --git a/openstack_dashboard/dashboards/project/network_topology/views.py b/openstack_dashboard/dashboards/project/network_topology/views.py
index 040e85c9..cde289d7 100644
--- a/openstack_dashboard/dashboards/project/network_topology/views.py
+++ b/openstack_dashboard/dashboards/project/network_topology/views.py
@@ -51,29 +51,72 @@ class JSONView(View):
def get(self, request, *args, **kwargs):
data = {}
# Get nova data
- novaclient = api.nova.novaclient(request)
- servers = novaclient.servers.list()
+ try:
+ servers, more = api.nova.server_list(request)
+ except:
+ servers = []
data['servers'] = [{'name': server.name,
'status': server.status,
'id': server.id} for server in servers]
self.add_resource_url('horizon:project:instances:detail',
data['servers'])
+
# Get quantum data
- quantumclient = api.quantum.quantumclient(request)
- networks = quantumclient.list_networks()
- subnets = quantumclient.list_subnets()
- ports = quantumclient.list_ports()
- routers = quantumclient.list_routers()
- data['networks'] = sorted(networks.get('networks', []),
+ try:
+ quantum_public_networks = api.quantum.network_list(request,
+ **{'router:external': True})
+ quantum_networks = api.quantum.network_list_for_tenant(request,
+ request.user.tenant_id)
+ quantum_subnets = api.quantum.subnet_list(request,
+ tenant_id=request.user.tenant_id)
+ quantum_ports = api.quantum.port_list(request,
+ tenant_id=request.user.tenant_id)
+ quantum_routers = api.quantum.router_list(request,
+ tenant_id=request.user.tenant_id)
+ except:
+ quantum_public_networks = []
+ quantum_networks = []
+ quantum_subnets = []
+ quantum_ports = []
+ quantum_routers = []
+
+ networks = [{'name': network.name,
+ 'id': network.id,
+ 'router:external': network['router:external']}
+ for network in quantum_networks]
+ self.add_resource_url('horizon:project:networks:detail',
+ networks)
+ # Add public networks to the networks list
+ for publicnet in quantum_public_networks:
+ found = False
+ for network in networks:
+ if publicnet.id == network['id']:
+ found = True
+ if not found:
+ networks.append({'name': publicnet.name,
+ 'id': publicnet.id,
+ 'router:external': publicnet['router:external']})
+ data['networks'] = sorted(networks,
key=lambda x: x.get('router:external'),
reverse=True)
- self.add_resource_url('horizon:project:networks:detail',
- data['networks'])
- data['subnets'] = subnets.get('subnets', [])
- data['ports'] = ports.get('ports', [])
+
+ data['subnets'] = [{'id': subnet.id,
+ 'cidr': subnet.cidr,
+ 'network_id': subnet.network_id}
+ for subnet in quantum_subnets]
+
+ data['ports'] = [{'id': port.id,
+ 'network_id': port.network_id,
+ 'device_id': port.device_id,
+ 'fixed_ips': port.fixed_ips} for port in quantum_ports]
self.add_resource_url('horizon:project:networks:ports:detail',
data['ports'])
- data['routers'] = routers.get('routers', [])
+
+ data['routers'] = [{'id': router.id,
+ 'name': router.name,
+ 'external_gateway_info': router.external_gateway_info}
+ for router in quantum_routers]
+
# user can't see port on external network. so we are
# adding fake port based on router information
for router in data['routers']: