- terminate_primitives = config_descriptor.get("terminate-config-primitive")
- vdu_id = vca_deployed.get("vdu_id")
- vdu_count_index = vca_deployed.get("vdu_count_index")
- vdu_name = vca_deployed.get("vdu_name")
- vnf_index = vca_deployed.get("member-vnf-index")
- if terminate_primitives and vca_deployed.get("needed_terminate"):
- # Get all 'seq' tags in seq_list, order sequences numerically, ascending.
- terminate_primitives = sorted(terminate_primitives, key=lambda x: int(x['seq']))
- for seq in terminate_primitives:
- # For each sequence in list, get primitive and call _ns_execute_primitive()
- step = "Calling terminate action for vnf_member_index={} primitive={}".format(
- vnf_index, seq.get("name"))
- self.logger.debug(logging_text + step)
- # Create the primitive for each sequence, i.e. "primitive": "touch"
- primitive = seq.get('name')
- mapped_primitive_params = self._get_terminate_primitive_params(seq, vnf_index)
- # The following 3 parameters are currently set to None for 'terminate':
- # vdu_id, vdu_count_index, vdu_name
-
- # Add sub-operation
- self._add_suboperation(db_nslcmop,
- vnf_index,
- vdu_id,
- vdu_count_index,
- vdu_name,
- primitive,
- mapped_primitive_params)
- # Sub-operations: Call _ns_execute_primitive() instead of action()
- try:
- result, result_detail = await self._ns_execute_primitive(vca_deployed["ee_id"], primitive,
- mapped_primitive_params)
- except LcmException:
- # this happens when VCA is not deployed. In this case it is not needed to terminate
- continue
- result_ok = ['COMPLETED', 'PARTIALLY_COMPLETED']
- if result not in result_ok:
- raise LcmException("terminate_primitive {} for vnf_member_index={} fails with "
- "error {}".format(seq.get("name"), vnf_index, result_detail))
- # set that this VCA do not need terminated
- db_update_entry = "_admin.deployed.VCA.{}.needed_terminate".format(vca_index)
- self.update_db_2("nsrs", db_nslcmop["nsInstanceId"], {db_update_entry: False})
+ if exec_primitives:
+ terminate_primitives = config_descriptor.get("terminate-config-primitive")
+ vdu_id = vca_deployed.get("vdu_id")
+ vdu_count_index = vca_deployed.get("vdu_count_index")
+ vdu_name = vca_deployed.get("vdu_name")
+ vnf_index = vca_deployed.get("member-vnf-index")
+ if terminate_primitives and vca_deployed.get("needed_terminate"):
+ # Get all 'seq' tags in seq_list, order sequences numerically, ascending.
+ terminate_primitives = sorted(terminate_primitives, key=lambda x: int(x['seq']))
+ for seq in terminate_primitives:
+ # For each sequence in list, get primitive and call _ns_execute_primitive()
+ step = "Calling terminate action for vnf_member_index={} primitive={}".format(
+ vnf_index, seq.get("name"))
+ self.logger.debug(logging_text + step)
+ # Create the primitive for each sequence, i.e. "primitive": "touch"
+ primitive = seq.get('name')
+ mapped_primitive_params = self._get_terminate_primitive_params(seq, vnf_index)
+ # The following 3 parameters are currently set to None for 'terminate':
+ # vdu_id, vdu_count_index, vdu_name
+
+ # Add sub-operation
+ self._add_suboperation(db_nslcmop,
+ vnf_index,
+ vdu_id,
+ vdu_count_index,
+ vdu_name,
+ primitive,
+ mapped_primitive_params)
+ # Sub-operations: Call _ns_execute_primitive() instead of action()
+ try:
+ result, result_detail = await self._ns_execute_primitive(vca_deployed["ee_id"], primitive,
+ mapped_primitive_params,
+ vca_type=vca_type)
+ except LcmException:
+ # this happens when VCA is not deployed. In this case it is not needed to terminate
+ continue
+ result_ok = ['COMPLETED', 'PARTIALLY_COMPLETED']
+ if result not in result_ok:
+ raise LcmException("terminate_primitive {} for vnf_member_index={} fails with "
+ "error {}".format(seq.get("name"), vnf_index, result_detail))
+ # set that this VCA do not need terminated
+ db_update_entry = "_admin.deployed.VCA.{}.needed_terminate".format(vca_index)
+ self.update_db_2("nsrs", db_nslcmop["nsInstanceId"], {db_update_entry: False})