Merge "Change some compute admin image client methods to return one value"
This commit is contained in:
commit
7db9693282
@ -37,8 +37,7 @@ class AgentsAdminTestJSON(base.BaseV2ComputeAdminTest):
|
||||
hypervisor='common', os='linux', architecture='x86_64',
|
||||
version='7.0', url='xxx://xxxx/xxx/xxx',
|
||||
md5hash='add6bb58e139be103324d04d82d8f545')
|
||||
resp, body = self.client.create_agent(**params)
|
||||
self.assertEqual(200, resp.status)
|
||||
body = self.client.create_agent(**params)
|
||||
self.agent_id = body['agent_id']
|
||||
|
||||
def tearDown(self):
|
||||
@ -67,8 +66,7 @@ class AgentsAdminTestJSON(base.BaseV2ComputeAdminTest):
|
||||
hypervisor='kvm', os='win', architecture='x86',
|
||||
version='7.0', url='xxx://xxxx/xxx/xxx',
|
||||
md5hash='add6bb58e139be103324d04d82d8f545')
|
||||
resp, body = self.client.create_agent(**params)
|
||||
self.assertEqual(200, resp.status)
|
||||
body = self.client.create_agent(**params)
|
||||
self.addCleanup(self.client.delete_agent, body['agent_id'])
|
||||
for expected_item, value in params.items():
|
||||
self.assertEqual(value, body[expected_item])
|
||||
@ -79,27 +77,23 @@ class AgentsAdminTestJSON(base.BaseV2ComputeAdminTest):
|
||||
params = self._param_helper(
|
||||
version='8.0', url='xxx://xxxx/xxx/xxx2',
|
||||
md5hash='add6bb58e139be103324d04d82d8f547')
|
||||
resp, body = self.client.update_agent(self.agent_id, **params)
|
||||
self.assertEqual(200, resp.status)
|
||||
body = self.client.update_agent(self.agent_id, **params)
|
||||
for expected_item, value in params.items():
|
||||
self.assertEqual(value, body[expected_item])
|
||||
|
||||
@test.attr(type='gate')
|
||||
def test_delete_agent(self):
|
||||
# Delete an agent.
|
||||
resp, _ = self.client.delete_agent(self.agent_id)
|
||||
self.assertEqual(200, resp.status)
|
||||
self.client.delete_agent(self.agent_id)
|
||||
|
||||
# Verify the list doesn't contain the deleted agent.
|
||||
resp, agents = self.client.list_agents()
|
||||
self.assertEqual(200, resp.status)
|
||||
agents = self.client.list_agents()
|
||||
self.assertNotIn(self.agent_id, map(lambda x: x['agent_id'], agents))
|
||||
|
||||
@test.attr(type='gate')
|
||||
def test_list_agents(self):
|
||||
# List all agents.
|
||||
resp, agents = self.client.list_agents()
|
||||
self.assertEqual(200, resp.status)
|
||||
agents = self.client.list_agents()
|
||||
self.assertTrue(len(agents) > 0, 'Cannot get any agents.(%s)' % agents)
|
||||
self.assertIn(self.agent_id, map(lambda x: x['agent_id'], agents))
|
||||
|
||||
@ -110,14 +104,12 @@ class AgentsAdminTestJSON(base.BaseV2ComputeAdminTest):
|
||||
hypervisor='xen', os='linux', architecture='x86',
|
||||
version='7.0', url='xxx://xxxx/xxx/xxx1',
|
||||
md5hash='add6bb58e139be103324d04d82d8f546')
|
||||
resp, agent_xen = self.client.create_agent(**params)
|
||||
self.assertEqual(200, resp.status)
|
||||
agent_xen = self.client.create_agent(**params)
|
||||
self.addCleanup(self.client.delete_agent, agent_xen['agent_id'])
|
||||
|
||||
agent_id_xen = agent_xen['agent_id']
|
||||
params_filter = {'hypervisor': agent_xen['hypervisor']}
|
||||
resp, agents = self.client.list_agents(params_filter)
|
||||
self.assertEqual(200, resp.status)
|
||||
agents = self.client.list_agents(params_filter)
|
||||
self.assertTrue(len(agents) > 0, 'Cannot get any agents.(%s)' % agents)
|
||||
self.assertIn(agent_id_xen, map(lambda x: x['agent_id'], agents))
|
||||
self.assertNotIn(self.agent_id, map(lambda x: x['agent_id'], agents))
|
||||
|
@ -35,7 +35,7 @@ class AggregatesAdminTestJSON(base.BaseV2ComputeAdminTest):
|
||||
cls.aggregate_name_prefix = 'test_aggregate_'
|
||||
cls.az_name_prefix = 'test_az_'
|
||||
|
||||
resp, hosts_all = cls.os_adm.hosts_client.list_hosts()
|
||||
hosts_all = cls.os_adm.hosts_client.list_hosts()
|
||||
hosts = map(lambda x: x['host_name'],
|
||||
filter(lambda y: y['service'] == 'compute', hosts_all))
|
||||
cls.host = hosts[0]
|
||||
@ -52,14 +52,12 @@ class AggregatesAdminTestJSON(base.BaseV2ComputeAdminTest):
|
||||
def test_aggregate_create_delete(self):
|
||||
# Create and delete an aggregate.
|
||||
aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
|
||||
resp, aggregate = self.client.create_aggregate(name=aggregate_name)
|
||||
aggregate = self.client.create_aggregate(name=aggregate_name)
|
||||
self.addCleanup(self._try_delete_aggregate, aggregate['id'])
|
||||
self.assertEqual(200, resp.status)
|
||||
self.assertEqual(aggregate_name, aggregate['name'])
|
||||
self.assertIsNone(aggregate['availability_zone'])
|
||||
|
||||
resp, _ = self.client.delete_aggregate(aggregate['id'])
|
||||
self.assertEqual(200, resp.status)
|
||||
self.client.delete_aggregate(aggregate['id'])
|
||||
self.client.wait_for_resource_deletion(aggregate['id'])
|
||||
|
||||
@test.attr(type='gate')
|
||||
@ -67,26 +65,23 @@ class AggregatesAdminTestJSON(base.BaseV2ComputeAdminTest):
|
||||
# Create and delete an aggregate.
|
||||
aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
|
||||
az_name = data_utils.rand_name(self.az_name_prefix)
|
||||
resp, aggregate = self.client.create_aggregate(
|
||||
aggregate = self.client.create_aggregate(
|
||||
name=aggregate_name, availability_zone=az_name)
|
||||
self.addCleanup(self._try_delete_aggregate, aggregate['id'])
|
||||
self.assertEqual(200, resp.status)
|
||||
self.assertEqual(aggregate_name, aggregate['name'])
|
||||
self.assertEqual(az_name, aggregate['availability_zone'])
|
||||
|
||||
resp, _ = self.client.delete_aggregate(aggregate['id'])
|
||||
self.assertEqual(200, resp.status)
|
||||
self.client.delete_aggregate(aggregate['id'])
|
||||
self.client.wait_for_resource_deletion(aggregate['id'])
|
||||
|
||||
@test.attr(type='gate')
|
||||
def test_aggregate_create_verify_entry_in_list(self):
|
||||
# Create an aggregate and ensure it is listed.
|
||||
aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
|
||||
resp, aggregate = self.client.create_aggregate(name=aggregate_name)
|
||||
aggregate = self.client.create_aggregate(name=aggregate_name)
|
||||
self.addCleanup(self.client.delete_aggregate, aggregate['id'])
|
||||
|
||||
resp, aggregates = self.client.list_aggregates()
|
||||
self.assertEqual(200, resp.status)
|
||||
aggregates = self.client.list_aggregates()
|
||||
self.assertIn((aggregate['id'], aggregate['availability_zone']),
|
||||
map(lambda x: (x['id'], x['availability_zone']),
|
||||
aggregates))
|
||||
@ -95,11 +90,10 @@ class AggregatesAdminTestJSON(base.BaseV2ComputeAdminTest):
|
||||
def test_aggregate_create_update_metadata_get_details(self):
|
||||
# Create an aggregate and ensure its details are returned.
|
||||
aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
|
||||
resp, aggregate = self.client.create_aggregate(name=aggregate_name)
|
||||
aggregate = self.client.create_aggregate(name=aggregate_name)
|
||||
self.addCleanup(self.client.delete_aggregate, aggregate['id'])
|
||||
|
||||
resp, body = self.client.get_aggregate(aggregate['id'])
|
||||
self.assertEqual(200, resp.status)
|
||||
body = self.client.get_aggregate(aggregate['id'])
|
||||
self.assertEqual(aggregate['name'], body['name'])
|
||||
self.assertEqual(aggregate['availability_zone'],
|
||||
body['availability_zone'])
|
||||
@ -107,13 +101,11 @@ class AggregatesAdminTestJSON(base.BaseV2ComputeAdminTest):
|
||||
|
||||
# set the metadata of the aggregate
|
||||
meta = {"key": "value"}
|
||||
resp, body = self.client.set_metadata(aggregate['id'], meta)
|
||||
self.assertEqual(200, resp.status)
|
||||
body = self.client.set_metadata(aggregate['id'], meta)
|
||||
self.assertEqual(meta, body["metadata"])
|
||||
|
||||
# verify the metadata has been set
|
||||
resp, body = self.client.get_aggregate(aggregate['id'])
|
||||
self.assertEqual(200, resp.status)
|
||||
body = self.client.get_aggregate(aggregate['id'])
|
||||
self.assertEqual(meta, body["metadata"])
|
||||
|
||||
@test.attr(type='gate')
|
||||
@ -121,11 +113,10 @@ class AggregatesAdminTestJSON(base.BaseV2ComputeAdminTest):
|
||||
# Update an aggregate and ensure properties are updated correctly
|
||||
aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
|
||||
az_name = data_utils.rand_name(self.az_name_prefix)
|
||||
resp, aggregate = self.client.create_aggregate(
|
||||
aggregate = self.client.create_aggregate(
|
||||
name=aggregate_name, availability_zone=az_name)
|
||||
self.addCleanup(self.client.delete_aggregate, aggregate['id'])
|
||||
|
||||
self.assertEqual(200, resp.status)
|
||||
self.assertEqual(aggregate_name, aggregate['name'])
|
||||
self.assertEqual(az_name, aggregate['availability_zone'])
|
||||
self.assertIsNotNone(aggregate['id'])
|
||||
@ -134,15 +125,13 @@ class AggregatesAdminTestJSON(base.BaseV2ComputeAdminTest):
|
||||
new_aggregate_name = aggregate_name + '_new'
|
||||
new_az_name = az_name + '_new'
|
||||
|
||||
resp, resp_aggregate = self.client.update_aggregate(aggregate_id,
|
||||
resp_aggregate = self.client.update_aggregate(aggregate_id,
|
||||
new_aggregate_name,
|
||||
new_az_name)
|
||||
self.assertEqual(200, resp.status)
|
||||
self.assertEqual(new_aggregate_name, resp_aggregate['name'])
|
||||
self.assertEqual(new_az_name, resp_aggregate['availability_zone'])
|
||||
|
||||
resp, aggregates = self.client.list_aggregates()
|
||||
self.assertEqual(200, resp.status)
|
||||
aggregates = self.client.list_aggregates()
|
||||
self.assertIn((aggregate_id, new_aggregate_name, new_az_name),
|
||||
map(lambda x:
|
||||
(x['id'], x['name'], x['availability_zone']),
|
||||
@ -153,18 +142,16 @@ class AggregatesAdminTestJSON(base.BaseV2ComputeAdminTest):
|
||||
# Add an host to the given aggregate and remove.
|
||||
self.useFixture(fixtures.LockFixture('availability_zone'))
|
||||
aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
|
||||
resp, aggregate = self.client.create_aggregate(name=aggregate_name)
|
||||
aggregate = self.client.create_aggregate(name=aggregate_name)
|
||||
self.addCleanup(self.client.delete_aggregate, aggregate['id'])
|
||||
|
||||
resp, body = self.client.add_host(aggregate['id'], self.host)
|
||||
self.assertEqual(200, resp.status)
|
||||
body = self.client.add_host(aggregate['id'], self.host)
|
||||
self.assertEqual(aggregate_name, body['name'])
|
||||
self.assertEqual(aggregate['availability_zone'],
|
||||
body['availability_zone'])
|
||||
self.assertIn(self.host, body['hosts'])
|
||||
|
||||
resp, body = self.client.remove_host(aggregate['id'], self.host)
|
||||
self.assertEqual(200, resp.status)
|
||||
body = self.client.remove_host(aggregate['id'], self.host)
|
||||
self.assertEqual(aggregate_name, body['name'])
|
||||
self.assertEqual(aggregate['availability_zone'],
|
||||
body['availability_zone'])
|
||||
@ -175,12 +162,12 @@ class AggregatesAdminTestJSON(base.BaseV2ComputeAdminTest):
|
||||
# Add an host to the given aggregate and list.
|
||||
self.useFixture(fixtures.LockFixture('availability_zone'))
|
||||
aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
|
||||
resp, aggregate = self.client.create_aggregate(name=aggregate_name)
|
||||
aggregate = self.client.create_aggregate(name=aggregate_name)
|
||||
self.addCleanup(self.client.delete_aggregate, aggregate['id'])
|
||||
self.client.add_host(aggregate['id'], self.host)
|
||||
self.addCleanup(self.client.remove_host, aggregate['id'], self.host)
|
||||
|
||||
resp, aggregates = self.client.list_aggregates()
|
||||
aggregates = self.client.list_aggregates()
|
||||
aggs = filter(lambda x: x['id'] == aggregate['id'], aggregates)
|
||||
self.assertEqual(1, len(aggs))
|
||||
agg = aggs[0]
|
||||
@ -193,12 +180,12 @@ class AggregatesAdminTestJSON(base.BaseV2ComputeAdminTest):
|
||||
# Add an host to the given aggregate and get details.
|
||||
self.useFixture(fixtures.LockFixture('availability_zone'))
|
||||
aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
|
||||
resp, aggregate = self.client.create_aggregate(name=aggregate_name)
|
||||
aggregate = self.client.create_aggregate(name=aggregate_name)
|
||||
self.addCleanup(self.client.delete_aggregate, aggregate['id'])
|
||||
self.client.add_host(aggregate['id'], self.host)
|
||||
self.addCleanup(self.client.remove_host, aggregate['id'], self.host)
|
||||
|
||||
resp, body = self.client.get_aggregate(aggregate['id'])
|
||||
body = self.client.get_aggregate(aggregate['id'])
|
||||
self.assertEqual(aggregate_name, body['name'])
|
||||
self.assertIsNone(body['availability_zone'])
|
||||
self.assertIn(self.host, body['hosts'])
|
||||
@ -209,7 +196,7 @@ class AggregatesAdminTestJSON(base.BaseV2ComputeAdminTest):
|
||||
self.useFixture(fixtures.LockFixture('availability_zone'))
|
||||
aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
|
||||
az_name = data_utils.rand_name(self.az_name_prefix)
|
||||
resp, aggregate = self.client.create_aggregate(
|
||||
aggregate = self.client.create_aggregate(
|
||||
name=aggregate_name, availability_zone=az_name)
|
||||
self.addCleanup(self.client.delete_aggregate, aggregate['id'])
|
||||
self.client.add_host(aggregate['id'], self.host)
|
||||
|
@ -34,7 +34,7 @@ class AggregatesAdminNegativeTestJSON(base.BaseV2ComputeAdminTest):
|
||||
cls.aggregate_name_prefix = 'test_aggregate_'
|
||||
cls.az_name_prefix = 'test_az_'
|
||||
|
||||
resp, hosts_all = cls.os_adm.hosts_client.list_hosts()
|
||||
hosts_all = cls.os_adm.hosts_client.list_hosts()
|
||||
hosts = map(lambda x: x['host_name'],
|
||||
filter(lambda y: y['service'] == 'compute', hosts_all))
|
||||
cls.host = hosts[0]
|
||||
@ -66,8 +66,7 @@ class AggregatesAdminNegativeTestJSON(base.BaseV2ComputeAdminTest):
|
||||
def test_aggregate_create_with_existent_aggregate_name(self):
|
||||
# creating an aggregate with existent aggregate name is forbidden
|
||||
aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
|
||||
resp, aggregate = self.client.create_aggregate(name=aggregate_name)
|
||||
self.assertEqual(200, resp.status)
|
||||
aggregate = self.client.create_aggregate(name=aggregate_name)
|
||||
self.addCleanup(self.client.delete_aggregate, aggregate['id'])
|
||||
|
||||
self.assertRaises(exceptions.Conflict,
|
||||
@ -78,8 +77,7 @@ class AggregatesAdminNegativeTestJSON(base.BaseV2ComputeAdminTest):
|
||||
def test_aggregate_delete_as_user(self):
|
||||
# Regular user is not allowed to delete an aggregate.
|
||||
aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
|
||||
resp, aggregate = self.client.create_aggregate(name=aggregate_name)
|
||||
self.assertEqual(200, resp.status)
|
||||
aggregate = self.client.create_aggregate(name=aggregate_name)
|
||||
self.addCleanup(self.client.delete_aggregate, aggregate['id'])
|
||||
|
||||
self.assertRaises(exceptions.Unauthorized,
|
||||
@ -96,8 +94,7 @@ class AggregatesAdminNegativeTestJSON(base.BaseV2ComputeAdminTest):
|
||||
def test_aggregate_get_details_as_user(self):
|
||||
# Regular user is not allowed to get aggregate details.
|
||||
aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
|
||||
resp, aggregate = self.client.create_aggregate(name=aggregate_name)
|
||||
self.assertEqual(200, resp.status)
|
||||
aggregate = self.client.create_aggregate(name=aggregate_name)
|
||||
self.addCleanup(self.client.delete_aggregate, aggregate['id'])
|
||||
|
||||
self.assertRaises(exceptions.Unauthorized,
|
||||
@ -119,7 +116,7 @@ class AggregatesAdminNegativeTestJSON(base.BaseV2ComputeAdminTest):
|
||||
@test.attr(type=['negative', 'gate'])
|
||||
def test_aggregate_add_non_exist_host(self):
|
||||
# Adding a non-exist host to an aggregate should raise exceptions.
|
||||
resp, hosts_all = self.os_adm.hosts_client.list_hosts()
|
||||
hosts_all = self.os_adm.hosts_client.list_hosts()
|
||||
hosts = map(lambda x: x['host_name'], hosts_all)
|
||||
while True:
|
||||
non_exist_host = data_utils.rand_name('nonexist_host_')
|
||||
@ -127,7 +124,7 @@ class AggregatesAdminNegativeTestJSON(base.BaseV2ComputeAdminTest):
|
||||
break
|
||||
|
||||
aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
|
||||
resp, aggregate = self.client.create_aggregate(name=aggregate_name)
|
||||
aggregate = self.client.create_aggregate(name=aggregate_name)
|
||||
self.addCleanup(self.client.delete_aggregate, aggregate['id'])
|
||||
|
||||
self.assertRaises(exceptions.NotFound, self.client.add_host,
|
||||
@ -137,8 +134,7 @@ class AggregatesAdminNegativeTestJSON(base.BaseV2ComputeAdminTest):
|
||||
def test_aggregate_add_host_as_user(self):
|
||||
# Regular user is not allowed to add a host to an aggregate.
|
||||
aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
|
||||
resp, aggregate = self.client.create_aggregate(name=aggregate_name)
|
||||
self.assertEqual(200, resp.status)
|
||||
aggregate = self.client.create_aggregate(name=aggregate_name)
|
||||
self.addCleanup(self.client.delete_aggregate, aggregate['id'])
|
||||
|
||||
self.assertRaises(exceptions.Unauthorized,
|
||||
@ -149,12 +145,10 @@ class AggregatesAdminNegativeTestJSON(base.BaseV2ComputeAdminTest):
|
||||
def test_aggregate_add_existent_host(self):
|
||||
self.useFixture(fixtures.LockFixture('availability_zone'))
|
||||
aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
|
||||
resp, aggregate = self.client.create_aggregate(name=aggregate_name)
|
||||
self.assertEqual(200, resp.status)
|
||||
aggregate = self.client.create_aggregate(name=aggregate_name)
|
||||
self.addCleanup(self.client.delete_aggregate, aggregate['id'])
|
||||
|
||||
resp, body = self.client.add_host(aggregate['id'], self.host)
|
||||
self.assertEqual(200, resp.status)
|
||||
self.client.add_host(aggregate['id'], self.host)
|
||||
self.addCleanup(self.client.remove_host, aggregate['id'], self.host)
|
||||
|
||||
self.assertRaises(exceptions.Conflict, self.client.add_host,
|
||||
@ -165,11 +159,9 @@ class AggregatesAdminNegativeTestJSON(base.BaseV2ComputeAdminTest):
|
||||
# Regular user is not allowed to remove a host from an aggregate.
|
||||
self.useFixture(fixtures.LockFixture('availability_zone'))
|
||||
aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
|
||||
resp, aggregate = self.client.create_aggregate(name=aggregate_name)
|
||||
self.assertEqual(200, resp.status)
|
||||
aggregate = self.client.create_aggregate(name=aggregate_name)
|
||||
self.addCleanup(self.client.delete_aggregate, aggregate['id'])
|
||||
resp, body = self.client.add_host(aggregate['id'], self.host)
|
||||
self.assertEqual(200, resp.status)
|
||||
self.client.add_host(aggregate['id'], self.host)
|
||||
self.addCleanup(self.client.remove_host, aggregate['id'], self.host)
|
||||
|
||||
self.assertRaises(exceptions.Unauthorized,
|
||||
@ -180,8 +172,7 @@ class AggregatesAdminNegativeTestJSON(base.BaseV2ComputeAdminTest):
|
||||
def test_aggregate_remove_nonexistent_host(self):
|
||||
non_exist_host = data_utils.rand_name('nonexist_host_')
|
||||
aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
|
||||
resp, aggregate = self.client.create_aggregate(name=aggregate_name)
|
||||
self.assertEqual(200, resp.status)
|
||||
aggregate = self.client.create_aggregate(name=aggregate_name)
|
||||
self.addCleanup(self.client.delete_aggregate, aggregate['id'])
|
||||
|
||||
self.assertRaises(exceptions.NotFound, self.client.remove_host,
|
||||
|
@ -30,19 +30,17 @@ class HostsAdminTestJSON(base.BaseV2ComputeAdminTest):
|
||||
|
||||
@test.attr(type='gate')
|
||||
def test_list_hosts(self):
|
||||
resp, hosts = self.client.list_hosts()
|
||||
self.assertEqual(200, resp.status)
|
||||
hosts = self.client.list_hosts()
|
||||
self.assertTrue(len(hosts) >= 2, str(hosts))
|
||||
|
||||
@test.attr(type='gate')
|
||||
def test_list_hosts_with_zone(self):
|
||||
self.useFixture(fixtures.LockFixture('availability_zone'))
|
||||
resp, hosts = self.client.list_hosts()
|
||||
hosts = self.client.list_hosts()
|
||||
host = hosts[0]
|
||||
zone_name = host['zone']
|
||||
params = {'zone': zone_name}
|
||||
resp, hosts = self.client.list_hosts(params)
|
||||
self.assertEqual(200, resp.status)
|
||||
hosts = self.client.list_hosts(params)
|
||||
self.assertTrue(len(hosts) >= 1)
|
||||
self.assertIn(host, hosts)
|
||||
|
||||
@ -51,31 +49,27 @@ class HostsAdminTestJSON(base.BaseV2ComputeAdminTest):
|
||||
# If send the request with a blank zone, the request will be successful
|
||||
# and it will return all the hosts list
|
||||
params = {'zone': ''}
|
||||
resp, hosts = self.client.list_hosts(params)
|
||||
hosts = self.client.list_hosts(params)
|
||||
self.assertNotEqual(0, len(hosts))
|
||||
self.assertEqual(200, resp.status)
|
||||
|
||||
@test.attr(type='gate')
|
||||
def test_list_hosts_with_nonexistent_zone(self):
|
||||
# If send the request with a nonexistent zone, the request will be
|
||||
# successful and no hosts will be retured
|
||||
params = {'zone': 'xxx'}
|
||||
resp, hosts = self.client.list_hosts(params)
|
||||
hosts = self.client.list_hosts(params)
|
||||
self.assertEqual(0, len(hosts))
|
||||
self.assertEqual(200, resp.status)
|
||||
|
||||
@test.attr(type='gate')
|
||||
def test_show_host_detail(self):
|
||||
resp, hosts = self.client.list_hosts()
|
||||
self.assertEqual(200, resp.status)
|
||||
hosts = self.client.list_hosts()
|
||||
|
||||
hosts = [host for host in hosts if host['service'] == 'compute']
|
||||
self.assertTrue(len(hosts) >= 1)
|
||||
|
||||
for host in hosts:
|
||||
hostname = host['host_name']
|
||||
resp, resources = self.client.show_host_detail(hostname)
|
||||
self.assertEqual(200, resp.status)
|
||||
resources = self.client.show_host_detail(hostname)
|
||||
self.assertTrue(len(resources) >= 1)
|
||||
host_resource = resources[0]['resource']
|
||||
self.assertIsNotNone(host_resource)
|
||||
|
@ -31,8 +31,7 @@ class HostsAdminNegativeTestJSON(base.BaseV2ComputeAdminTest):
|
||||
cls.non_admin_client = cls.os.hosts_client
|
||||
|
||||
def _get_host_name(self):
|
||||
resp, hosts = self.client.list_hosts()
|
||||
self.assertEqual(200, resp.status)
|
||||
hosts = self.client.list_hosts()
|
||||
self.assertTrue(len(hosts) >= 1)
|
||||
hostname = hosts[0]['host_name']
|
||||
return hostname
|
||||
|
@ -30,8 +30,7 @@ class HypervisorAdminTestJSON(base.BaseV2ComputeAdminTest):
|
||||
|
||||
def _list_hypervisors(self):
|
||||
# List of hypervisors
|
||||
resp, hypers = self.client.get_hypervisor_list()
|
||||
self.assertEqual(200, resp.status)
|
||||
hypers = self.client.get_hypervisor_list()
|
||||
return hypers
|
||||
|
||||
def assertHypervisors(self, hypers):
|
||||
@ -46,8 +45,7 @@ class HypervisorAdminTestJSON(base.BaseV2ComputeAdminTest):
|
||||
@test.attr(type='gate')
|
||||
def test_get_hypervisor_list_details(self):
|
||||
# Display the details of the all hypervisor
|
||||
resp, hypers = self.client.get_hypervisor_list_details()
|
||||
self.assertEqual(200, resp.status)
|
||||
hypers = self.client.get_hypervisor_list_details()
|
||||
self.assertHypervisors(hypers)
|
||||
|
||||
@test.attr(type='gate')
|
||||
@ -56,9 +54,7 @@ class HypervisorAdminTestJSON(base.BaseV2ComputeAdminTest):
|
||||
hypers = self._list_hypervisors()
|
||||
self.assertHypervisors(hypers)
|
||||
|
||||
resp, details = (self.client.
|
||||
get_hypervisor_show_details(hypers[0]['id']))
|
||||
self.assertEqual(200, resp.status)
|
||||
details = self.client.get_hypervisor_show_details(hypers[0]['id'])
|
||||
self.assertTrue(len(details) > 0)
|
||||
self.assertEqual(details['hypervisor_hostname'],
|
||||
hypers[0]['hypervisor_hostname'])
|
||||
@ -70,15 +66,13 @@ class HypervisorAdminTestJSON(base.BaseV2ComputeAdminTest):
|
||||
self.assertHypervisors(hypers)
|
||||
|
||||
hostname = hypers[0]['hypervisor_hostname']
|
||||
resp, hypervisors = self.client.get_hypervisor_servers(hostname)
|
||||
self.assertEqual(200, resp.status)
|
||||
hypervisors = self.client.get_hypervisor_servers(hostname)
|
||||
self.assertTrue(len(hypervisors) > 0)
|
||||
|
||||
@test.attr(type='gate')
|
||||
def test_get_hypervisor_stats(self):
|
||||
# Verify the stats of the all hypervisor
|
||||
resp, stats = self.client.get_hypervisor_stats()
|
||||
self.assertEqual(200, resp.status)
|
||||
stats = self.client.get_hypervisor_stats()
|
||||
self.assertTrue(len(stats) > 0)
|
||||
|
||||
@test.attr(type='gate')
|
||||
@ -94,9 +88,7 @@ class HypervisorAdminTestJSON(base.BaseV2ComputeAdminTest):
|
||||
ironic_only = True
|
||||
hypers_without_ironic = []
|
||||
for hyper in hypers:
|
||||
resp, details = (self.client.
|
||||
get_hypervisor_show_details(hypers[0]['id']))
|
||||
self.assertEqual(200, resp.status)
|
||||
details = self.client.get_hypervisor_show_details(hypers[0]['id'])
|
||||
if details['hypervisor_type'] != 'ironic':
|
||||
hypers_without_ironic.append(hyper)
|
||||
ironic_only = False
|
||||
@ -110,8 +102,8 @@ class HypervisorAdminTestJSON(base.BaseV2ComputeAdminTest):
|
||||
# because hypervisors might be disabled, this loops looking
|
||||
# for any good hit.
|
||||
try:
|
||||
resp, uptime = self.client.get_hypervisor_uptime(hyper['id'])
|
||||
if (resp.status == 200) and (len(uptime) > 0):
|
||||
uptime = self.client.get_hypervisor_uptime(hyper['id'])
|
||||
if len(uptime) > 0:
|
||||
has_valid_uptime = True
|
||||
break
|
||||
except Exception:
|
||||
@ -124,7 +116,6 @@ class HypervisorAdminTestJSON(base.BaseV2ComputeAdminTest):
|
||||
def test_search_hypervisor(self):
|
||||
hypers = self._list_hypervisors()
|
||||
self.assertHypervisors(hypers)
|
||||
resp, hypers = self.client.search_hypervisor(
|
||||
hypers = self.client.search_hypervisor(
|
||||
hypers[0]['hypervisor_hostname'])
|
||||
self.assertEqual(200, resp.status)
|
||||
self.assertHypervisors(hypers)
|
||||
|
@ -35,8 +35,7 @@ class HypervisorAdminNegativeTestJSON(base.BaseV2ComputeAdminTest):
|
||||
|
||||
def _list_hypervisors(self):
|
||||
# List of hypervisors
|
||||
resp, hypers = self.client.get_hypervisor_list()
|
||||
self.assertEqual(200, resp.status)
|
||||
hypers = self.client.get_hypervisor_list()
|
||||
return hypers
|
||||
|
||||
@test.attr(type=['negative', 'gate'])
|
||||
|
@ -31,29 +31,27 @@ class ServicesAdminTestJSON(base.BaseV2ComputeAdminTest):
|
||||
|
||||
@test.attr(type='gate')
|
||||
def test_list_services(self):
|
||||
resp, services = self.client.list_services()
|
||||
self.assertEqual(200, resp.status)
|
||||
services = self.client.list_services()
|
||||
self.assertNotEqual(0, len(services))
|
||||
|
||||
@test.attr(type='gate')
|
||||
def test_get_service_by_service_binary_name(self):
|
||||
binary_name = 'nova-compute'
|
||||
params = {'binary': binary_name}
|
||||
resp, services = self.client.list_services(params)
|
||||
self.assertEqual(200, resp.status)
|
||||
services = self.client.list_services(params)
|
||||
self.assertNotEqual(0, len(services))
|
||||
for service in services:
|
||||
self.assertEqual(binary_name, service['binary'])
|
||||
|
||||
@test.attr(type='gate')
|
||||
def test_get_service_by_host_name(self):
|
||||
resp, services = self.client.list_services()
|
||||
services = self.client.list_services()
|
||||
host_name = services[0]['host']
|
||||
services_on_host = [service for service in services if
|
||||
service['host'] == host_name]
|
||||
params = {'host': host_name}
|
||||
|
||||
resp, services = self.client.list_services(params)
|
||||
services = self.client.list_services(params)
|
||||
|
||||
# we could have a periodic job checkin between the 2 service
|
||||
# lookups, so only compare binary lists.
|
||||
@ -66,13 +64,12 @@ class ServicesAdminTestJSON(base.BaseV2ComputeAdminTest):
|
||||
|
||||
@test.attr(type='gate')
|
||||
def test_get_service_by_service_and_host_name(self):
|
||||
resp, services = self.client.list_services()
|
||||
services = self.client.list_services()
|
||||
host_name = services[0]['host']
|
||||
binary_name = services[0]['binary']
|
||||
params = {'host': host_name, 'binary': binary_name}
|
||||
|
||||
resp, services = self.client.list_services(params)
|
||||
self.assertEqual(200, resp.status)
|
||||
services = self.client.list_services(params)
|
||||
self.assertEqual(1, len(services))
|
||||
self.assertEqual(host_name, services[0]['host'])
|
||||
self.assertEqual(binary_name, services[0]['binary'])
|
||||
|
@ -37,26 +37,23 @@ class ServicesAdminNegativeTestJSON(base.BaseV2ComputeAdminTest):
|
||||
@test.attr(type=['negative', 'gate'])
|
||||
def test_get_service_by_invalid_params(self):
|
||||
# return all services if send the request with invalid parameter
|
||||
resp, services = self.client.list_services()
|
||||
services = self.client.list_services()
|
||||
params = {'xxx': 'nova-compute'}
|
||||
resp, services_xxx = self.client.list_services(params)
|
||||
self.assertEqual(200, resp.status)
|
||||
services_xxx = self.client.list_services(params)
|
||||
self.assertEqual(len(services), len(services_xxx))
|
||||
|
||||
@test.attr(type=['negative', 'gate'])
|
||||
def test_get_service_by_invalid_service_and_valid_host(self):
|
||||
resp, services = self.client.list_services()
|
||||
services = self.client.list_services()
|
||||
host_name = services[0]['host']
|
||||
params = {'host': host_name, 'binary': 'xxx'}
|
||||
resp, services = self.client.list_services(params)
|
||||
self.assertEqual(200, resp.status)
|
||||
services = self.client.list_services(params)
|
||||
self.assertEqual(0, len(services))
|
||||
|
||||
@test.attr(type=['negative', 'gate'])
|
||||
def test_get_service_with_valid_service_and_invalid_host(self):
|
||||
resp, services = self.client.list_services()
|
||||
services = self.client.list_services()
|
||||
binary_name = services[0]['binary']
|
||||
params = {'host': 'xxx', 'binary': binary_name}
|
||||
resp, services = self.client.list_services(params)
|
||||
self.assertEqual(200, resp.status)
|
||||
services = self.client.list_services(params)
|
||||
self.assertEqual(0, len(services))
|
||||
|
@ -36,7 +36,7 @@ class LiveBlockMigrationTestJSON(base.BaseV2ComputeAdminTest):
|
||||
cls.created_server_ids = []
|
||||
|
||||
def _get_compute_hostnames(self):
|
||||
_resp, body = self.admin_hosts_client.list_hosts()
|
||||
body = self.admin_hosts_client.list_hosts()
|
||||
return [
|
||||
host_record['host_name']
|
||||
for host_record in body
|
||||
|
@ -43,7 +43,7 @@ class TestAggregatesBasicOps(manager.ScenarioTest):
|
||||
return cls.admin_credentials()
|
||||
|
||||
def _create_aggregate(self, **kwargs):
|
||||
_, aggregate = self.aggregates_client.create_aggregate(**kwargs)
|
||||
aggregate = self.aggregates_client.create_aggregate(**kwargs)
|
||||
self.addCleanup(self._delete_aggregate, aggregate)
|
||||
aggregate_name = kwargs['name']
|
||||
availability_zone = kwargs['availability_zone']
|
||||
@ -55,23 +55,23 @@ class TestAggregatesBasicOps(manager.ScenarioTest):
|
||||
self.aggregates_client.delete_aggregate(aggregate['id'])
|
||||
|
||||
def _get_host_name(self):
|
||||
_, hosts = self.hosts_client.list_hosts()
|
||||
hosts = self.hosts_client.list_hosts()
|
||||
self.assertTrue(len(hosts) >= 1)
|
||||
computes = [x for x in hosts if x['service'] == 'compute']
|
||||
return computes[0]['host_name']
|
||||
|
||||
def _add_host(self, aggregate_id, host):
|
||||
_, aggregate = self.aggregates_client.add_host(aggregate_id, host)
|
||||
aggregate = self.aggregates_client.add_host(aggregate_id, host)
|
||||
self.addCleanup(self._remove_host, aggregate['id'], host)
|
||||
self.assertIn(host, aggregate['hosts'])
|
||||
|
||||
def _remove_host(self, aggregate_id, host):
|
||||
_, aggregate = self.aggregates_client.remove_host(aggregate_id, host)
|
||||
aggregate = self.aggregates_client.remove_host(aggregate_id, host)
|
||||
self.assertNotIn(host, aggregate['hosts'])
|
||||
|
||||
def _check_aggregate_details(self, aggregate, aggregate_name, azone,
|
||||
hosts, metadata):
|
||||
_, aggregate = self.aggregates_client.get_aggregate(aggregate['id'])
|
||||
aggregate = self.aggregates_client.get_aggregate(aggregate['id'])
|
||||
self.assertEqual(aggregate_name, aggregate['name'])
|
||||
self.assertEqual(azone, aggregate['availability_zone'])
|
||||
self.assertEqual(hosts, aggregate['hosts'])
|
||||
@ -81,7 +81,7 @@ class TestAggregatesBasicOps(manager.ScenarioTest):
|
||||
aggregate['metadata'][meta_key])
|
||||
|
||||
def _set_aggregate_metadata(self, aggregate, meta):
|
||||
_, aggregate = self.aggregates_client.set_metadata(aggregate['id'],
|
||||
aggregate = self.aggregates_client.set_metadata(aggregate['id'],
|
||||
meta)
|
||||
|
||||
for key, value in meta.items():
|
||||
@ -89,7 +89,7 @@ class TestAggregatesBasicOps(manager.ScenarioTest):
|
||||
|
||||
def _update_aggregate(self, aggregate, aggregate_name,
|
||||
availability_zone):
|
||||
_, aggregate = self.aggregates_client.update_aggregate(
|
||||
aggregate = self.aggregates_client.update_aggregate(
|
||||
aggregate['id'], name=aggregate_name,
|
||||
availability_zone=availability_zone)
|
||||
self.assertEqual(aggregate['name'], aggregate_name)
|
||||
|
@ -17,6 +17,7 @@ import urllib
|
||||
|
||||
from tempest.api_schema.response.compute import agents as common_schema
|
||||
from tempest.api_schema.response.compute.v2 import agents as schema
|
||||
from tempest.common import service_client
|
||||
from tempest.services.compute.json import base
|
||||
|
||||
|
||||
@ -33,7 +34,7 @@ class AgentsClientJSON(base.ComputeClient):
|
||||
resp, body = self.get(url)
|
||||
body = json.loads(body)
|
||||
self.validate_response(common_schema.list_agents, resp, body)
|
||||
return resp, body['agents']
|
||||
return service_client.ResponseBodyList(resp, body['agents'])
|
||||
|
||||
def create_agent(self, **kwargs):
|
||||
"""Create an agent build."""
|
||||
@ -41,16 +42,16 @@ class AgentsClientJSON(base.ComputeClient):
|
||||
resp, body = self.post('os-agents', post_body)
|
||||
body = json.loads(body)
|
||||
self.validate_response(schema.create_agent, resp, body)
|
||||
return resp, body['agent']
|
||||
return service_client.ResponseBody(resp, body['agent'])
|
||||
|
||||
def delete_agent(self, agent_id):
|
||||
"""Delete an existing agent build."""
|
||||
resp, body = self.delete("os-agents/%s" % str(agent_id))
|
||||
self.validate_response(schema.delete_agent, resp, body)
|
||||
return resp, body
|
||||
return service_client.ResponseBody(resp, body)
|
||||
|
||||
def update_agent(self, agent_id, **kwargs):
|
||||
"""Update an agent build."""
|
||||
put_body = json.dumps({'para': kwargs})
|
||||
resp, body = self.put('os-agents/%s' % str(agent_id), put_body)
|
||||
return resp, self._parse_resp(body)
|
||||
return service_client.ResponseBody(resp, self._parse_resp(body))
|
||||
|
@ -17,6 +17,7 @@ import json
|
||||
|
||||
from tempest.api_schema.response.compute import aggregates as schema
|
||||
from tempest.api_schema.response.compute.v2 import aggregates as v2_schema
|
||||
from tempest.common import service_client
|
||||
from tempest import exceptions
|
||||
from tempest.services.compute.json import base
|
||||
|
||||
@ -28,14 +29,14 @@ class AggregatesClientJSON(base.ComputeClient):
|
||||
resp, body = self.get("os-aggregates")
|
||||
body = json.loads(body)
|
||||
self.validate_response(schema.list_aggregates, resp, body)
|
||||
return resp, body['aggregates']
|
||||
return service_client.ResponseBodyList(resp, body['aggregates'])
|
||||
|
||||
def get_aggregate(self, aggregate_id):
|
||||
"""Get details of the given aggregate."""
|
||||
resp, body = self.get("os-aggregates/%s" % str(aggregate_id))
|
||||
body = json.loads(body)
|
||||
self.validate_response(schema.get_aggregate, resp, body)
|
||||
return resp, body['aggregate']
|
||||
return service_client.ResponseBody(resp, body['aggregate'])
|
||||
|
||||
def create_aggregate(self, **kwargs):
|
||||
"""Creates a new aggregate."""
|
||||
@ -44,7 +45,7 @@ class AggregatesClientJSON(base.ComputeClient):
|
||||
|
||||
body = json.loads(body)
|
||||
self.validate_response(v2_schema.create_aggregate, resp, body)
|
||||
return resp, body['aggregate']
|
||||
return service_client.ResponseBody(resp, body['aggregate'])
|
||||
|
||||
def update_aggregate(self, aggregate_id, name, availability_zone=None):
|
||||
"""Update a aggregate."""
|
||||
@ -57,13 +58,13 @@ class AggregatesClientJSON(base.ComputeClient):
|
||||
|
||||
body = json.loads(body)
|
||||
self.validate_response(schema.update_aggregate, resp, body)
|
||||
return resp, body['aggregate']
|
||||
return service_client.ResponseBody(resp, body['aggregate'])
|
||||
|
||||
def delete_aggregate(self, aggregate_id):
|
||||
"""Deletes the given aggregate."""
|
||||
resp, body = self.delete("os-aggregates/%s" % str(aggregate_id))
|
||||
self.validate_response(v2_schema.delete_aggregate, resp, body)
|
||||
return resp, body
|
||||
return service_client.ResponseBody(resp, body)
|
||||
|
||||
def is_resource_deleted(self, id):
|
||||
try:
|
||||
@ -87,7 +88,7 @@ class AggregatesClientJSON(base.ComputeClient):
|
||||
post_body)
|
||||
body = json.loads(body)
|
||||
self.validate_response(schema.aggregate_add_remove_host, resp, body)
|
||||
return resp, body['aggregate']
|
||||
return service_client.ResponseBody(resp, body['aggregate'])
|
||||
|
||||
def remove_host(self, aggregate_id, host):
|
||||
"""Removes a host from the given aggregate."""
|
||||
@ -99,7 +100,7 @@ class AggregatesClientJSON(base.ComputeClient):
|
||||
post_body)
|
||||
body = json.loads(body)
|
||||
self.validate_response(schema.aggregate_add_remove_host, resp, body)
|
||||
return resp, body['aggregate']
|
||||
return service_client.ResponseBody(resp, body['aggregate'])
|
||||
|
||||
def set_metadata(self, aggregate_id, meta):
|
||||
"""Replaces the aggregate's existing metadata with new metadata."""
|
||||
@ -111,4 +112,4 @@ class AggregatesClientJSON(base.ComputeClient):
|
||||
post_body)
|
||||
body = json.loads(body)
|
||||
self.validate_response(schema.aggregate_set_metadata, resp, body)
|
||||
return resp, body['aggregate']
|
||||
return service_client.ResponseBody(resp, body['aggregate'])
|
||||
|
@ -17,6 +17,7 @@ import urllib
|
||||
|
||||
from tempest.api_schema.response.compute import hosts as schema
|
||||
from tempest.api_schema.response.compute.v2 import hosts as v2_schema
|
||||
from tempest.common import service_client
|
||||
from tempest.services.compute.json import base
|
||||
|
||||
|
||||
@ -32,7 +33,7 @@ class HostsClientJSON(base.ComputeClient):
|
||||
resp, body = self.get(url)
|
||||
body = json.loads(body)
|
||||
self.validate_response(schema.list_hosts, resp, body)
|
||||
return resp, body['hosts']
|
||||
return service_client.ResponseBodyList(resp, body['hosts'])
|
||||
|
||||
def show_host_detail(self, hostname):
|
||||
"""Show detail information for the host."""
|
||||
@ -40,7 +41,7 @@ class HostsClientJSON(base.ComputeClient):
|
||||
resp, body = self.get("os-hosts/%s" % str(hostname))
|
||||
body = json.loads(body)
|
||||
self.validate_response(schema.show_host_detail, resp, body)
|
||||
return resp, body['host']
|
||||
return service_client.ResponseBodyList(resp, body['host'])
|
||||
|
||||
def update_host(self, hostname, **kwargs):
|
||||
"""Update a host."""
|
||||
@ -55,7 +56,7 @@ class HostsClientJSON(base.ComputeClient):
|
||||
resp, body = self.put("os-hosts/%s" % str(hostname), request_body)
|
||||
body = json.loads(body)
|
||||
self.validate_response(v2_schema.update_host, resp, body)
|
||||
return resp, body
|
||||
return service_client.ResponseBody(resp, body)
|
||||
|
||||
def startup_host(self, hostname):
|
||||
"""Startup a host."""
|
||||
@ -63,7 +64,7 @@ class HostsClientJSON(base.ComputeClient):
|
||||
resp, body = self.get("os-hosts/%s/startup" % str(hostname))
|
||||
body = json.loads(body)
|
||||
self.validate_response(v2_schema.startup_host, resp, body)
|
||||
return resp, body['host']
|
||||
return service_client.ResponseBody(resp, body['host'])
|
||||
|
||||
def shutdown_host(self, hostname):
|
||||
"""Shutdown a host."""
|
||||
@ -71,7 +72,7 @@ class HostsClientJSON(base.ComputeClient):
|
||||
resp, body = self.get("os-hosts/%s/shutdown" % str(hostname))
|
||||
body = json.loads(body)
|
||||
self.validate_response(v2_schema.shutdown_host, resp, body)
|
||||
return resp, body['host']
|
||||
return service_client.ResponseBody(resp, body['host'])
|
||||
|
||||
def reboot_host(self, hostname):
|
||||
"""reboot a host."""
|
||||
@ -79,4 +80,4 @@ class HostsClientJSON(base.ComputeClient):
|
||||
resp, body = self.get("os-hosts/%s/reboot" % str(hostname))
|
||||
body = json.loads(body)
|
||||
self.validate_response(v2_schema.reboot_host, resp, body)
|
||||
return resp, body['host']
|
||||
return service_client.ResponseBody(resp, body['host'])
|
||||
|
@ -17,6 +17,7 @@ import json
|
||||
|
||||
from tempest.api_schema.response.compute import hypervisors as common_schema
|
||||
from tempest.api_schema.response.compute.v2 import hypervisors as v2schema
|
||||
from tempest.common import service_client
|
||||
from tempest.services.compute.json import base
|
||||
|
||||
|
||||
@ -28,7 +29,7 @@ class HypervisorClientJSON(base.ComputeClient):
|
||||
body = json.loads(body)
|
||||
self.validate_response(common_schema.common_hypervisors_detail,
|
||||
resp, body)
|
||||
return resp, body['hypervisors']
|
||||
return service_client.ResponseBodyList(resp, body['hypervisors'])
|
||||
|
||||
def get_hypervisor_list_details(self):
|
||||
"""Show detailed hypervisors information."""
|
||||
@ -36,7 +37,7 @@ class HypervisorClientJSON(base.ComputeClient):
|
||||
body = json.loads(body)
|
||||
self.validate_response(common_schema.common_list_hypervisors_detail,
|
||||
resp, body)
|
||||
return resp, body['hypervisors']
|
||||
return service_client.ResponseBodyList(resp, body['hypervisors'])
|
||||
|
||||
def get_hypervisor_show_details(self, hyper_id):
|
||||
"""Display the details of the specified hypervisor."""
|
||||
@ -44,28 +45,28 @@ class HypervisorClientJSON(base.ComputeClient):
|
||||
body = json.loads(body)
|
||||
self.validate_response(common_schema.common_show_hypervisor,
|
||||
resp, body)
|
||||
return resp, body['hypervisor']
|
||||
return service_client.ResponseBody(resp, body['hypervisor'])
|
||||
|
||||
def get_hypervisor_servers(self, hyper_name):
|
||||
"""List instances belonging to the specified hypervisor."""
|
||||
resp, body = self.get('os-hypervisors/%s/servers' % hyper_name)
|
||||
body = json.loads(body)
|
||||
self.validate_response(v2schema.hypervisors_servers, resp, body)
|
||||
return resp, body['hypervisors']
|
||||
return service_client.ResponseBodyList(resp, body['hypervisors'])
|
||||
|
||||
def get_hypervisor_stats(self):
|
||||
"""Get hypervisor statistics over all compute nodes."""
|
||||
resp, body = self.get('os-hypervisors/statistics')
|
||||
body = json.loads(body)
|
||||
self.validate_response(common_schema.hypervisor_statistics, resp, body)
|
||||
return resp, body['hypervisor_statistics']
|
||||
return service_client.ResponseBody(resp, body['hypervisor_statistics'])
|
||||
|
||||
def get_hypervisor_uptime(self, hyper_id):
|
||||
"""Display the uptime of the specified hypervisor."""
|
||||
resp, body = self.get('os-hypervisors/%s/uptime' % hyper_id)
|
||||
body = json.loads(body)
|
||||
self.validate_response(common_schema.hypervisor_uptime, resp, body)
|
||||
return resp, body['hypervisor']
|
||||
return service_client.ResponseBody(resp, body['hypervisor'])
|
||||
|
||||
def search_hypervisor(self, hyper_name):
|
||||
"""Search specified hypervisor."""
|
||||
@ -73,4 +74,4 @@ class HypervisorClientJSON(base.ComputeClient):
|
||||
body = json.loads(body)
|
||||
self.validate_response(common_schema.common_hypervisors_detail,
|
||||
resp, body)
|
||||
return resp, body['hypervisors']
|
||||
return service_client.ResponseBodyList(resp, body['hypervisors'])
|
||||
|
@ -18,6 +18,7 @@ import json
|
||||
import urllib
|
||||
|
||||
from tempest.api_schema.response.compute import services as schema
|
||||
from tempest.common import service_client
|
||||
from tempest.services.compute.json import base
|
||||
|
||||
|
||||
@ -31,7 +32,7 @@ class ServicesClientJSON(base.ComputeClient):
|
||||
resp, body = self.get(url)
|
||||
body = json.loads(body)
|
||||
self.validate_response(schema.list_services, resp, body)
|
||||
return resp, body['services']
|
||||
return service_client.ResponseBodyList(resp, body['services'])
|
||||
|
||||
def enable_service(self, host_name, binary):
|
||||
"""
|
||||
@ -43,7 +44,7 @@ class ServicesClientJSON(base.ComputeClient):
|
||||
resp, body = self.put('os-services/enable', post_body)
|
||||
body = json.loads(body)
|
||||
self.validate_response(schema.enable_service, resp, body)
|
||||
return resp, body['service']
|
||||
return service_client.ResponseBody(resp, body['service'])
|
||||
|
||||
def disable_service(self, host_name, binary):
|
||||
"""
|
||||
@ -54,4 +55,4 @@ class ServicesClientJSON(base.ComputeClient):
|
||||
post_body = json.dumps({'binary': binary, 'host': host_name})
|
||||
resp, body = self.put('os-services/disable', post_body)
|
||||
body = json.loads(body)
|
||||
return resp, body['service']
|
||||
return service_client.ResponseBody(resp, body['service'])
|
||||
|
Loading…
Reference in New Issue
Block a user