def init_common_services(self, with_cloud_account=True, zone_name=None): """ Initialize common service, When 'zone_name' is defined " at $zone_name" is added to service names :param bool with_cloud_account: :param str zone_name: :return: OR tuple(Workflow, Vault), OR tuple(Workflow, Vault, CloudAccount) with services """ zone_names = ZoneConstants(zone_name) type_to_app = lambda t: self.organization.applications[system_application_types.get(t, t)] wf_service = self.organization.service(name=zone_names.DEFAULT_WORKFLOW_SERVICE, application=type_to_app(WORKFLOW_SERVICE_TYPE), environment=self) key_service = self.organization.service(name=zone_names.DEFAULT_CREDENTIAL_SERVICE, application=type_to_app(COBALT_SECURE_STORE_TYPE), environment=self) if not with_cloud_account: with self as env: env.add_service(wf_service) env.add_service(key_service) return wf_service, key_service cloud_account_service = self.organization.service(name=zone_names.DEFAULT_CLOUD_ACCOUNT_SERVICE, application=type_to_app(CLOUD_ACCOUNT_TYPE), environment=self, parameters=PROVIDER_CONFIG) with self as env: env.add_service(wf_service) env.add_service(key_service) env.add_service(cloud_account_service) return wf_service, key_service, cloud_account_service
def __service(self, environment, service_data): application = self.organization.applications[system_application_types.get(service_data["type"],service_data["type"])] service = self.organization.service(application=application, name=service_data["name"], environment=environment, parameters=(service_data.get("parameters"))) service.ready(1) environment.add_service(service) if COBALT_SECURE_STORE_TYPE is service_data["type"]: key_id = service.regenerate()['id'] environment.add_policy({ "action": "provisionVms", "parameter": "publicKeyId", "value": key_id }) service_data["id"] = service.instanceId
def init_common_services(self, with_cloud_account=True, zone_name=None): """ Initialize common service, When 'zone_name' is defined " at $zone_name" is added to service names :param bool with_cloud_account: :param str zone_name: :return: OR tuple(Workflow, Vault), OR tuple(Workflow, Vault, CloudAccount) with services """ zone_names = ZoneConstants(zone_name) type_to_app = lambda t: self.organization.applications[system_application_types.get(t, t)] wf_service = self.organization.service( name=zone_names.DEFAULT_WORKFLOW_SERVICE, application=type_to_app(WORKFLOW_SERVICE_TYPE), environment=self ) key_service = self.organization.service( name=zone_names.DEFAULT_CREDENTIAL_SERVICE, application=type_to_app(COBALT_SECURE_STORE_TYPE), environment=self, ) assert wf_service.running() assert key_service.running() if not with_cloud_account: with self as env: env.add_service(wf_service, force=True) env.add_service(key_service, force=True) return wf_service, key_service cloud_account_service = self.organization.instance( name=zone_names.DEFAULT_CLOUD_ACCOUNT_SERVICE, application=type_to_app(CLOUD_ACCOUNT_TYPE), environment=self, parameters=PROVIDER_CONFIG, destroyInterval=0, ) # Imidiate adding to env cause CA not to drop destroy interval. Known issue 6132. So, add service as instance with # destroyInterval set to 'never' assert cloud_account_service.running() with self as env: env.add_service(wf_service, force=True) env.add_service(key_service, force=True) env.add_service(cloud_account_service, force=True) return wf_service, key_service, cloud_account_service
def init_common_services(self, with_cloud_account=True, zone_name=None): """ Initialize common service, When 'zone_name' is defined " at $zone_name" is added to service names :param bool with_cloud_account: :param str zone_name: :return: OR tuple(Workflow, Vault), OR tuple(Workflow, Vault, CloudAccount) with services """ zone_names = ZoneConstants(zone_name) type_to_app = lambda t: self.organization.applications[ system_application_types.get(t, t)] wf_service = self.organization.service( name=zone_names.DEFAULT_WORKFLOW_SERVICE, application=type_to_app(WORKFLOW_SERVICE_TYPE), environment=self) key_service = self.organization.service( name=zone_names.DEFAULT_CREDENTIAL_SERVICE, application=type_to_app(COBALT_SECURE_STORE_TYPE), environment=self) assert wf_service.running() assert key_service.running() if not with_cloud_account: with self as env: env.add_service(wf_service, force=True) env.add_service(key_service, force=True) return wf_service, key_service cloud_account_service = self.organization.instance( name=zone_names.DEFAULT_CLOUD_ACCOUNT_SERVICE, application=type_to_app(CLOUD_ACCOUNT_TYPE), environment=self, parameters=PROVIDER_CONFIG, destroyInterval=0) # Imidiate adding to env cause CA not to drop destroy interval. Known issue 6132. So, add service as instance with # destroyInterval set to 'never' assert cloud_account_service.running() with self as env: env.add_service(wf_service, force=True) env.add_service(key_service, force=True) env.add_service(cloud_account_service, force=True) return wf_service, key_service, cloud_account_service
def type_to_app(t): return self.organization.applications[system_application_types.get(t, t)]
def type_to_app(t): return org.applications[system_application_types.get(t, t)]