Merge "Add response information for Individual Subscription"
This commit is contained in:
commit
0a2c5d16b9
|
@ -655,6 +655,13 @@ filter_operation_types:
|
||||||
in: body
|
in: body
|
||||||
required: false
|
required: false
|
||||||
type: string
|
type: string
|
||||||
|
filter_vnf_instance_subscription_filter:
|
||||||
|
description: |
|
||||||
|
This type represents subscription filter
|
||||||
|
criteria to match VNF instances.
|
||||||
|
in: body
|
||||||
|
required: false
|
||||||
|
type: object
|
||||||
fixed_addresses:
|
fixed_addresses:
|
||||||
description: |
|
description: |
|
||||||
Fixed addresses to assign (from the subnet defined by "subnetId"
|
Fixed addresses to assign (from the subnet defined by "subnetId"
|
||||||
|
|
|
@ -1,14 +1,52 @@
|
||||||
{
|
{
|
||||||
"id": "76057f8e65ab37fb82d9382dfc3f3c8b",
|
"id": "76057f8e65ab37fb82d9382dfc3f3c8b",
|
||||||
"filter": {
|
"filter": {
|
||||||
"notificationTypes": [
|
"vnfInstanceSubscriptionFilter": {
|
||||||
"VnfLcmOperationOccurrenceNotification"
|
"vnfdIds": [],
|
||||||
]
|
"vnfProductsFromProviders": {
|
||||||
},
|
"vnfProvider": "Vnf Provider 1",
|
||||||
"callbackUri": "http://sample1.com/notification",
|
"vnfProducts": [
|
||||||
"_links": {
|
{
|
||||||
"self": {
|
"vnfProductName": "Vnf Product 1",
|
||||||
"href": "https://sample1.com/vnflcm/v1/subscriptions/76057f8e65ab37fb82d9382dfc3f3c8b"
|
"versions": [
|
||||||
}
|
{
|
||||||
}
|
"vnfSoftwareVersion": "v1",
|
||||||
|
"vnfdVersions": [
|
||||||
|
"vnfd.v1.1"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notificationTypes": [
|
||||||
|
"VnfLcmOperationOccurrenceNotification",
|
||||||
|
"VnfIdentifierCreationNotification",
|
||||||
|
"VnfIdentifierDeletionNotification"
|
||||||
|
],
|
||||||
|
"operationTypes": [
|
||||||
|
"INSTANTIATE",
|
||||||
|
"SCALE",
|
||||||
|
"TERMINATE",
|
||||||
|
"HEAL",
|
||||||
|
"CHANGE_EXT_CONN",
|
||||||
|
"MODIFY_INFO"
|
||||||
|
],
|
||||||
|
"operationStates": [
|
||||||
|
"STARTING",
|
||||||
|
"PROCESSING",
|
||||||
|
"COMPLETED",
|
||||||
|
"FAILED_TEMP",
|
||||||
|
"FAILED",
|
||||||
|
"ROLLING_BACK",
|
||||||
|
"ROLLED_BACK"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"callbackUri": "http://sample1.com/notification",
|
||||||
|
"_links": {
|
||||||
|
"self": {
|
||||||
|
"href": "https://sample1.com/vnflcm/v1/subscriptions/76057f8e65ab37fb82d9382dfc3f3c8b"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1258,8 +1258,10 @@ Response Parameters
|
||||||
|
|
||||||
- id: subscription_id_response
|
- id: subscription_id_response
|
||||||
- filter: filter
|
- filter: filter
|
||||||
|
- vnfInstanceSubscriptionFilter: filter_vnf_instance_subscription_filter
|
||||||
- notificationTypes: filter_notification_types
|
- notificationTypes: filter_notification_types
|
||||||
- operationTypes: filter_operation_types
|
- operationTypes: filter_operation_types
|
||||||
|
- operationStates: filter_operation_states
|
||||||
- callbackUri: callback_uri
|
- callbackUri: callback_uri
|
||||||
- _links: vnf_instance_links
|
- _links: vnf_instance_links
|
||||||
|
|
||||||
|
|
|
@ -282,6 +282,9 @@ class ViewBuilder(base.BaseViewBuilder):
|
||||||
return self._subscription_filter(
|
return self._subscription_filter(
|
||||||
vnf_lcm_subscriptions, nextpage_opaque_marker, paging)
|
vnf_lcm_subscriptions, nextpage_opaque_marker, paging)
|
||||||
|
|
||||||
|
# TODO(esto.aln): To remove show subscription related processing
|
||||||
|
# in vnf_lcm.py. Current processing for show subscription is in
|
||||||
|
# vnf_subscriptions.py.
|
||||||
def subscription_show(self, vnf_lcm_subscriptions):
|
def subscription_show(self, vnf_lcm_subscriptions):
|
||||||
return self._get_vnf_lcm_subscription(vnf_lcm_subscriptions)
|
return self._get_vnf_lcm_subscription(vnf_lcm_subscriptions)
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
import datetime
|
import datetime
|
||||||
import iso8601
|
import iso8601
|
||||||
|
import json
|
||||||
import os
|
import os
|
||||||
import webob
|
import webob
|
||||||
|
|
||||||
|
@ -1692,10 +1693,27 @@ def _fake_subscription_obj(**updates):
|
||||||
"vnfInstanceNames": ["Vnf Name 1"]
|
"vnfInstanceNames": ["Vnf Name 1"]
|
||||||
},
|
},
|
||||||
"notificationTypes": [
|
"notificationTypes": [
|
||||||
"VnfLcmOperationOccurrenceNotification"
|
"VnfLcmOperationOccurrenceNotification",
|
||||||
|
"VnfIdentifierCreationNotification",
|
||||||
|
"VnfIdentifierDeletionNotification"
|
||||||
],
|
],
|
||||||
"operationTypes": ["INSTANTIATE"],
|
"operationTypes": [
|
||||||
"operationStates": ["STARTING"]
|
"INSTANTIATE",
|
||||||
|
"SCALE",
|
||||||
|
"TERMINATE",
|
||||||
|
"HEAL",
|
||||||
|
"CHANGE_EXT_CONN",
|
||||||
|
"MODIFY_INFO"
|
||||||
|
],
|
||||||
|
"operationStates": [
|
||||||
|
"STARTING",
|
||||||
|
"PROCESSING",
|
||||||
|
"COMPLETED",
|
||||||
|
"FAILED_TEMP",
|
||||||
|
"FAILED",
|
||||||
|
"ROLLING_BACK",
|
||||||
|
"ROLLED_BACK"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
'callback_uri': 'http://localhost/sample_callback_uri'}
|
'callback_uri': 'http://localhost/sample_callback_uri'}
|
||||||
|
|
||||||
|
@ -1713,3 +1731,34 @@ def return_subscription_object(**updates):
|
||||||
def return_vnf_subscription_list(**updates):
|
def return_vnf_subscription_list(**updates):
|
||||||
vnc_lcm_subscription = return_subscription_object(**updates)
|
vnc_lcm_subscription = return_subscription_object(**updates)
|
||||||
return [vnc_lcm_subscription]
|
return [vnc_lcm_subscription]
|
||||||
|
|
||||||
|
|
||||||
|
def _subscription_links(subscription_dict):
|
||||||
|
links = {
|
||||||
|
"_links": {
|
||||||
|
"self": {
|
||||||
|
"href": "%(endpoint)s/vnflcm/v1/subscriptions/%(id)s"
|
||||||
|
% {'id': subscription_dict['id'],
|
||||||
|
'endpoint': CONF.vnf_lcm.endpoint_url}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
subscription_dict.update(links)
|
||||||
|
|
||||||
|
return subscription_dict
|
||||||
|
|
||||||
|
|
||||||
|
def return_subscription_obj(**updates):
|
||||||
|
subscription = _fake_subscription_obj(**updates)
|
||||||
|
subscription['filter'] = json.dumps(subscription['filter'])
|
||||||
|
obj = objects.LccnSubscriptionRequest(**subscription)
|
||||||
|
|
||||||
|
return obj
|
||||||
|
|
||||||
|
|
||||||
|
def fake_subscription_response(**updates):
|
||||||
|
data = _fake_subscription_obj(**updates)
|
||||||
|
data = utils.convert_snakecase_to_camelcase(data)
|
||||||
|
data = _subscription_links(data)
|
||||||
|
|
||||||
|
return data
|
||||||
|
|
|
@ -3943,6 +3943,27 @@ class TestController(base.TestCase):
|
||||||
resp = req.get_response(self.app)
|
resp = req.get_response(self.app)
|
||||||
self.assertEqual(500, resp.status_code)
|
self.assertEqual(500, resp.status_code)
|
||||||
|
|
||||||
|
@mock.patch.object(TackerManager, 'get_service_plugins',
|
||||||
|
return_value={'VNFM':
|
||||||
|
test_nfvo_plugin.FakeVNFMPlugin()})
|
||||||
|
@mock.patch.object(objects.LccnSubscriptionRequest,
|
||||||
|
"vnf_lcm_subscriptions_show")
|
||||||
|
def test_subscription_show(self, mock_get_subscription,
|
||||||
|
mock_get_service_plugins):
|
||||||
|
mock_get_subscription.return_value =\
|
||||||
|
fakes.return_subscription_obj()
|
||||||
|
|
||||||
|
req = fake_request.HTTPRequest.blank(
|
||||||
|
'/subscriptions/%s' % uuidsentinel.subscription_id)
|
||||||
|
req.method = 'GET'
|
||||||
|
|
||||||
|
resp = req.get_response(self.app)
|
||||||
|
|
||||||
|
expected_vnf = fakes.fake_subscription_response()
|
||||||
|
|
||||||
|
self.assertEqual(http_client.OK, resp.status_code)
|
||||||
|
self.assertEqual(expected_vnf, resp.json)
|
||||||
|
|
||||||
@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()})
|
||||||
|
@ -3999,6 +4020,26 @@ class TestController(base.TestCase):
|
||||||
else:
|
else:
|
||||||
self.assertEqual(expected_result, resp.json)
|
self.assertEqual(expected_result, resp.json)
|
||||||
|
|
||||||
|
@mock.patch.object(TackerManager, 'get_service_plugins',
|
||||||
|
return_value={'VNFM':
|
||||||
|
test_nfvo_plugin.FakeVNFMPlugin()})
|
||||||
|
@mock.patch.object(objects.LccnSubscriptionRequest,
|
||||||
|
"vnf_lcm_subscriptions_show")
|
||||||
|
def test_subscription_show_not_found(self, mock_get_subscription,
|
||||||
|
mock_get_service_plugins):
|
||||||
|
req = fake_request.HTTPRequest.blank(
|
||||||
|
'/subscriptions/%s' % uuidsentinel.subscription_id)
|
||||||
|
req.method = 'GET'
|
||||||
|
|
||||||
|
mock_get_subscription.return_value = None
|
||||||
|
|
||||||
|
msg = _("Can not find requested vnf lcm subscriptions: %s"
|
||||||
|
% uuidsentinel.subscription_id)
|
||||||
|
res = self._make_problem_detail(msg, 404, title='Not Found')
|
||||||
|
|
||||||
|
resp = req.get_response(self.app)
|
||||||
|
self.assertEqual(res.text, resp.text)
|
||||||
|
|
||||||
@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()})
|
||||||
|
@ -4011,3 +4052,19 @@ class TestController(base.TestCase):
|
||||||
resp = req.get_response(self.app)
|
resp = req.get_response(self.app)
|
||||||
|
|
||||||
self.assertEqual(400, resp.status_code)
|
self.assertEqual(400, resp.status_code)
|
||||||
|
|
||||||
|
@mock.patch.object(TackerManager, 'get_service_plugins',
|
||||||
|
return_value={'VNFM':
|
||||||
|
test_nfvo_plugin.FakeVNFMPlugin()})
|
||||||
|
@mock.patch.object(objects.LccnSubscriptionRequest,
|
||||||
|
"vnf_lcm_subscriptions_show")
|
||||||
|
def test_subscription_show_error(self, mock_get_subscription,
|
||||||
|
mock_get_service_plugins):
|
||||||
|
req = fake_request.HTTPRequest.blank(
|
||||||
|
'/subscriptions/%s' % uuidsentinel.subscription_id)
|
||||||
|
req.method = 'GET'
|
||||||
|
|
||||||
|
mock_get_subscription.side_effect = Exception
|
||||||
|
|
||||||
|
resp = req.get_response(self.app)
|
||||||
|
self.assertEqual(500, resp.status_code)
|
||||||
|
|
Loading…
Reference in New Issue