From e2b3ac88540dcb2d3e5f2666ce12df4e14392f9c Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Wed, 28 Mar 2012 18:50:44 +0000 Subject: [PATCH] Fix display of volumes and snapshots * displayName -> display_name * displayDescription -> display_description * serverId -> server_id * volumeId -> volume_id * fixes bug 967408 Change-Id: I05b66716246be4f010719a51c242dc74811549c0 --- .../nova/images_and_snapshots/images/views.py | 4 ++-- .../volume_snapshots/tables.py | 2 +- .../volume_snapshots/tests.py | 8 ++++---- .../instances_and_volumes/volumes/forms.py | 2 +- .../instances_and_volumes/volumes/tables.py | 18 +++++++++--------- .../nova/instances_and_volumes/volumes/tabs.py | 3 ++- .../instances_and_volumes/volumes/tests.py | 2 +- .../instances/_detail_overview.html | 4 ++-- .../volumes/_detail_overview.html | 10 +++++----- horizon/tests/test_data/nova_data.py | 8 ++++---- 10 files changed, 31 insertions(+), 30 deletions(-) diff --git a/horizon/dashboards/nova/images_and_snapshots/images/views.py b/horizon/dashboards/nova/images_and_snapshots/images/views.py index f30614566..1ec1eaef7 100644 --- a/horizon/dashboards/nova/images_and_snapshots/images/views.py +++ b/horizon/dashboards/nova/images_and_snapshots/images/views.py @@ -111,14 +111,14 @@ class LaunchView(forms.ModalFormView): volume_options = [("", _("Select Volume"))] def _get_volume_select_item(volume): - if hasattr(volume, "volumeId"): + if hasattr(volume, "volume_id"): vol_type = "snap" visible_label = _("Snapshot") else: vol_type = "vol" visible_label = _("Volume") return (("%s:%s" % (volume.id, vol_type)), - ("%s - %s GB (%s)" % (volume.displayName, + ("%s - %s GB (%s)" % (volume.display_name, volume.size, visible_label))) diff --git a/horizon/dashboards/nova/images_and_snapshots/volume_snapshots/tables.py b/horizon/dashboards/nova/images_and_snapshots/volume_snapshots/tables.py index 5868e0bbf..eb3a4e5c6 100644 --- a/horizon/dashboards/nova/images_and_snapshots/volume_snapshots/tables.py +++ b/horizon/dashboards/nova/images_and_snapshots/volume_snapshots/tables.py @@ -35,7 +35,7 @@ class DeleteVolumeSnapshot(tables.DeleteAction): class VolumeSnapshotsTable(volume_tables.VolumesTableBase): - volume_id = tables.Column("volumeId", verbose_name=_("Volume ID")) + volume_id = tables.Column("volume_id", verbose_name=_("Volume ID")) class Meta: name = "volume_snapshots" diff --git a/horizon/dashboards/nova/images_and_snapshots/volume_snapshots/tests.py b/horizon/dashboards/nova/images_and_snapshots/volume_snapshots/tests.py index a6315f80c..26beb2c54 100644 --- a/horizon/dashboards/nova/images_and_snapshots/volume_snapshots/tests.py +++ b/horizon/dashboards/nova/images_and_snapshots/volume_snapshots/tests.py @@ -46,16 +46,16 @@ class VolumeSnapshotsViewTests(test.TestCase): self.mox.StubOutWithMock(api, 'volume_snapshot_create') api.volume_snapshot_create(IsA(http.HttpRequest), volume.id, - snapshot.displayName, - snapshot.displayDescription) \ + snapshot.display_name, + snapshot.display_description) \ .AndReturn(snapshot) self.mox.ReplayAll() formData = {'method': 'CreateSnapshotForm', 'tenant_id': self.tenant.id, 'volume_id': volume.id, - 'name': snapshot.displayName, - 'description': snapshot.displayDescription} + 'name': snapshot.display_name, + 'description': snapshot.display_description} url = reverse('horizon:nova:instances_and_volumes:volumes:' 'create_snapshot', args=[volume.id]) res = self.client.post(url, formData) diff --git a/horizon/dashboards/nova/instances_and_volumes/volumes/forms.py b/horizon/dashboards/nova/instances_and_volumes/volumes/forms.py index 246a77d2f..818b90637 100644 --- a/horizon/dashboards/nova/instances_and_volumes/volumes/forms.py +++ b/horizon/dashboards/nova/instances_and_volumes/volumes/forms.py @@ -75,7 +75,7 @@ class AttachForm(forms.SelfHandlingForm): data['volume_id'], data['instance'], data['device']) - vol_name = api.volume_get(request, data['volume_id']).displayName + vol_name = api.volume_get(request, data['volume_id']).display_name message = (_('Attaching volume %(vol)s to instance ' '%(inst)s at %(dev)s') % diff --git a/horizon/dashboards/nova/instances_and_volumes/volumes/tables.py b/horizon/dashboards/nova/instances_and_volumes/volumes/tables.py index 8dba8332b..50ddac639 100644 --- a/horizon/dashboards/nova/instances_and_volumes/volumes/tables.py +++ b/horizon/dashboards/nova/instances_and_volumes/volumes/tables.py @@ -90,10 +90,10 @@ def get_attachment(volume): # Filter out "empty" attachments which the client returns... for attachment in [att for att in volume.attachments if att]: url = reverse("%s:instances:detail" % URL_PREFIX, - args=(attachment["serverId"],)) + args=(attachment["server_id"],)) # TODO(jake): Make "instance" the instance name vals = {"url": url, - "instance": attachment["serverId"], + "instance": attachment["server_id"], "dev": attachment["device"]} attachments.append(link % vals) return safestring.mark_safe(", ".join(attachments)) @@ -106,9 +106,9 @@ class VolumesTableBase(tables.DataTable): ("creating", None), ("error", False), ) - name = tables.Column("displayName", verbose_name=_("Name"), + name = tables.Column("display_name", verbose_name=_("Name"), link="%s:volumes:detail" % URL_PREFIX) - description = tables.Column("displayDescription", + description = tables.Column("display_description", verbose_name=_("Description")) size = tables.Column(get_size, verbose_name=_("Size")) status = tables.Column("status", @@ -118,11 +118,11 @@ class VolumesTableBase(tables.DataTable): status_choices=STATUS_CHOICES) def get_object_display(self, obj): - return obj.displayName + return obj.display_name class VolumesTable(VolumesTableBase): - name = tables.Column("displayName", + name = tables.Column("display_name", verbose_name=_("Name"), link="%s:volumes:detail" % URL_PREFIX) attachments = tables.Column(get_attachment, @@ -146,7 +146,7 @@ class DetachVolume(tables.BatchAction): classes = ('btn-danger', 'btn-detach') def action(self, request, obj_id): - instance_id = self.table.get_object_by_id(obj_id)['serverId'] + instance_id = self.table.get_object_by_id(obj_id)['server_id'] api.volume_detach(request, instance_id, obj_id) def get_success_url(self, request): @@ -154,7 +154,7 @@ class DetachVolume(tables.BatchAction): class AttachmentsTable(tables.DataTable): - instance = tables.Column("serverId", verbose_name=_("Instance")) + instance = tables.Column("server_id", verbose_name=_("Instance")) device = tables.Column("device") def get_object_id(self, obj): @@ -162,7 +162,7 @@ class AttachmentsTable(tables.DataTable): def get_object_display(self, obj): vals = {"dev": obj['device'], - "instance": obj['serverId']} + "instance": obj['server_id']} return "Attachment %(dev)s on %(instance)s" % vals def get_object_by_id(self, obj_id): diff --git a/horizon/dashboards/nova/instances_and_volumes/volumes/tabs.py b/horizon/dashboards/nova/instances_and_volumes/volumes/tabs.py index 07b27b77a..d3836604e 100644 --- a/horizon/dashboards/nova/instances_and_volumes/volumes/tabs.py +++ b/horizon/dashboards/nova/instances_and_volumes/volumes/tabs.py @@ -33,7 +33,8 @@ class OverviewTab(tabs.Tab): try: volume = api.nova.volume_get(request, volume_id) for att in volume.attachments: - att['instance'] = api.nova.server_get(request, att['serverId']) + att['instance'] = api.nova.server_get(request, + att['server_id']) except: redirect = reverse('horizon:nova:instances_and_volumes:index') exceptions.handle(self.request, diff --git a/horizon/dashboards/nova/instances_and_volumes/volumes/tests.py b/horizon/dashboards/nova/instances_and_volumes/volumes/tests.py index 9ef8adc1c..b6bf901ec 100644 --- a/horizon/dashboards/nova/instances_and_volumes/volumes/tests.py +++ b/horizon/dashboards/nova/instances_and_volumes/volumes/tests.py @@ -49,7 +49,7 @@ class VolumeViewTests(test.TestCase): def test_detail_view(self): volume = self.volumes.first() server = self.servers.first() - volume.attachments = [{"serverId": server.id}] + volume.attachments = [{"server_id": server.id}] self.mox.StubOutWithMock(api.nova, 'volume_get') self.mox.StubOutWithMock(api.nova, 'server_get') api.nova.volume_get(IsA(http.HttpRequest), volume.id).AndReturn(volume) diff --git a/horizon/dashboards/nova/templates/nova/instances_and_volumes/instances/_detail_overview.html b/horizon/dashboards/nova/templates/nova/instances_and_volumes/instances/_detail_overview.html index aa89de27a..b5b4141a5 100644 --- a/horizon/dashboards/nova/templates/nova/instances_and_volumes/instances/_detail_overview.html +++ b/horizon/dashboards/nova/templates/nova/instances_and_volumes/instances/_detail_overview.html @@ -80,8 +80,8 @@ {% for volume in instance.volumes %}
  • {% trans "Volume" %}: - - {{ volume.volumeId }} ({{ volume.device }}) + + {{ volume.volume_id }} ({{ volume.device }})
  • {% endfor %} diff --git a/horizon/dashboards/nova/templates/nova/instances_and_volumes/volumes/_detail_overview.html b/horizon/dashboards/nova/templates/nova/instances_and_volumes/volumes/_detail_overview.html index 0b1c5d14e..33e056394 100644 --- a/horizon/dashboards/nova/templates/nova/instances_and_volumes/volumes/_detail_overview.html +++ b/horizon/dashboards/nova/templates/nova/instances_and_volumes/volumes/_detail_overview.html @@ -1,15 +1,15 @@ {% load i18n sizeformat parse_date %} -

    {% trans "Volume Overview" %}: {{volume.displayName }}

    +

    {% trans "Volume Overview" %}: {{volume.display_name }}

    {% trans "Info" %}


    @@ -38,7 +38,7 @@ {% for attachment in volume.attachments %}
  • {% trans "Attached To" %}: - {% url horizon:nova:instances_and_volumes:volumes:detail attachment.serverId as instance_url%} + {% url horizon:nova:instances_and_volumes:volumes:detail attachment.server_id as instance_url%} {% trans "Instance" %} {{ attachment.instance.id }} ({{ attachment.instance.name }}) {% trans "on" %} {{ attachment.device }}
  • diff --git a/horizon/tests/test_data/nova_data.py b/horizon/tests/test_data/nova_data.py index 71b765e82..3f1387402 100644 --- a/horizon/tests/test_data/nova_data.py +++ b/horizon/tests/test_data/nova_data.py @@ -147,7 +147,7 @@ def data(TEST): name='test_volume', status='available', size=40, - displayName='', + display_name='', attachments={})) TEST.volumes.add(volume) @@ -275,11 +275,11 @@ def data(TEST): volume_snapshot = vol_snaps.Snapshot(vol_snaps.SnapshotManager(None), {'id': 2, - 'displayName': 'test snapshot', - 'displayDescription': 'vol snap!', + 'display_name': 'test snapshot', + 'display_description': 'vol snap!', 'size': 40, 'status': 'available', - 'volumeId': 1}) + 'volume_id': 1}) TEST.volume_snapshots.add(volume_snapshot) cert_data = {'private_key': 'private',