Merge "Use nova os-services to retrieve host list"
This commit is contained in:
commit
795b10280a
@ -984,11 +984,6 @@ def aggregate_set_metadata(request, aggregate_id, metadata):
|
||||
return novaclient(request).aggregates.set_metadata(aggregate_id, metadata)
|
||||
|
||||
|
||||
@profiler.trace
|
||||
def host_list(request):
|
||||
return novaclient(request).hosts.list()
|
||||
|
||||
|
||||
@profiler.trace
|
||||
def add_host_to_aggregate(request, aggregate_id, host):
|
||||
return novaclient(request).aggregates.add_host(aggregate_id, host)
|
||||
|
@ -30,39 +30,21 @@ class BaseAggregateWorkflowTests(test.BaseAdminViewTests):
|
||||
"availability_zone": aggregate.availability_zone}
|
||||
|
||||
if hosts:
|
||||
compute_hosts = []
|
||||
for host in hosts:
|
||||
if host.service == 'compute':
|
||||
compute_hosts.append(host)
|
||||
|
||||
host_field_name = 'add_host_to_aggregate_role_member'
|
||||
aggregate_info[host_field_name] = \
|
||||
[h.host_name for h in compute_hosts]
|
||||
|
||||
return aggregate_info
|
||||
|
||||
def _get_manage_workflow_data(self, aggregate, hosts=None, ):
|
||||
aggregate_info = {"id": aggregate.id}
|
||||
|
||||
if hosts:
|
||||
compute_hosts = []
|
||||
for host in hosts:
|
||||
if host.service == 'compute':
|
||||
compute_hosts.append(host)
|
||||
|
||||
host_field_name = 'add_host_to_aggregate_role_member'
|
||||
aggregate_info[host_field_name] = \
|
||||
[h.host_name for h in compute_hosts]
|
||||
aggregate_info[host_field_name] = hosts
|
||||
|
||||
return aggregate_info
|
||||
|
||||
|
||||
class CreateAggregateWorkflowTests(BaseAggregateWorkflowTests):
|
||||
|
||||
@test.create_stubs({api.nova: ('host_list', ), })
|
||||
@test.create_stubs({api.nova: ('service_list', ), })
|
||||
def test_workflow_get(self):
|
||||
|
||||
api.nova.host_list(IsA(http.HttpRequest)).AndReturn(self.hosts.list())
|
||||
compute_services = [s for s in self.services.list()
|
||||
if s.binary == 'nova-compute']
|
||||
api.nova.service_list(IsA(http.HttpRequest), binary='nova-compute') \
|
||||
.AndReturn(compute_services)
|
||||
self.mox.ReplayAll()
|
||||
|
||||
url = reverse(constants.AGGREGATES_CREATE_URL)
|
||||
@ -76,13 +58,16 @@ class CreateAggregateWorkflowTests(BaseAggregateWorkflowTests):
|
||||
['<SetAggregateInfoStep: set_aggregate_info>',
|
||||
'<AddHostsToAggregateStep: add_host_to_aggregate>'])
|
||||
|
||||
@test.create_stubs({api.nova: ('host_list', 'aggregate_details_list',
|
||||
@test.create_stubs({api.nova: ('service_list', 'aggregate_details_list',
|
||||
'aggregate_create'), })
|
||||
def _test_generic_create_aggregate(self, workflow_data, aggregate,
|
||||
existing_aggregates=(),
|
||||
error_count=0,
|
||||
expected_error_message=None):
|
||||
api.nova.host_list(IsA(http.HttpRequest)).AndReturn(self.hosts.list())
|
||||
compute_services = [s for s in self.services.list()
|
||||
if s.binary == 'nova-compute']
|
||||
api.nova.service_list(IsA(http.HttpRequest), binary='nova-compute') \
|
||||
.AndReturn(compute_services)
|
||||
api.nova.aggregate_details_list(IsA(http.HttpRequest)) \
|
||||
.AndReturn(existing_aggregates)
|
||||
if not expected_error_message:
|
||||
@ -140,33 +125,32 @@ class CreateAggregateWorkflowTests(BaseAggregateWorkflowTests):
|
||||
existing_aggregates, 1,
|
||||
expected_error_message)
|
||||
|
||||
@test.create_stubs({api.nova: ('host_list',
|
||||
@test.create_stubs({api.nova: ('service_list',
|
||||
'aggregate_details_list',
|
||||
'aggregate_create',
|
||||
'add_host_to_aggregate'), })
|
||||
def test_create_aggregate_with_hosts(self):
|
||||
aggregate = self.aggregates.first()
|
||||
hosts = self.hosts.list()
|
||||
|
||||
api.nova.host_list(IsA(http.HttpRequest)).AndReturn(self.hosts.list())
|
||||
compute_services = [s for s in self.services.list()
|
||||
if s.binary == 'nova-compute']
|
||||
compute_hosts = [s.host for s in compute_services]
|
||||
api.nova.service_list(IsA(http.HttpRequest), binary='nova-compute') \
|
||||
.AndReturn(compute_services)
|
||||
api.nova.aggregate_details_list(IsA(http.HttpRequest)).AndReturn([])
|
||||
|
||||
workflow_data = self._get_create_workflow_data(aggregate, hosts)
|
||||
workflow_data = self._get_create_workflow_data(aggregate,
|
||||
compute_hosts)
|
||||
api.nova.aggregate_create(
|
||||
IsA(http.HttpRequest),
|
||||
name=workflow_data['name'],
|
||||
availability_zone=workflow_data['availability_zone'],
|
||||
).AndReturn(aggregate)
|
||||
|
||||
compute_hosts = []
|
||||
for host in hosts:
|
||||
if host.service == 'compute':
|
||||
compute_hosts.append(host)
|
||||
|
||||
for host in compute_hosts:
|
||||
api.nova.add_host_to_aggregate(
|
||||
IsA(http.HttpRequest),
|
||||
aggregate.id, host.host_name).InAnyOrder()
|
||||
aggregate.id, host).InAnyOrder()
|
||||
|
||||
self.mox.ReplayAll()
|
||||
|
||||
@ -177,18 +161,13 @@ class CreateAggregateWorkflowTests(BaseAggregateWorkflowTests):
|
||||
self.assertRedirectsNoFollow(res,
|
||||
reverse(constants.AGGREGATES_INDEX_URL))
|
||||
|
||||
@test.create_stubs({api.nova: ('host_list', 'aggregate_details_list', ), })
|
||||
def test_host_list_nova_compute(self):
|
||||
|
||||
hosts = self.hosts.list()
|
||||
compute_hosts = []
|
||||
|
||||
for host in hosts:
|
||||
if host.service == 'compute':
|
||||
compute_hosts.append(host)
|
||||
|
||||
api.nova.host_list(IsA(http.HttpRequest)).AndReturn(self.hosts.list())
|
||||
|
||||
@test.create_stubs({api.nova: ('service_list',
|
||||
'aggregate_details_list', ), })
|
||||
def test_service_list_nova_compute(self):
|
||||
compute_services = [s for s in self.services.list()
|
||||
if s.binary == 'nova-compute']
|
||||
api.nova.service_list(IsA(http.HttpRequest), binary='nova-compute') \
|
||||
.AndReturn(compute_services)
|
||||
self.mox.ReplayAll()
|
||||
|
||||
url = reverse(constants.AGGREGATES_CREATE_URL)
|
||||
@ -197,7 +176,7 @@ class CreateAggregateWorkflowTests(BaseAggregateWorkflowTests):
|
||||
step = workflow.get_step("add_host_to_aggregate")
|
||||
field_name = step.get_member_field_name('member')
|
||||
self.assertEqual(len(step.action.fields[field_name].choices),
|
||||
len(compute_hosts))
|
||||
len(compute_services))
|
||||
|
||||
|
||||
class AggregatesViewTests(test.BaseAdminViewTests):
|
||||
@ -273,14 +252,16 @@ class AggregatesViewTests(test.BaseAdminViewTests):
|
||||
|
||||
class ManageHostsTests(test.BaseAdminViewTests):
|
||||
|
||||
@test.create_stubs({api.nova: ('aggregate_get', 'host_list')})
|
||||
@test.create_stubs({api.nova: ('aggregate_get', 'service_list')})
|
||||
def test_manage_hosts(self):
|
||||
aggregate = self.aggregates.first()
|
||||
|
||||
api.nova.aggregate_get(IsA(http.HttpRequest), str(aggregate.id)) \
|
||||
.AndReturn(aggregate)
|
||||
api.nova.host_list(IsA(http.HttpRequest)) \
|
||||
.AndReturn(self.hosts.list())
|
||||
compute_services = [s for s in self.services.list()
|
||||
if s.binary == 'nova-compute']
|
||||
api.nova.service_list(IsA(http.HttpRequest), binary='nova-compute') \
|
||||
.AndReturn(compute_services)
|
||||
self.mox.ReplayAll()
|
||||
|
||||
res = self.client.get(reverse(constants.AGGREGATES_MANAGE_HOSTS_URL,
|
||||
@ -291,13 +272,14 @@ class ManageHostsTests(test.BaseAdminViewTests):
|
||||
|
||||
@test.create_stubs({api.nova: ('aggregate_get', 'add_host_to_aggregate',
|
||||
'remove_host_from_aggregate',
|
||||
'host_list')})
|
||||
'service_list')})
|
||||
def test_manage_hosts_update_add_remove_not_empty_aggregate(self):
|
||||
aggregate = self.aggregates.first()
|
||||
aggregate.hosts = ['host1', 'host2']
|
||||
host = self.hosts.list()[0]
|
||||
form_data = {'manageaggregatehostsaction_role_member':
|
||||
[host.host_name]}
|
||||
compute_services = [s for s in self.services.list()
|
||||
if s.binary == 'nova-compute']
|
||||
host = compute_services[0].host
|
||||
form_data = {'manageaggregatehostsaction_role_member': [host]}
|
||||
|
||||
api.nova.remove_host_from_aggregate(IsA(http.HttpRequest),
|
||||
str(aggregate.id),
|
||||
@ -307,12 +289,14 @@ class ManageHostsTests(test.BaseAdminViewTests):
|
||||
'host1').InAnyOrder()
|
||||
api.nova.aggregate_get(IsA(http.HttpRequest), str(aggregate.id)) \
|
||||
.AndReturn(aggregate)
|
||||
api.nova.host_list(IsA(http.HttpRequest)) \
|
||||
.AndReturn(self.hosts.list())
|
||||
compute_services = [s for s in self.services.list()
|
||||
if s.binary == 'nova-compute']
|
||||
api.nova.service_list(IsA(http.HttpRequest), binary='nova-compute') \
|
||||
.AndReturn(compute_services)
|
||||
api.nova.aggregate_get(IsA(http.HttpRequest), str(aggregate.id)) \
|
||||
.AndReturn(aggregate)
|
||||
api.nova.add_host_to_aggregate(IsA(http.HttpRequest),
|
||||
str(aggregate.id), host.host_name)
|
||||
str(aggregate.id), host)
|
||||
self.mox.ReplayAll()
|
||||
|
||||
res = self.client.post(reverse(constants.AGGREGATES_MANAGE_HOSTS_URL,
|
||||
@ -324,23 +308,25 @@ class ManageHostsTests(test.BaseAdminViewTests):
|
||||
|
||||
@test.create_stubs({api.nova: ('aggregate_get', 'add_host_to_aggregate',
|
||||
'remove_host_from_aggregate',
|
||||
'host_list')})
|
||||
'service_list')})
|
||||
def test_manage_hosts_update_add_not_empty_aggregate_should_fail(self):
|
||||
aggregate = self.aggregates.first()
|
||||
aggregate.hosts = ['devstack001']
|
||||
host1 = self.hosts.list()[0]
|
||||
host3 = self.hosts.list()[2]
|
||||
form_data = {'manageaggregatehostsaction_role_member':
|
||||
[host1.host_name, host3.host_name]}
|
||||
compute_services = [s for s in self.services.list()
|
||||
if s.binary == 'nova-compute']
|
||||
host1 = compute_services[0].host
|
||||
host3 = compute_services[2].host
|
||||
form_data = {'manageaggregatehostsaction_role_member': [host1, host3]}
|
||||
|
||||
api.nova.aggregate_get(IsA(http.HttpRequest), str(aggregate.id)) \
|
||||
.InAnyOrder().AndReturn(aggregate)
|
||||
api.nova.host_list(IsA(http.HttpRequest)) \
|
||||
.InAnyOrder().AndReturn(self.hosts.list())
|
||||
api.nova.service_list(IsA(http.HttpRequest), binary='nova-compute') \
|
||||
.AndReturn(compute_services)
|
||||
api.nova.aggregate_get(IsA(http.HttpRequest), str(aggregate.id)) \
|
||||
.InAnyOrder().AndReturn(aggregate)
|
||||
api.nova.add_host_to_aggregate(IsA(http.HttpRequest),
|
||||
str(aggregate.id), host3.host_name) \
|
||||
str(aggregate.id),
|
||||
host3) \
|
||||
.InAnyOrder().AndRaise(self.exceptions.nova)
|
||||
self.mox.ReplayAll()
|
||||
|
||||
@ -354,7 +340,7 @@ class ManageHostsTests(test.BaseAdminViewTests):
|
||||
|
||||
@test.create_stubs({api.nova: ('aggregate_get', 'add_host_to_aggregate',
|
||||
'remove_host_from_aggregate',
|
||||
'host_list')})
|
||||
'service_list')})
|
||||
def test_manage_hosts_update_clean_not_empty_aggregate_should_fail(self):
|
||||
aggregate = self.aggregates.first()
|
||||
aggregate.hosts = ['host2']
|
||||
@ -367,8 +353,10 @@ class ManageHostsTests(test.BaseAdminViewTests):
|
||||
.AndRaise(self.exceptions.nova)
|
||||
api.nova.aggregate_get(IsA(http.HttpRequest), str(aggregate.id)) \
|
||||
.AndReturn(aggregate)
|
||||
api.nova.host_list(IsA(http.HttpRequest)) \
|
||||
.AndReturn(self.hosts.list())
|
||||
compute_services = [s for s in self.services.list()
|
||||
if s.binary == 'nova-compute']
|
||||
api.nova.service_list(IsA(http.HttpRequest), binary='nova-compute') \
|
||||
.AndReturn(compute_services)
|
||||
api.nova.aggregate_get(IsA(http.HttpRequest), str(aggregate.id)) \
|
||||
.AndReturn(aggregate)
|
||||
self.mox.ReplayAll()
|
||||
@ -383,7 +371,7 @@ class ManageHostsTests(test.BaseAdminViewTests):
|
||||
|
||||
@test.create_stubs({api.nova: ('aggregate_get', 'add_host_to_aggregate',
|
||||
'remove_host_from_aggregate',
|
||||
'host_list')})
|
||||
'service_list')})
|
||||
def _test_manage_hosts_update(self,
|
||||
host,
|
||||
aggregate,
|
||||
@ -402,14 +390,16 @@ class ManageHostsTests(test.BaseAdminViewTests):
|
||||
'host1').InAnyOrder()
|
||||
api.nova.aggregate_get(IsA(http.HttpRequest), str(aggregate.id)) \
|
||||
.AndReturn(aggregate)
|
||||
api.nova.host_list(IsA(http.HttpRequest)) \
|
||||
.AndReturn(self.hosts.list())
|
||||
compute_services = [s for s in self.services.list()
|
||||
if s.binary == 'nova-compute']
|
||||
api.nova.service_list(IsA(http.HttpRequest), binary='nova-compute') \
|
||||
.AndReturn(compute_services)
|
||||
api.nova.aggregate_get(IsA(http.HttpRequest), str(aggregate.id)) \
|
||||
.AndReturn(aggregate)
|
||||
if addAggregate:
|
||||
api.nova.add_host_to_aggregate(IsA(http.HttpRequest),
|
||||
str(aggregate.id),
|
||||
host.host_name)
|
||||
host)
|
||||
self.mox.ReplayAll()
|
||||
|
||||
res = self.client.post(reverse(constants.AGGREGATES_MANAGE_HOSTS_URL,
|
||||
@ -421,10 +411,11 @@ class ManageHostsTests(test.BaseAdminViewTests):
|
||||
|
||||
def test_manage_hosts_update_nothing_not_empty_aggregate(self):
|
||||
aggregate = self.aggregates.first()
|
||||
host = self.hosts.list()[0]
|
||||
aggregate.hosts = [host.host_name]
|
||||
form_data = {'manageaggregatehostsaction_role_member':
|
||||
[host.host_name]}
|
||||
compute_services = [s for s in self.services.list()
|
||||
if s.binary == 'nova-compute']
|
||||
host = compute_services[0].host
|
||||
aggregate.hosts = [host]
|
||||
form_data = {'manageaggregatehostsaction_role_member': [host]}
|
||||
self._test_manage_hosts_update(host,
|
||||
aggregate,
|
||||
form_data,
|
||||
@ -443,9 +434,10 @@ class ManageHostsTests(test.BaseAdminViewTests):
|
||||
def test_manage_hosts_update_add_empty_aggregate(self):
|
||||
aggregate = self.aggregates.first()
|
||||
aggregate.hosts = []
|
||||
host = self.hosts.list()[0]
|
||||
form_data = {'manageaggregatehostsaction_role_member':
|
||||
[host.host_name]}
|
||||
compute_services = [s for s in self.services.list()
|
||||
if s.binary == 'nova-compute']
|
||||
host = compute_services[0].host
|
||||
form_data = {'manageaggregatehostsaction_role_member': [host]}
|
||||
self._test_manage_hosts_update(host,
|
||||
aggregate,
|
||||
form_data,
|
||||
@ -454,10 +446,11 @@ class ManageHostsTests(test.BaseAdminViewTests):
|
||||
def test_manage_hosts_update_add_not_empty_aggregate(self):
|
||||
aggregate = self.aggregates.first()
|
||||
aggregate.hosts = ['devstack001']
|
||||
host1 = self.hosts.list()[0]
|
||||
host3 = self.hosts.list()[2]
|
||||
form_data = {'manageaggregatehostsaction_role_member':
|
||||
[host1.host_name, host3.host_name]}
|
||||
compute_services = [s for s in self.services.list()
|
||||
if s.binary == 'nova-compute']
|
||||
host1 = compute_services[0].host
|
||||
host3 = compute_services[2].host
|
||||
form_data = {'manageaggregatehostsaction_role_member': [host1, host3]}
|
||||
self._test_manage_hosts_update(host3,
|
||||
aggregate,
|
||||
form_data,
|
||||
|
@ -76,16 +76,13 @@ class AddHostsToAggregateAction(workflows.MembershipAction):
|
||||
field_name = self.get_member_field_name('member')
|
||||
self.fields[field_name] = forms.MultipleChoiceField(required=False)
|
||||
|
||||
hosts = []
|
||||
services = []
|
||||
try:
|
||||
hosts = api.nova.host_list(request)
|
||||
services = api.nova.service_list(request, binary='nova-compute')
|
||||
except Exception:
|
||||
exceptions.handle(request, err_msg)
|
||||
|
||||
host_names = []
|
||||
for host in hosts:
|
||||
if host.host_name not in host_names and host.service == u'compute':
|
||||
host_names.append(host.host_name)
|
||||
host_names = [s.host for s in services]
|
||||
host_names.sort()
|
||||
|
||||
self.fields[field_name].choices = \
|
||||
@ -114,16 +111,13 @@ class ManageAggregateHostsAction(workflows.MembershipAction):
|
||||
aggregate = api.nova.aggregate_get(request, aggregate_id)
|
||||
current_aggregate_hosts = aggregate.hosts
|
||||
|
||||
hosts = []
|
||||
services = []
|
||||
try:
|
||||
hosts = api.nova.host_list(request)
|
||||
services = api.nova.service_list(request, binary='nova-compute')
|
||||
except Exception:
|
||||
exceptions.handle(request, err_msg)
|
||||
|
||||
host_names = []
|
||||
for host in hosts:
|
||||
if host.host_name not in host_names and host.service == u'compute':
|
||||
host_names.append(host.host_name)
|
||||
host_names = [s.host for s in services]
|
||||
host_names.sort()
|
||||
|
||||
self.fields[field_name].choices = \
|
||||
|
@ -48,11 +48,7 @@ class LiveMigrateForm(forms.SelfHandlingForm):
|
||||
def populate_host_choices(self, request, initial):
|
||||
hosts = initial.get('hosts')
|
||||
current_host = initial.get('current_host')
|
||||
host_list = [(host.host_name,
|
||||
host.host_name)
|
||||
for host in hosts
|
||||
if (host.service.startswith('compute') and
|
||||
host.host_name != current_host)]
|
||||
host_list = [(host, host) for host in hosts if host != current_host]
|
||||
if host_list:
|
||||
host_list.insert(0, ("AUTO_SCHEDULE",
|
||||
_("Automatically schedule new host.")))
|
||||
|
@ -257,14 +257,16 @@ class InstanceViewTest(test.BaseAdminViewTests):
|
||||
self.assertContains(res, "instances__revert")
|
||||
self.assertNotContains(res, "instances__migrate")
|
||||
|
||||
@test.create_stubs({api.nova: ('host_list',
|
||||
@test.create_stubs({api.nova: ('service_list',
|
||||
'server_get',)})
|
||||
def test_instance_live_migrate_get(self):
|
||||
server = self.servers.first()
|
||||
compute_services = [s for s in self.services.list()
|
||||
if s.binary == 'nova-compute']
|
||||
api.nova.server_get(IsA(http.HttpRequest), server.id) \
|
||||
.AndReturn(server)
|
||||
api.nova.host_list(IsA(http.HttpRequest)) \
|
||||
.AndReturn(self.hosts.list())
|
||||
api.nova.service_list(IsA(http.HttpRequest), binary='nova-compute') \
|
||||
.AndReturn(compute_services)
|
||||
|
||||
self.mox.ReplayAll()
|
||||
|
||||
@ -288,13 +290,13 @@ class InstanceViewTest(test.BaseAdminViewTests):
|
||||
|
||||
self.assertRedirectsNoFollow(res, INDEX_URL)
|
||||
|
||||
@test.create_stubs({api.nova: ('host_list',
|
||||
@test.create_stubs({api.nova: ('service_list',
|
||||
'server_get',)})
|
||||
def test_instance_live_migrate_list_hypervisor_get_exception(self):
|
||||
def test_instance_live_migrate_list_host_get_exception(self):
|
||||
server = self.servers.first()
|
||||
api.nova.server_get(IsA(http.HttpRequest), server.id) \
|
||||
.AndReturn(server)
|
||||
api.nova.host_list(IsA(http.HttpRequest)) \
|
||||
api.nova.service_list(IsA(http.HttpRequest), binary='nova-compute') \
|
||||
.AndRaise(self.exceptions.nova)
|
||||
|
||||
self.mox.ReplayAll()
|
||||
@ -304,40 +306,42 @@ class InstanceViewTest(test.BaseAdminViewTests):
|
||||
|
||||
self.assertRedirectsNoFollow(res, INDEX_URL)
|
||||
|
||||
@test.create_stubs({api.nova: ('host_list',
|
||||
@test.create_stubs({api.nova: ('service_list',
|
||||
'server_get',)})
|
||||
def test_instance_live_migrate_list_hypervisor_without_current(self):
|
||||
def test_instance_live_migrate_list_host_without_current(self):
|
||||
server = self.servers.first()
|
||||
compute_services = [s for s in self.services.list()
|
||||
if s.binary == 'nova-compute']
|
||||
api.nova.server_get(IsA(http.HttpRequest), server.id) \
|
||||
.AndReturn(server)
|
||||
api.nova.host_list(IsA(http.HttpRequest)) \
|
||||
.AndReturn(self.hosts.list())
|
||||
api.nova.service_list(IsA(http.HttpRequest), binary='nova-compute') \
|
||||
.AndReturn(compute_services)
|
||||
|
||||
self.mox.ReplayAll()
|
||||
|
||||
url = reverse('horizon:admin:instances:live_migrate',
|
||||
args=[server.id])
|
||||
res = self.client.get(url)
|
||||
self.assertNotContains(
|
||||
res, "<option value=\"instance-host\">devstack004</option>")
|
||||
self.assertContains(
|
||||
res, "<option value=\"devstack001\">devstack001</option>")
|
||||
self.assertNotContains(
|
||||
res, "<option value=\"devstack002\">devstack002</option>")
|
||||
self.assertContains(
|
||||
res, "<option value=\"devstack003\">devstack003</option>")
|
||||
res, "<option value=\"devstack002\">devstack002</option>")
|
||||
self.assertNotContains(
|
||||
res, "<option value=\"instance-host\">instance-host</option>")
|
||||
|
||||
@test.create_stubs({api.nova: ('host_list',
|
||||
@test.create_stubs({api.nova: ('service_list',
|
||||
'server_get',
|
||||
'server_live_migrate',)})
|
||||
def test_instance_live_migrate_post(self):
|
||||
server = self.servers.first()
|
||||
host = self.hosts.first().host_name
|
||||
compute_services = [s for s in self.services.list()
|
||||
if s.binary == 'nova-compute']
|
||||
host = compute_services[0].host
|
||||
|
||||
api.nova.server_get(IsA(http.HttpRequest), server.id) \
|
||||
.AndReturn(server)
|
||||
api.nova.host_list(IsA(http.HttpRequest)) \
|
||||
.AndReturn(self.hosts.list())
|
||||
api.nova.service_list(IsA(http.HttpRequest), binary='nova-compute') \
|
||||
.AndReturn(compute_services)
|
||||
api.nova.server_live_migrate(IsA(http.HttpRequest), server.id, host,
|
||||
block_migration=False,
|
||||
disk_over_commit=False) \
|
||||
@ -351,7 +355,7 @@ class InstanceViewTest(test.BaseAdminViewTests):
|
||||
self.assertNoFormErrors(res)
|
||||
self.assertRedirectsNoFollow(res, INDEX_URL)
|
||||
|
||||
@test.create_stubs({api.nova: ('host_list',
|
||||
@test.create_stubs({api.nova: ('service_list',
|
||||
'server_get',
|
||||
'server_live_migrate',)})
|
||||
def test_instance_live_migrate_auto_sched(self):
|
||||
@ -359,8 +363,10 @@ class InstanceViewTest(test.BaseAdminViewTests):
|
||||
host = "AUTO_SCHEDULE"
|
||||
api.nova.server_get(IsA(http.HttpRequest), server.id) \
|
||||
.AndReturn(server)
|
||||
api.nova.host_list(IsA(http.HttpRequest)) \
|
||||
.AndReturn(self.hosts.list())
|
||||
compute_services = [s for s in self.services.list()
|
||||
if s.binary == 'nova-compute']
|
||||
api.nova.service_list(IsA(http.HttpRequest), binary='nova-compute') \
|
||||
.AndReturn(compute_services)
|
||||
api.nova.server_live_migrate(IsA(http.HttpRequest), server.id, None,
|
||||
block_migration=False,
|
||||
disk_over_commit=False) \
|
||||
@ -374,17 +380,19 @@ class InstanceViewTest(test.BaseAdminViewTests):
|
||||
self.assertNoFormErrors(res)
|
||||
self.assertRedirectsNoFollow(res, INDEX_URL)
|
||||
|
||||
@test.create_stubs({api.nova: ('host_list',
|
||||
@test.create_stubs({api.nova: ('service_list',
|
||||
'server_get',
|
||||
'server_live_migrate',)})
|
||||
def test_instance_live_migrate_post_api_exception(self):
|
||||
server = self.servers.first()
|
||||
host = self.hosts.first().host_name
|
||||
compute_services = [s for s in self.services.list()
|
||||
if s.binary == 'nova-compute']
|
||||
host = compute_services[0].host
|
||||
|
||||
api.nova.server_get(IsA(http.HttpRequest), server.id) \
|
||||
.AndReturn(server)
|
||||
api.nova.host_list(IsA(http.HttpRequest)) \
|
||||
.AndReturn(self.hosts.list())
|
||||
api.nova.service_list(IsA(http.HttpRequest), binary='nova-compute') \
|
||||
.AndReturn(compute_services)
|
||||
api.nova.server_live_migrate(IsA(http.HttpRequest), server.id, host,
|
||||
block_migration=False,
|
||||
disk_over_commit=False) \
|
||||
|
@ -215,7 +215,9 @@ class LiveMigrateView(forms.ModalFormView):
|
||||
@memoized.memoized_method
|
||||
def get_hosts(self, *args, **kwargs):
|
||||
try:
|
||||
return api.nova.host_list(self.request)
|
||||
services = api.nova.service_list(self.request,
|
||||
binary='nova-compute')
|
||||
return [s.host for s in services]
|
||||
except Exception:
|
||||
redirect = reverse("horizon:admin:instances:index")
|
||||
msg = _('Unable to retrieve host information.')
|
||||
|
@ -18,7 +18,6 @@ from novaclient.v2 import aggregates
|
||||
from novaclient.v2 import availability_zones
|
||||
from novaclient.v2 import flavor_access
|
||||
from novaclient.v2 import flavors
|
||||
from novaclient.v2 import hosts
|
||||
from novaclient.v2 import hypervisors
|
||||
from novaclient.v2 import keypairs
|
||||
from novaclient.v2 import quotas
|
||||
@ -167,7 +166,6 @@ def data(TEST):
|
||||
TEST.hypervisors = utils.TestDataContainer()
|
||||
TEST.services = utils.TestDataContainer()
|
||||
TEST.aggregates = utils.TestDataContainer()
|
||||
TEST.hosts = utils.TestDataContainer()
|
||||
TEST.server_groups = utils.TestDataContainer()
|
||||
|
||||
# Volumes
|
||||
@ -483,7 +481,7 @@ def data(TEST):
|
||||
"vcpus_used": 1,
|
||||
"hypervisor_type": "QEMU",
|
||||
"local_gb_used": 20,
|
||||
"hypervisor_hostname": "devstack001",
|
||||
"hypervisor_hostname": "devstack002",
|
||||
"memory_mb_used": 1500,
|
||||
"memory_mb": 2000,
|
||||
"current_workload": 0,
|
||||
@ -509,7 +507,7 @@ def data(TEST):
|
||||
"vcpus_used": 1,
|
||||
"hypervisor_type": "QEMU",
|
||||
"local_gb_used": 20,
|
||||
"hypervisor_hostname": "devstack003",
|
||||
"hypervisor_hostname": "instance-host",
|
||||
"memory_mb_used": 1500,
|
||||
"memory_mb": 2000,
|
||||
"current_workload": 0,
|
||||
@ -622,35 +620,6 @@ def data(TEST):
|
||||
TEST.aggregates.add(aggregate_1)
|
||||
TEST.aggregates.add(aggregate_2)
|
||||
|
||||
host1 = hosts.Host(hosts.HostManager(None), {
|
||||
"host_name": "devstack001",
|
||||
"service": "compute",
|
||||
"zone": "testing",
|
||||
})
|
||||
|
||||
host2 = hosts.Host(hosts.HostManager(None), {
|
||||
"host_name": "devstack002",
|
||||
"service": "nova-conductor",
|
||||
"zone": "testing",
|
||||
})
|
||||
|
||||
host3 = hosts.Host(hosts.HostManager(None), {
|
||||
"host_name": "devstack003",
|
||||
"service": "compute",
|
||||
"zone": "testing",
|
||||
})
|
||||
|
||||
host4 = hosts.Host(hosts.HostManager(None), {
|
||||
"host_name": "devstack004",
|
||||
"service": "compute",
|
||||
"zone": "testing",
|
||||
})
|
||||
|
||||
TEST.hosts.add(host1)
|
||||
TEST.hosts.add(host2)
|
||||
TEST.hosts.add(host3)
|
||||
TEST.hosts.add(host4)
|
||||
|
||||
server_group_1 = server_groups.ServerGroup(
|
||||
server_groups.ServerGroupsManager(None),
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user