Skip to content

Commit 68bc878

Browse files
committed
virt: Remove 'reset_network' API
This one is tied into an admin action in the server actions API, which means we must remove that API action also. Otherwise, this isn't too crazy. Change-Id: I58343b94b67915062d044fa0f53aeab01b77738f Signed-off-by: Stephen Finucane <[email protected]>
1 parent 30067be commit 68bc878

File tree

17 files changed

+28
-136
lines changed

17 files changed

+28
-136
lines changed

api-ref/source/servers-admin-action.inc

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -170,16 +170,19 @@ Response
170170
If successful, this method does not return content in the response body.
171171

172172

173-
Reset Networking On A Server (resetNetwork Action)
174-
==================================================
173+
Reset Networking On A Server (resetNetwork Action) (DEPRECATED)
174+
===============================================================
175175

176176
.. rest_method:: POST /servers/{server_id}/action
177177

178178
Resets networking on a server.
179179

180-
.. note::
180+
.. warning::
181181

182-
No longer supported by any in-tree virt driver.
182+
This action was only supported by the XenAPI virt driver, which was
183+
deprecated in the 20.0.0 (Train) release and removed in the 22.0.0
184+
(Victoria) release. This action should be avoided in new applications. It
185+
was removed in the 23.0.0 (Wallaby) release.
183186

184187
Specify the ``resetNetwork`` action in the request body.
185188

@@ -190,7 +193,7 @@ through the ``policy.json`` file.
190193
Normal response codes: 202
191194

192195
Error response codes: unauthorized(401), forbidden(403), itemNotFound(404),
193-
conflict(409)
196+
conflict(409), gone(410)
194197

195198
Request
196199
-------

nova/api/openstack/compute/admin_actions.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,11 @@ def __init__(self):
3434
super(AdminActionsController, self).__init__()
3535
self.compute_api = compute.API()
3636

37-
@wsgi.response(202)
38-
@wsgi.expected_errors((404, 409))
37+
@wsgi.expected_errors(410)
3938
@wsgi.action('resetNetwork')
4039
def _reset_network(self, req, id, body):
41-
"""Permit admins to reset networking on a server."""
42-
context = req.environ['nova.context']
43-
instance = common.get_instance(self.compute_api, context, id)
44-
context.can(aa_policies.POLICY_ROOT % 'reset_network',
45-
target={'project_id': instance.project_id})
46-
try:
47-
self.compute_api.reset_network(context, instance)
48-
except exception.InstanceIsLocked as e:
49-
raise exc.HTTPConflict(explanation=e.format_message())
40+
"""(Removed) Permit admins to reset networking on a server."""
41+
raise exc.HTTPGone()
5042

5143
@wsgi.response(202)
5244
@wsgi.expected_errors((404, 409))

nova/compute/api.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4530,11 +4530,6 @@ def unlock(self, context, instance):
45304530
action=fields_obj.NotificationAction.UNLOCK,
45314531
source=fields_obj.NotificationSource.API)
45324532

4533-
@check_instance_lock
4534-
def reset_network(self, context, instance):
4535-
"""Reset networking on the instance."""
4536-
self.compute_rpcapi.reset_network(context, instance=instance)
4537-
45384533
@check_instance_lock
45394534
def inject_network_info(self, context, instance):
45404535
"""Inject network info for the instance."""

nova/compute/manager.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6075,7 +6075,6 @@ def add_fixed_ip_to_instance(self, context, network_id, instance):
60756075
instance,
60766076
network_id)
60776077
self._inject_network_info(instance, network_info)
6078-
self.reset_network(context, instance)
60796078

60806079
# NOTE(russellb) We just want to bump updated_at. See bug 1143466.
60816080
instance.updated_at = timeutils.utcnow()
@@ -6098,7 +6097,6 @@ def remove_fixed_ip_from_instance(self, context, address, instance):
60986097
instance,
60996098
address)
61006099
self._inject_network_info(instance, network_info)
6101-
self.reset_network(context, instance)
61026100

61036101
# NOTE(russellb) We just want to bump updated_at. See bug 1143466.
61046102
instance.updated_at = timeutils.utcnow()
@@ -6629,11 +6627,9 @@ def _unshelve_instance(self, context, instance, image, filter_properties,
66296627

66306628
# TODO(stephenfin): Remove this in RPC 6.0 since it's nova-network only
66316629
@messaging.expected_exceptions(NotImplementedError)
6632-
@wrap_instance_fault
66336630
def reset_network(self, context, instance):
66346631
"""Reset networking on the given instance."""
6635-
LOG.debug('Reset network', instance=instance)
6636-
self.driver.reset_network(instance)
6632+
raise NotImplementedError()
66376633

66386634
def _inject_network_info(self, instance, network_info):
66396635
"""Inject network info for the given instance."""

nova/compute/rpcapi.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1124,13 +1124,6 @@ def rescue_instance(self, ctxt, instance, rescue_password,
11241124
server=_compute_host(None, instance), version=version)
11251125
cctxt.cast(ctxt, 'rescue_instance', **msg_args)
11261126

1127-
# Remove as it only supports nova network
1128-
def reset_network(self, ctxt, instance):
1129-
version = '5.0'
1130-
cctxt = self.router.client(ctxt).prepare(
1131-
server=_compute_host(None, instance), version=version)
1132-
cctxt.cast(ctxt, 'reset_network', instance=instance)
1133-
11341127
def resize_instance(self, ctxt, instance, migration, image, instance_type,
11351128
request_spec, clean_shutdown=True):
11361129
msg_args = {'instance': instance, 'migration': migration,

nova/policies/admin_actions.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,6 @@
4444
}
4545
],
4646
scope_types=['system', 'project']),
47-
policy.DocumentedRuleDefault(
48-
name=POLICY_ROOT % 'reset_network',
49-
check_str=base.SYSTEM_ADMIN,
50-
description="Reset networking on a server",
51-
operations=[
52-
{
53-
'method': 'POST',
54-
'path': '/servers/{server_id}/action (resetNetwork)'
55-
}
56-
],
57-
scope_types=['system', 'project'])
5847
]
5948

6049

nova/tests/functional/api_sample_tests/api_samples/os-admin-actions/admin-actions-reset-network.json.tpl

Lines changed: 0 additions & 3 deletions
This file was deleted.

nova/tests/functional/api_sample_tests/test_admin_actions.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ def setUp(self):
3131

3232
def test_post_reset_network(self):
3333
# Get api samples to reset server network request.
34-
response = self._do_post('servers/%s/action' % self.uuid,
35-
'admin-actions-reset-network', {})
36-
self.assertEqual(202, response.status_code)
34+
self.api.api_post(
35+
'servers/%s/action' % self.uuid, {'resetNetwork': None},
36+
check_response_status=[410])
3737

3838
def test_post_inject_network_info(self):
3939
# Get api samples to inject network info request.

nova/tests/unit/api/openstack/compute/test_admin_actions.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,18 @@ def setUp(self):
2929
lambda *a, **k: self.controller)
3030

3131
def test_actions(self):
32-
actions = ['_reset_network', '_inject_network_info']
33-
method_translations = {'_reset_network': 'reset_network',
34-
'_inject_network_info': 'inject_network_info'}
32+
actions = ['_inject_network_info']
33+
method_translations = {'_inject_network_info': 'inject_network_info'}
3534

3635
self._test_actions(actions, method_translations)
3736

3837
def test_actions_with_non_existed_instance(self):
39-
actions = ['_reset_network', '_inject_network_info']
38+
actions = ['_inject_network_info']
4039
self._test_actions_with_non_existed_instance(actions)
4140

4241
def test_actions_with_locked_instance(self):
43-
actions = ['_reset_network', '_inject_network_info']
44-
method_translations = {'_reset_network': 'reset_network',
45-
'_inject_network_info': 'inject_network_info'}
42+
actions = ['_inject_network_info']
43+
method_translations = {'_inject_network_info': 'inject_network_info'}
4644

47-
self._test_actions_with_locked_instance(actions,
48-
method_translations=method_translations)
45+
self._test_actions_with_locked_instance(
46+
actions, method_translations=method_translations)

nova/tests/unit/compute/test_compute.py

Lines changed: 4 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3360,26 +3360,6 @@ def fake_driver_inject_network(self, instance, network_info):
33603360
self.assertTrue(called['inject'])
33613361
self.compute.terminate_instance(self.context, instance, [])
33623362

3363-
def test_reset_network(self):
3364-
# Ensure we can reset networking on an instance.
3365-
called = {'count': 0}
3366-
3367-
def fake_driver_reset_network(self, instance):
3368-
called['count'] += 1
3369-
3370-
self.stub_out('nova.virt.fake.FakeDriver.reset_network',
3371-
fake_driver_reset_network)
3372-
3373-
instance = self._create_fake_instance_obj()
3374-
self.compute.build_and_run_instance(self.context, instance, {}, {}, {},
3375-
block_device_mapping=[])
3376-
3377-
self.compute.reset_network(self.context, instance)
3378-
3379-
self.assertEqual(called['count'], 1)
3380-
3381-
self.compute.terminate_instance(self.context, instance, [])
3382-
33833363
def _get_snapshotting_instance(self):
33843364
# Ensure instance can be snapshotted.
33853365
instance = self._create_fake_instance_obj()
@@ -4250,10 +4230,8 @@ def test_add_fixed_ip_usage_notification(self):
42504230
def dummy(*args, **kwargs):
42514231
pass
42524232

4253-
self.stub_out('nova.compute.manager.ComputeManager.'
4254-
'inject_network_info', dummy)
4255-
self.stub_out('nova.compute.manager.ComputeManager.'
4256-
'reset_network', dummy)
4233+
self.stub_out(
4234+
'nova.compute.manager.ComputeManager.inject_network_info', dummy)
42574235

42584236
instance = self._create_fake_instance_obj()
42594237

@@ -4270,10 +4248,8 @@ def test_remove_fixed_ip_usage_notification(self):
42704248
def dummy(*args, **kwargs):
42714249
pass
42724250

4273-
self.stub_out('nova.compute.manager.ComputeManager.'
4274-
'inject_network_info', dummy)
4275-
self.stub_out('nova.compute.manager.ComputeManager.'
4276-
'reset_network', dummy)
4251+
self.stub_out(
4252+
'nova.compute.manager.ComputeManager.inject_network_info', dummy)
42774253

42784254
instance = self._create_fake_instance_obj()
42794255

@@ -11213,13 +11189,6 @@ def test_inject_network_info(self):
1121311189
instance = self.compute_api.get(self.context, instance['uuid'])
1121411190
self.compute_api.inject_network_info(self.context, instance)
1121511191

11216-
def test_reset_network(self):
11217-
instance = self._create_fake_instance_obj()
11218-
self.compute.build_and_run_instance(self.context,
11219-
instance, {}, {}, {}, block_device_mapping=[])
11220-
instance = self.compute_api.get(self.context, instance['uuid'])
11221-
self.compute_api.reset_network(self.context, instance)
11222-
1122311192
@mock.patch('nova.compute.utils.notify_about_instance_action')
1122411193
@mock.patch('nova.context.RequestContext.elevated')
1122511194
@mock.patch('nova.compute.api.API._record_action_start')

nova/tests/unit/compute/test_compute_mgr.py

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5136,27 +5136,6 @@ def do_test(save_mock, power_off_mock, notify_mock,
51365136

51375137
do_test()
51385138

5139-
def test_reset_network_driver_not_implemented(self):
5140-
instance = fake_instance.fake_instance_obj(self.context)
5141-
5142-
@mock.patch.object(self.compute.driver, 'reset_network',
5143-
side_effect=NotImplementedError())
5144-
@mock.patch.object(compute_utils, 'add_instance_fault_from_exc')
5145-
def do_test(mock_add_fault, mock_reset):
5146-
self.assertRaises(messaging.ExpectedException,
5147-
self.compute.reset_network,
5148-
self.context,
5149-
instance)
5150-
5151-
self.compute = utils.ExceptionHelper(self.compute)
5152-
5153-
self.assertRaises(NotImplementedError,
5154-
self.compute.reset_network,
5155-
self.context,
5156-
instance)
5157-
5158-
do_test()
5159-
51605139
@mock.patch.object(manager.ComputeManager, '_set_migration_status')
51615140
@mock.patch.object(manager.ComputeManager,
51625141
'_do_rebuild_instance_with_claim')

nova/tests/unit/compute/test_rpcapi.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -776,10 +776,6 @@ def test_rescue_instance(self):
776776
rescue_image_ref='fake_image_ref',
777777
clean_shutdown=True, version='5.0')
778778

779-
def test_reset_network(self):
780-
self._test_compute_api('reset_network', 'cast',
781-
instance=self.fake_instance_obj)
782-
783779
def test_resize_instance(self):
784780
self._test_compute_api('resize_instance', 'cast',
785781
instance=self.fake_instance_obj, migration={'id': 'fake_id'},

nova/tests/unit/fake_policy.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@
5151
"os_compute_api:servers:migrations:show": "",
5252
"os_compute_api:servers:migrations:delete": "",
5353
"os_compute_api:os-admin-actions:inject_network_info": "",
54-
"os_compute_api:os-admin-actions:reset_network": "",
5554
"os_compute_api:os-admin-actions:reset_state": "",
5655
"os_compute_api:os-admin-password": "",
5756
"os_compute_api:os-aggregates:set_metadata": "",

nova/tests/unit/policies/test_admin_actions.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,6 @@ def test_inject_network_info_policy(self):
7575
self.controller._inject_network_info,
7676
self.req, self.instance.uuid, body={})
7777

78-
def test_reset_network_policy(self):
79-
rule_name = "os_compute_api:os-admin-actions:reset_network"
80-
with mock.patch.object(self.controller.compute_api, "reset_network"):
81-
self.common_policy_check(self.admin_authorized_contexts,
82-
self.admin_unauthorized_contexts,
83-
rule_name, self.controller._reset_network,
84-
self.req, self.instance.uuid, body={})
85-
8678

8779
class AdminActionsScopeTypePolicyTest(AdminActionsPolicyTest):
8880
"""Test Admin Actions APIs policies with system scope enabled.

nova/tests/unit/test_policy.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,6 @@ def setUp(self):
326326
"os_compute_api:servers:show:host_status:unknown-only",
327327
"os_compute_api:servers:migrations:force_complete",
328328
"os_compute_api:servers:migrations:delete",
329-
"os_compute_api:os-admin-actions:reset_network",
330329
"os_compute_api:os-admin-actions:inject_network_info",
331330
"os_compute_api:os-admin-actions:reset_state",
332331
"os_compute_api:os-aggregates:index",

nova/virt/driver.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1347,13 +1347,6 @@ def get_instance_disk_info(self, instance,
13471347
"""
13481348
raise NotImplementedError()
13491349

1350-
# TODO(stephenfin): This was only implemented (properly) for XenAPI and
1351-
# should be removed.
1352-
def reset_network(self, instance):
1353-
"""reset networking for specified instance."""
1354-
# TODO(Vek): Need to pass context in for access to auth_token
1355-
pass
1356-
13571350
def set_admin_password(self, instance, new_pass):
13581351
"""Set the root password on the specified instance.
13591352

releasenotes/notes/remove-xenapi-driver-194756049f22dc9e.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ upgrade:
1212
* ``POST /os-agents``
1313
* ``PUT /os-agents/{agent_id}``
1414
* ``DELETE /os-agents/{agent_id}``
15+
* ``POST /servers/{server_id}/action (resetNetwork)``
1516
1617
The ``XenAPI`` specific policies have been removed:
1718
@@ -20,6 +21,7 @@ upgrade:
2021
* ``os_compute_api:os-agents:create``
2122
* ``os_compute_api:os-agents:update``
2223
* ``os_compute_api:os-agents:delete``
24+
* ``os_compute_api:os-admin-actions:reset_network``
2325
2426
The ``XenAPI`` specific configuration options have been removed.
2527

0 commit comments

Comments
 (0)