aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lcm/ns/views/deprecated/term_ns_view.py2
-rw-r--r--lcm/ns_vnfs/biz/handle_notification.py39
-rw-r--r--lcm/ns_vnfs/biz/subscribe.py5
-rw-r--r--lcm/ns_vnfs/biz/terminate_nfs.py2
-rw-r--r--lcm/pub/config/config.py4
-rw-r--r--lcm/pub/exceptions.py4
-rw-r--r--lcm/pub/msapi/aai.py8
-rw-r--r--lcm/pub/utils/restcall.py6
-rw-r--r--lcm/settings.py4
-rw-r--r--requirements.txt4
10 files changed, 48 insertions, 30 deletions
diff --git a/lcm/ns/views/deprecated/term_ns_view.py b/lcm/ns/views/deprecated/term_ns_view.py
index 6d37f30d..0e3a485f 100644
--- a/lcm/ns/views/deprecated/term_ns_view.py
+++ b/lcm/ns/views/deprecated/term_ns_view.py
@@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import logging
+import time
from drf_yasg.utils import swagger_auto_schema
from rest_framework import status
@@ -47,6 +48,7 @@ class NSTerminateView(APIView):
raise BadRequestException(req_serializer.errors)
job_id = JobUtil.create_job(JOB_TYPE.NS, JOB_ACTION.TERMINATE, ns_instance_id)
+ time.sleep(2)
TerminateNsService(ns_instance_id, job_id, request.data).start()
resp_serializer = _NsOperateJobSerializer(data={'jobId': job_id})
diff --git a/lcm/ns_vnfs/biz/handle_notification.py b/lcm/ns_vnfs/biz/handle_notification.py
index a66946da..4e957d1a 100644
--- a/lcm/ns_vnfs/biz/handle_notification.py
+++ b/lcm/ns_vnfs/biz/handle_notification.py
@@ -16,6 +16,7 @@ import logging
import traceback
import uuid
+
from rest_framework import status
from rest_framework.response import Response
@@ -23,7 +24,7 @@ from lcm.ns_vnfs.enum import INST_TYPE
from lcm.pub.config.config import REPORT_TO_AAI
from lcm.pub.database.models import (CPInstModel, NfInstModel, PortInstModel,
VLInstModel, VmInstModel, VNFCInstModel)
-from lcm.pub.exceptions import NSLCMException
+from lcm.pub.exceptions import NSLCMException, RequestException
from lcm.pub.msapi.aai import (create_network_aai, create_vserver_aai,
delete_network_aai, delete_vserver_aai,
query_network_aai, query_vserver_aai)
@@ -216,12 +217,15 @@ class HandleVnfLcmOocNotification(object):
try:
# query network in aai, get resource_version
customer_info = query_network_aai(vlInstanceId)
- resource_version = customer_info["resource-version"]
-
- # delete network from aai
- resp_data, resp_status = delete_network_aai(vlInstanceId, resource_version)
- logger.debug("Success to delete network[%s] from aai, resp_status: [%s]."
- % (vlInstanceId, resp_status))
+ if customer_info:
+ resource_version = customer_info["resource-version"]
+
+ # delete network from aai
+ resp_data, resp_status = delete_network_aai(vlInstanceId, resource_version)
+ logger.debug("Success to delete network[%s] from aai, resp_status: [%s]."
+ % (vlInstanceId, resp_status))
+ except RequestException:
+ logger.debug("Network has been delted in aai")
except NSLCMException as e:
logger.debug("Fail to delete network[%s] to aai, detail message: %s" % (vlInstanceId, e.args[0]))
except:
@@ -277,15 +281,18 @@ class HandleVnfLcmOocNotification(object):
# query vserver instance in aai, get resource_version
vserver_info = query_vserver_aai(cloud_owner, cloud_region_id, tenant_id, vserver_id)
- resource_version = vserver_info["resource-version"]
-
- # delete vserver instance from aai
- resp_data, resp_status = delete_vserver_aai(cloud_owner, cloud_region_id,
- tenant_id, vserver_id, resource_version)
- logger.debug(
- "Success to delete vserver instance[%s] from aai, resp_status: [%s]." %
- (vserver_id, resp_status))
- logger.debug("delete_vserver_in_aai end!")
+ if vserver_info:
+ resource_version = vserver_info["resource-version"]
+
+ # delete vserver instance from aai
+ resp_data, resp_status = delete_vserver_aai(cloud_owner, cloud_region_id,
+ tenant_id, vserver_id, resource_version)
+ logger.debug(
+ "Success to delete vserver instance[%s] from aai, resp_status: [%s]." %
+ (vserver_id, resp_status))
+ logger.debug("delete_vserver_in_aai end!")
+ except RequestException:
+ logger.debug("Vserver has been deleted from aai")
except NSLCMException as e:
logger.debug("Fail to delete vserver from aai, detail message: %s" % e.args[0])
except:
diff --git a/lcm/ns_vnfs/biz/subscribe.py b/lcm/ns_vnfs/biz/subscribe.py
index 2de67ca7..af375a52 100644
--- a/lcm/ns_vnfs/biz/subscribe.py
+++ b/lcm/ns_vnfs/biz/subscribe.py
@@ -19,7 +19,6 @@ from lcm.pub.database.models import SubscriptionModel
from lcm.pub.exceptions import NSLCMException
from lcm.pub.msapi.extsys import get_vnfm_by_id
from lcm.pub.utils.restcall import req_by_msb
-from lcm.pub.utils.values import ignore_case_get
from lcm.pub.config import config as pub_config
logger = logging.getLogger(__name__)
@@ -43,7 +42,7 @@ class SubscriptionCreation(object):
def prepare_lccn_subscription_request_data(self):
vnfm_info = get_vnfm_by_id(self.vnfm_id)
- call_back = "http://%s:%s/api/gvnfmdriver/v1/vnfs/lifecyclechangesnotification" % (pub_config.MSB_SERVICE_IP, pub_config.MSB_SERVICE_PORT)
+ call_back = "%s/api/gvnfmdriver/v1/vnfs/lifecyclechangesnotification" % pub_config.MSB_BASE_URL
self.subscription_request_data = {
"filter": {
"notificationTypes": ["VnfLcmOperationOccurrenceNotification"],
@@ -130,7 +129,7 @@ class SubscriptionDeletion(object):
def send_subscription_deletion_request(self):
if self.subscription:
- self.subscription_id = ignore_case_get(self.subscription.__dict__, 'id')
+ self.subscription_id = self.subscription.subscription_id
ret = req_by_msb('api/gvnfmdriver/v1/%s/subscriptions/%s' % (self.vnfm_id, self.subscription_id), 'DELETE')
if ret[0] != 0:
logger.error('Status code is %s, detail is %s.', ret[2], ret[1])
diff --git a/lcm/ns_vnfs/biz/terminate_nfs.py b/lcm/ns_vnfs/biz/terminate_nfs.py
index 1dec71d2..0205535b 100644
--- a/lcm/ns_vnfs/biz/terminate_nfs.py
+++ b/lcm/ns_vnfs/biz/terminate_nfs.py
@@ -140,7 +140,7 @@ class TerminateVnfs(threading.Thread):
def delete_subscription(self):
try:
- SubscriptionDeletion(self.vnfm_inst_id, self.vnf_inst_id).do_biz()
+ SubscriptionDeletion(self.vnfm_inst_id, self.vnf_uuid).do_biz()
except Exception as e:
logger.error("delete_subscription failed: %s", e.args[0])
diff --git a/lcm/pub/config/config.py b/lcm/pub/config/config.py
index a02d4bac..f97f1c00 100644
--- a/lcm/pub/config/config.py
+++ b/lcm/pub/config/config.py
@@ -14,8 +14,8 @@
# [MSB]
MSB_SERVICE_IP = '10.0.14.1'
-MSB_SERVICE_PORT = '80'
-MSB_BASE_URL = "http://%s:%s" % (MSB_SERVICE_IP, MSB_SERVICE_PORT)
+MSB_SERVICE_PORT = '30283'
+MSB_BASE_URL = "https://%s:%s" % (MSB_SERVICE_IP, MSB_SERVICE_PORT)
# [REDIS]
REDIS_HOST = '127.0.0.1'
diff --git a/lcm/pub/exceptions.py b/lcm/pub/exceptions.py
index 798a8abb..9b71f2bf 100644
--- a/lcm/pub/exceptions.py
+++ b/lcm/pub/exceptions.py
@@ -26,6 +26,10 @@ class BadRequestException(BaseException):
pass
+class RequestException(BaseException):
+ pass
+
+
class NSLCMException(BaseException):
pass
diff --git a/lcm/pub/msapi/aai.py b/lcm/pub/msapi/aai.py
index 7c814487..e6fe545f 100644
--- a/lcm/pub/msapi/aai.py
+++ b/lcm/pub/msapi/aai.py
@@ -17,7 +17,7 @@ import logging
import uuid
from lcm.pub.config.config import AAI_BASE_URL, AAI_USER, AAI_PASSWD
-from lcm.pub.exceptions import NSLCMException
+from lcm.pub.exceptions import NSLCMException, RequestException
from lcm.pub.utils import restcall
@@ -230,6 +230,9 @@ def delete_vserver_aai(cloud_owner, cloud_region_id, tenant_id, vserver_id, reso
if ret[0] != 0:
logger.error("Status code is %s, detail is %s.", ret[2], ret[1])
raise NSLCMException("Vserver delete exception in AAI")
+ if ret[2] == 404:
+ logger.error("Vserver has been deleted in aai")
+ raise RequestException("Vserver delete exception in AAI")
return json.JSONDecoder().decode(ret[1]) if ret[1] else ret[1], ret[2]
@@ -283,6 +286,9 @@ def delete_network_aai(network_id, resource_version=""):
if ret[0] != 0:
logger.error("Status code is %s, detail is %s.", ret[2], ret[1])
raise NSLCMException("Network delete exception in AAI")
+ if ret[2] == 404:
+ logger.error("Network has been deleted in aai")
+ raise RequestException("Network delete exception in AAI")
return json.JSONDecoder().decode(ret[1]) if ret[1] else ret[1], ret[2]
diff --git a/lcm/pub/utils/restcall.py b/lcm/pub/utils/restcall.py
index 9fd81601..b2f14e3c 100644
--- a/lcm/pub/utils/restcall.py
+++ b/lcm/pub/utils/restcall.py
@@ -23,7 +23,7 @@ import uuid
import httplib2
import requests
-from lcm.pub.config.config import MSB_SERVICE_IP, MSB_SERVICE_PORT
+from lcm.pub.config.config import MSB_BASE_URL
rest_no_auth, rest_oneway_auth, rest_bothway_auth = 0, 1, 2
HTTP_200_OK, HTTP_201_CREATED, HTTP_204_NO_CONTENT, HTTP_202_ACCEPTED = '200', '201', '204', '202'
@@ -90,13 +90,13 @@ def call_req(base_url, user, passwd, auth_type, resource, method, content='', ad
def req_by_msb(resource, method, content=''):
logger.debug("resource: %s, method: %s, content: %s" % (resource, method, content))
- base_url = "http://%s:%s/" % (MSB_SERVICE_IP, MSB_SERVICE_PORT)
+ base_url = MSB_BASE_URL
return call_req(base_url, "", "", rest_no_auth, resource, method, content)
def upload_by_msb(resource, method, file_data):
headers = {'accept': 'application/json'}
- full_url = "http://%s:%s/%s" % (MSB_SERVICE_IP, MSB_SERVICE_PORT, resource)
+ full_url = "%s/%s" % (MSB_BASE_URL, resource)
r = requests.post(full_url, files=file_data, headers=headers)
resp_status, resp_body = str(r.status_code), r.text
if resp_status not in status_ok_list:
diff --git a/lcm/settings.py b/lcm/settings.py
index 18a5932c..08006c4d 100644
--- a/lcm/settings.py
+++ b/lcm/settings.py
@@ -133,8 +133,8 @@ TIME_ZONE = 'UTC'
STATIC_URL = '/static/'
-pub_config.AAI_BASE_URL = "http://%s:%s/aai/v11" % (pub_config.MSB_SERVICE_IP, pub_config.MSB_SERVICE_PORT)
-pub_config.SDC_BASE_URL = "http://%s:%s/api" % (pub_config.MSB_SERVICE_IP, pub_config.MSB_SERVICE_PORT)
+pub_config.AAI_BASE_URL = "%s/aai/v11" % pub_config.MSB_BASE_URL
+pub_config.SDC_BASE_URL = "%s/api" % pub_config.MSB_BASE_URL
if platform.system() == 'Windows' or 'test' in sys.argv:
LOGGING = {
diff --git a/requirements.txt b/requirements.txt
index 2986c3e7..505116c2 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,6 +1,6 @@
# rest framework
Django==2.1.10
-djangorestframework==3.9.4
+djangorestframework==3.10.0
# for access MySQL
PyMySQL==0.9.3
@@ -27,7 +27,7 @@ unittest_xml_reporting==1.12.0
# for swagger
ruamel.yaml==0.15.97
-drf-yasg==1.14.0
+drf-yasg==1.17.0
# for the validation feature
flex>=6.11.1