Snapshot Name is optional parameter on create and update snapshot form
Change-Id: I32aed4f1e27ce53ab9303f470b50145c9715c4ce Closes-Bug: #1828195
This commit is contained in:
parent
2f7e630ba0
commit
002c163d56
|
@ -22,7 +22,8 @@ from openstack_dashboard.api import cinder
|
|||
|
||||
|
||||
class UpdateForm(forms.SelfHandlingForm):
|
||||
name = forms.CharField(max_length=255, label=_("Snapshot Name"))
|
||||
name = forms.CharField(max_length=255, label=_("Snapshot Name"),
|
||||
required=False)
|
||||
description = forms.CharField(max_length=255,
|
||||
widget=forms.Textarea(attrs={'rows': 4}),
|
||||
label=_("Description"),
|
||||
|
@ -31,12 +32,14 @@ class UpdateForm(forms.SelfHandlingForm):
|
|||
def handle(self, request, data):
|
||||
snapshot_id = self.initial['snapshot_id']
|
||||
try:
|
||||
cinder.volume_snapshot_update(request,
|
||||
snapshot_id,
|
||||
data['name'],
|
||||
data['description'])
|
||||
snapshot = cinder.volume_snapshot_update(request,
|
||||
snapshot_id,
|
||||
data['name'],
|
||||
data['description'])
|
||||
|
||||
message = _('Updating volume snapshot "%s"') % data['name']
|
||||
name_or_id = (snapshot["snapshot"]["name"] or
|
||||
snapshot["snapshot"]["id"])
|
||||
message = _('Updating volume snapshot "%s"') % name_or_id
|
||||
messages.info(request, message)
|
||||
return True
|
||||
except Exception:
|
||||
|
|
|
@ -538,7 +538,8 @@ class AttachForm(forms.SelfHandlingForm):
|
|||
|
||||
|
||||
class CreateSnapshotForm(forms.SelfHandlingForm):
|
||||
name = forms.CharField(max_length=255, label=_("Snapshot Name"))
|
||||
name = forms.CharField(max_length=255, label=_("Snapshot Name"),
|
||||
required=False)
|
||||
description = forms.CharField(max_length=255,
|
||||
widget=forms.Textarea(attrs={'rows': 4}),
|
||||
label=_("Description"),
|
||||
|
@ -557,18 +558,18 @@ class CreateSnapshotForm(forms.SelfHandlingForm):
|
|||
volume = cinder.volume_get(request,
|
||||
data['volume_id'])
|
||||
force = False
|
||||
message = _('Creating volume snapshot "%s".') % data['name']
|
||||
message = _('Creating volume snapshot "%s".')
|
||||
if volume.status == 'in-use':
|
||||
force = True
|
||||
message = _('Forcing to create snapshot "%s" '
|
||||
'from attached volume.') % data['name']
|
||||
'from attached volume.')
|
||||
snapshot = cinder.volume_snapshot_create(request,
|
||||
data['volume_id'],
|
||||
data['name'],
|
||||
data['description'],
|
||||
force=force)
|
||||
|
||||
messages.info(request, message)
|
||||
messages.info(request, message % snapshot.name)
|
||||
return snapshot
|
||||
except Exception as e:
|
||||
redirect = reverse("horizon:project:volumes:index")
|
||||
|
|
Loading…
Reference in New Issue