Missing Location in http header
This patch fixes the problem regarding the "Location" HTTP header which is missing in the response when changing external connectivity. According to the specification file, When operating on VNF instance resource. The VNFM returns a "202 Accepted" response with an empty payload body and a "Location" HTTP header that points to the new "Individual VNF LCM operation occurrence" resource, i.e. it includes the URI of that resource which is "…/vnf_lcm_op_occs/{vnfLcmOpOccId}" but now "Location" HTTP header is missing in the response when changing external connectivity. Closes-Bug: #1945387 Change-Id: I77c161b08c9c468fe6d4d243c1d098a0855bb2c8
This commit is contained in:
parent
7bb1bf8f5e
commit
c062072813
|
@ -1842,7 +1842,7 @@ class VnfLcmController(wsgi.Controller):
|
||||||
409,
|
409,
|
||||||
title='VNF IS NOT INSTANTIATED')
|
title='VNF IS NOT INSTANTIATED')
|
||||||
vnf['before_error_point'] = EP.INITIAL
|
vnf['before_error_point'] = EP.INITIAL
|
||||||
self._change_ext_conn(context, vnf_instance, vnf, body)
|
return self._change_ext_conn(context, vnf_instance, vnf, body)
|
||||||
|
|
||||||
def _change_ext_conn(self, context, vnf_instance, vnf, request_body):
|
def _change_ext_conn(self, context, vnf_instance, vnf, request_body):
|
||||||
req_body = utils.convert_camelcase_to_snakecase(request_body)
|
req_body = utils.convert_camelcase_to_snakecase(request_body)
|
||||||
|
@ -1868,6 +1868,14 @@ class VnfLcmController(wsgi.Controller):
|
||||||
change_ext_conn_req,
|
change_ext_conn_req,
|
||||||
vnf_lcm_op_occs_id)
|
vnf_lcm_op_occs_id)
|
||||||
|
|
||||||
|
# set response header
|
||||||
|
res = webob.Response()
|
||||||
|
res.status_int = 202
|
||||||
|
location = ('Location',
|
||||||
|
self._get_vnf_lcm_op_occs_href(vnf_lcm_op_occs_id))
|
||||||
|
res.headerlist.append(location)
|
||||||
|
return res
|
||||||
|
|
||||||
|
|
||||||
def create_resource():
|
def create_resource():
|
||||||
return wsgi.Resource(VnfLcmController())
|
return wsgi.Resource(VnfLcmController())
|
||||||
|
|
|
@ -4074,6 +4074,40 @@ class TestController(base.TestCase):
|
||||||
self.assertEqual(http_client.ACCEPTED, resp.status_code)
|
self.assertEqual(http_client.ACCEPTED, resp.status_code)
|
||||||
mock_rpc.assert_called_once()
|
mock_rpc.assert_called_once()
|
||||||
|
|
||||||
|
@mock.patch('tacker.api.vnflcm.v1.controller.'
|
||||||
|
'VnfLcmController._notification_process')
|
||||||
|
@mock.patch.object(TackerManager, 'get_service_plugins',
|
||||||
|
return_value={'VNFM':
|
||||||
|
test_nfvo_plugin.FakeVNFMPlugin()})
|
||||||
|
@mock.patch('tacker.api.vnflcm.v1.controller.'
|
||||||
|
'VnfLcmController._notification_process')
|
||||||
|
@mock.patch('tacker.api.vnflcm.v1.controller.'
|
||||||
|
'VnfLcmController._get_vnf')
|
||||||
|
@mock.patch.object(objects.VnfInstance, "get_by_id")
|
||||||
|
@mock.patch.object(objects.VnfInstance, "save")
|
||||||
|
@mock.patch.object(vnf_lcm_rpc.VNFLcmRPCAPI, "change_ext_conn")
|
||||||
|
def test_change_ext_conn_location(self, mock_rpc, mock_save,
|
||||||
|
mock_vnf_by_id, mock_get_vnf,
|
||||||
|
mock_notification_process,
|
||||||
|
mock_get_service_plugins, mock_insta_notfi_process):
|
||||||
|
vnf_instance_obj = fakes.return_vnf_instance(
|
||||||
|
fields.VnfInstanceState.INSTANTIATED)
|
||||||
|
mock_vnf_by_id.return_value = vnf_instance_obj
|
||||||
|
mock_get_vnf.return_value = \
|
||||||
|
self._get_dummy_vnf(vnf_id=vnf_instance_obj.id, status='ACTIVE')
|
||||||
|
body = fakes.get_change_ext_conn_request_body()
|
||||||
|
req = fake_request.HTTPRequest.blank(
|
||||||
|
'/vnf_instances/%s/change_ext_conn' % uuidsentinel.vnf_instance_id)
|
||||||
|
req.body = jsonutils.dump_as_bytes(body)
|
||||||
|
req.headers['Content-Type'] = 'application/json'
|
||||||
|
req.method = 'POST'
|
||||||
|
resp = req.get_response(self.app)
|
||||||
|
self.assertTrue('Location' in resp.headers.keys())
|
||||||
|
expected_location = (self.expected_location_prefix +
|
||||||
|
str(mock_insta_notfi_process.return_value))
|
||||||
|
self.assertEqual(expected_location, resp.headers['location'])
|
||||||
|
self.assertEqual(http_client.ACCEPTED, resp.status_code)
|
||||||
|
|
||||||
@mock.patch.object(TackerManager, 'get_service_plugins',
|
@mock.patch.object(TackerManager, 'get_service_plugins',
|
||||||
return_value={'VNFM':
|
return_value={'VNFM':
|
||||||
test_nfvo_plugin.FakeVNFMPlugin()})
|
test_nfvo_plugin.FakeVNFMPlugin()})
|
||||||
|
|
Loading…
Reference in New Issue