X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FNBI.git;a=blobdiff_plain;f=osm_nbi%2Fadmin_topics.py;h=7a7ace668854a26b155dcfdb431a0b185ec9ee50;hp=670629eb68f844ed507240b82a65271fe5fd9e93;hb=675b804e93d2e616c81f1746532cefe226e6b752;hpb=bee3bad8d15fe0893855d0dff92cef4351629edb 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"