# 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 traceback
def run(self):
try:
- self.term_pre()
- self.grant_resource()
- self.query_inst_resource()
- self.query_notify_data()
- self.delete_resource()
- self.lcm_notify()
+ if self.term_pre():
+ self.grant_resource()
+ self.query_inst_resource()
+ self.query_notify_data()
+ self.delete_resource()
+ self.lcm_notify()
JobUtil.add_job_status(self.job_id, 100, "Terminate Vnf success.")
except NFLCMException as e:
self.vnf_term_failed_handle(e.message)
def term_pre(self):
vnf_insts = NfInstModel.objects.filter(nfinstid=self.nf_inst_id)
if not vnf_insts.exists():
- raise NFLCMException('VnfInst(%s) does not exist' % self.nf_inst_id)
- sel_vnf = vnf_insts[0]
- #if sel_vnf.status != 'VNF_INSTANTIATED':
+ logger.warn('VnfInst(%s) does not exist' % self.nf_inst_id)
+ return False
+ # raise NFLCMException('VnfInst(%s) does not exist' % self.nf_inst_id)
+ # sel_vnf = vnf_insts[0]
+ # if sel_vnf.status != 'VNF_INSTANTIATED':
# raise NFLCMException("Don't allow to terminate vnf(status:[%s])" % sel_vnf.status)
if self.terminationType == 'GRACEFUL' and not self.gracefulTerminationTimeout:
- raise NFLCMException("Graceful termination must set timeout")
+ logger.warn("Set Graceful default termination timeout = 60")
+ self.gracefulTerminationTimeout = 60
+ # raise NFLCMException("Graceful termination must set timeout")
NfInstModel.objects.filter(nfinstid=self.nf_inst_id).update(status=VNF_STATUS.TERMINATING)
JobUtil.add_job_status(self.job_id, 10, 'Nf terminating pre-check finish')
logger.info("Nf terminating pre-check finish")
+ return True
def grant_resource(self):
logger.info("nf_cancel_task grant_resource begin")
'affectedVnfc': affected_vnfc,
'affectedVirtualLink': affected_vl,
'affectedVirtualStorage': affected_vs,
- 'affectedCp': affected_cp
- }
+ 'affectedCp': affected_cp}
+
vnfmInfo = NfvoRegInfoModel.objects.filter(nfvoid=self.nf_inst_id)
if len(vnfmInfo) == 0:
raise NFLCMException('nf_inst_id(%s) does not exist in NfvoRegInfoModel' % self.nf_inst_id)
def lcm_notify(self):
NfInstModel.objects.filter(nfinstid=self.nf_inst_id).update(status='NOT_INSTANTIATED', lastuptime=now_time())
logger.info('[NF termination] send notify request to nfvo end')
- resp = notify_lcm_to_nfvo(self.notify_data)
+ resp = notify_lcm_to_nfvo(json.dumps(self.notify_data))
logger.info('[NF termination] get lcm response %s' % resp)
logger.info('[NF termination] send notify request to nfvo end')