Remove unused code of vnflcm 35/27335/1
authorying.yunlong <ying.yunlong@zte.com.cn>
Thu, 4 Jan 2018 06:59:42 +0000 (14:59 +0800)
committerying.yunlong <ying.yunlong@zte.com.cn>
Thu, 4 Jan 2018 06:59:42 +0000 (14:59 +0800)
Change-Id: Ie331deee73e8d59d9a8e3387b64abca2b49f5ae0
Issue-ID: VFC-630
Signed-off-by: ying.yunlong <ying.yunlong@zte.com.cn>
lcm/lcm/nf/vnfs/vnf_cancel/delete_vnf_identifier.py
lcm/lcm/nf/vnfs/vnf_create/create_vnf_identifier.py
lcm/lcm/pub/config/config.py
lcm/lcm/pub/msapi/aai.py [deleted file]

index 128ba35..65dc677 100644 (file)
 
 import logging
 
-from lcm.pub.config.config import REPORT_TO_AAI
 from lcm.pub.database.models import NfInstModel, NfvoRegInfoModel
 from lcm.pub.exceptions import NFLCMException
-from lcm.pub.msapi.aai import query_vnf_aai, delete_vnf_aai
 
 logger = logging.getLogger(__name__)
 
@@ -30,8 +28,6 @@ class DeleteVnf:
     def do_biz(self):
         try:
             self.check_parameter()
-            if REPORT_TO_AAI:
-                self.delete_vnf_in_aai()
             self.delete_info_from_db()
         except NFLCMException as e:
             logger.debug('Delete VNF instance[%s] failed: %s', self.nf_inst_id, e.message)
@@ -50,18 +46,3 @@ class DeleteVnf:
     def delete_info_from_db(self):
         NfInstModel.objects.filter(nfinstid=self.nf_inst_id).delete()
         NfvoRegInfoModel.objects.filter(nfvoid=self.nf_inst_id).delete()
-
-    def delete_vnf_in_aai(self):
-        logger.debug("DeleteVnf::delete_vnf_in_aai::delete vnf instance[%s] in aai." % self.nf_inst_id)
-
-        # query vnf instance in aai, get resource_version
-        customer_info = query_vnf_aai(self.nf_inst_id)
-        resource_version = customer_info["resource-version"]
-
-        # delete vnf instance from aai
-        resp_data, resp_status = delete_vnf_aai(self.nf_inst_id, resource_version)
-        if resp_data:
-            logger.debug("Fail to delete vnf instance[%s] from aai, resp_status: [%s]." % (self.nf_inst_id, resp_status))
-        else:
-            logger.debug(
-                "Success to delete vnf instance[%s] from aai, resp_status: [%s]." % (self.nf_inst_id, resp_status))
index 9b4231b..c1113e1 100644 (file)
@@ -16,10 +16,8 @@ import json
 import logging
 import uuid
 
-from lcm.pub.config.config import REPORT_TO_AAI
 from lcm.pub.database.models import NfInstModel
 from lcm.pub.exceptions import NFLCMException
-from lcm.pub.msapi.aai import create_vnf_aai
 from lcm.pub.msapi.catalog import query_rawdata_from_catalog
 from lcm.pub.msapi.gvnfmdriver import get_packageinfo_by_vnfdid
 from lcm.pub.utils import toscautil
@@ -46,8 +44,6 @@ class CreateVnf:
             self.check_vnf_name_valid()
             self.get_vnfd_info()
             self.save_info_to_db()
-            if REPORT_TO_AAI:
-                self.create_vnf_in_aai()
         except NFLCMException as e:
             logger.debug('Create VNF instance[%s] to AAI failed: %s', self.nf_inst_id, e.message)
         except:
@@ -109,18 +105,3 @@ class CreateVnf:
                                    vnfdid=self.vnfd_id,
                                    vnfSoftwareVersion=vnfsoftwareversion,
                                    create_time=now_time())
-
-    def create_vnf_in_aai(self):
-        logger.debug("CreateVnf::create_vnf_in_aai::report vnf instance[%s] to aai." % self.nf_inst_id)
-        data = {
-            "vnf-id": self.nf_inst_id,
-            "vnf-name": self.vnf_instance_mame,
-            "vnf-type": "INFRA",
-            "in-maint": True,
-            "is-closed-loop-disabled": False
-        }
-        resp_data, resp_status = create_vnf_aai(self.nf_inst_id, data)
-        if resp_data:
-            logger.debug("Fail to create vnf instance[%s] to aai, resp_status: [%s]." % (self.nf_inst_id, resp_status))
-        else:
-            logger.debug("Success to create vnf instance[%s] to aai, resp_status: [%s]." % (self.nf_inst_id, resp_status))
index 5dadd9f..bbc79eb 100644 (file)
 MSB_SERVICE_IP = '127.0.0.1'
 MSB_SERVICE_PORT = '80'
 
-# [AAI]
-AAI_BASE_URL = "https://127.0.0.1:8443/aai/v11"
-AAI_USER = "AAI"
-AAI_PASSWORD = "AAI"
-REPORT_TO_AAI = False
-
 # [REDIS]
 REDIS_HOST = '127.0.0.1'
 REDIS_PORT = '6379'
diff --git a/lcm/lcm/pub/msapi/aai.py b/lcm/lcm/pub/msapi/aai.py
deleted file mode 100644 (file)
index 77127e0..0000000
+++ /dev/null
@@ -1,246 +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 json
-import logging
-import uuid
-
-from lcm.pub.config.config import AAI_BASE_URL, AAI_USER, AAI_PASSWORD
-from lcm.pub.exceptions import NFLCMException
-from lcm.pub.utils import restcall
-
-logger = logging.getLogger(__name__)
-
-
-def call_aai(resource, method, data=''):
-    additional_headers = {
-        'X-FromAppId': 'VFC-GVNFM-VNFLCM',
-        'X-TransactionId': str(uuid.uuid1())
-    }
-    return restcall.call_req(AAI_BASE_URL,
-                             AAI_USER,
-                             AAI_PASSWORD,
-                             restcall.rest_no_auth,
-                             resource,
-                             method,
-                             data,
-                             additional_headers)
-
-
-def create_customer_aai(global_customer_id, data):
-    resource = "/business/customers/customer/%s" % global_customer_id
-    ret = call_aai(resource, "PUT", data)
-    if ret[0] != 0:
-        logger.error("Status code is %s, detail is %s.", ret[2], ret[1])
-        raise NFLCMException("Customer creation exception in AAI")
-    return json.JSONDecoder().decode(ret[1]), ret[2]
-
-
-def query_customer_aai(global_customer_id):
-    resource = "/business/customers/customer/%s?depth=all" % global_customer_id
-    ret = call_aai(resource, "GET")
-    if ret[0] != 0:
-        logger.error("Status code is %s, detail is %s.", ret[2], ret[1])
-        raise NFLCMException("Get customer info exception in AAI")
-    return json.JSONDecoder().decode(ret[1]), ret[2]
-
-
-def delete_customer_aai(global_customer_id, resource_version=""):
-    resource = "/business/customers/customer/%s" % global_customer_id
-    if resource_version:
-        resource = resource + "?resource-version=%s" % resource_version
-    ret = call_aai(resource, "DELETE")
-    if ret[0] != 0:
-        logger.error("Status code is %s, detail is %s.", ret[2], ret[1])
-        raise NFLCMException("Customer delete exception in AAI")
-    return json.JSONDecoder().decode(ret[1]), ret[2]
-
-
-def put_customer_relationship(global_customer_id, data):
-    resource = "/business/customers/customer/{global-customer-id}/relationship-list/relationship" % global_customer_id
-    ret = call_aai(resource, "PUT", data)
-    if ret[0] != 0:
-        logger.error("Status code is %s, detail is %s.", ret[2], ret[1])
-        raise NFLCMException("Put or update customer relationship exception in AAI")
-    return json.JSONDecoder().decode(ret[1]), ret[2]
-
-
-def delete_customer_relationship(global_customer_id):
-    resource = "/business/customers/customer/{global-customer-id}/relationship-list/relationship" % global_customer_id
-    ret = call_aai(resource, "DELETE")
-    if ret[0] != 0:
-        logger.error("Status code is %s, detail is %s.", ret[2], ret[1])
-        raise NFLCMException("Delete customer relationship exception in AAI")
-    return json.JSONDecoder().decode(ret[1]), ret[2]
-
-
-def create_ns_aai(global_customer_id, service_type, service_instance_id, data):
-    resource = "/business/customers/customer/%s/service-subscriptions/service-subscription/" \
-               "%s/service-instances/service-instance/%s" % \
-               (global_customer_id, service_type, service_instance_id)
-    ret = call_aai(resource, "PUT", data)
-    if ret[0] != 0:
-        logger.error("Status code is %s, detail is %s.", ret[2], ret[1])
-        raise NFLCMException("Ns instance creation exception in AAI")
-    return json.JSONDecoder().decode(ret[1]), ret[2]
-
-
-def query_ns_aai(global_customer_id, service_type, service_instance_id):
-    resource = "/business/customers/customer/%s/service-subscriptions/service-subscription/" \
-               "%s/service-instances/service-instance/%s?depth=all" % \
-               (global_customer_id, service_type, service_instance_id)
-    ret = call_aai(resource, "GET")
-    if ret[0] != 0:
-        logger.error("Status code is %s, detail is %s.", ret[2], ret[1])
-        raise NFLCMException("Ns instance query exception in AAI")
-    return json.JSONDecoder().decode(ret[1])
-
-
-def delete_ns_aai(global_customer_id, service_type, service_instance_id, resource_version=""):
-    resource = "/business/customers/customer/%s/service-subscriptions/service-subscription/" \
-               "%s/service-instances/service-instance/%s" % \
-               (global_customer_id, service_type, service_instance_id)
-    if resource_version:
-        resource = resource + "?resource-version=%s" % resource_version
-    ret = call_aai(resource, "DELETE")
-    if ret[0] != 0:
-        logger.error("Status code is %s, detail is %s.", ret[2], ret[1])
-        raise NFLCMException("Ns instance delete exception in AAI")
-    return json.JSONDecoder().decode(ret[1]), ret[2]
-
-
-def put_ns_relationship(global_customer_id, service_type, service_instance_id, data):
-    resource = "/business/customers/customer/%s/service-subscriptions/service-subscription/" \
-               "%s/service-instances/service-instance/%s/relationship-list/relationship" % \
-               (global_customer_id, service_type, service_instance_id)
-    ret = call_aai(resource, "PUT", data)
-    if ret[0] != 0:
-        logger.error("Status code is %s, detail is %s.", ret[2], ret[1])
-        raise NFLCMException("Put or update ns instance relationship exception in AAI")
-    return json.JSONDecoder().decode(ret[1]), ret[2]
-
-
-def delete_ns_relationship(global_customer_id, service_type, service_instance_id):
-    resource = "/business/customers/customer/%s/service-subscriptions/service-subscription/" \
-               "%s/service-instances/service-instance/%s/relationship-list/relationship" % \
-               (global_customer_id, service_type, service_instance_id)
-    ret = call_aai(resource, "DELETE")
-    if ret[0] != 0:
-        logger.error("Status code is %s, detail is %s.", ret[2], ret[1])
-        raise NFLCMException("Delete ns instance relationship exception in AAI")
-    return json.JSONDecoder().decode(ret[1]), ret[2]
-
-
-def create_vnf_aai(vnf_id, data):
-    resource = "/network/generic-vnfs/generic-vnf/%s" % vnf_id
-    ret = call_aai(resource, "PUT", data)
-    if ret[0] != 0:
-        logger.error("Status code is %s, detail is %s.", ret[2], ret[1])
-        raise NFLCMException("Vnf instance creation exception in AAI")
-    return json.JSONDecoder().decode(ret[1]), ret[2]
-
-
-def query_vnf_aai(vnf_id):
-    resource = "/network/generic-vnfs/generic-vnf/%s?depth=all" % vnf_id
-    ret = call_aai(resource, "GET")
-    if ret[0] != 0:
-        logger.error("Status code is %s, detail is %s.", ret[2], ret[1])
-        raise NFLCMException("Vnf instance query exception in AAI")
-    return json.JSONDecoder().decode(ret[1])
-
-
-def delete_vnf_aai(vnf_id, resource_version=""):
-    resource = "/network/generic-vnfs/generic-vnf/%s" % vnf_id
-    if resource_version:
-        resource = resource + "?resource-version=%s" % resource_version
-    ret = call_aai(resource, "DELETE")
-    if ret[0] != 0:
-        logger.error("Status code is %s, detail is %s.", ret[2], ret[1])
-        raise NFLCMException("Vnf instance delete exception in AAI")
-    return json.JSONDecoder().decode(ret[1]), ret[2]
-
-
-def put_vnf_relationship(vnf_id, data):
-    resource = "/network/generic-vnfs/generic-vnf/%s/relationship-list/relationship" % vnf_id
-    ret = call_aai(resource, "PUT", data)
-    if ret[0] != 0:
-        logger.error("Status code is %s, detail is %s.", ret[2], ret[1])
-        raise NFLCMException("Put or update vnf instance relationship exception in AAI")
-    return json.JSONDecoder().decode(ret[1]), ret[2]
-
-
-def delete_vnf_relationship(vnf_id):
-    resource = "/network/generic-vnfs/generic-vnf/%s/relationship-list/relationship" % vnf_id
-    ret = call_aai(resource, "DELETE")
-    if ret[0] != 0:
-        logger.error("Status code is %s, detail is %s.", ret[2], ret[1])
-        raise NFLCMException("Delete vnf instance relationship exception in AAI")
-    return json.JSONDecoder().decode(ret[1]), ret[2]
-
-
-def create_vserver_aai(cloud_owner, cloud_region_id, tenant_id, vserver_id, data):
-    resource = "/cloud-infrastructure/cloud-regions/cloud-region/%s/" \
-               "%s/tenants/tenant/%s/vservers/vserver/%s" % \
-               (cloud_owner, cloud_region_id, tenant_id, vserver_id)
-    ret = call_aai(resource, "PUT", data)
-    if ret[0] != 0:
-        logger.error("Status code is %s, detail is %s.", ret[2], ret[1])
-        raise NFLCMException("Vserver creation exception in AAI")
-    return json.JSONDecoder().decode(ret[1]), ret[2]
-
-
-def query_vserver_aai(cloud_owner, cloud_region_id, tenant_id, vserver_id):
-    resource = "/cloud-infrastructure/cloud-regions/cloud-region/%s/" \
-               "%s/tenants/tenant/%s/vservers/vserver/%s?depth=all" % \
-               (cloud_owner, cloud_region_id, tenant_id, vserver_id)
-    ret = call_aai(resource, "GET")
-    if ret[0] != 0:
-        logger.error("Status code is %s, detail is %s.", ret[2], ret[1])
-        raise NFLCMException("Vserver query exception in AAI")
-    return json.JSONDecoder().decode(ret[1])
-
-
-def delete_vserver_aai(cloud_owner, cloud_region_id, tenant_id, vserver_id, resource_version=""):
-    resource = "/cloud-infrastructure/cloud-regions/cloud-region/%s/" \
-               "%s/tenants/tenant/%s/vservers/vserver/%s" % \
-               (cloud_owner, cloud_region_id, tenant_id, vserver_id)
-    if resource_version:
-        resource = resource + "?resource-version=%s" % resource_version
-    ret = call_aai(resource, "DELETE")
-    if ret[0] != 0:
-        logger.error("Status code is %s, detail is %s.", ret[2], ret[1])
-        raise NFLCMException("Vserver delete exception in AAI")
-    return json.JSONDecoder().decode(ret[1]), ret[2]
-
-
-def put_vserver_relationship(cloud_owner, cloud_region_id, tenant_id, vserver_id, data):
-    resource = "/cloud-infrastructure/cloud-regions/cloud-region/%s/" \
-               "%s/tenants/tenant/%s/vservers/vserver/%s/relationship-list/relationship" % \
-               (cloud_owner, cloud_region_id, tenant_id, vserver_id)
-    ret = call_aai(resource, "PUT", data)
-    if ret[0] != 0:
-        logger.error("Status code is %s, detail is %s.", ret[2], ret[1])
-        raise NFLCMException("Put or update vserver relationship exception in AAI")
-    return json.JSONDecoder().decode(ret[1]), ret[2]
-
-
-def delete_vserver_relationship(cloud_owner, cloud_region_id, tenant_id, vserver_id):
-    resource = "/cloud-infrastructure/cloud-regions/cloud-region/%s/" \
-               "%s/tenants/tenant/%s/vservers/vserver/%s/relationship-list/relationship" % \
-               (cloud_owner, cloud_region_id, tenant_id, vserver_id)
-    ret = call_aai(resource, "DELETE")
-    if ret[0] != 0:
-        logger.error("Status code is %s, detail is %s.", ret[2], ret[1])
-        raise NFLCMException("Delete vserver relationship exception in AAI")
-    return json.JSONDecoder().decode(ret[1]), ret[2]