summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-x[-rw-r--r--]docker/docker-env-conf.sh0
-rw-r--r--lcm/ns/biz/ns_get.py16
-rw-r--r--lcm/ns/biz/ns_heal.py50
-rw-r--r--lcm/ns/biz/query_subscription.py3
-rw-r--r--lcm/ns/tests/test_query_subscriptions.py3
-rw-r--r--lcm/settings.py1
-rwxr-xr-xrun.sh2
7 files changed, 39 insertions, 36 deletions
diff --git a/docker/docker-env-conf.sh b/docker/docker-env-conf.sh
index 8cb20001..8cb20001 100644..100755
--- a/docker/docker-env-conf.sh
+++ b/docker/docker-env-conf.sh
diff --git a/lcm/ns/biz/ns_get.py b/lcm/ns/biz/ns_get.py
index 1839bf0e..697d7c42 100644
--- a/lcm/ns/biz/ns_get.py
+++ b/lcm/ns/biz/ns_get.py
@@ -17,8 +17,12 @@ import logging
from lcm.ns.const import NS_INSTANCE_BASE_URI
from lcm.ns.enum import OWNER_TYPE
-from lcm.pub.utils import restcall
-from lcm.pub.database.models import NSInstModel, NfInstModel, VLInstModel, CPInstModel, VNFFGInstModel
+from lcm.pub.database.models import NSInstModel
+from lcm.pub.database.models import NfInstModel
+from lcm.pub.database.models import VLInstModel
+from lcm.pub.database.models import CPInstModel
+from lcm.pub.database.models import VNFFGInstModel
+from lcm.pub.database.models import PNFInstModel
logger = logging.getLogger(__name__)
@@ -167,9 +171,5 @@ class GetNSInfoService(object):
@staticmethod
def get_pnf_infos(ns_instance_id):
- uri = "api/nslcm/v1/pnfs?nsInstanceId=%s" % ns_instance_id
- ret = restcall.req_by_msb(uri, "GET")
- if ret[0] == 0:
- return json.loads(ret[1])
- else:
- return []
+ pnfs = PNFInstModel.objects.filter(nsInstances__contains=ns_instance_id)
+ return [pnf.__dict__ for pnf in pnfs]
diff --git a/lcm/ns/biz/ns_heal.py b/lcm/ns/biz/ns_heal.py
index 20db7722..096561e0 100644
--- a/lcm/ns/biz/ns_heal.py
+++ b/lcm/ns/biz/ns_heal.py
@@ -63,20 +63,22 @@ class NSHealService(threading.Thread):
def get_and_check_params(self):
ns_info = NSInstModel.objects.filter(id=self.ns_instance_id)
if not ns_info:
- logger.error('NS [id=%s] does not exist' % self.ns_instance_id)
- raise NSLCMException(
- 'NS [id=%s] does not exist' % self.ns_instance_id)
+ errmsg = 'NS [id=%s] does not exist' % self.ns_instance_id
+ logger.error(errmsg)
+ raise NSLCMException(errmsg)
+
self.heal_ns_data = ignore_case_get(self.request_data, 'healNsData')
self.heal_vnf_data = ignore_case_get(self.request_data, 'healVnfData')
+
if self.heal_ns_data and self.heal_vnf_data:
- logger.error('healNsData and healVnfData can not exist together')
- raise NSLCMException(
- 'healNsData and healVnfData can not exist together')
+ errmsg = 'healNsData and healVnfData can not exist together'
+ logger.error(errmsg)
+ raise NSLCMException(errmsg)
+
if not self.heal_ns_data and not self.heal_vnf_data:
- logger.error(
- 'healNsData and healVnfData parameters does not exist or value is incorrect.')
- raise NSLCMException(
- 'healNsData and healVnfData parameters does not exist or value is incorrect.')
+ errmsg = 'healNsData and healVnfData parameters does not exist or value is incorrect.'
+ logger.error(errmsg)
+ raise NSLCMException(errmsg)
def do_heal(self):
if self.heal_vnf_data:
@@ -86,8 +88,9 @@ class NSHealService(threading.Thread):
logger.info('nf[%s] heal handle end' % vnf_heal_params.get('vnfInstanceId'))
self.update_job(90, desc='nf[%s] heal handle end' % vnf_heal_params.get('vnfInstanceId'))
else:
- logger.error('nf heal failed')
- raise NSLCMException('nf heal failed')
+ errmsg = 'nf heal failed'
+ logger.error(errmsg)
+ raise NSLCMException(errmsg)
else:
ns_heal_params = self.prepare_ns_heal_params(self.heal_ns_data)
for ns_heal_param in ns_heal_params:
@@ -96,8 +99,9 @@ class NSHealService(threading.Thread):
logger.info('nf[%s] heal handle end' % ns_heal_param.get('vnfInstanceId'))
self.update_job(90, desc='nf[%s] heal handle end' % ns_heal_param.get('vnfInstanceId'))
else:
- logger.error('nf heal failed')
- raise NSLCMException('nf heal failed')
+ errmsg = 'nf heal failed'
+ logger.error(errmsg)
+ raise NSLCMException(errmsg)
def do_vnf_or_ns_heal(self, heal_param, progress):
instance_id = heal_param.get('vnfInstanceId')
@@ -111,8 +115,9 @@ class NSHealService(threading.Thread):
def prepare_ns_heal_params(self, ns_data):
degree_healing = ignore_case_get(ns_data, 'degreeHealing')
if not degree_healing:
- logger.error('degreeHealing does not exist.')
- raise NSLCMException('degreeHealing does not exist.')
+ errmsg = 'degreeHealing does not exist.'
+ logger.error(errmsg)
+ raise NSLCMException(errmsg)
ns_instance_id = self.ns_instance_id
cause = 'vm is down'
# action = ignore_case_get(ns_data, 'actionsHealing')
@@ -149,17 +154,16 @@ class NSHealService(threading.Thread):
result_arr.append(result)
return result_arr
else:
- logger.error(
- 'The degree of healing dose not exist or value is incorrect.')
- raise NSLCMException(
- 'The degree of healing dose not exist or value is incorrect.')
+ errmsg = 'The degree of healing dose not exist or value is incorrect.'
+ logger.error(errmsg)
+ raise NSLCMException(errmsg)
def prepare_vnf_heal_params(self, vnf_data):
vnf_instance_id = ignore_case_get(vnf_data, 'vnfInstanceId')
if not vnf_instance_id:
- logger.error('vnfinstanceid does not exist or value is incorrect.')
- raise NSLCMException(
- 'vnfinstanceid does not exist or value is incorrect.')
+ errmsg = 'vnfinstanceid does not exist or value is incorrect.'
+ logger.error(errmsg)
+ raise NSLCMException(errmsg)
cause = ignore_case_get(vnf_data, 'cause')
additional_params = ignore_case_get(vnf_data, 'additionalParams')
action = ignore_case_get(additional_params, 'action')
diff --git a/lcm/ns/biz/query_subscription.py b/lcm/ns/biz/query_subscription.py
index 4b36aa78..237c87a9 100644
--- a/lcm/ns/biz/query_subscription.py
+++ b/lcm/ns/biz/query_subscription.py
@@ -17,7 +17,6 @@ import json
import logging
from lcm.pub.database.models import SubscriptionModel
-from lcm.pub.exceptions import NSLCMException
logger = logging.getLogger(__name__)
ROOT_FILTERS = {
@@ -55,8 +54,6 @@ class QuerySubscription:
subscriptions = SubscriptionModel.objects.filter(**query_data)
else:
subscriptions = SubscriptionModel.objects.all()
- if not subscriptions.exists():
- raise NSLCMException('Subscriptions do not exist')
return [self.fill_resp_data(subscription) for subscription in subscriptions]
def fill_resp_data(self, subscription):
diff --git a/lcm/ns/tests/test_query_subscriptions.py b/lcm/ns/tests/test_query_subscriptions.py
index 04759ee8..c797a07e 100644
--- a/lcm/ns/tests/test_query_subscriptions.py
+++ b/lcm/ns/tests/test_query_subscriptions.py
@@ -115,7 +115,8 @@ class TestQuerySubscriptions(TestCase):
links=json.dumps(links),
ns_instance_filter=json.dumps(ns_instance_filter)).save()
response = self.client.get("/api/nslcm/v1/subscriptions?nsInstanceId=dummy", format='json')
- self.assertEqual(response.status_code, status.HTTP_500_INTERNAL_SERVER_ERROR)
+ self.assertEqual(response.status_code, status.HTTP_200_OK)
+ self.assertEqual([], response.data)
def test_get_subscriptions_with_invalid_filter(self):
ns_instance_filter = {
diff --git a/lcm/settings.py b/lcm/settings.py
index f20f363a..71e609b4 100644
--- a/lcm/settings.py
+++ b/lcm/settings.py
@@ -173,6 +173,7 @@ else:
if 'test' in sys.argv:
pub_config.REG_TO_MSB_WHEN_START = False
pub_config.DEPLOY_WORKFLOW_WHEN_START = False
+ pub_config.REPORT_TO_AAI = False
DATABASES = {}
DATABASES['default'] = {
'ENGINE': 'django.db.backends.sqlite3',
diff --git a/run.sh b/run.sh
index 8053d09c..dccfd2ee 100755
--- a/run.sh
+++ b/run.sh
@@ -21,7 +21,7 @@ fi
# nohup python manage.py runserver 0.0.0.0:8403 > /dev/null &
#nohup uwsgi --http :8403 -t 120 --module lcm.wsgi --master --processes 4 &
-if [ ${SSL_ENABLED} = "true" ]; then
+if [ "${SSL_ENABLED}" = "true" ]; then
nohup uwsgi --https :8403,lcm/pub/ssl/cert/foobar.crt,lcm/pub/ssl/cert/foobar.key, HIGH -t 120 --module lcm.wsgi --master --processes 4 &
else
nohup uwsgi --http :8403 -t 120 --module lcm.wsgi --master --processes 4 &