from time import time
from osm_common.dbbase import deep_update_rfc7396
from osm_nbi.validation import validate_input, ValidationError, is_valid_uuid
+from yaml import safe_load, YAMLError
__author__ = "Alfonso Tierno <alfonso.tiernosepulveda@telefonica.com>"
pass
@staticmethod
- def _update_input_with_kwargs(desc, kwargs):
+ def _update_input_with_kwargs(desc, kwargs, yaml_format=False):
"""
Update descriptor with the kwargs. It contains dot separated keys
:param desc: dictionary to be updated
:param kwargs: plain dictionary to be used for updating.
+ :param yaml_format: get kwargs values as yaml format.
:return: None, 'desc' is modified. It raises EngineException.
"""
if not kwargs:
else:
raise EngineException(
"Invalid query string '{}'. Descriptor is not a list nor dict at '{}'".format(k, kitem))
- update_content[kitem_old] = v
+ update_content[kitem_old] = v if not yaml_format else safe_load(v)
except KeyError:
raise EngineException(
"Invalid query string '{}'. Descriptor does not contain '{}'".format(k, kitem_old))
except IndexError:
raise EngineException(
"Invalid query string '{}'. Index '{}' out of range".format(k, kitem_old))
+ except YAMLError:
+ raise EngineException("Invalid query string '{}' yaml format".format(k))
def show(self, session, _id):
"""
from http import HTTPStatus
from time import time
from copy import copy, deepcopy
-from osm_nbi.validation import validate_input, ValidationError, ns_instantiate, ns_action, ns_scale, nsi_instantiate
+from osm_nbi.validation import validate_input, ValidationError, ns_instantiate, ns_terminate, ns_action, ns_scale,\
+ nsi_instantiate
from osm_nbi.base_topic import BaseTopic, EngineException, get_iterable, deep_get
# from descriptor_topics import DescriptorTopic
from yaml import safe_dump
"instantiate": ns_instantiate,
"action": ns_action,
"scale": ns_scale,
- "terminate": None,
+ "terminate": ns_terminate,
}
def __init__(self, db, fs, msg, auth):
try:
# Override descriptor with query string kwargs
- self._update_input_with_kwargs(indata, kwargs)
+ self._update_input_with_kwargs(indata, kwargs, yaml_format=True)
operation = indata["lcmOperationType"]
nsInstanceId = indata["nsInstanceId"]
"nsInstanceId": _id,
"autoremove": True
}
- opp_id, _ = self.engine.new_item(rollback, engine_session, "nslcmops", nslcmop_desc, None)
+ opp_id, _ = self.engine.new_item(rollback, engine_session, "nslcmops", nslcmop_desc, kwargs)
if opp_id:
delete_in_process = True
outdata = {"_id": opp_id}
"additionalProperties": False
}
+ns_terminate = {
+ "title": "ns terminate input schema",
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "type": "object",
+ "properties": {
+ "lcmOperationType": string_schema,
+ "nsInstanceId": id_schema,
+ "autoremove": bool_schema,
+ "timeout_ns_terminate": integer1_schema,
+ "skip_terminate_primitives": bool_schema,
+ },
+ "additionalProperties": False
+}
+
ns_action = { # TODO for the moment it is only contemplated the vnfd primitive execution
"title": "ns action input schema",
"$schema": "http://json-schema.org/draft-04/schema#",