k8srepo_edit_schema,
vca_new_schema,
vca_edit_schema,
+ paas_new_schema,
+ paas_edit_schema,
osmrepo_new_schema,
osmrepo_edit_schema,
validate_input,
"""
super().format_on_new(content, project_id=project_id, make_public=make_public)
content["schema_version"] = schema_version = "1.11"
+ self._encrypt_password(content, schema_version)
+ self._encrypt_config_fields(content, schema_version)
+ content["_admin"]["operationalState"] = "PROCESSING"
+ self._insert_create_operation(content)
+ return "{}:0".format(content["_id"])
- # encrypt passwords
+ def _encrypt_password(self, content, schema_version):
if content.get(self.password_to_encrypt):
content[self.password_to_encrypt] = self.db.encrypt(
content[self.password_to_encrypt],
schema_version=schema_version,
salt=content["_id"],
)
+
+ def _encrypt_config_fields(self, content, schema_version):
config_to_encrypt_keys = self.config_to_encrypt.get(
schema_version
) or self.config_to_encrypt.get("default")
salt=content["_id"],
)
- content["_admin"]["operationalState"] = "PROCESSING"
-
+ def _insert_create_operation(self, content):
# create operation
content["_admin"]["operations"] = [self._create_operation("create")]
content["_admin"]["current_operation"] = None
if content.get("vim_type"):
if content["vim_type"] == "openstack":
compute = {
- "ram": {
- "total": None,
- "used": None
- },
- "vcpus": {
- "total": None,
- "used": None
- },
- "instances": {
- "total": None,
- "used": None
- }
+ "ram": {"total": None, "used": None},
+ "vcpus": {"total": None, "used": None},
+ "instances": {"total": None, "used": None},
}
storage = {
- "volumes": {
- "total": None,
- "used": None
- },
- "snapshots": {
- "total": None,
- "used": None
- },
- "storage": {
- "total": None,
- "used": None
- }
+ "volumes": {"total": None, "used": None},
+ "snapshots": {"total": None, "used": None},
+ "storage": {"total": None, "used": None},
}
network = {
- "networks": {
- "total": None,
- "used": None
- },
- "subnets": {
- "total": None,
- "used": None
- },
- "floating_ips": {
- "total": None,
- "used": None
- }
+ "networks": {"total": None, "used": None},
+ "subnets": {"total": None, "used": None},
+ "floating_ips": {"total": None, "used": None},
+ }
+ content["resources"] = {
+ "compute": compute,
+ "storage": storage,
+ "network": network,
}
- content["resources"] = {"compute": compute, "storage": storage, "network": network}
-
-
- return "{}:0".format(content["_id"])
def delete(self, session, _id, dry_run=False, not_send_msg=None):
"""
schema_new = wim_account_new_schema
schema_edit = wim_account_edit_schema
multiproject = True
- password_to_encrypt = "wim_password"
+ password_to_encrypt = "password"
config_to_encrypt = {}
super().check_conflict_on_del(session, _id, db_content)
+class PaasTopic(CommonVimWimSdn):
+ topic = "paas"
+ topic_msg = "paas"
+ schema_new = paas_new_schema
+ schema_edit = paas_edit_schema
+ multiproject = True
+ password_to_encrypt = "secret"
+ config_to_encrypt = {}
+
+ def format_on_edit(self, final_content, edit_content):
+ oid = super().format_on_edit(final_content, edit_content)
+ final_content["_admin"]["operationalState"] = "PROCESSING"
+ final_content["_admin"]["detailed-status"] = "Editing"
+ return oid
+
+ def _check_if_used_by_ns(self):
+ pass
+
+ def check_conflict_on_del(self, session, _id, db_content):
+ """
+ Check if deletion can be done because of dependencies if it is not force.
+ :param session: contains "username", "admin", "force", "public", "project_id", "set_project"
+ :param _id: internal _id
+ :param db_content: The database content of this item _id
+ :return: None if ok or raises EngineException with the conflict
+ """
+ if session["force"]:
+ return
+ self._check_if_used_by_ns()
+
+ super().check_conflict_on_del(session, _id, db_content)
+
+
class K8sRepoTopic(CommonVimWimSdn):
topic = "k8srepos"
topic_msg = "k8srepo"
if to_add["project"] in (
mapping["project"],
mapping["project_name"],
- ) and to_add["role"] in (
- mapping["role"],
- mapping["role_name"],
- ):
+ ) and to_add["role"] in (mapping["role"], mapping["role_name"]):
if mapping in mappings_to_remove: # do not remove
mappings_to_remove.remove(mapping)
if to_set["project"] in (
mapping["project"],
mapping["project_name"],
- ) and to_set["role"] in (
- mapping["role"],
- mapping["role_name"],
- ):
+ ) and to_set["role"] in (mapping["role"], mapping["role_name"]):
if mapping in mappings_to_remove: # do not remove
mappings_to_remove.remove(mapping)
break # do not add, it is already at user
if to_set["project"] in (
mapping["project"],
mapping["project_name"],
- ) and to_set["role"] in (
- mapping["role"],
- mapping["role_name"],
- ):
+ ) and to_set["role"] in (mapping["role"], mapping["role_name"]):
break
else:
# delete
"_id": _id,
"username": indata.get("username"),
"password": indata.get("password"),
+ "old_password": indata.get("old_password"),
"add_project_role_mappings": mappings_to_add,
"remove_project_role_mappings": mappings_to_remove,
}