summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlaili <lai.li@zte.com.cn>2018-08-09 21:24:21 +0800
committerlaili <lai.li@zte.com.cn>2018-08-10 08:55:38 +0800
commit6249f6864d9c5a3711d48b432810f2accf41f56a (patch)
tree139c9aa57b399fcf076d13119df2dd247dd95854
parente5509db55fa65d01e3b02cf957487e28846dbfdc (diff)
Modify vnf query related stuffs in vnflcm.
Add instantiationState and set vnfState to STARTED in query.py. Make relevant changes in test_query_vnf.py and vnf_instance.py. Change-Id: I069f1334ecd63a7a51aab56ec870c1e1ac5fe543 Issue-ID: VFC-1016 Signed-off-by: laili <lai.li@zte.com.cn>
-rw-r--r--lcm/lcm/nf/biz/query_vnf.py3
-rw-r--r--lcm/lcm/nf/serializers/vnf_instance.py6
-rw-r--r--lcm/lcm/nf/tests/test_query_vnf.py14
3 files changed, 14 insertions, 9 deletions
diff --git a/lcm/lcm/nf/biz/query_vnf.py b/lcm/lcm/nf/biz/query_vnf.py
index f3b2997e..bd4a1e3a 100644
--- a/lcm/lcm/nf/biz/query_vnf.py
+++ b/lcm/lcm/nf/biz/query_vnf.py
@@ -99,9 +99,10 @@ class QueryVnf:
"vnfPkgId": vnf.package_id,
"vnfdVersion": vnf.version,
"vnfProvider": vnf.vendor,
+ "instantiationState": vnf.status,
"instantiatedVnfInfo": {
"flavourId": vnf.flavour_id,
- "vnfState": vnf.status,
+ "vnfState": "STARTED",
"scaleStatus": [],
"extCpInfo": [],
"extVirtualLinkInfo": [],
diff --git a/lcm/lcm/nf/serializers/vnf_instance.py b/lcm/lcm/nf/serializers/vnf_instance.py
index bd453629..c7ff8890 100644
--- a/lcm/lcm/nf/serializers/vnf_instance.py
+++ b/lcm/lcm/nf/serializers/vnf_instance.py
@@ -95,9 +95,9 @@ class VnfInstanceSerializer(serializers.Serializer):
instantiationState = serializers.ChoiceField(
help_text="The instantiation state of the VNF.",
choices=["NOT_INSTANTIATED", "INSTANTIATED"],
- required=False,
- allow_null=True,
- allow_blank=True)
+ required=True,
+ allow_null=False,
+ allow_blank=False)
instantiatedVnfInfo = InstantiatedVnfInfoSerializer(
help_text="Information specific to an instantiated VNF instance. \
This attribute shall be present if the instantiateState attribute value is INSTANTIATED",
diff --git a/lcm/lcm/nf/tests/test_query_vnf.py b/lcm/lcm/nf/tests/test_query_vnf.py
index e092223b..ccb40c05 100644
--- a/lcm/lcm/nf/tests/test_query_vnf.py
+++ b/lcm/lcm/nf/tests/test_query_vnf.py
@@ -27,8 +27,9 @@ class ResourceTest(TestCase):
"id": "1",
"vnfInstanceName": "VNF1",
"vnfProvider": None,
+ "instantiationState": "INSTANTIATED",
"instantiatedVnfInfo": {
- "vnfState": None,
+ "vnfState": "STARTED",
"extCpInfo": [],
"virtualStorageResourceInfo": [
{
@@ -54,8 +55,9 @@ class ResourceTest(TestCase):
"id": "1",
"vnfInstanceName": "VNF1",
"vnfProvider": None,
+ "instantiationState": "INSTANTIATED",
"instantiatedVnfInfo": {
- "vnfState": None,
+ "vnfState": "STARTED",
"extCpInfo": [],
"virtualStorageResourceInfo": [
{
@@ -80,8 +82,9 @@ class ResourceTest(TestCase):
"id": "2",
"vnfInstanceName": "VNF2",
"vnfProvider": None,
+ "instantiationState": "INSTANTIATED",
"instantiatedVnfInfo": {
- "vnfState": None,
+ "vnfState": "STARTED",
"extCpInfo": [],
"virtualStorageResourceInfo": [
{
@@ -109,7 +112,7 @@ class ResourceTest(TestCase):
def test_get_vnf(self):
vnf_inst_id = "1"
- NfInstModel(nfinstid=vnf_inst_id, nf_name='VNF1').save()
+ NfInstModel(nfinstid=vnf_inst_id, nf_name='VNF1', status='INSTANTIATED').save()
StorageInstModel(storageid='s02',
vimid='vim01',
resouceid='resource01',
@@ -122,7 +125,8 @@ class ResourceTest(TestCase):
def test_get_vnfs(self):
for i in range(1, 3):
NfInstModel(nfinstid='%s' % i,
- nf_name='VNF%s' % i).save()
+ nf_name='VNF%s' % i,
+ status='INSTANTIATED').save()
StorageInstModel(storageid='s0%s' % i,
vimid='vim0%s' % i,
resouceid='resource0%s' % i,