Merge "UUID Cleanup."
This commit is contained in:
commit
ede50840aa
@ -482,11 +482,23 @@ def volume_list(request):
|
||||
|
||||
|
||||
def volume_get(request, volume_id):
|
||||
return cinderclient(request).volumes.get(volume_id)
|
||||
volume_data = cinderclient(request).volumes.get(volume_id)
|
||||
|
||||
for attachment in volume_data.attachments:
|
||||
instance = server_get(request, attachment['server_id'])
|
||||
attachment[u'instance_name'] = instance.name
|
||||
|
||||
return volume_data
|
||||
|
||||
|
||||
def volume_instance_list(request, instance_id):
|
||||
return novaclient(request).volumes.get_server_volumes(instance_id)
|
||||
volumes = novaclient(request).volumes.get_server_volumes(instance_id)
|
||||
|
||||
for volume in volumes:
|
||||
volume_data = cinderclient(request).volumes.get(volume.id)
|
||||
volume.name = volume_data.display_name
|
||||
|
||||
return volumes
|
||||
|
||||
|
||||
def volume_create(request, size, name, description):
|
||||
|
@ -81,15 +81,14 @@ class InstancesAndVolumesViewTest(test.TestCase):
|
||||
self.assertItemsEqual(resp_volumes, volumes)
|
||||
|
||||
self.assertContains(res, ">Volume name<", 1, 200)
|
||||
self.assertContains(res, ">40 GB<", 1, 200)
|
||||
self.assertContains(res, ">40GB<", 1, 200)
|
||||
self.assertContains(res, ">Available<", 1, 200)
|
||||
|
||||
self.assertContains(res, ">Volume2 name<", 1, 200)
|
||||
self.assertContains(res, ">80 GB<", 1, 200)
|
||||
self.assertContains(res, ">80GB<", 1, 200)
|
||||
self.assertContains(res, ">In-Use<", 1, 200)
|
||||
self.assertContains(res,
|
||||
">Instance server_1 (1)</a> on /dev/hdn",
|
||||
1, 200)
|
||||
self.assertContains(res, ">server_1<", 2, 200)
|
||||
self.assertContains(res, "(/dev/hdn)", 1, 200)
|
||||
|
||||
def test_index_server_list_exception(self):
|
||||
self.mox.StubOutWithMock(api, 'server_list')
|
||||
|
@ -22,6 +22,7 @@
|
||||
"""
|
||||
Views for Instances and Volumes.
|
||||
"""
|
||||
import re
|
||||
import logging
|
||||
|
||||
from django.contrib import messages
|
||||
@ -70,6 +71,17 @@ class IndexView(tables.MultiTableView):
|
||||
instances = SortedDict([(inst.id, inst) for inst in
|
||||
self._get_instances()])
|
||||
for volume in volumes:
|
||||
# Truncate the description for proper display.
|
||||
if len(getattr(volume, 'display_description', '')) > 33:
|
||||
truncated_string = volume.display_description[:30].strip()
|
||||
# Remove non-word, and underscore characters, from the end
|
||||
# of the string before we add the ellepsis.
|
||||
truncated_string = re.sub(ur'[^\w\s]+$',
|
||||
'',
|
||||
truncated_string)
|
||||
|
||||
volume.display_description = truncated_string + u'...'
|
||||
|
||||
for att in volume.attachments:
|
||||
att['instance'] = instances[att['server_id']]
|
||||
except novaclient_exceptions.ClientException, e:
|
||||
|
@ -80,13 +80,12 @@ class UpdateRow(tables.Row):
|
||||
|
||||
|
||||
def get_size(volume):
|
||||
return _("%s GB") % volume.size
|
||||
return _("%sGB") % volume.size
|
||||
|
||||
|
||||
def get_attachment(volume):
|
||||
attachments = []
|
||||
link = '<a href="%(url)s">Instance %(name)s (%(instance)s)</a> ' \
|
||||
'on %(dev)s'
|
||||
link = '<a href="%(url)s">%(name)s</a> (%(dev)s)'
|
||||
# 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,
|
||||
@ -128,7 +127,7 @@ class VolumesTable(VolumesTableBase):
|
||||
verbose_name=_("Name"),
|
||||
link="%s:volumes:detail" % URL_PREFIX)
|
||||
attachments = tables.Column(get_attachment,
|
||||
verbose_name=_("Attachments"))
|
||||
verbose_name=_("Attached To"))
|
||||
|
||||
class Meta:
|
||||
name = "volumes"
|
||||
@ -156,7 +155,7 @@ class DetachVolume(tables.BatchAction):
|
||||
|
||||
|
||||
class AttachmentsTable(tables.DataTable):
|
||||
instance = tables.Column("server_id", verbose_name=_("Instance"))
|
||||
instance = tables.Column("instance_name", verbose_name=_("Instance Name"))
|
||||
device = tables.Column("device")
|
||||
|
||||
def get_object_id(self, obj):
|
||||
|
@ -104,7 +104,7 @@ class VolumeViewTests(test.TestCase):
|
||||
self.assertContains(res, "<dd>40 GB</dd>", 1, 200)
|
||||
self.assertContains(res, "<dd>04/01/12 at 10:30:00</dd>", 1, 200)
|
||||
self.assertContains(res, "<a href=\"/nova/instances_and_volumes/"
|
||||
"instances/1/detail\">Instance server_1 "
|
||||
"instances/1/detail\"><strong>server_1</strong> "
|
||||
"(1)</a>", 1, 200)
|
||||
|
||||
self.assertNoMessages()
|
||||
|
@ -79,14 +79,14 @@
|
||||
</div>
|
||||
|
||||
<div class="volumes row-fluid detail">
|
||||
<h4>{% trans "Volumes" %}</h4>
|
||||
<h4>{% trans "Volumes Attached" %}</h4>
|
||||
<hr class="header_rule">
|
||||
<dl>
|
||||
{% for volume in instance.volumes %}
|
||||
<dt>{% trans "Volume" %}</dt>
|
||||
<dt>{% trans "Attached On" %} {{ volume.device }}</dt>
|
||||
<dd>
|
||||
<a href="{% url horizon:nova:instances_and_volumes:volumes:detail volume.volumeId %}">
|
||||
{{ volume.volumeId }} ({{ volume.device }})
|
||||
<strong>{{ volume.name }}</strong> ({{ volume.id }})
|
||||
</a>
|
||||
</dd>
|
||||
{% empty %}
|
||||
|
@ -38,7 +38,7 @@
|
||||
<dt>{% trans "Attached To" %}</dt>
|
||||
<dd>
|
||||
{% url horizon:nova:instances_and_volumes:instances:detail attachment.server_id as instance_url%}
|
||||
<a href="{{ instance_url }}">{% trans "Instance" %} {{ attachment.instance.name }} ({{ attachment.instance.id }})</a>
|
||||
<a href="{{ instance_url }}"><strong>{{ attachment.instance.name }}</strong> ({{ attachment.instance.id }})</a>
|
||||
<span> {% trans "on" %} {{ attachment.device }}</span>
|
||||
</dd>
|
||||
{% empty %}
|
||||
|
Loading…
x
Reference in New Issue
Block a user