Ns descriptor related stuffs. 03/62003/1
authorlaili <lai.li@zte.com.cn>
Thu, 23 Aug 2018 06:27:04 +0000 (14:27 +0800)
committerlaili <lai.li@zte.com.cn>
Thu, 23 Aug 2018 06:32:42 +0000 (14:32 +0800)
Implement the biz for creation of a pnfd.
Add a serializer pnfd_infos.

Change-Id: Id9ecde485a102623bc084672a1119b3f6a56061c
Issue-ID: VFC-1037
Signed-off-by: laili <lai.li@zte.com.cn>
catalog/packages/biz/pnf_descriptor.py
catalog/packages/serializers/pnfd_infos.py
catalog/packages/urls.py
catalog/packages/views/pnf_descriptor_views.py

index d6710c4..a711fa5 100644 (file)
@@ -20,6 +20,7 @@ import uuid
 from catalog.pub.config.config import CATALOG_ROOT_PATH
 from catalog.pub.utils import fileutil
 from catalog.pub.utils.values import ignore_case_get
+from catalog.pub.database.models import PnfPackageModel
 
 logger = logging.getLogger(__name__)
 
@@ -33,6 +34,12 @@ def create(data):
         'userDefinedData': user_defined_data,
         '_links': None  # TODO
     }
+    PnfPackageModel(
+        pnfPackageId=data['id'],
+        onboardingState=data['pnfdOnboardingState'],
+        usageState=data['pnfdUsageState'],
+        userDefinedData=data['userDefinedData']
+    ).save()
     return data
 
 
index e69de29..26df221 100644 (file)
@@ -0,0 +1,17 @@
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#         http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+from rest_framework import serializers
+from pnfd_info import PnfdInfoSerializer
+
+
+class PnfdInfosSerializer(serializers.ListSerializer):
+    child = PnfdInfoSerializer()
index b656c75..e51fd41 100644 (file)
@@ -32,7 +32,7 @@ urlpatterns = [
     url(r'^api/nsd/v1/ns_descriptors/(?P<nsdInfoId>[0-9a-zA-Z\-\_]+)/nsd_content$', ns_descriptor_views.nsd_content_ru, name='nsd_content_ru'),
 
     # PNF
-    url(r'^api/nsd/v1/pnf_descriptors$', pnf_descriptor_views.create_pnf_descriptors, name='pnf_descriptors_rc'),
+    url(r'^api/nsd/v1/pnf_descriptors$', pnf_descriptor_views.pnf_descriptors_rc, name='pnf_descriptors_rc'),
     url(r'^api/nsd/v1/pnf_descriptors/(?P<pnfdInfoId>[0-9a-zA-Z\-\_]+)/pnfd_content$', pnf_descriptor_views.pnfd_content_ru, name='pnfd_content_ru'),
     # TODO SOL005 & SOL003
 
index fecba34..a55fb27 100644 (file)
@@ -63,7 +63,7 @@ def query_single_pnfd(self, request):
     }
 )
 @api_view(http_method_names=['POST'])
-def create_pnf_descriptors(request, *args, **kwargs):
+def pnf_descriptors_rc(request, *args, **kwargs):
     try:
         create_pnfd_info_request = CreatePnfdInfoRequestSerializer(data=request.data)
         if not create_pnfd_info_request.is_valid():