Ejemplo n.º 1
0
    def sync_app_services(self, tenant, region_name, app_id):
        group_services = base_service.get_group_services_list(
            tenant.tenant_id, region_name, app_id)
        service_ids = []
        if group_services:
            for service in group_services:
                service_ids.append(service["service_id"])

        try:
            region_app_id = region_app_repo.get_region_app_id(
                region_name, app_id)
            body = {"service_ids": service_ids}
            region_api.batch_update_service_app_id(region_name,
                                                   tenant.tenant_name,
                                                   region_app_id, body)
        except RegionApp.DoesNotExist:
            app = group_repo.get_group_by_id(app_id)
            create_body = {
                "app_name": app.group_name,
                "service_ids": service_ids
            }
            bean = region_api.create_application(region_name, tenant,
                                                 create_body)
            req = {
                "region_name": region_name,
                "region_app_id": bean["app_id"],
                "app_id": app_id
            }
            region_app_repo.create(**req)
Ejemplo n.º 2
0
    def create_region_app(self, tenant, region_name, app):
        region_app = region_api.create_application(
            region_name, tenant.tenant_name, {
                "app_name": app.group_name,
            })

        # record the dependencies between region app and console app
        data = {
            "region_name": region_name,
            "region_app_id": region_app["app_id"],
            "app_id": app.ID,
        }
        region_app_repo.create(**data)
Ejemplo n.º 3
0
    def create_app(self, tenant, region_name, app_name, note=""):
        app = self.add_group(tenant, region_name, app_name, note)

        region_app = region_api.create_application(region_name,
                                                   tenant.tenant_name, {
                                                       "app_name": app_name,
                                                   })

        # record the dependencies between region app and console app
        data = {
            "region_name": region_name,
            "region_app_id": region_app["app_id"],
            "app_id": app.ID,
        }
        region_app_repo.create(**data)

        return app.to_dict()
Ejemplo n.º 4
0
    def create_region_app(self, tenant, region_name, app, eid=""):
        region_app = region_api.create_application(
            region_name, tenant.tenant_name, {
                "eid": eid,
                "app_name": app.group_name,
                "app_type": app.app_type,
                "app_store_name": app.app_store_name,
                "app_store_url": app.app_store_url,
                "app_template_name": app.app_template_name,
                "version": app.version,
            })

        # record the dependencies between region app and console app
        data = {
            "region_name": region_name,
            "region_app_id": region_app["app_id"],
            "app_id": app.ID,
        }
        region_app_repo.create(**data)