def __init__(self, db, fs, msg, auth):
super().__init__(db, fs, msg, auth)
+ self.infra_contr_topic = InfraContTopic(db, fs, msg, auth)
+ self.infra_conf_topic = InfraConfTopic(db, fs, msg, auth)
+ self.resource_topic = ResourceTopic(db, fs, msg, auth)
+ self.app_topic = AppTopic(db, fs, msg, auth)
@staticmethod
def format_on_new(content, project_id=None, make_public=False):
operation_params = cls_add_request
step = "filling cluster details from input data"
- cls_add_request = self._add_cluster(cls_add_request, session)
+ cls_add_request = self._add_cluster(
+ cls_add_request, rollback, session, indata, kwargs, headers
+ )
step = "registering the cluster at database"
self.format_on_new(
) as e:
raise type(e)("{} while '{}'".format(e, step), http_code=e.http_code)
- def _add_cluster(self, cls_add_request, session):
+ def _add_cluster(self, cls_add_request, rollback, session, indata, kwargs, headers):
cls_add = {
"name": cls_add_request["name"],
"credentials": cls_add_request["credentials"],
"vim_account": cls_add_request["vim_account"],
"bootstrap": cls_add_request["bootstrap"],
+ "infra_controller_profiles": [
+ self._create_default_profiles(
+ rollback, session, indata, kwargs, headers, self.infra_contr_topic
+ )
+ ],
+ "infra_config_profiles": [
+ self._create_default_profiles(
+ rollback, session, indata, kwargs, headers, self.infra_conf_topic
+ )
+ ],
+ "resource_profiles": [
+ self._create_default_profiles(
+ rollback, session, indata, kwargs, headers, self.resource_topic
+ )
+ ],
+ "app_profiles": [
+ self._create_default_profiles(
+ rollback, session, indata, kwargs, headers, self.app_topic
+ )
+ ],
"created": "false",
"state": "IN_CREATION",
"operatingState": "PROCESSING",
cls_add["description"] = cls_add_request["description"]
return cls_add
+ def check_vim(self, session, name):
+ try:
+ vim_account_details = self.db.get_one("vim_accounts", {"name": name})
+ if vim_account_details is not None:
+ return name
+ except ValidationError as e:
+ raise EngineException(
+ e,
+ HTTPStatus.UNPROCESSABLE_ENTITY,
+ )
+
+ def _create_default_profiles(
+ self, rollback, session, indata, kwargs, headers, topic
+ ):
+ topic = self.to_select_topic(topic)
+ default_profiles = topic.default(rollback, session, indata, kwargs, headers)
+ return default_profiles
+
+ def to_select_topic(self, topic):
+ if topic == "infra_controller_profiles":
+ topic = self.infra_contr_topic
+ elif topic == "infra_config_profiles":
+ topic = self.infra_conf_topic
+ elif topic == "resource_profiles":
+ topic = self.resource_topic
+ elif topic == "app_profiles":
+ topic = self.app_topic
+ return topic
+
def remove(self, session, _id, dry_run=False, not_send_msg=None):
"""
Delete item by its internal _id