[Sahara] Replaced several IDs with names and names with links

Change-Id: I49cd489bcb1524859dfe09311e41c6f88bd804d3
Closes-Bug: #1367010
This commit is contained in:
Andrew Lazarev 2014-09-09 15:40:10 -07:00
parent 0a81213ab2
commit 2b1c8ecf4c
5 changed files with 37 additions and 8 deletions

View File

@ -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
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,

View File

@ -34,7 +34,7 @@
<dd>{% trans "Template not specified" %}</dd>
{% endif %}
<dt>{% trans "Base Image" %}</dt>
<dd>{{ base_image.name }}</dd>
<dd><a href="{% url 'horizon:project:images:images:detail' base_image.id %}">{{ base_image.name }}</a></dd>
{% if network %}
<dt>{% trans "Neutron Management Network" %}</dt>
<dd>{{ network }}</dd>

View File

@ -16,7 +16,7 @@
{% if node_group.floating_ip_pool %}
<dt>{% trans "Floating IP Pool" %}</dt>
<dd>{{ node_group.floating_ip_pool }}</dd>
<dd><a href="{% url 'horizon:project:networks:detail' node_group.floating_ip_pool %}">{{ node_group.floating_ip_pool_name }}</a></dd>
{% endif %}
<dt>{% trans "Template" %}</dt>

View File

@ -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):

View File

@ -17,7 +17,7 @@
{% if template.floating_ip_pool %}
<dl>
<dt>{% trans "Floating IP Pool" %}</dt>
<dd>{{ template.floating_ip_pool }}</dd>
<dd><a href="{% url 'horizon:project:networks:detail' template.floating_ip_pool %}">{{ floating_ip_pool_name }}</a></dd>
</dl>
{% endif %}
<dl>