Merge "Live Migration should not contain current host in the new host list"

This commit is contained in:
Jenkins 2014-03-14 14:32:51 +00:00 committed by Gerrit Code Review
commit be21417296
3 changed files with 73 additions and 1 deletions

View File

@ -53,7 +53,7 @@ class LiveMigrateForm(forms.SelfHandlingForm):
host_list = [(host.hypervisor_hostname, host_list = [(host.hypervisor_hostname,
host.hypervisor_hostname) host.hypervisor_hostname)
for host in hosts for host in hosts
if host.hypervisor_hostname != current_host] if host.service['host'] != current_host]
if host_list: if host_list:
host_list.insert(0, ("", _("Select a new host"))) host_list.insert(0, ("", _("Select a new host")))
else: else:

View File

@ -268,6 +268,27 @@ class InstanceViewTest(test.BaseAdminViewTests):
self.assertRedirectsNoFollow(res, INDEX_URL) self.assertRedirectsNoFollow(res, INDEX_URL)
@test.create_stubs({api.nova: ('hypervisor_list',
'server_get',)})
def test_instance_live_migrate_list_hypervisor_without_current(self):
server = self.servers.first()
api.nova.server_get(IsA(http.HttpRequest), server.id) \
.AndReturn(server)
api.nova.hypervisor_list(IsA(http.HttpRequest)) \
.AndReturn(self.hypervisors.list())
self.mox.ReplayAll()
url = reverse('horizon:admin:instances:live_migrate',
args=[server.id])
res = self.client.get(url)
self.assertNotContains(
res, "<option value=\"devstack003\">devstack003</option>")
self.assertContains(
res, "<option value=\"devstack001\">devstack001</option>")
self.assertContains(
res, "<option value=\"devstack002\">devstack002</option>")
@test.create_stubs({api.nova: ('hypervisor_list', @test.create_stubs({api.nova: ('hypervisor_list',
'server_get', 'server_get',
'server_live_migrate',)}) 'server_live_migrate',)})

View File

@ -572,7 +572,58 @@ def data(TEST):
"id": 1 "id": 1
} }
) )
hypervisor_2 = hypervisors.Hypervisor(hypervisors.HypervisorManager(None),
{
"service": {"host": "devstack002", "id": 4},
"vcpus_used": 1,
"hypervisor_type": "QEMU",
"local_gb_used": 20,
"hypervisor_hostname": "devstack002",
"memory_mb_used": 1500,
"memory_mb": 2000,
"current_workload": 0,
"vcpus": 1,
"cpu_info": '{"vendor": "Intel", "model": "core2duo",'
'"arch": "x86_64", "features": ["lahf_lm"'
', "rdtscp"], "topology": {"cores": 1, "t'
'hreads": 1, "sockets": 1}}',
"running_vms": 1,
"free_disk_gb": 9,
"hypervisor_version": 1002000,
"disk_available_least": 6,
"local_gb": 29,
"free_ram_mb": 500,
"id": 2
}
)
hypervisor_3 = hypervisors.Hypervisor(hypervisors.HypervisorManager(None),
{
"service": {"host": "instance-host", "id": 5},
"vcpus_used": 1,
"hypervisor_type": "QEMU",
"local_gb_used": 20,
"hypervisor_hostname": "devstack003",
"memory_mb_used": 1500,
"memory_mb": 2000,
"current_workload": 0,
"vcpus": 1,
"cpu_info": '{"vendor": "Intel", "model": "core2duo",'
'"arch": "x86_64", "features": ["lahf_lm"'
', "rdtscp"], "topology": {"cores": 1, "t'
'hreads": 1, "sockets": 1}}',
"running_vms": 1,
"free_disk_gb": 9,
"hypervisor_version": 1002000,
"disk_available_least": 6,
"local_gb": 29,
"free_ram_mb": 500,
"id": 3
}
)
TEST.hypervisors.add(hypervisor_1) TEST.hypervisors.add(hypervisor_1)
TEST.hypervisors.add(hypervisor_2)
TEST.hypervisors.add(hypervisor_3)
TEST.hypervisors.stats = { TEST.hypervisors.stats = {
"hypervisor_statistics": { "hypervisor_statistics": {