Merge "* Removes instance ID from create volume snapshot Fixes launchpad bug #1039080 * Changes volume id to name in volume snapshot Fixes launchpad bug #1039082"
This commit is contained in:
commit
a9604ef6b5
@ -34,8 +34,8 @@ LOG = logging.getLogger(__name__)
|
|||||||
|
|
||||||
class CreateSnapshot(forms.SelfHandlingForm):
|
class CreateSnapshot(forms.SelfHandlingForm):
|
||||||
instance_id = forms.CharField(label=_("Instance ID"),
|
instance_id = forms.CharField(label=_("Instance ID"),
|
||||||
widget=forms.TextInput(
|
widget=forms.HiddenInput(),
|
||||||
attrs={'readonly': 'readonly'}))
|
required=False)
|
||||||
name = forms.CharField(max_length="20", label=_("Snapshot Name"))
|
name = forms.CharField(max_length="20", label=_("Snapshot Name"))
|
||||||
|
|
||||||
def handle(self, request, data):
|
def handle(self, request, data):
|
||||||
|
@ -31,14 +31,25 @@ INDEX_URL = reverse('horizon:nova:images_and_snapshots:index')
|
|||||||
|
|
||||||
|
|
||||||
class ImagesAndSnapshotsTests(test.TestCase):
|
class ImagesAndSnapshotsTests(test.TestCase):
|
||||||
|
@test.create_stubs({api: ('image_list_detailed', 'snapshot_list_detailed',
|
||||||
|
'volume_snapshot_list', 'volume_get',)})
|
||||||
def test_index(self):
|
def test_index(self):
|
||||||
images = self.images.list()
|
images = self.images.list()
|
||||||
snapshots = self.snapshots.list()
|
snapshots = self.snapshots.list()
|
||||||
self.mox.StubOutWithMock(api, 'image_list_detailed')
|
volumes = self.volumes.list()
|
||||||
self.mox.StubOutWithMock(api, 'snapshot_list_detailed')
|
|
||||||
self.mox.StubOutWithMock(api, 'volume_snapshot_list')
|
for volume in volumes:
|
||||||
|
volume.volume_id = volume.id
|
||||||
|
for volume in volumes:
|
||||||
|
api.volume_get(IsA(http.HttpRequest), volume.volume_id) \
|
||||||
|
.AndReturn(volume)
|
||||||
|
for volume in volumes:
|
||||||
|
api.volume_get(IsA(http.HttpRequest), volume.volume_id) \
|
||||||
|
.AndReturn(volume)
|
||||||
|
api.volume_get(IsA(http.HttpRequest), volume.volume_id)
|
||||||
|
|
||||||
api.volume_snapshot_list(IsA(http.HttpRequest)) \
|
api.volume_snapshot_list(IsA(http.HttpRequest)) \
|
||||||
.AndReturn(self.volumes.list())
|
.AndReturn(volumes)
|
||||||
api.image_list_detailed(IsA(http.HttpRequest),
|
api.image_list_detailed(IsA(http.HttpRequest),
|
||||||
marker=None).AndReturn([images, False])
|
marker=None).AndReturn([images, False])
|
||||||
api.snapshot_list_detailed(IsA(http.HttpRequest),
|
api.snapshot_list_detailed(IsA(http.HttpRequest),
|
||||||
@ -53,12 +64,23 @@ class ImagesAndSnapshotsTests(test.TestCase):
|
|||||||
filtered_images = filter(filter_func, images)
|
filtered_images = filter(filter_func, images)
|
||||||
self.assertItemsEqual(images, filtered_images)
|
self.assertItemsEqual(images, filtered_images)
|
||||||
|
|
||||||
|
@test.create_stubs({api: ('image_list_detailed', 'snapshot_list_detailed',
|
||||||
|
'volume_snapshot_list', 'volume_get',)})
|
||||||
def test_index_no_images(self):
|
def test_index_no_images(self):
|
||||||
self.mox.StubOutWithMock(api, 'snapshot_list_detailed')
|
volumes = self.volumes.list()
|
||||||
self.mox.StubOutWithMock(api, 'image_list_detailed')
|
|
||||||
self.mox.StubOutWithMock(api, 'volume_snapshot_list')
|
for volume in volumes:
|
||||||
|
volume.volume_id = volume.id
|
||||||
|
for volume in volumes:
|
||||||
|
api.volume_get(IsA(http.HttpRequest), volume.volume_id) \
|
||||||
|
.AndReturn(volume)
|
||||||
|
for volume in volumes:
|
||||||
|
api.volume_get(IsA(http.HttpRequest), volume.volume_id) \
|
||||||
|
.AndReturn(volume)
|
||||||
|
api.volume_get(IsA(http.HttpRequest), volume.volume_id)
|
||||||
|
|
||||||
api.volume_snapshot_list(IsA(http.HttpRequest)) \
|
api.volume_snapshot_list(IsA(http.HttpRequest)) \
|
||||||
.AndReturn(self.volumes.list())
|
.AndReturn(volumes)
|
||||||
api.image_list_detailed(IsA(http.HttpRequest),
|
api.image_list_detailed(IsA(http.HttpRequest),
|
||||||
marker=None).AndReturn([(), False])
|
marker=None).AndReturn([(), False])
|
||||||
api.snapshot_list_detailed(IsA(http.HttpRequest), marker=None) \
|
api.snapshot_list_detailed(IsA(http.HttpRequest), marker=None) \
|
||||||
@ -68,12 +90,23 @@ class ImagesAndSnapshotsTests(test.TestCase):
|
|||||||
res = self.client.get(INDEX_URL)
|
res = self.client.get(INDEX_URL)
|
||||||
self.assertTemplateUsed(res, 'nova/images_and_snapshots/index.html')
|
self.assertTemplateUsed(res, 'nova/images_and_snapshots/index.html')
|
||||||
|
|
||||||
|
@test.create_stubs({api: ('image_list_detailed', 'snapshot_list_detailed',
|
||||||
|
'volume_snapshot_list', 'volume_get',)})
|
||||||
def test_index_error(self):
|
def test_index_error(self):
|
||||||
self.mox.StubOutWithMock(api, 'image_list_detailed')
|
volumes = self.volumes.list()
|
||||||
self.mox.StubOutWithMock(api, 'snapshot_list_detailed')
|
|
||||||
self.mox.StubOutWithMock(api, 'volume_snapshot_list')
|
for volume in volumes:
|
||||||
|
volume.volume_id = volume.id
|
||||||
|
for volume in volumes:
|
||||||
|
api.volume_get(IsA(http.HttpRequest), volume.volume_id) \
|
||||||
|
.AndReturn(volume)
|
||||||
|
for volume in volumes:
|
||||||
|
api.volume_get(IsA(http.HttpRequest), volume.volume_id) \
|
||||||
|
.AndReturn(volume)
|
||||||
|
api.volume_get(IsA(http.HttpRequest), volume.volume_id)
|
||||||
|
|
||||||
api.volume_snapshot_list(IsA(http.HttpRequest)) \
|
api.volume_snapshot_list(IsA(http.HttpRequest)) \
|
||||||
.AndReturn(self.volumes.list())
|
.AndReturn(volumes)
|
||||||
api.image_list_detailed(IsA(http.HttpRequest),
|
api.image_list_detailed(IsA(http.HttpRequest),
|
||||||
marker=None).AndRaise(self.exceptions.glance)
|
marker=None).AndRaise(self.exceptions.glance)
|
||||||
api.snapshot_list_detailed(IsA(http.HttpRequest), marker=None) \
|
api.snapshot_list_detailed(IsA(http.HttpRequest), marker=None) \
|
||||||
@ -84,14 +117,24 @@ class ImagesAndSnapshotsTests(test.TestCase):
|
|||||||
self.assertTemplateUsed(res, 'nova/images_and_snapshots/index.html')
|
self.assertTemplateUsed(res, 'nova/images_and_snapshots/index.html')
|
||||||
|
|
||||||
@test.create_stubs({api: ('image_list_detailed', 'snapshot_list_detailed',
|
@test.create_stubs({api: ('image_list_detailed', 'snapshot_list_detailed',
|
||||||
'volume_snapshot_list')})
|
'volume_snapshot_list', 'volume_get',)})
|
||||||
def test_queued_snapshot_actions(self):
|
def test_queued_snapshot_actions(self):
|
||||||
images = self.images.list()
|
images = self.images.list()
|
||||||
|
|
||||||
snapshots = self.snapshots.list()
|
snapshots = self.snapshots.list()
|
||||||
|
volumes = self.volumes.list()
|
||||||
|
|
||||||
|
for volume in volumes:
|
||||||
|
volume.volume_id = volume.id
|
||||||
|
for volume in volumes:
|
||||||
|
api.volume_get(IsA(http.HttpRequest), volume.volume_id) \
|
||||||
|
.AndReturn(volume)
|
||||||
|
for volume in volumes:
|
||||||
|
api.volume_get(IsA(http.HttpRequest), volume.volume_id) \
|
||||||
|
.AndReturn(volume)
|
||||||
|
api.volume_get(IsA(http.HttpRequest), volume.volume_id)
|
||||||
|
|
||||||
api.volume_snapshot_list(IsA(http.HttpRequest)) \
|
api.volume_snapshot_list(IsA(http.HttpRequest)) \
|
||||||
.AndReturn(self.volumes.list())
|
.AndReturn(volumes)
|
||||||
api.image_list_detailed(IsA(http.HttpRequest),
|
api.image_list_detailed(IsA(http.HttpRequest),
|
||||||
marker=None).AndReturn([images, False])
|
marker=None).AndReturn([images, False])
|
||||||
api.snapshot_list_detailed(IsA(http.HttpRequest), marker=None) \
|
api.snapshot_list_detailed(IsA(http.HttpRequest), marker=None) \
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse
|
||||||
|
from django.utils import safestring
|
||||||
from django.utils.http import urlencode
|
from django.utils.http import urlencode
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
@ -59,10 +60,26 @@ class UpdateRow(tables.Row):
|
|||||||
return snapshot
|
return snapshot
|
||||||
|
|
||||||
|
|
||||||
|
class SnapshotVolumeNameColumn(tables.Column):
|
||||||
|
"""
|
||||||
|
Customized column class that does complex processing on the attachments
|
||||||
|
for a volume instance.
|
||||||
|
"""
|
||||||
|
def get_raw_data(self, snapshot):
|
||||||
|
request = self.table.request
|
||||||
|
volume_name = api.volume_get(request, snapshot.volume_id).display_name
|
||||||
|
return safestring.mark_safe(volume_name)
|
||||||
|
|
||||||
|
def get_link_url(self, snapshot):
|
||||||
|
volume_id = api.volume_get(self.table.request, snapshot.volume_id).id
|
||||||
|
return reverse(self.link, args=(volume_id,))
|
||||||
|
|
||||||
|
|
||||||
class VolumeSnapshotsTable(volume_tables.VolumesTableBase):
|
class VolumeSnapshotsTable(volume_tables.VolumesTableBase):
|
||||||
name = tables.Column("display_name", verbose_name=_("Name"))
|
name = tables.Column("display_name", verbose_name=_("Name"))
|
||||||
volume_id = tables.Column("volume_id",
|
volume_name = SnapshotVolumeNameColumn("display_name",
|
||||||
verbose_name=_("Volume ID"))
|
verbose_name=_("Volume Name"),
|
||||||
|
link="horizon:nova:volumes:detail")
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
name = "volume_snapshots"
|
name = "volume_snapshots"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user