Ns descriptor related stuffs. 65/61965/1
authorlaili <lai.li@zte.com.cn>
Thu, 23 Aug 2018 05:06:01 +0000 (13:06 +0800)
committerlaili <lai.li@zte.com.cn>
Thu, 23 Aug 2018 05:06:15 +0000 (13:06 +0800)
Add a field in NSPackege model.
Add a PnfPackage model.

Change-Id: I09872d9bdf5650530d8405a1e9e0b6b8e94b1504
Issue-ID: VFC-1037
Signed-off-by: laili <lai.li@zte.com.cn>
catalog/packages/tests/test_pnfd.py [deleted file]
catalog/pub/database/models.py

diff --git a/catalog/packages/tests/test_pnfd.py b/catalog/packages/tests/test_pnfd.py
deleted file mode 100644 (file)
index 35e7720..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-# Copyright 2017 ZTE Corporation.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# 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.
-
-import os
-
-from django.test import TestCase
-from rest_framework import status
-from rest_framework.test import APIClient
-
-
-class TestPnfDescriptor(TestCase):
-    def setUp(self):
-        self.client = APIClient()
-
-    def tearDown(self):
-        pass
-
-    def test_pnfd_create_normal(self):
-        reqest_data = {
-            'userDefinedData': {
-                'key1': 'value1',
-                'key2': 'value2',
-                'key3': 'value3',
-            }
-        }
-        expected_reponse_data = {
-            'pnfdOnboardingState': 'CREATED',
-            'pnfdUsageState': 'NOT_IN_USE',
-            'userDefinedData': {
-                'key1': 'value1',
-                'key2': 'value2',
-                'key3': 'value3',
-            },
-            '_links': None
-        }
-        response = self.client.post(
-            '/api/nsd/v1/pnf_descriptors',
-            data=reqest_data,
-            format='json'
-        )
-        response.data.pop('id')
-        self.assertEqual(response.status_code, status.HTTP_201_CREATED)
-        self.assertEqual(expected_reponse_data, response.data)
-
-    def test_pnfd_content_upload_normal(self):
-        with open('pnfd_content.txt', 'wb') as fp:
-            fp.write('test')
-
-        with open('pnfd_content.txt', 'rb') as fp:
-            resp = self.client.put(
-                "/api/nsd/v1/pnf_descriptors/22/pnfd_content",
-                {'file': fp},
-            )
-        self.assertEqual(resp.status_code, status.HTTP_204_NO_CONTENT)
-        self.assertEqual({}, resp.data)
-
-        os.remove('pnfd_content.txt')
-
-    def test_pnfd_content_upload_failure(self):
-        pass
index 3ae7d70..3b9e909 100644 (file)
@@ -60,6 +60,28 @@ class VnfPackageModel(models.Model):
         db_table = 'CATALOG_VNFPACKAGE'
 
 
+class PnfPackageModel(models.Model):
+    # uuid = models.CharField(db_column='UUID', primary_key=True, max_length=255)
+    pnfPackageId = models.CharField(db_column='PNFPACKAGEID', primary_key=True, max_length=50)   # onboardedPnfPkgInfoId
+    pnfPackageUri = models.CharField(db_column='PNFPACKAGEURI', max_length=300, null=True, blank=True)  # downloadUri
+    SdcCSARUri = models.CharField(db_column='SDCCSARURI', max_length=300, null=True, blank=True)  # SdcCSARUri
+    checksum = models.CharField(db_column='CHECKSUM', max_length=50, null=True, blank=True)  # checksum
+    onboardingState = models.CharField(db_column='ONBOARDINGSTATE', max_length=20, blank=True, null=True)
+    usageState = models.CharField(db_column='USAGESTATE', max_length=20, blank=True, null=True)  # usageState
+    deletionPending = models.CharField(db_column='DELETIONPENDING', max_length=20, blank=True, null=True)  # deletionPending
+    pnfdId = models.CharField(db_column='PNFDID', max_length=50, blank=True, null=True)                # pnfdId
+    pnfVendor = models.CharField(db_column='VENDOR', max_length=50, blank=True, null=True)  # pnfProvider
+    pnfdProductName = models.CharField(db_column='PNFDPRODUCTNAME', max_length=50, blank=True, null=True)  # pnfProductName
+    pnfdVersion = models.CharField(db_column='PNFDVERSION', max_length=20, blank=True, null=True)     # pnfdVersion
+    pnfSoftwareVersion = models.CharField(db_column='PNFSOFTWAREVERSION', max_length=20, blank=True, null=True)   # pnfSoftwareVersion
+    userDefinedData = models.TextField(db_column='USERDEFINEDDATA', max_length=1024, blank=True, null=True)  # userDefinedData
+    localFilePath = models.CharField(db_column='LOCALFILEPATH', max_length=300, null=True, blank=True)
+    pnfdModel = models.TextField(db_column='PNFDMODEL', max_length=65535, blank=True, null=True)  # pnfd
+
+    class Meta:
+        db_table = 'CATALOG_PNFPACKAGE'
+
+
 class SoftwareImageModel(models.Model):
     imageid = models.CharField(db_column='IMAGEID', primary_key=True, max_length=50)
     containerFormat = models.CharField(db_column='CONTAINERFORMAT', max_length=20)