From: tierno Date: Tue, 17 Dec 2019 16:46:12 +0000 (+0000) Subject: Change for SDN creation parameters X-Git-Tag: v7.0.1rc1~4 X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FNBI.git;a=commitdiff_plain;h=7adaeb0a49340e8f46e82b6526bce4d6ecefd80e Change for SDN creation parameters Change-Id: I5d0fcf0153c9ad71e0757db45df073f3abf26603 Signed-off-by: tierno --- diff --git a/osm_nbi/admin_topics.py b/osm_nbi/admin_topics.py index 670629e..7a7ace6 100644 --- a/osm_nbi/admin_topics.py +++ b/osm_nbi/admin_topics.py @@ -404,6 +404,25 @@ class SdnTopic(CommonVimWimSdn): password_to_encrypt = "password" config_to_encrypt = {} + def _obtain_url(self, input, create): + if input.get("ip") or input.get("port"): + if not input.get("ip") or not input.get("port") or input.get('url'): + raise ValidationError("You must provide both 'ip' and 'port' (deprecated); or just 'url' (prefered)") + input['url'] = "http://{}:{}/".format(input["ip"], input["port"]) + del input["ip"] + del input["port"] + elif create and not input.get('url'): + raise ValidationError("You must provide 'url'") + return input + + def _validate_input_new(self, input, force=False): + input = super()._validate_input_new(input, force) + return self._obtain_url(input, True) + + def _validate_input_edit(self, input, force=False): + input = super()._validate_input_edit(input, force) + return self._obtain_url(input, False) + class K8sClusterTopic(CommonVimWimSdn): topic = "k8sclusters" diff --git a/osm_nbi/validation.py b/osm_nbi/validation.py index 69caff7..c4f6fb7 100644 --- a/osm_nbi/validation.py +++ b/osm_nbi/validation.py @@ -480,21 +480,24 @@ wim_account_new_schema = { sdn_properties = { "name": name_schema, + "type": {"type": "string"}, + "url": {"type": "string"}, + "user": shortname_schema, + "password": passwd_schema, + "config": {"type": "object"}, "description": description_schema, + # The folowing are deprecated. Maintanied for backward compatibility "dpid": dpid_Schema, "ip": ip_schema, "port": port_schema, - "type": {"type": "string", "enum": ["opendaylight", "floodlight", "onos"]}, "version": {"type": "string", "minLength": 1, "maxLength": 12}, - "user": shortname_schema, - "password": passwd_schema } sdn_new_schema = { "title": "sdn controller information schema", "$schema": "http://json-schema.org/draft-04/schema#", "type": "object", "properties": sdn_properties, - "required": ["name", "port", 'ip', 'dpid', 'type'], + "required": ["name", 'type'], "additionalProperties": False } sdn_edit_schema = {