diff options
author | Tzu-Mainn Chen <tzumainn@redhat.com> | 2013-06-24 18:14:29 -0400 |
---|---|---|
committer | Tomas Sedovic <tomas@sedovic.cz> | 2013-08-01 16:18:55 +0200 |
commit | a94deb53590b23a828dac5856a58b55f209502af (patch) | |
tree | 5813b950cf86437fed16ee804f4b29d4776ed5af | |
parent | 69b07ad7408d8f9a99a1d74bbe81feb56825d5d0 (diff) | |
download | tuskar-ui-a94deb53590b23a828dac5856a58b55f209502af.tar.gz |
Added additional flavor attributes to detail page
It looks like the database allows a flavor to be associated
with the same resource class multiple times. This is a bug,
in our temporary API, but one that should go away when the
"real" API comes into play, so I don't see the need to fix
it now.
The instance count returns something arbitrary for now.
Change-Id: I1ec11627babe5056bfc22fa737e1cab222313f5e
3 files changed, 30 insertions, 2 deletions
diff --git a/openstack_dashboard/api/management.py b/openstack_dashboard/api/management.py index 373e6d42..ec3e236f 100644 --- a/openstack_dashboard/api/management.py +++ b/openstack_dashboard/api/management.py @@ -469,6 +469,28 @@ class Flavor(StringIdAPIResourceWrapper): def swap_disk(self): return self.capacity('swap_disk') + @property + def resource_class_flavors(self): + if "_resource_class_flavors" not in self.__dict__: + self._resource_class_flavors = [ResourceClassFlavor(r) for r in ( + self._apiresource.resourceclassflavor_set.all())] + return self.__dict__['_resource_class_flavors'] + + @property + def resource_classes(self): + if "_resource_classes" not in self.__dict__: + added_flavors = self.resource_class_flavors + self._resource_classes = [] + for f in added_flavors: + self._resource_classes.append(ResourceClass(f.resource_class)) + + return self.__dict__['_resource_classes'] + + @property + def running_virtual_machines(self): + # arbitrary number + return len(self.resource_classes) * 2 + @classmethod def update(cls, request, flavor_id, name, vcpu, ram, root_disk, ephemeral_disk, swap_disk): diff --git a/openstack_dashboard/dashboards/infrastructure/resource_management/flavors/tests.py b/openstack_dashboard/dashboards/infrastructure/resource_management/flavors/tests.py index 43d428cc..636cdae0 100644 --- a/openstack_dashboard/dashboards/infrastructure/resource_management/flavors/tests.py +++ b/openstack_dashboard/dashboards/infrastructure/resource_management/flavors/tests.py @@ -99,6 +99,8 @@ class FlavorsTests(test.BaseAdminViewTests): api.management.Flavor.get(IsA(http.HttpRequest), flavor.id).AndReturn(flavor) + api.management.Flavor.resource_classes = self. \ + management_resource_classes self.mox.ReplayAll() diff --git a/openstack_dashboard/dashboards/infrastructure/resource_management/templates/resource_management/flavors/_detail_overview.html b/openstack_dashboard/dashboards/infrastructure/resource_management/templates/resource_management/flavors/_detail_overview.html index 86df0994..18d900a4 100644 --- a/openstack_dashboard/dashboards/infrastructure/resource_management/templates/resource_management/flavors/_detail_overview.html +++ b/openstack_dashboard/dashboards/infrastructure/resource_management/templates/resource_management/flavors/_detail_overview.html @@ -10,9 +10,13 @@ <dt>{% trans "Name" %}</dt> <dd>{{ flavor.name|default:_("None") }}</dd> <dt>{% trans "Classes" %}</dt> - <dd>TBD</dd> + <dd> + {% for resource_class in flavor.resource_classes %} + <dd><a href="{% url 'horizon:infrastructure:resource_management:resource_classes:detail' resource_class.id%}">{{ resource_class.name }}</a></dd> + {% endfor %} + </dd> <dt>{% trans "Instances" %}</dt> - <dd>TBD</dd> + <dd>{{ flavor.running_virtual_machines }}</dd> </dl> <h4>{% trans "Specification" %}</h4> <hr class="header_rule"> |