summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakashi NATSUME <natsume.takashi@lab.ntt.co.jp>2015-12-25 12:45:49 +0900
committerTakashi NATSUME <natsume.takashi@lab.ntt.co.jp>2016-01-28 11:23:36 +0000
commit9f10d7d0b0fc03ea6843c61519db020fab77f9e0 (patch)
tree77af1cc640cb5bc5c6bef8dcc5e66a1dda37702d
parent0414bab3d3c1a202060f6fc18c79f8d22f993817 (diff)
Add return-request-id-to-caller function(4/5)
Add return-request-id-to-caller function to resources and resource managers in the following files. The methods in the resource class and resource manager return a wrapper class that has 'request_ids' property. The caller can get request ids of the callee via the property. * novaclient/v2/contrib/assisted_volume_snapshots.py * novaclient/v2/contrib/baremetal.py * novaclient/v2/contrib/cells.py * novaclient/v2/contrib/instance_action.py * novaclient/v2/contrib/list_extensions.py * novaclient/v2/contrib/migrations.py * novaclient/v2/contrib/server_external_events.py * novaclient/v2/contrib/tenant_networks.py Co-authored-by: Ankit Agrawal <ankit11.agrawal@nttdata.com> Change-Id: I58ec61eb585d145cb7d638bcb690b3ebee0461e9 Implements: blueprint return-request-id-to-caller
Notes
Notes (review): Code-Review+2: Kevin L. Mitchell <kevin.mitchell@rackspace.com> Code-Review+2: Michael Still <mikal@stillhq.com> Workflow+1: Kevin L. Mitchell <kevin.mitchell@rackspace.com> Verified+2: Jenkins Submitted-by: Jenkins Submitted-at: Thu, 28 Jan 2016 18:38:00 +0000 Reviewed-on: https://review.openstack.org/261407 Project: openstack/python-novaclient Branch: refs/heads/master
-rw-r--r--novaclient/tests/unit/v2/contrib/fakes.py30
-rw-r--r--novaclient/tests/unit/v2/contrib/test_assisted_volume_snapshots.py6
-rw-r--r--novaclient/tests/unit/v2/contrib/test_baremetal.py13
-rw-r--r--novaclient/tests/unit/v2/contrib/test_cells.py9
-rw-r--r--novaclient/tests/unit/v2/contrib/test_instance_actions.py6
-rw-r--r--novaclient/tests/unit/v2/contrib/test_list_extensions.py1
-rw-r--r--novaclient/tests/unit/v2/contrib/test_migrations.py2
-rw-r--r--novaclient/tests/unit/v2/contrib/test_server_external_events.py1
-rw-r--r--novaclient/tests/unit/v2/contrib/test_tenant_networks.py12
-rw-r--r--novaclient/tests/unit/v2/fakes.py12
-rw-r--r--novaclient/v2/contrib/assisted_volume_snapshots.py15
-rw-r--r--novaclient/v2/contrib/baremetal.py18
-rw-r--r--novaclient/v2/contrib/tenant_networks.py15
13 files changed, 95 insertions, 45 deletions
diff --git a/novaclient/tests/unit/v2/contrib/fakes.py b/novaclient/tests/unit/v2/contrib/fakes.py
index 8e82f9c..921d87e 100644
--- a/novaclient/tests/unit/v2/contrib/fakes.py
+++ b/novaclient/tests/unit/v2/contrib/fakes.py
@@ -15,6 +15,9 @@
15from novaclient.tests.unit.v2 import fakes 15from novaclient.tests.unit.v2 import fakes
16from novaclient.v2 import client 16from novaclient.v2 import client
17 17
18FAKE_REQUEST_ID_LIST = fakes.FAKE_REQUEST_ID_LIST
19FAKE_RESPONSE_HEADERS = fakes.FAKE_RESPONSE_HEADERS
20
18 21
19class FakeClient(fakes.FakeClient): 22class FakeClient(fakes.FakeClient):
20 def __init__(self, *args, **kwargs): 23 def __init__(self, *args, **kwargs):
@@ -27,29 +30,29 @@ class FakeClient(fakes.FakeClient):
27 30
28class FakeHTTPClient(fakes.FakeHTTPClient): 31class FakeHTTPClient(fakes.FakeHTTPClient):
29 def get_os_tenant_networks(self): 32 def get_os_tenant_networks(self):
30 return (200, {}, { 33 return (200, FAKE_RESPONSE_HEADERS, {
31 'networks': [{"label": "1", "cidr": "10.0.0.0/24", 34 'networks': [{"label": "1", "cidr": "10.0.0.0/24",
32 'project_id': '4ffc664c198e435e9853f2538fbcd7a7', 35 'project_id': '4ffc664c198e435e9853f2538fbcd7a7',
33 'id': '1'}]}) 36 'id': '1'}]})
34 37
35 def get_os_tenant_networks_1(self, **kw): 38 def get_os_tenant_networks_1(self, **kw):
36 return (200, {}, { 39 return (200, FAKE_RESPONSE_HEADERS, {
37 'network': {"label": "1", "cidr": "10.0.0.0/24", 40 'network': {"label": "1", "cidr": "10.0.0.0/24",
38 'project_id': '4ffc664c198e435e9853f2538fbcd7a7', 41 'project_id': '4ffc664c198e435e9853f2538fbcd7a7',
39 'id': '1'}}) 42 'id': '1'}})
40 43
41 def post_os_tenant_networks(self, **kw): 44 def post_os_tenant_networks(self, **kw):
42 return (201, {}, { 45 return (201, FAKE_RESPONSE_HEADERS, {
43 'network': {"label": "1", "cidr": "10.0.0.0/24", 46 'network': {"label": "1", "cidr": "10.0.0.0/24",
44 'project_id': '4ffc664c198e435e9853f2538fbcd7a7', 47 'project_id': '4ffc664c198e435e9853f2538fbcd7a7',
45 'id': '1'}}) 48 'id': '1'}})
46 49
47 def delete_os_tenant_networks_1(self, **kw): 50 def delete_os_tenant_networks_1(self, **kw):
48 return (204, {}, None) 51 return (204, FAKE_RESPONSE_HEADERS, None)
49 52
50 def get_os_baremetal_nodes(self, **kw): 53 def get_os_baremetal_nodes(self, **kw):
51 return ( 54 return (
52 200, {}, { 55 200, FAKE_RESPONSE_HEADERS, {
53 'nodes': [ 56 'nodes': [
54 { 57 {
55 "id": 1, 58 "id": 1,
@@ -72,7 +75,7 @@ class FakeHTTPClient(fakes.FakeHTTPClient):
72 75
73 def get_os_baremetal_nodes_1(self, **kw): 76 def get_os_baremetal_nodes_1(self, **kw):
74 return ( 77 return (
75 200, {}, { 78 200, FAKE_RESPONSE_HEADERS, {
76 'node': { 79 'node': {
77 "id": 1, 80 "id": 1,
78 "instance_uuid": None, 81 "instance_uuid": None,
@@ -93,7 +96,7 @@ class FakeHTTPClient(fakes.FakeHTTPClient):
93 96
94 def post_os_baremetal_nodes(self, **kw): 97 def post_os_baremetal_nodes(self, **kw):
95 return ( 98 return (
96 200, {}, { 99 200, FAKE_RESPONSE_HEADERS, {
97 'node': { 100 'node': {
98 "id": 1, 101 "id": 1,
99 "instance_uuid": None, 102 "instance_uuid": None,
@@ -112,14 +115,14 @@ class FakeHTTPClient(fakes.FakeHTTPClient):
112 ) 115 )
113 116
114 def delete_os_baremetal_nodes_1(self, **kw): 117 def delete_os_baremetal_nodes_1(self, **kw):
115 return (202, {}, {}) 118 return (202, FAKE_RESPONSE_HEADERS, {})
116 119
117 def post_os_baremetal_nodes_1_action(self, **kw): 120 def post_os_baremetal_nodes_1_action(self, **kw):
118 body = kw['body'] 121 body = kw['body']
119 action = list(body)[0] 122 action = list(body)[0]
120 if action == "add_interface": 123 if action == "add_interface":
121 return ( 124 return (
122 200, {}, { 125 200, FAKE_RESPONSE_HEADERS, {
123 'interface': { 126 'interface': {
124 "id": 2, 127 "id": 2,
125 "address": "bb:cc:dd:ee:ff:aa", 128 "address": "bb:cc:dd:ee:ff:aa",
@@ -129,18 +132,19 @@ class FakeHTTPClient(fakes.FakeHTTPClient):
129 } 132 }
130 ) 133 )
131 elif action == "remove_interface": 134 elif action == "remove_interface":
132 return (202, {}, {}) 135 return (202, FAKE_RESPONSE_HEADERS, {})
133 else: 136 else:
134 return (500, {}, {}) 137 return (500, {}, {})
135 138
136 def post_os_assisted_volume_snapshots(self, **kw): 139 def post_os_assisted_volume_snapshots(self, **kw):
137 return (202, {}, {'snapshot': {'id': 'blah', 'volumeId': '1'}}) 140 return (202, FAKE_RESPONSE_HEADERS,
141 {'snapshot': {'id': 'blah', 'volumeId': '1'}})
138 142
139 def delete_os_assisted_volume_snapshots_x(self, **kw): 143 def delete_os_assisted_volume_snapshots_x(self, **kw):
140 return (202, {}, {}) 144 return (202, FAKE_RESPONSE_HEADERS, {})
141 145
142 def post_os_server_external_events(self, **kw): 146 def post_os_server_external_events(self, **kw):
143 return (200, {}, { 147 return (200, FAKE_RESPONSE_HEADERS, {
144 'events': [ 148 'events': [
145 {'name': 'test-event', 149 {'name': 'test-event',
146 'status': 'completed', 150 'status': 'completed',
diff --git a/novaclient/tests/unit/v2/contrib/test_assisted_volume_snapshots.py b/novaclient/tests/unit/v2/contrib/test_assisted_volume_snapshots.py
index 8ab732a..8cce986 100644
--- a/novaclient/tests/unit/v2/contrib/test_assisted_volume_snapshots.py
+++ b/novaclient/tests/unit/v2/contrib/test_assisted_volume_snapshots.py
@@ -32,11 +32,13 @@ cs = fakes.FakeClient(extensions=extensions)
32class AssistedVolumeSnapshotsTestCase(utils.TestCase): 32class AssistedVolumeSnapshotsTestCase(utils.TestCase):
33 33
34 def test_create_snap(self): 34 def test_create_snap(self):
35 cs.assisted_volume_snapshots.create('1', {}) 35 vs = cs.assisted_volume_snapshots.create('1', {})
36 self.assert_request_id(vs, fakes.FAKE_REQUEST_ID_LIST)
36 cs.assert_called('POST', '/os-assisted-volume-snapshots') 37 cs.assert_called('POST', '/os-assisted-volume-snapshots')
37 38
38 def test_delete_snap(self): 39 def test_delete_snap(self):
39 cs.assisted_volume_snapshots.delete('x', {}) 40 vs = cs.assisted_volume_snapshots.delete('x', {})
41 self.assert_request_id(vs, fakes.FAKE_REQUEST_ID_LIST)
40 cs.assert_called( 42 cs.assert_called(
41 'DELETE', 43 'DELETE',
42 '/os-assisted-volume-snapshots/x?delete_info={}') 44 '/os-assisted-volume-snapshots/x?delete_info={}')
diff --git a/novaclient/tests/unit/v2/contrib/test_baremetal.py b/novaclient/tests/unit/v2/contrib/test_baremetal.py
index a5ee414..e44cd14 100644
--- a/novaclient/tests/unit/v2/contrib/test_baremetal.py
+++ b/novaclient/tests/unit/v2/contrib/test_baremetal.py
@@ -30,35 +30,42 @@ class BaremetalExtensionTest(utils.TestCase):
30 30
31 def test_list_nodes(self): 31 def test_list_nodes(self):
32 nl = cs.baremetal.list() 32 nl = cs.baremetal.list()
33 self.assert_request_id(nl, fakes.FAKE_REQUEST_ID_LIST)
33 cs.assert_called('GET', '/os-baremetal-nodes') 34 cs.assert_called('GET', '/os-baremetal-nodes')
34 for n in nl: 35 for n in nl:
35 self.assertIsInstance(n, baremetal.BareMetalNode) 36 self.assertIsInstance(n, baremetal.BareMetalNode)
36 37
37 def test_get_node(self): 38 def test_get_node(self):
38 n = cs.baremetal.get(1) 39 n = cs.baremetal.get(1)
40 self.assert_request_id(n, fakes.FAKE_REQUEST_ID_LIST)
39 cs.assert_called('GET', '/os-baremetal-nodes/1') 41 cs.assert_called('GET', '/os-baremetal-nodes/1')
40 self.assertIsInstance(n, baremetal.BareMetalNode) 42 self.assertIsInstance(n, baremetal.BareMetalNode)
41 43
42 def test_create_node(self): 44 def test_create_node(self):
43 n = cs.baremetal.create("service_host", 1, 1024, 2048, 45 n = cs.baremetal.create("service_host", 1, 1024, 2048,
44 "aa:bb:cc:dd:ee:ff") 46 "aa:bb:cc:dd:ee:ff")
47 self.assert_request_id(n, fakes.FAKE_REQUEST_ID_LIST)
45 cs.assert_called('POST', '/os-baremetal-nodes') 48 cs.assert_called('POST', '/os-baremetal-nodes')
46 self.assertIsInstance(n, baremetal.BareMetalNode) 49 self.assertIsInstance(n, baremetal.BareMetalNode)
47 50
48 def test_delete_node(self): 51 def test_delete_node(self):
49 n = cs.baremetal.get(1) 52 n = cs.baremetal.get(1)
50 cs.baremetal.delete(n) 53 ret = cs.baremetal.delete(n)
54 self.assert_request_id(ret, fakes.FAKE_REQUEST_ID_LIST)
51 cs.assert_called('DELETE', '/os-baremetal-nodes/1') 55 cs.assert_called('DELETE', '/os-baremetal-nodes/1')
52 56
53 def test_node_add_interface(self): 57 def test_node_add_interface(self):
54 i = cs.baremetal.add_interface(1, "bb:cc:dd:ee:ff:aa", 1, 2) 58 i = cs.baremetal.add_interface(1, "bb:cc:dd:ee:ff:aa", 1, 2)
59 self.assert_request_id(i, fakes.FAKE_REQUEST_ID_LIST)
55 cs.assert_called('POST', '/os-baremetal-nodes/1/action') 60 cs.assert_called('POST', '/os-baremetal-nodes/1/action')
56 self.assertIsInstance(i, baremetal.BareMetalNodeInterface) 61 self.assertIsInstance(i, baremetal.BareMetalNodeInterface)
57 62
58 def test_node_remove_interface(self): 63 def test_node_remove_interface(self):
59 cs.baremetal.remove_interface(1, "bb:cc:dd:ee:ff:aa") 64 ret = cs.baremetal.remove_interface(1, "bb:cc:dd:ee:ff:aa")
65 self.assert_request_id(ret, fakes.FAKE_REQUEST_ID_LIST)
60 cs.assert_called('POST', '/os-baremetal-nodes/1/action') 66 cs.assert_called('POST', '/os-baremetal-nodes/1/action')
61 67
62 def test_node_list_interfaces(self): 68 def test_node_list_interfaces(self):
63 cs.baremetal.list_interfaces(1) 69 il = cs.baremetal.list_interfaces(1)
70 self.assert_request_id(il, fakes.FAKE_REQUEST_ID_LIST)
64 cs.assert_called('GET', '/os-baremetal-nodes/1') 71 cs.assert_called('GET', '/os-baremetal-nodes/1')
diff --git a/novaclient/tests/unit/v2/contrib/test_cells.py b/novaclient/tests/unit/v2/contrib/test_cells.py
index e411502..dd242c2 100644
--- a/novaclient/tests/unit/v2/contrib/test_cells.py
+++ b/novaclient/tests/unit/v2/contrib/test_cells.py
@@ -29,14 +29,17 @@ cs = fakes.FakeClient(extensions=extensions)
29class CellsExtensionTests(utils.TestCase): 29class CellsExtensionTests(utils.TestCase):
30 def test_get_cells(self): 30 def test_get_cells(self):
31 cell_name = 'child_cell' 31 cell_name = 'child_cell'
32 cs.cells.get(cell_name) 32 cell = cs.cells.get(cell_name)
33 self.assert_request_id(cell, fakes.FAKE_REQUEST_ID_LIST)
33 cs.assert_called('GET', '/os-cells/%s' % cell_name) 34 cs.assert_called('GET', '/os-cells/%s' % cell_name)
34 35
35 def test_get_capacities_for_a_given_cell(self): 36 def test_get_capacities_for_a_given_cell(self):
36 cell_name = 'child_cell' 37 cell_name = 'child_cell'
37 cs.cells.capacities(cell_name) 38 ca = cs.cells.capacities(cell_name)
39 self.assert_request_id(ca, fakes.FAKE_REQUEST_ID_LIST)
38 cs.assert_called('GET', '/os-cells/%s/capacities' % cell_name) 40 cs.assert_called('GET', '/os-cells/%s/capacities' % cell_name)
39 41
40 def test_get_capacities_for_all_cells(self): 42 def test_get_capacities_for_all_cells(self):
41 cs.cells.capacities() 43 ca = cs.cells.capacities()
44 self.assert_request_id(ca, fakes.FAKE_REQUEST_ID_LIST)
42 cs.assert_called('GET', '/os-cells/capacities') 45 cs.assert_called('GET', '/os-cells/capacities')
diff --git a/novaclient/tests/unit/v2/contrib/test_instance_actions.py b/novaclient/tests/unit/v2/contrib/test_instance_actions.py
index 0b0400a..4f17fbd 100644
--- a/novaclient/tests/unit/v2/contrib/test_instance_actions.py
+++ b/novaclient/tests/unit/v2/contrib/test_instance_actions.py
@@ -29,7 +29,8 @@ cs = fakes.FakeClient(extensions=extensions)
29class InstanceActionExtensionTests(utils.TestCase): 29class InstanceActionExtensionTests(utils.TestCase):
30 def test_list_instance_actions(self): 30 def test_list_instance_actions(self):
31 server_uuid = '1234' 31 server_uuid = '1234'
32 cs.instance_action.list(server_uuid) 32 ial = cs.instance_action.list(server_uuid)
33 self.assert_request_id(ial, fakes.FAKE_REQUEST_ID_LIST)
33 cs.assert_called( 34 cs.assert_called(
34 'GET', '/servers/%s/os-instance-actions' % 35 'GET', '/servers/%s/os-instance-actions' %
35 server_uuid) 36 server_uuid)
@@ -37,7 +38,8 @@ class InstanceActionExtensionTests(utils.TestCase):
37 def test_get_instance_action(self): 38 def test_get_instance_action(self):
38 server_uuid = '1234' 39 server_uuid = '1234'
39 request_id = 'req-abcde12345' 40 request_id = 'req-abcde12345'
40 cs.instance_action.get(server_uuid, request_id) 41 ia = cs.instance_action.get(server_uuid, request_id)
42 self.assert_request_id(ia, fakes.FAKE_REQUEST_ID_LIST)
41 cs.assert_called( 43 cs.assert_called(
42 'GET', '/servers/%s/os-instance-actions/%s' 44 'GET', '/servers/%s/os-instance-actions/%s'
43 % (server_uuid, request_id)) 45 % (server_uuid, request_id))
diff --git a/novaclient/tests/unit/v2/contrib/test_list_extensions.py b/novaclient/tests/unit/v2/contrib/test_list_extensions.py
index 3fa5253..3c77293 100644
--- a/novaclient/tests/unit/v2/contrib/test_list_extensions.py
+++ b/novaclient/tests/unit/v2/contrib/test_list_extensions.py
@@ -27,6 +27,7 @@ cs = fakes.FakeClient(extensions=extensions)
27class ListExtensionsTests(utils.TestCase): 27class ListExtensionsTests(utils.TestCase):
28 def test_list_extensions(self): 28 def test_list_extensions(self):
29 all_exts = cs.list_extensions.show_all() 29 all_exts = cs.list_extensions.show_all()
30 self.assert_request_id(all_exts, fakes.FAKE_REQUEST_ID_LIST)
30 cs.assert_called('GET', '/extensions') 31 cs.assert_called('GET', '/extensions')
31 self.assertTrue(len(all_exts) > 0) 32 self.assertTrue(len(all_exts) > 0)
32 for r in all_exts: 33 for r in all_exts:
diff --git a/novaclient/tests/unit/v2/contrib/test_migrations.py b/novaclient/tests/unit/v2/contrib/test_migrations.py
index 881fd1e..29cac5d 100644
--- a/novaclient/tests/unit/v2/contrib/test_migrations.py
+++ b/novaclient/tests/unit/v2/contrib/test_migrations.py
@@ -26,12 +26,14 @@ class MigrationsTest(utils.TestCase):
26 26
27 def test_list_migrations(self): 27 def test_list_migrations(self):
28 ml = cs.migrations.list() 28 ml = cs.migrations.list()
29 self.assert_request_id(ml, fakes.FAKE_REQUEST_ID_LIST)
29 cs.assert_called('GET', '/os-migrations') 30 cs.assert_called('GET', '/os-migrations')
30 for m in ml: 31 for m in ml:
31 self.assertIsInstance(m, migrations.Migration) 32 self.assertIsInstance(m, migrations.Migration)
32 33
33 def test_list_migrations_with_filters(self): 34 def test_list_migrations_with_filters(self):
34 ml = cs.migrations.list('host1', 'finished', 'child1') 35 ml = cs.migrations.list('host1', 'finished', 'child1')
36 self.assert_request_id(ml, fakes.FAKE_REQUEST_ID_LIST)
35 37
36 cs.assert_called('GET', 38 cs.assert_called('GET',
37 '/os-migrations?cell_name=child1&host=host1' 39 '/os-migrations?cell_name=child1&host=host1'
diff --git a/novaclient/tests/unit/v2/contrib/test_server_external_events.py b/novaclient/tests/unit/v2/contrib/test_server_external_events.py
index 1b941c9..b843bd8 100644
--- a/novaclient/tests/unit/v2/contrib/test_server_external_events.py
+++ b/novaclient/tests/unit/v2/contrib/test_server_external_events.py
@@ -40,5 +40,6 @@ class ServerExternalEventsTestCase(utils.TestCase):
40 'status': 'completed', 40 'status': 'completed',
41 'tag': 'tag'}] 41 'tag': 'tag'}]
42 result = cs.server_external_events.create(events) 42 result = cs.server_external_events.create(events)
43 self.assert_request_id(result, fakes.FAKE_REQUEST_ID_LIST)
43 self.assertEqual(events, result) 44 self.assertEqual(events, result)
44 cs.assert_called('POST', '/os-server-external-events') 45 cs.assert_called('POST', '/os-server-external-events')
diff --git a/novaclient/tests/unit/v2/contrib/test_tenant_networks.py b/novaclient/tests/unit/v2/contrib/test_tenant_networks.py
index 13159ce..2f0d7e3 100644
--- a/novaclient/tests/unit/v2/contrib/test_tenant_networks.py
+++ b/novaclient/tests/unit/v2/contrib/test_tenant_networks.py
@@ -29,18 +29,22 @@ cs = fakes.FakeClient(extensions=extensions)
29class TenantNetworkExtensionTests(utils.TestCase): 29class TenantNetworkExtensionTests(utils.TestCase):
30 def test_list_tenant_networks(self): 30 def test_list_tenant_networks(self):
31 nets = cs.tenant_networks.list() 31 nets = cs.tenant_networks.list()
32 self.assert_request_id(nets, fakes.FAKE_REQUEST_ID_LIST)
32 cs.assert_called('GET', '/os-tenant-networks') 33 cs.assert_called('GET', '/os-tenant-networks')
33 self.assertTrue(len(nets) > 0) 34 self.assertTrue(len(nets) > 0)
34 35
35 def test_get_tenant_network(self): 36 def test_get_tenant_network(self):
36 cs.tenant_networks.get(1) 37 net = cs.tenant_networks.get(1)
38 self.assert_request_id(net, fakes.FAKE_REQUEST_ID_LIST)
37 cs.assert_called('GET', '/os-tenant-networks/1') 39 cs.assert_called('GET', '/os-tenant-networks/1')
38 40
39 def test_create_tenant_networks(self): 41 def test_create_tenant_networks(self):
40 cs.tenant_networks.create(label="net", 42 net = cs.tenant_networks.create(label="net",
41 cidr="10.0.0.0/24") 43 cidr="10.0.0.0/24")
44 self.assert_request_id(net, fakes.FAKE_REQUEST_ID_LIST)
42 cs.assert_called('POST', '/os-tenant-networks') 45 cs.assert_called('POST', '/os-tenant-networks')
43 46
44 def test_delete_tenant_networks(self): 47 def test_delete_tenant_networks(self):
45 cs.tenant_networks.delete(1) 48 ret = cs.tenant_networks.delete(1)
49 self.assert_request_id(ret, fakes.FAKE_REQUEST_ID_LIST)
46 cs.assert_called('DELETE', '/os-tenant-networks/1') 50 cs.assert_called('DELETE', '/os-tenant-networks/1')
diff --git a/novaclient/tests/unit/v2/fakes.py b/novaclient/tests/unit/v2/fakes.py
index 50192d0..2958d33 100644
--- a/novaclient/tests/unit/v2/fakes.py
+++ b/novaclient/tests/unit/v2/fakes.py
@@ -296,7 +296,7 @@ class FakeHTTPClient(base_client.HTTPClient):
296 "updated": "2011-11-03T00:00:00+00:00" 296 "updated": "2011-11-03T00:00:00+00:00"
297 }, 297 },
298 ] 298 ]
299 return (200, {}, { 299 return (200, FAKE_RESPONSE_HEADERS, {
300 "extensions": exts, 300 "extensions": exts,
301 }) 301 })
302 302
@@ -2304,7 +2304,7 @@ class FakeHTTPClient(base_client.HTTPClient):
2304 return (200, {}, {}) 2304 return (200, {}, {})
2305 2305
2306 def get_servers_1234_os_instance_actions(self, **kw): 2306 def get_servers_1234_os_instance_actions(self, **kw):
2307 return (200, {}, { 2307 return (200, FAKE_RESPONSE_HEADERS, {
2308 "instanceActions": 2308 "instanceActions":
2309 [{"instance_uuid": "1234", 2309 [{"instance_uuid": "1234",
2310 "user_id": "b968c25e04ab405f9fe4e6ca54cce9a5", 2310 "user_id": "b968c25e04ab405f9fe4e6ca54cce9a5",
@@ -2315,7 +2315,7 @@ class FakeHTTPClient(base_client.HTTPClient):
2315 "project_id": "04019601fe3648c0abd4f4abfb9e6106"}]}) 2315 "project_id": "04019601fe3648c0abd4f4abfb9e6106"}]})
2316 2316
2317 def get_servers_1234_os_instance_actions_req_abcde12345(self, **kw): 2317 def get_servers_1234_os_instance_actions_req_abcde12345(self, **kw):
2318 return (200, {}, { 2318 return (200, FAKE_RESPONSE_HEADERS, {
2319 "instanceAction": 2319 "instanceAction":
2320 {"instance_uuid": "1234", 2320 {"instance_uuid": "1234",
2321 "user_id": "b968c25e04ab405f9fe4e6ca54cce9a5", 2321 "user_id": "b968c25e04ab405f9fe4e6ca54cce9a5",
@@ -2352,7 +2352,7 @@ class FakeHTTPClient(base_client.HTTPClient):
2352 'rpc_port': 5673, 2352 'rpc_port': 5673,
2353 'loaded': True 2353 'loaded': True
2354 }} 2354 }}
2355 return (200, {}, cell) 2355 return (200, FAKE_RESPONSE_HEADERS, cell)
2356 2356
2357 def get_os_cells_capacities(self, **kw): 2357 def get_os_cells_capacities(self, **kw):
2358 cell_capacities_response = {"cell": {"capacities": {"ram_free": { 2358 cell_capacities_response = {"cell": {"capacities": {"ram_free": {
@@ -2360,7 +2360,7 @@ class FakeHTTPClient(base_client.HTTPClient):
2360 "16384": 0}, "total_mb": 7680}, "disk_free": { 2360 "16384": 0}, "total_mb": 7680}, "disk_free": {
2361 "units_by_mb": {"81920": 11, "20480": 46, "40960": 23, "163840": 5, 2361 "units_by_mb": {"81920": 11, "20480": 46, "40960": 23, "163840": 5,
2362 "0": 0}, "total_mb": 1052672}}}} 2362 "0": 0}, "total_mb": 1052672}}}}
2363 return (200, {}, cell_capacities_response) 2363 return (200, FAKE_RESPONSE_HEADERS, cell_capacities_response)
2364 2364
2365 def get_os_cells_child_cell_capacities(self, **kw): 2365 def get_os_cells_child_cell_capacities(self, **kw):
2366 return self.get_os_cells_capacities() 2366 return self.get_os_cells_capacities()
@@ -2381,7 +2381,7 @@ class FakeHTTPClient(base_client.HTTPClient):
2381 "status": "Done", 2381 "status": "Done",
2382 "updated_at": "2012-10-29T13:42:02.000000" 2382 "updated_at": "2012-10-29T13:42:02.000000"
2383 }]} 2383 }]}
2384 return (200, {}, migrations) 2384 return (200, FAKE_RESPONSE_HEADERS, migrations)
2385 2385
2386 def post_os_server_external_events(self, **kw): 2386 def post_os_server_external_events(self, **kw):
2387 return (200, {}, {'events': [ 2387 return (200, {}, {'events': [
diff --git a/novaclient/v2/contrib/assisted_volume_snapshots.py b/novaclient/v2/contrib/assisted_volume_snapshots.py
index ce1a041..a6c6a16 100644
--- a/novaclient/v2/contrib/assisted_volume_snapshots.py
+++ b/novaclient/v2/contrib/assisted_volume_snapshots.py
@@ -28,8 +28,10 @@ class Snapshot(base.Resource):
28 def delete(self): 28 def delete(self):
29 """ 29 """
30 Delete this snapshot. 30 Delete this snapshot.
31
32 :returns: An instance of novaclient.base.TupleWithMeta
31 """ 33 """
32 self.manager.delete(self) 34 return self.manager.delete(self)
33 35
34 36
35class AssistedSnapshotManager(base.Manager): 37class AssistedSnapshotManager(base.Manager):
@@ -41,8 +43,15 @@ class AssistedSnapshotManager(base.Manager):
41 return self._create('/os-assisted-volume-snapshots', body, 'snapshot') 43 return self._create('/os-assisted-volume-snapshots', body, 'snapshot')
42 44
43 def delete(self, snapshot, delete_info): 45 def delete(self, snapshot, delete_info):
44 self._delete("/os-assisted-volume-snapshots/%s?delete_info=%s" % ( 46 """
45 base.getid(snapshot), json.dumps(delete_info))) 47 Delete a specified assisted volume snapshot.
48
49 :param snapshot: an assisted volume snapshot to delete
50 :param delete_info: Information for snapshot deletion
51 :returns: An instance of novaclient.base.TupleWithMeta
52 """
53 return self._delete("/os-assisted-volume-snapshots/%s?delete_info=%s" %
54 (base.getid(snapshot), json.dumps(delete_info)))
46 55
47manager_class = AssistedSnapshotManager 56manager_class = AssistedSnapshotManager
48name = 'assisted_volume_snapshots' 57name = 'assisted_volume_snapshots'
diff --git a/novaclient/v2/contrib/baremetal.py b/novaclient/v2/contrib/baremetal.py
index d23a38e..e03e20f 100644
--- a/novaclient/v2/contrib/baremetal.py
+++ b/novaclient/v2/contrib/baremetal.py
@@ -88,8 +88,9 @@ class BareMetalNodeManager(base.ManagerWithFind):
88 Delete a baremetal node. 88 Delete a baremetal node.
89 89
90 :param node: The :class:`BareMetalNode` to delete. 90 :param node: The :class:`BareMetalNode` to delete.
91 :returns: An instance of novaclient.base.TupleWithMeta
91 """ 92 """
92 self._delete('/os-baremetal-nodes/%s' % base.getid(node)) 93 return self._delete('/os-baremetal-nodes/%s' % base.getid(node))
93 94
94 def get(self, node_id): 95 def get(self, node_id):
95 """ 96 """
@@ -122,8 +123,8 @@ class BareMetalNodeManager(base.ManagerWithFind):
122 'datapath_id': datapath_id, 123 'datapath_id': datapath_id,
123 'port_no': port_no}} 124 'port_no': port_no}}
124 url = '/os-baremetal-nodes/%s/action' % node_id 125 url = '/os-baremetal-nodes/%s/action' % node_id
125 _resp, body = self.api.client.post(url, body=body) 126 resp, body = self.api.client.post(url, body=body)
126 return BareMetalNodeInterface(self, body['interface']) 127 return BareMetalNodeInterface(self, body['interface'], resp=resp)
127 128
128 def remove_interface(self, node_id, address): 129 def remove_interface(self, node_id, address):
129 """ 130 """
@@ -131,21 +132,24 @@ class BareMetalNodeManager(base.ManagerWithFind):
131 132
132 :param node_id: The ID of the node to modify. 133 :param node_id: The ID of the node to modify.
133 :param address: The MAC address to remove. 134 :param address: The MAC address to remove.
134 :rtype: bool 135 :returns: An instance of novaclient.base.TupleWithMeta
135 """ 136 """
136 req_body = {'remove_interface': {'address': address}} 137 req_body = {'remove_interface': {'address': address}}
137 url = '/os-baremetal-nodes/%s/action' % node_id 138 url = '/os-baremetal-nodes/%s/action' % node_id
138 self.api.client.post(url, body=req_body) 139 resp, body = self.api.client.post(url, body=req_body)
140
141 return self.convert_into_with_meta(body, resp)
139 142
140 def list_interfaces(self, node_id): 143 def list_interfaces(self, node_id):
141 """ 144 """
142 List the interfaces on a baremetal node. 145 List the interfaces on a baremetal node.
143 146
144 :param node_id: The ID of the node to list. 147 :param node_id: The ID of the node to list.
145 :rtype: list 148 :rtype: novaclient.base.ListWithMeta
146 """ 149 """
147 interfaces = [] 150 interfaces = base.ListWithMeta([], None)
148 node = self._get("/os-baremetal-nodes/%s" % node_id, 'node') 151 node = self._get("/os-baremetal-nodes/%s" % node_id, 'node')
152 interfaces.append_request_ids(node.request_ids)
149 for interface in node.interfaces: 153 for interface in node.interfaces:
150 interface_object = BareMetalNodeInterface(self, interface) 154 interface_object = BareMetalNodeInterface(self, interface)
151 interfaces.append(interface_object) 155 interfaces.append(interface_object)
diff --git a/novaclient/v2/contrib/tenant_networks.py b/novaclient/v2/contrib/tenant_networks.py
index 0bc5693..e124cbe 100644
--- a/novaclient/v2/contrib/tenant_networks.py
+++ b/novaclient/v2/contrib/tenant_networks.py
@@ -20,7 +20,12 @@ from novaclient import utils
20 20
21class TenantNetwork(base.Resource): 21class TenantNetwork(base.Resource):
22 def delete(self): 22 def delete(self):
23 self.manager.delete(network=self) 23 """
24 Delete this project network.
25
26 :returns: An instance of novaclient.base.TupleWithMeta
27 """
28 return self.manager.delete(network=self)
24 29
25 30
26class TenantNetworkManager(base.ManagerWithFind): 31class TenantNetworkManager(base.ManagerWithFind):
@@ -34,7 +39,13 @@ class TenantNetworkManager(base.ManagerWithFind):
34 'network') 39 'network')
35 40
36 def delete(self, network): 41 def delete(self, network):
37 self._delete('/os-tenant-networks/%s' % base.getid(network)) 42 """
43 Delete a specified project network.
44
45 :param network: a project network to delete
46 :returns: An instance of novaclient.base.TupleWithMeta
47 """
48 return self._delete('/os-tenant-networks/%s' % base.getid(network))
38 49
39 def create(self, label, cidr): 50 def create(self, label, cidr):
40 body = {'network': {'label': label, 'cidr': cidr}} 51 body = {'network': {'label': label, 'cidr': cidr}}