summaryrefslogtreecommitdiffstats
path: root/lcm/lcm/nf/biz/terminate_vnf.py
diff options
context:
space:
mode:
Diffstat (limited to 'lcm/lcm/nf/biz/terminate_vnf.py')
-rw-r--r--lcm/lcm/nf/biz/terminate_vnf.py22
1 files changed, 13 insertions, 9 deletions
diff --git a/lcm/lcm/nf/biz/terminate_vnf.py b/lcm/lcm/nf/biz/terminate_vnf.py
index d63cdfa9..4f74f62d 100644
--- a/lcm/lcm/nf/biz/terminate_vnf.py
+++ b/lcm/lcm/nf/biz/terminate_vnf.py
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-import json
+# import json
import logging
import traceback
from threading import Thread
@@ -24,12 +24,15 @@ from lcm.pub.database.models import (
FlavourInstModel, SubNetworkInstModel
)
from lcm.pub.exceptions import NFLCMException
-from lcm.pub.msapi.gvnfmdriver import prepare_notification_data, notify_lcm_to_nfvo
+from lcm.pub.msapi.gvnfmdriver import prepare_notification_data
+# from lcm.pub.msapi.gvnfmdriver import notify_lcm_to_nfvo
from lcm.pub.utils.jobutil import JobUtil
from lcm.pub.utils.timeutil import now_time
+from lcm.pub.utils.notificationsutil import NotificationsUtil
from lcm.pub.utils.values import ignore_case_get
from lcm.pub.vimapi import adaptor
from lcm.nf.biz.grant_vnf import grant_resource
+from lcm.nf.const import CHANGE_TYPE, GRANT_TYPE, OPERATION_TYPE
logger = logging.getLogger(__name__)
@@ -43,7 +46,7 @@ class TerminateVnf(Thread):
self.terminationType = ignore_case_get(self.data, "terminationType")
self.gracefulTerminationTimeout = ignore_case_get(self.data, "gracefulTerminationTimeout")
self.inst_resource = {'volumn': [], 'network': [], 'subnet': [], 'port': [], 'flavor': [], 'vm': []}
- self.grant_type = "Terminate"
+ self.grant_type = GRANT_TYPE.TERMINATE
def run(self):
try:
@@ -83,7 +86,7 @@ class TerminateVnf(Thread):
resource_table = globals().get(resource_type + 'InstModel')
resource_insts = resource_table.objects.filter(instid=self.nf_inst_id)
for resource_inst in resource_insts:
- if not resource_inst.resouceid:
+ if not resource_inst.resourceid:
continue
self.inst_resource[RESOURCE_MAP.get(resource_type)].append(self.get_resource(resource_inst))
logger.info('Query resource end, resource=%s' % self.inst_resource)
@@ -92,12 +95,12 @@ class TerminateVnf(Thread):
return {
"vim_id": resource.vimid,
"tenant_id": resource.tenant,
- "res_id": resource.resouceid,
+ "res_id": resource.resourceid,
"is_predefined": resource.is_predefined
}
def query_notify_data(self):
- self.notify_data = prepare_notification_data(self.nf_inst_id, self.job_id, "RMOVED")
+ self.notify_data = prepare_notification_data(self.nf_inst_id, self.job_id, CHANGE_TYPE.REMOVED, OPERATION_TYPE.TERMINATE)
NetworkInstModel.objects.filter(instid=self.nf_inst_id)
StorageInstModel.objects.filter(instid=self.nf_inst_id)
PortInstModel.objects.filter(instid=self.nf_inst_id)
@@ -114,13 +117,14 @@ class TerminateVnf(Thread):
logger.error('Deleting [%s] resource, resourceid [%s]' % (res_type, res_id))
resource_type = RESOURCE_MAP.keys()[RESOURCE_MAP.values().index(res_type)]
resource_table = globals().get(resource_type + 'InstModel')
- resource_table.objects.filter(instid=self.nf_inst_id, resouceid=res_id).delete()
+ resource_table.objects.filter(instid=self.nf_inst_id, resourceid=res_id).delete()
def lcm_notify(self):
NfInstModel.objects.filter(nfinstid=self.nf_inst_id).update(status='NOT_INSTANTIATED', lastuptime=now_time())
logger.info('Send notify request to nfvo')
- resp = notify_lcm_to_nfvo(json.dumps(self.notify_data))
- logger.info('Lcm notify end, response: %s' % resp)
+ # resp = notify_lcm_to_nfvo(json.dumps(self.notify_data))
+ # logger.info('Lcm notify end, response: %s' % resp)
+ NotificationsUtil().send_notification(self.notify_data)
def vnf_term_failed_handle(self, error_msg):
logger.error('VNF termination failed, detail message: %s' % error_msg)