Check the target host before live migrating a instance
In the live migrate form, the selections "Automatically schedule new host." and "No other hosts available" both use an empty value, and this input is not required, that causes I can submit the form even there are no other hosts available. I think the value of selection "Automatically schedule new host." should not be empty, and this input should be required. Change-Id: I6a88ffa23087a0d845cf8a71a6359f3f4fbddbe0 Closes-Bug: #1684604
This commit is contained in:
parent
612c2e5e95
commit
9d9a2f6c1b
@ -30,8 +30,7 @@ class LiveMigrateForm(forms.SelfHandlingForm):
|
||||
attrs={'readonly': 'readonly'}))
|
||||
host = forms.ThemableChoiceField(
|
||||
label=_("New Host"),
|
||||
help_text=_("Choose a Host to migrate to."),
|
||||
required=False)
|
||||
help_text=_("Choose a Host to migrate to."))
|
||||
disk_over_commit = forms.BooleanField(label=_("Disk Over Commit"),
|
||||
initial=False, required=False)
|
||||
block_migration = forms.BooleanField(label=_("Block Migration"),
|
||||
@ -55,7 +54,8 @@ class LiveMigrateForm(forms.SelfHandlingForm):
|
||||
if (host.service.startswith('compute') and
|
||||
host.host_name != current_host)]
|
||||
if host_list:
|
||||
host_list.insert(0, ("", _("Automatically schedule new host.")))
|
||||
host_list.insert(0, ("AUTO_SCHEDULE",
|
||||
_("Automatically schedule new host.")))
|
||||
else:
|
||||
host_list.insert(0, ("", _("No other hosts available")))
|
||||
return sorted(host_list)
|
||||
@ -64,7 +64,7 @@ class LiveMigrateForm(forms.SelfHandlingForm):
|
||||
try:
|
||||
block_migration = data['block_migration']
|
||||
disk_over_commit = data['disk_over_commit']
|
||||
host = None if not data['host'] else data['host']
|
||||
host = None if data['host'] == 'AUTO_SCHEDULE' else data['host']
|
||||
api.nova.server_live_migrate(request,
|
||||
data['instance_id'],
|
||||
host,
|
||||
|
@ -371,7 +371,7 @@ class InstanceViewTest(test.BaseAdminViewTests):
|
||||
'server_live_migrate',)})
|
||||
def test_instance_live_migrate_auto_sched(self):
|
||||
server = self.servers.first()
|
||||
host = ""
|
||||
host = "AUTO_SCHEDULE"
|
||||
api.nova.server_get(IsA(http.HttpRequest), server.id) \
|
||||
.AndReturn(server)
|
||||
api.nova.host_list(IsA(http.HttpRequest)) \
|
||||
|
Loading…
Reference in New Issue
Block a user