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"
raise EngineException("You cannot delete role '{}'".format(role["name"]), http_code=HTTPStatus.FORBIDDEN)
# If any user is using this role, raise CONFLICT exception
- for user in self.auth.get_user_list():
- for prm in user.get("project_role_mappings"):
- if prm["role"] == _id:
- raise EngineException("Role '{}' ({}) is being used by user '{}'"
- .format(role["name"], _id, user["username"]), HTTPStatus.CONFLICT)
+ if not session["force"]:
+ for user in self.auth.get_user_list():
+ for prm in user.get("project_role_mappings"):
+ if prm["role"] == _id:
+ raise EngineException("Role '{}' ({}) is being used by user '{}'"
+ .format(role["name"], _id, user["username"]), HTTPStatus.CONFLICT)
@staticmethod
def format_on_new(content, project_id=None, make_public=False): # TO BE REMOVED ?