schema_version
) or self.config_to_encrypt.get("default")
if edit_content.get("config") and config_to_encrypt_keys:
-
for p in config_to_encrypt_keys:
if edit_content["config"].get(p):
final_content["config"][p] = self.db.encrypt(
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"])
"vrops_password",
),
}
+ valid_paas_providers = ["juju"]
+
+ def check_conflict_on_new(self, session, indata):
+ super().check_conflict_on_new(session, indata)
+ self._check_paas_account(indata)
+
+ def _is_paas_vim_type(self, indata):
+ return indata.get("vim_type") and indata["vim_type"] == "paas"
+
+ def _check_paas_account(self, indata):
+ if self._is_paas_vim_type(indata):
+ self._check_paas_provider_is_valid(indata)
+
+ def _check_paas_provider_is_valid(self, indata):
+ try:
+ paas_provider = indata["config"]["paas_provider"]
+ if paas_provider in self.valid_paas_providers:
+ return
+ except Exception:
+ pass
+ raise EngineException(
+ "Invalid paas_provider for VIM account '{}'.".format(indata["name"]),
+ HTTPStatus.UNPROCESSABLE_ENTITY,
+ )
def check_conflict_on_del(self, session, _id, db_content):
"""
)
super().check_conflict_on_del(session, _id, db_content)
+ def _send_msg(self, action, content, not_send_msg=None):
+ if self._is_paas_vim_type(content):
+ return
+ super()._send_msg(action, content, not_send_msg)
+
class WimAccountTopic(CommonVimWimSdn):
topic = "wim_accounts"
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 = {}
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