- BaseTopic.format_on_new(content, project_id=project_id, make_public=make_public)
- content["schema_version"] = schema_version = "1.1"
- # encrypt passwords
- if content.get("password"):
- content["password"] = self.db.encrypt(content["password"], schema_version=schema_version,
- salt=content["_id"])
-
- content["_admin"]["operationalState"] = "PROCESSING"
-
- def delete(self, session, _id, dry_run=False):
- """
- Delete item by its internal _id
- :param session: contains "username", "admin", "force", "public", "project_id", "set_project"
- :param _id: server internal id
- :param dry_run: make checking but do not delete
- :return: dictionary with deleted item _id. It raises EngineException on error: not found, conflict, ...
- """
- if dry_run or session["force"]: # delete completely
- return BaseTopic.delete(self, session, _id, dry_run)
- else: # if not sent to kafka
- v = BaseTopic.delete(self, session, _id, dry_run=True)
- self.db.set_one("sdns", {"_id": _id}, {"_admin.to_delete": True}) # TODO change status
- self._send_msg("delete", {"_id": _id})
- return v # TODO indicate an offline operation to return 202 ACCEPTED
+ 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 = {}