X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FNBI.git;a=blobdiff_plain;f=osm_nbi%2Fadmin_topics.py;h=e887afb3bb310762c5b5c74b7177236b0f352cac;hp=71dfa3c1110f8cbde18e76071012dbb54c813484;hb=refs%2Fchanges%2F12%2F8112%2F3;hpb=029405dc71e09d30e7660fa68f799737d017acbf diff --git a/osm_nbi/admin_topics.py b/osm_nbi/admin_topics.py index 71dfa3c..e887afb 100644 --- a/osm_nbi/admin_topics.py +++ b/osm_nbi/admin_topics.py @@ -21,6 +21,7 @@ from time import time from osm_nbi.validation import user_new_schema, user_edit_schema, project_new_schema, project_edit_schema, \ vim_account_new_schema, vim_account_edit_schema, sdn_new_schema, sdn_edit_schema, \ wim_account_new_schema, wim_account_edit_schema, roles_new_schema, roles_edit_schema, \ + k8scluster_new_schema, k8scluster_edit_schema, k8srepo_new_schema, k8srepo_edit_schema, \ validate_input, ValidationError, is_valid_uuid # To check that User/Project Names don't look like UUIDs from osm_nbi.base_topic import BaseTopic, EngineException from osm_nbi.authconn import AuthconnNotFoundException, AuthconnConflictException @@ -247,6 +248,7 @@ class CommonVimWimSdn(BaseTopic): :param edit_content: user requested update content :return: operation id """ + super().format_on_edit(final_content, edit_content) # encrypt passwords schema_version = final_content.get("schema_version") @@ -387,6 +389,40 @@ class SdnTopic(CommonVimWimSdn): config_to_encrypt = {} +class K8sClusterTopic(CommonVimWimSdn): + topic = "k8sclusters" + topic_msg = "k8scluster" + schema_new = k8scluster_new_schema + schema_edit = k8scluster_edit_schema + multiproject = True + password_to_encrypt = None + config_to_encrypt = {} + + def format_on_new(self, content, project_id=None, make_public=False): + oid = super().format_on_new(content, project_id, make_public) + self.db.encrypt_decrypt_fields(content["credentials"], 'encrypt', ['password', 'secret'], + schema_version=content["schema_version"], salt=content["_id"]) + return oid + + def format_on_edit(self, final_content, edit_content): + if final_content.get("schema_version") and edit_content.get("credentials"): + self.db.encrypt_decrypt_fields(edit_content["credentials"], 'encrypt', ['password', 'secret'], + schema_version=final_content["schema_version"], salt=final_content["_id"]) + deep_update_rfc7396(final_content["credentials"], edit_content["credentials"]) + oid = super().format_on_edit(final_content, edit_content) + return oid + + +class K8sRepoTopic(CommonVimWimSdn): + topic = "k8srepos" + topic_msg = "k8srepo" + schema_new = k8srepo_new_schema + schema_edit = k8srepo_edit_schema + multiproject = True + password_to_encrypt = None + config_to_encrypt = {} + + class UserTopicAuth(UserTopic): # topic = "users" # topic_msg = "users" @@ -530,7 +566,7 @@ class UserTopicAuth(UserTopic): rollback.append({"topic": self.topic, "_id": _id}) # del content["password"] - # self._send_msg("create", content) + # self._send_msg("created", content) return _id, None except ValidationError as e: raise EngineException(e, HTTPStatus.UNPROCESSABLE_ENTITY) @@ -814,7 +850,7 @@ class ProjectTopicAuth(ProjectTopic): self.format_on_new(content, project_id=session["project_id"], make_public=session["public"]) _id = self.auth.create_project(content) rollback.append({"topic": self.topic, "_id": _id}) - # self._send_msg("create", content) + # self._send_msg("created", content) return _id, None except ValidationError as e: raise EngineException(e, HTTPStatus.UNPROCESSABLE_ENTITY) @@ -1127,7 +1163,7 @@ class RoleTopicAuth(BaseTopic): content["_id"] = rid # _id = self.db.create(self.topic, content) rollback.append({"topic": self.topic, "_id": rid}) - # self._send_msg("create", content) + # self._send_msg("created", content) return rid, None except ValidationError as e: raise EngineException(e, HTTPStatus.UNPROCESSABLE_ENTITY)