diff options
author | ying.yunlong <ying.yunlong@zte.com.cn> | 2017-09-18 18:35:29 +0800 |
---|---|---|
committer | ying.yunlong <ying.yunlong@zte.com.cn> | 2017-09-18 18:35:29 +0800 |
commit | 2e6d9184a2ef7cda6150e7a92e98803f8c4bb888 (patch) | |
tree | b046140f8d01053fd0af76cb11626ae2ca1f3181 | |
parent | c360b0588017d6f20af9c5f3dea6742da84badc9 (diff) |
Fix some bugs in vfc lcm
Change-Id: Ia6ebf71fa790507263b19c8312f66362552799ff
Issue-ID: VFC-374
Signed-off-by: ying.yunlong <ying.yunlong@zte.com.cn>
-rw-r--r-- | lcm/ns/ns_create.py | 4 | ||||
-rw-r--r-- | lcm/ns/ns_delete.py | 4 | ||||
-rw-r--r-- | lcm/ns/tests/test_ns_instant.py | 6 | ||||
-rw-r--r-- | lcm/ns/tests/vls/tests.py | 71 | ||||
-rw-r--r-- | lcm/ns/vnfs/create_vnfs.py | 6 | ||||
-rw-r--r-- | lcm/ns/vnfs/terminate_nfs.py | 4 | ||||
-rw-r--r-- | lcm/pub/config/config.py | 1 |
7 files changed, 53 insertions, 43 deletions
diff --git a/lcm/ns/ns_create.py b/lcm/ns/ns_create.py index a80bf8d5..620427f3 100644 --- a/lcm/ns/ns_create.py +++ b/lcm/ns/ns_create.py @@ -14,6 +14,7 @@ import logging import uuid +from lcm.pub.config.config import REPORT_TO_AAI from lcm.pub.database.models import NSDModel, NSInstModel from lcm.pub.exceptions import NSLCMException from lcm.pub.msapi.aai import create_customer_aai @@ -34,7 +35,8 @@ class CreateNSService(object): self.check_nsd_valid() self.check_ns_inst_name_exist() self.create_ns_inst() - self.create_ns_in_aai() + if REPORT_TO_AAI: + self.create_ns_in_aai() logger.debug("CreateNSService::do_biz::ns_inst_id=%s" % self.ns_inst_id) return self.ns_inst_id diff --git a/lcm/ns/ns_delete.py b/lcm/ns/ns_delete.py index 7d51df46..0883cf2a 100644 --- a/lcm/ns/ns_delete.py +++ b/lcm/ns/ns_delete.py @@ -16,6 +16,7 @@ import logging import traceback +from lcm.pub.config.config import REPORT_TO_AAI from lcm.pub.database.models import DefPkgMappingModel, InputParamMappingModel, ServiceBaseInfoModel from lcm.pub.database.models import NSInstModel from lcm.pub.msapi.aai import get_customer_aai, delete_customer_aai @@ -31,7 +32,8 @@ class DeleteNsService(object): def do_biz(self): try: self.delete_ns() - self.delete_ns_in_aai() + if REPORT_TO_AAI: + self.delete_ns_in_aai() except: logger.error(traceback.format_exc()) diff --git a/lcm/ns/tests/test_ns_instant.py b/lcm/ns/tests/test_ns_instant.py index 77fb7f38..955284ce 100644 --- a/lcm/ns/tests/test_ns_instant.py +++ b/lcm/ns/tests/test_ns_instant.py @@ -60,6 +60,6 @@ class TestNsInstant(TestCase): self.assertEqual(resp.status_code, status.HTTP_200_OK) """ - # def test_swagger_ok(self): - # resp = self.client.get("/api/nslcm/v1/swagger.json", format='json') - # self.assertEqual(resp.status_code, status.HTTP_200_OK) + def test_swagger_ok(self): + resp = self.client.get("/api/nslcm/v1/swagger.json", format='json') + self.assertEqual(resp.status_code, status.HTTP_200_OK) diff --git a/lcm/ns/tests/vls/tests.py b/lcm/ns/tests/vls/tests.py index 5895c936..366fcef7 100644 --- a/lcm/ns/tests/vls/tests.py +++ b/lcm/ns/tests/vls/tests.py @@ -23,42 +23,43 @@ from lcm.pub.database.models import VLInstModel, NSInstModel, VNFFGInstModel from lcm.pub.nfvi.vim import vimadaptor from lcm.pub.utils import restcall -vim_info = {"cloud-owner": "example-cloud-owner-val-97336", - "cloud-region-id": "example-cloud-region-id-val-35532", - "cloud-type": "example-cloud-type-val-18046", - "owner-defined-type": "example-owner-defined-type-val-9413", - "cloud-region-version": "example-cloud-region-version-val-85706", - "identity-url": "example-identity-url-val-71252", - "cloud-zone": "example-cloud-zone-val-27112", - "complex-name": "example-complex-name-val-85283", - "sriov-automation": True, - "cloud-extra-info": "example-cloud-extra-info-val-90854", - "cloud-epa-caps": "example-cloud-epa-caps-val-2409", - "resource-version": "example-resource-version-val-42094", - "esr-system-info-list": { - "esr-system-info": [ - { - "esr-system-info-id": "example-esr-system-info-id-val-7713", - "system-name": "example-system-name-val-19801", - "type": "example-type-val-24477", - "vendor": "example-vendor-val-50079", - "version": "example-version-val-93146", - "service-url": "example-service-url-val-68090", - "user-name": "example-user-name-val-14470", - "password": "example-password-val-84190", - "system-type": "example-system-type-val-42773", - "protocal": "example-protocal-val-85736", - "ssl-cacert": "example-ssl-cacert-val-33989", - "ssl-insecure": True, - "ip-address": "example-ip-address-val-99038", - "port": "example-port-val-27323", - "cloud-domain": "example-cloud-domain-val-55163", - "default-tenant": "admin", - "resource-version": "example-resource-version-val-15424" - } - ] - } +vim_info = { + "cloud-owner": "example-cloud-owner-val-97336", + "cloud-region-id": "example-cloud-region-id-val-35532", + "cloud-type": "example-cloud-type-val-18046", + "owner-defined-type": "example-owner-defined-type-val-9413", + "cloud-region-version": "example-cloud-region-version-val-85706", + "identity-url": "example-identity-url-val-71252", + "cloud-zone": "example-cloud-zone-val-27112", + "complex-name": "example-complex-name-val-85283", + "sriov-automation": True, + "cloud-extra-info": "example-cloud-extra-info-val-90854", + "cloud-epa-caps": "example-cloud-epa-caps-val-2409", + "resource-version": "example-resource-version-val-42094", + "esr-system-info-list": { + "esr-system-info": [ + { + "esr-system-info-id": "example-esr-system-info-id-val-7713", + "system-name": "example-system-name-val-19801", + "type": "example-type-val-24477", + "vendor": "example-vendor-val-50079", + "version": "example-version-val-93146", + "service-url": "example-service-url-val-68090", + "user-name": "example-user-name-val-14470", + "password": "example-password-val-84190", + "system-type": "example-system-type-val-42773", + "protocal": "example-protocal-val-85736", + "ssl-cacert": "example-ssl-cacert-val-33989", + "ssl-insecure": True, + "ip-address": "example-ip-address-val-99038", + "port": "example-port-val-27323", + "cloud-domain": "example-cloud-domain-val-55163", + "default-tenant": "admin", + "resource-version": "example-resource-version-val-15424" } + ] + } +} class TestVlViews(TestCase): def setUp(self): diff --git a/lcm/ns/vnfs/create_vnfs.py b/lcm/ns/vnfs/create_vnfs.py index b170d73f..6850ba07 100644 --- a/lcm/ns/vnfs/create_vnfs.py +++ b/lcm/ns/vnfs/create_vnfs.py @@ -20,6 +20,7 @@ from lcm.ns.const import OWNER_TYPE from lcm.ns.vnfs.const import VNF_STATUS, NFVO_VNF_INST_TIMEOUT_SECOND, INST_TYPE, INST_TYPE_NAME from lcm.ns.vnfs.wait_job import wait_job_finish +from lcm.pub.config.config import REPORT_TO_AAI from lcm.pub.database.models import NfPackageModel, NfInstModel, NSInstModel, VmInstModel, VNFFGInstModel, VLInstModel from lcm.pub.exceptions import NSLCMException from lcm.pub.msapi.aai import create_vnf_aai, create_vserver_aai @@ -76,8 +77,9 @@ class CreateVnfs(Thread): self.wait_vnfm_job_finish() self.write_vnf_creation_info() self.save_info_to_db() - self.create_vnf_in_aai() - self.create_vserver_in_aai() + if REPORT_TO_AAI: + self.create_vnf_in_aai() + self.create_vserver_in_aai() except NSLCMException as e: self.vnf_inst_failed_handle(e.message) except Exception: diff --git a/lcm/ns/vnfs/terminate_nfs.py b/lcm/ns/vnfs/terminate_nfs.py index 9bc0cbbd..fe4ebdf0 100644 --- a/lcm/ns/vnfs/terminate_nfs.py +++ b/lcm/ns/vnfs/terminate_nfs.py @@ -18,6 +18,7 @@ import json import threading from lcm.ns.vnfs.wait_job import wait_job_finish +from lcm.pub.config.config import REPORT_TO_AAI from lcm.pub.database.models import NfInstModel from lcm.ns.vnfs.const import VNF_STATUS, NFVO_VNF_INST_TIMEOUT_SECOND from lcm.pub.msapi.aai import query_vnf_aai, delete_vnf_aai @@ -49,7 +50,8 @@ class TerminateVnfs(threading.Thread): self.wait_vnfm_job_finish() self.send_terminate_vnf_to_resMgr() self.delete_data_from_db() - self.delete_vnf_in_aai() + if REPORT_TO_AAI: + self.delete_vnf_in_aai() except NSLCMException as e: self.exception(e.message) except Exception: diff --git a/lcm/pub/config/config.py b/lcm/pub/config/config.py index 278e8a09..fdde894a 100644 --- a/lcm/pub/config/config.py +++ b/lcm/pub/config/config.py @@ -60,6 +60,7 @@ CATALOG_URL_PATH = None AAI_BASE_URL = "https://127.0.0.1:8443/aai/v11" AAI_USER = "AAI" AAI_PASSWD = "AAI" +REPORT_TO_AAI = False # [sdc config] SDC_BASE_URL = "https://127.0.0.1:8443/api/sdc/v1" |