summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlaili <lai.li@zte.com.cn>2018-08-23 13:06:01 +0800
committerlaili <lai.li@zte.com.cn>2018-08-23 13:06:15 +0800
commit4b5f56a96b559f9da7ffd9d409dcdbfe9389e899 (patch)
treefe8a1e3ca860b1e64e431a5465c654c5f4f31a2e
parentd544a5d35e1a09a4f9aa61f0a9c23efa7fd2b4d0 (diff)
Ns descriptor related stuffs.
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>
-rw-r--r--catalog/packages/tests/test_pnfd.py71
-rw-r--r--catalog/pub/database/models.py22
2 files changed, 22 insertions, 71 deletions
diff --git a/catalog/packages/tests/test_pnfd.py b/catalog/packages/tests/test_pnfd.py
deleted file mode 100644
index 35e7720f..00000000
--- a/catalog/packages/tests/test_pnfd.py
+++ /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
diff --git a/catalog/pub/database/models.py b/catalog/pub/database/models.py
index 3ae7d702..3b9e909a 100644
--- a/catalog/pub/database/models.py
+++ b/catalog/pub/database/models.py
@@ -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)