Made instance state values in the CSV summary translatable
The instance state values ("Active", "Stopped" and others) captured in the CSV Summary from the Project Overview page were not translatable. Two changes were needed. Some of the possible values from Nova were missing from the STATUS_DISPLAY_CHOICES tuple and needed to be added. Then the state values needed to be translated into the proper locale when the CSV was built. It should be noted that I used the same style Lucas Palm proposed in change 226579 (launchpad 1490031) for the second change. Change-Id: Ib52d4c1fade22199390c6a568fc8f1101784a88d Closes-Bug: #1496953
This commit is contained in:
parent
483fd0fa93
commit
c0561280de
@ -1003,6 +1003,11 @@ STATUS_DISPLAY_CHOICES = (
|
||||
("shelved", pgettext_lazy("Current status of an Instance", u"Shelved")),
|
||||
("shelved_offloaded", pgettext_lazy("Current status of an Instance",
|
||||
u"Shelved Offloaded")),
|
||||
# these vm states are used when generating CSV usage summary
|
||||
("building", pgettext_lazy("Current status of an Instance", u"Building")),
|
||||
("stopped", pgettext_lazy("Current status of an Instance", u"Stopped")),
|
||||
("rescued", pgettext_lazy("Current status of an Instance", u"Rescued")),
|
||||
("resized", pgettext_lazy("Current status of an Instance", u"Resized")),
|
||||
)
|
||||
|
||||
TASK_DISPLAY_NONE = pgettext_lazy("Task status of an Instance", u"None")
|
||||
|
@ -26,6 +26,11 @@ from horizon import views
|
||||
|
||||
from openstack_dashboard import usage
|
||||
|
||||
from openstack_dashboard.dashboards.project.instances \
|
||||
import tables as project_tables
|
||||
|
||||
from openstack_dashboard.utils import filters
|
||||
|
||||
|
||||
class ProjectUsageCsvRenderer(csvbase.BaseCsvResponse):
|
||||
|
||||
@ -35,14 +40,17 @@ class ProjectUsageCsvRenderer(csvbase.BaseCsvResponse):
|
||||
|
||||
def get_row_data(self):
|
||||
|
||||
choices = project_tables.STATUS_DISPLAY_CHOICES
|
||||
for inst in self.context['usage'].get_instances():
|
||||
state_label = (
|
||||
filters.get_display_label(choices, inst['state']))
|
||||
yield (inst['name'],
|
||||
inst['vcpus'],
|
||||
inst['memory_mb'],
|
||||
inst['local_gb'],
|
||||
floatformat(inst['hours'], 2),
|
||||
inst['uptime'],
|
||||
capfirst(inst['state']))
|
||||
capfirst(state_label))
|
||||
|
||||
|
||||
class ProjectOverview(usage.UsageView):
|
||||
|
Loading…
x
Reference in New Issue
Block a user