Fix display of volumes and snapshots
* displayName -> display_name * displayDescription -> display_description * serverId -> server_id * volumeId -> volume_id * fixes bug 967408 Change-Id: I05b66716246be4f010719a51c242dc74811549c0
This commit is contained in:
parent
b2ff1ee446
commit
e2b3ac8854
@ -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)))
|
||||
|
||||
|
@ -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"
|
||||
|
@ -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)
|
||||
|
@ -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') %
|
||||
|
@ -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):
|
||||
|
@ -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,
|
||||
|
@ -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)
|
||||
|
@ -80,8 +80,8 @@
|
||||
{% for volume in instance.volumes %}
|
||||
<li>
|
||||
<strong>{% trans "Volume" %}:</strong>
|
||||
<a href="{% url horizon:nova:instances_and_volumes:volumes:detail volume.volumeId %}">
|
||||
{{ volume.volumeId }} ({{ volume.device }})
|
||||
<a href="{% url horizon:nova:instances_and_volumes:volumes:detail volume.volume_id %}">
|
||||
{{ volume.volume_id }} ({{ volume.device }})
|
||||
</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
|
@ -1,15 +1,15 @@
|
||||
{% load i18n sizeformat parse_date %}
|
||||
|
||||
<h3>{% trans "Volume Overview" %}: {{volume.displayName }}</h3>
|
||||
<h3>{% trans "Volume Overview" %}: {{volume.display_name }}</h3>
|
||||
|
||||
<div class="info row-fluid">
|
||||
<h4>{% trans "Info" %}</h4>
|
||||
<hr class="header_rule">
|
||||
<ul>
|
||||
<li><strong>{% trans "Name" %}:</strong> {{ volume.displayName }}</li>
|
||||
<li><strong>{% trans "Name" %}:</strong> {{ volume.display_name }}</li>
|
||||
<li><strong>{% trans "ID" %}:</strong> {{ volume.id }}</li>
|
||||
{% if volume.displayDescription %}
|
||||
<li><strong>{% trans "Description" %}:</strong> {{ volume.displayDescription }}</li>
|
||||
{% if volume.display_description %}
|
||||
<li><strong>{% trans "Description" %}:</strong> {{ volume.display_description }}</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</div>
|
||||
@ -38,7 +38,7 @@
|
||||
{% for attachment in volume.attachments %}
|
||||
<li>
|
||||
<strong>{% trans "Attached To" %}:</strong>
|
||||
{% 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%}
|
||||
<a href="{{ instance_url }}">{% trans "Instance" %} {{ attachment.instance.id }} ({{ attachment.instance.name }})</a>
|
||||
<span>{% trans "on" %} {{ attachment.device }}</span>
|
||||
</li>
|
||||
|
@ -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',
|
||||
|
Loading…
x
Reference in New Issue
Block a user