summaryrefslogtreecommitdiffstats
path: root/gvnfmadapter
diff options
context:
space:
mode:
authormaopengzhang <zhang.maopeng1@zte.com.cn>2018-11-10 13:29:02 +0800
committermaopengzhang <zhang.maopeng1@zte.com.cn>2018-11-10 13:49:45 +0800
commitf49edb6e4f3489ec864ed1348e062b94e8b2f915 (patch)
treea8d033f88a6d239fb1d853fd65b714b1766f8898 /gvnfmadapter
parent2cb896940c8c70df0053003996c32e668ed8c546 (diff)
fix get job error
fix get job error Change-Id: I6a9bff556f9ae9d1dd1e2ee62323241fe9c59a1f Issue-ID: VFC-1158 Signed-off-by: maopengzhang <zhang.maopeng1@zte.com.cn>
Diffstat (limited to 'gvnfmadapter')
-rw-r--r--gvnfmadapter/driver/interfaces/serializers/heal_request.py2
-rw-r--r--gvnfmadapter/driver/interfaces/serializers/lccn_subscription_request.py1
-rw-r--r--gvnfmadapter/driver/interfaces/serializers/problem_details.py1
-rw-r--r--gvnfmadapter/driver/interfaces/serializers/subscription_authentication.py14
-rw-r--r--gvnfmadapter/driver/interfaces/serializers/vnf_instance_subscription_filter.py12
-rw-r--r--gvnfmadapter/driver/interfaces/tests.py37
-rw-r--r--gvnfmadapter/driver/interfaces/views.py11
7 files changed, 46 insertions, 32 deletions
diff --git a/gvnfmadapter/driver/interfaces/serializers/heal_request.py b/gvnfmadapter/driver/interfaces/serializers/heal_request.py
index c212769..9a3a240 100644
--- a/gvnfmadapter/driver/interfaces/serializers/heal_request.py
+++ b/gvnfmadapter/driver/interfaces/serializers/heal_request.py
@@ -20,10 +20,12 @@ class AffectedVm(serializers.Serializer):
vduid = serializers.CharField(help_text="Vdu id", required=True)
vmname = serializers.CharField(help_text="Vm name", required=True)
+
class VnfHealRequestSerializer(serializers.Serializer):
action = serializers.CharField(help_text="Action for NS heal", required=True, allow_null=True)
affectedvm = AffectedVm(help_text="Get the vm information to be healed", required=True)
+
class HealVnfRequestSerializerToVnfm(serializers.Serializer):
cause = serializers.CharField(help_text="Cause of NS heal", required=False, allow_null=True)
additionalParams = serializers.DictField(
diff --git a/gvnfmadapter/driver/interfaces/serializers/lccn_subscription_request.py b/gvnfmadapter/driver/interfaces/serializers/lccn_subscription_request.py
index 88797bc..8f5cfe8 100644
--- a/gvnfmadapter/driver/interfaces/serializers/lccn_subscription_request.py
+++ b/gvnfmadapter/driver/interfaces/serializers/lccn_subscription_request.py
@@ -17,6 +17,7 @@ from rest_framework import serializers
from driver.interfaces.serializers.lccn_filter import LifeCycleChangeNotificationsFilterSerializer
from driver.interfaces.serializers.subscription_authentication import SubscriptionAuthenticationSerializer
+
class LccnSubscriptionRequestSerializer(serializers.Serializer):
callbackUri = serializers.URLField(
help_text="The URI of the endpoint to send the notification to.",
diff --git a/gvnfmadapter/driver/interfaces/serializers/problem_details.py b/gvnfmadapter/driver/interfaces/serializers/problem_details.py
index fefc403..19639ce 100644
--- a/gvnfmadapter/driver/interfaces/serializers/problem_details.py
+++ b/gvnfmadapter/driver/interfaces/serializers/problem_details.py
@@ -14,6 +14,7 @@
from rest_framework import serializers
+
class ProblemDetailsSerializer(serializers.Serializer):
type = serializers.CharField(
help_text='A URI reference according to IETF RFC 3986 [5] that identifies the problem type.',
diff --git a/gvnfmadapter/driver/interfaces/serializers/subscription_authentication.py b/gvnfmadapter/driver/interfaces/serializers/subscription_authentication.py
index d9129ed..37a0195 100644
--- a/gvnfmadapter/driver/interfaces/serializers/subscription_authentication.py
+++ b/gvnfmadapter/driver/interfaces/serializers/subscription_authentication.py
@@ -46,12 +46,16 @@ class BasicAuthSerializer(serializers.Serializer):
userName = serializers.CharField(
help_text="Username to be used in HTTP Basic authentication.",
max_length=255,
- required=False
+ required=False,
+ allow_null=True,
+ allow_blank=True
)
password = serializers.CharField(
help_text="Password to be used in HTTP Basic authentication.",
max_length=255,
- required=False
+ required=False,
+ allow_null=True,
+ allow_blank=True
)
@@ -65,10 +69,12 @@ class SubscriptionAuthenticationSerializer(serializers.Serializer):
)
paramsBasic = BasicAuthSerializer(
help_text="Parameters for authentication/authorization using BASIC.",
- required=False
+ required=False,
+ allow_null=True
)
paramsOauth2ClientCredentials = OAuthCredentialsSerializer(
help_text="Parameters for authentication/authorization \
using OAUTH2_CLIENT_CREDENTIALS.",
- required=False
+ required=False,
+ allow_null=True
)
diff --git a/gvnfmadapter/driver/interfaces/serializers/vnf_instance_subscription_filter.py b/gvnfmadapter/driver/interfaces/serializers/vnf_instance_subscription_filter.py
index c46dc50..33fecbb 100644
--- a/gvnfmadapter/driver/interfaces/serializers/vnf_instance_subscription_filter.py
+++ b/gvnfmadapter/driver/interfaces/serializers/vnf_instance_subscription_filter.py
@@ -61,20 +61,24 @@ class VnfInstanceSubscriptionFilterSerializer(serializers.Serializer):
help_text="VNF instances that were created \
based on a VNFD identified by one of the vnfdId values",
child=serializers.UUIDField(),
- required=False
+ required=False,
+ allow_null=True
)
vnfInstanceIds = serializers.ListField(
help_text="VNF instance IDs that has to be matched",
child=serializers.UUIDField(),
- required=False
+ required=False,
+ allow_null=True
)
vnfInstanceNames = serializers.ListField(
help_text="VNF Instance names that has to be matched",
child=serializers.CharField(max_length=255, required=True),
- required=False
+ required=False,
+ allow_null=True
)
vnfProductsFromProviders = VnfProductsProvidersSerializer(
help_text="match VNF instances \
that belong to VNF products from certain providers.",
- required=False
+ required=False,
+ allow_null=True
)
diff --git a/gvnfmadapter/driver/interfaces/tests.py b/gvnfmadapter/driver/interfaces/tests.py
index 72f47b8..c4e1791 100644
--- a/gvnfmadapter/driver/interfaces/tests.py
+++ b/gvnfmadapter/driver/interfaces/tests.py
@@ -197,24 +197,22 @@ class InterfacesTest(TestCase):
}
}
resp_body = {
- "ResponseInfo": {
- "vnfLcOpId": "NF-CREATE-11-ec6c2f2a-9f48-11e6-9405-fa163e91c2f9",
- "responseDescriptor": {
- "responseId": 3,
- "progress": 40,
- "lcmOperationStatus": "PROCESSING",
- "statusDescription": "OMC VMs are decommissioned in VIM",
- "errorCode": "null",
- "responseHistoryList": [
- {
- "status": "error",
- "progress": 255,
- "errorcode": "",
- "responseid": 20,
- "statusdescription": "'JsonParser' object has no attribute 'parser_info'"
- }
- ]
- }
+ "jobId": "NF-CREATE-11-ec6c2f2a-9f48-11e6-9405-fa163e91c2f9",
+ "responseDescriptor": {
+ "responseId": 3,
+ "progress": 40,
+ "status": "PROCESSING",
+ "statusDescription": "OMC VMs are decommissioned in VIM",
+ "errorCode": "null",
+ "responseHistoryList": [
+ {
+ "status": "error",
+ "progress": 255,
+ "errorcode": "",
+ "responseid": 20,
+ "statusdescription": "'JsonParser' object has no attribute 'parser_info'"
+ }
+ ]
}
}
r1 = [0, json.JSONEncoder().encode(vnfm_info), '200']
@@ -222,6 +220,7 @@ class InterfacesTest(TestCase):
mock_call_req.side_effect = [r1, r2]
response = self.client.get("/api/gvnfmdriver/v1/%s/jobs/%s?responseId=0"
% (vnfm_info["vnfmId"], expected_body["jobId"]))
+ print response
self.assertEqual(status.HTTP_200_OK, response.status_code)
self.assertDictEqual(expected_body, response.data)
@@ -654,7 +653,7 @@ class InterfacesTest(TestCase):
"filter": {
"notificationTypes": ["VnfLcmOperationOccurrenceNotification"],
"operationTypes": ["INSTANTIATE"],
- "operationStates": ["STARTING"],
+ "operationStates": ["STARTING"]
},
"callbackUri": "http://aurl.com",
"authentication": {
diff --git a/gvnfmadapter/driver/interfaces/views.py b/gvnfmadapter/driver/interfaces/views.py
index 3a62b24..d246080 100644
--- a/gvnfmadapter/driver/interfaces/views.py
+++ b/gvnfmadapter/driver/interfaces/views.py
@@ -220,13 +220,13 @@ class VnfOperInfo(APIView):
raise GvnfmDriverException('Failed to query vnf operation status.')
resp_data = json.JSONDecoder().decode(ret[1])
logger.debug("[%s]resp_data=%s", fun_name(), resp_data)
- ResponseInfo = ignorcase_get(resp_data, "ResponseInfo")
- responseDescriptor = ignorcase_get(ResponseInfo, "responseDescriptor")
- status_tmp = ignorcase_get(responseDescriptor, "lcmOperationStatus")
- del responseDescriptor["lcmOperationStatus"]
+ # ResponseInfo = ignorcase_get(resp_data, "ResponseInfo")
+ responseDescriptor = ignorcase_get(resp_data, "responseDescriptor")
+ status_tmp = ignorcase_get(responseDescriptor, "status")
+ # del responseDescriptor["lcmOperationStatus"]
responseDescriptor["status"] = status_tmp
operation_data = {
- "jobId": ignorcase_get(ResponseInfo, "vnfLcOpId"),
+ "jobId": ignorcase_get(resp_data, "jobId"),
"responseDescriptor": responseDescriptor
}
return Response(data=operation_data, status=status.HTTP_200_OK)
@@ -409,6 +409,7 @@ class VnfPkgsInfo(APIView):
logger.error(traceback.format_exc())
return Response(data={'error': 'unexpected exception'}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
+
class QuerySingleVnfLcmOpOcc(APIView):
@swagger_auto_schema(
responses={