From 2b1c8ecf4cfdaf79c68f2c4b503e8c2cb95b23b6 Mon Sep 17 00:00:00 2001 From: Andrew Lazarev Date: Tue, 9 Sep 2014 15:40:10 -0700 Subject: [PATCH] [Sahara] Replaced several IDs with names and names with links Change-Id: I49cd489bcb1524859dfe09311e41c6f88bd804d3 Closes-Bug: #1367010 --- .../project/data_processing/clusters/tabs.py | 19 ++++++++++++++---- .../data_processing.clusters/_details.html | 2 +- .../_nodegroups_details.html | 2 +- .../nodegroup_templates/tabs.py | 20 ++++++++++++++++++- .../_details.html | 2 +- 5 files changed, 37 insertions(+), 8 deletions(-) diff --git a/openstack_dashboard/dashboards/project/data_processing/clusters/tabs.py b/openstack_dashboard/dashboards/project/data_processing/clusters/tabs.py index e66ef966e9..bb0b4891ec 100644 --- a/openstack_dashboard/dashboards/project/data_processing/clusters/tabs.py +++ b/openstack_dashboard/dashboards/project/data_processing/clusters/tabs.py @@ -23,6 +23,7 @@ from openstack_dashboard.dashboards.project. \ data_processing.utils import workflow_helpers as helpers from openstack_dashboard.api import glance +from openstack_dashboard.api import network from openstack_dashboard.api import neutron from openstack_dashboard.api import nova @@ -93,10 +94,14 @@ class NodeGroupsTab(tabs.Tab): sahara = saharaclient.client(request) cluster = sahara.clusters.get(cluster_id) for ng in cluster.node_groups: - if not ng["flavor_id"]: - continue - ng["flavor_name"] = ( - nova.flavor_get(request, ng["flavor_id"]).name) + if ng["flavor_id"]: + ng["flavor_name"] = ( + nova.flavor_get(request, ng["flavor_id"]).name) + if ng["floating_ip_pool"]: + ng["floating_ip_pool_name"] = ( + self._get_floating_ip_pool_name( + request, ng["floating_ip_pool"])) + ng["node_group_template"] = helpers.safe_call( sahara.node_group_templates.get, ng.get("node_group_template_id", None)) @@ -107,6 +112,12 @@ class NodeGroupsTab(tabs.Tab): return {"cluster": cluster} + def _get_floating_ip_pool_name(self, request, pool_id): + pools = [pool for pool in network.floating_ip_pools_list( + request) if pool.id == pool_id] + + return pools[0].name if pools else pool_id + class Instance(object): def __init__(self, name=None, id=None, internal_ip=None, diff --git a/openstack_dashboard/dashboards/project/data_processing/clusters/templates/data_processing.clusters/_details.html b/openstack_dashboard/dashboards/project/data_processing/clusters/templates/data_processing.clusters/_details.html index e9e197141c..5c35cc4d9b 100644 --- a/openstack_dashboard/dashboards/project/data_processing/clusters/templates/data_processing.clusters/_details.html +++ b/openstack_dashboard/dashboards/project/data_processing/clusters/templates/data_processing.clusters/_details.html @@ -34,7 +34,7 @@
{% trans "Template not specified" %}
{% endif %}
{% trans "Base Image" %}
-
{{ base_image.name }}
+
{{ base_image.name }}
{% if network %}
{% trans "Neutron Management Network" %}
{{ network }}
diff --git a/openstack_dashboard/dashboards/project/data_processing/clusters/templates/data_processing.clusters/_nodegroups_details.html b/openstack_dashboard/dashboards/project/data_processing/clusters/templates/data_processing.clusters/_nodegroups_details.html index 321a1d4677..a89ee3ffff 100644 --- a/openstack_dashboard/dashboards/project/data_processing/clusters/templates/data_processing.clusters/_nodegroups_details.html +++ b/openstack_dashboard/dashboards/project/data_processing/clusters/templates/data_processing.clusters/_nodegroups_details.html @@ -16,7 +16,7 @@ {% if node_group.floating_ip_pool %}
{% trans "Floating IP Pool" %}
-
{{ node_group.floating_ip_pool }}
+
{{ node_group.floating_ip_pool_name }}
{% endif %}
{% trans "Template" %}
diff --git a/openstack_dashboard/dashboards/project/data_processing/nodegroup_templates/tabs.py b/openstack_dashboard/dashboards/project/data_processing/nodegroup_templates/tabs.py index ccb8f442fd..87352f73b1 100644 --- a/openstack_dashboard/dashboards/project/data_processing/nodegroup_templates/tabs.py +++ b/openstack_dashboard/dashboards/project/data_processing/nodegroup_templates/tabs.py @@ -18,6 +18,7 @@ from django.utils.translation import ugettext_lazy as _ from horizon import exceptions from horizon import tabs +from openstack_dashboard.api import network from openstack_dashboard.api import nova from openstack_dashboard.api import sahara as saharaclient @@ -46,7 +47,24 @@ class GeneralTab(tabs.Tab): flavor = {} exceptions.handle(request, _("Unable to fetch flavor for template.")) - return {"template": template, "flavor": flavor} + + floating_ip_pool_name = None + if template.floating_ip_pool: + try: + floating_ip_pool_name = self._get_floating_ip_pool_name( + request, template.floating_ip_pool) + except Exception: + exceptions.handle(request, + _("Unable to fetch floating ip pools.")) + + return {"template": template, "flavor": flavor, + "floating_ip_pool_name": floating_ip_pool_name} + + def _get_floating_ip_pool_name(self, request, pool_id): + pools = [pool for pool in network.floating_ip_pools_list( + request) if pool.id == pool_id] + + return pools[0].name if pools else pool_id class ConfigsTab(tabs.Tab): diff --git a/openstack_dashboard/dashboards/project/data_processing/nodegroup_templates/templates/data_processing.nodegroup_templates/_details.html b/openstack_dashboard/dashboards/project/data_processing/nodegroup_templates/templates/data_processing.nodegroup_templates/_details.html index a9507c9709..42b9d15437 100644 --- a/openstack_dashboard/dashboards/project/data_processing/nodegroup_templates/templates/data_processing.nodegroup_templates/_details.html +++ b/openstack_dashboard/dashboards/project/data_processing/nodegroup_templates/templates/data_processing.nodegroup_templates/_details.html @@ -17,7 +17,7 @@ {% if template.floating_ip_pool %}
{% trans "Floating IP Pool" %}
-
{{ template.floating_ip_pool }}
+
{{ floating_ip_pool_name }}
{% endif %}