Merge "Check the target host before live migrating a instance"

This commit is contained in:
Jenkins 2017-04-26 09:45:58 +00:00 committed by Gerrit Code Review
commit b80668e7d4
2 changed files with 5 additions and 5 deletions

View File

@ -30,8 +30,7 @@ class LiveMigrateForm(forms.SelfHandlingForm):
attrs={'readonly': 'readonly'})) attrs={'readonly': 'readonly'}))
host = forms.ThemableChoiceField( host = forms.ThemableChoiceField(
label=_("New Host"), label=_("New Host"),
help_text=_("Choose a Host to migrate to."), help_text=_("Choose a Host to migrate to."))
required=False)
disk_over_commit = forms.BooleanField(label=_("Disk Over Commit"), disk_over_commit = forms.BooleanField(label=_("Disk Over Commit"),
initial=False, required=False) initial=False, required=False)
block_migration = forms.BooleanField(label=_("Block Migration"), block_migration = forms.BooleanField(label=_("Block Migration"),
@ -55,7 +54,8 @@ class LiveMigrateForm(forms.SelfHandlingForm):
if (host.service.startswith('compute') and if (host.service.startswith('compute') and
host.host_name != current_host)] host.host_name != current_host)]
if host_list: if host_list:
host_list.insert(0, ("", _("Automatically schedule new host."))) host_list.insert(0, ("AUTO_SCHEDULE",
_("Automatically schedule new host.")))
else: else:
host_list.insert(0, ("", _("No other hosts available"))) host_list.insert(0, ("", _("No other hosts available")))
return sorted(host_list) return sorted(host_list)
@ -64,7 +64,7 @@ class LiveMigrateForm(forms.SelfHandlingForm):
try: try:
block_migration = data['block_migration'] block_migration = data['block_migration']
disk_over_commit = data['disk_over_commit'] 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, api.nova.server_live_migrate(request,
data['instance_id'], data['instance_id'],
host, host,

View File

@ -371,7 +371,7 @@ class InstanceViewTest(test.BaseAdminViewTests):
'server_live_migrate',)}) 'server_live_migrate',)})
def test_instance_live_migrate_auto_sched(self): def test_instance_live_migrate_auto_sched(self):
server = self.servers.first() server = self.servers.first()
host = "" host = "AUTO_SCHEDULE"
api.nova.server_get(IsA(http.HttpRequest), server.id) \ api.nova.server_get(IsA(http.HttpRequest), server.id) \
.AndReturn(server) .AndReturn(server)
api.nova.host_list(IsA(http.HttpRequest)) \ api.nova.host_list(IsA(http.HttpRequest)) \