예제 #1
0
    def get_group_app_metadata(self, group_id, tenant):
        all_data = dict()
        compose_group_info = compose_repo.get_group_compose_by_group_id(
            group_id)
        compose_service_relation = None
        if compose_group_info:
            compose_service_relation = compose_relation_repo.get_compose_service_relation_by_compose_id(
                compose_group_info.compose_id)
        group_info = group_repo.get_group_by_id(group_id)

        service_group_relations = group_service_relation_repo.get_services_by_group(
            group_id)
        service_ids = [sgr.service_id for sgr in service_group_relations]
        services = service_repo.get_services_by_service_ids(*service_ids)
        all_data["compose_group_info"] = compose_group_info.to_dict(
        ) if compose_group_info else None
        all_data["compose_service_relation"] = [
            relation.to_dict() for relation in compose_service_relation
        ] if compose_service_relation else None
        all_data["group_info"] = group_info.to_dict()
        all_data["service_group_relation"] = [
            sgr.to_dict() for sgr in service_group_relations
        ]
        apps = []
        for service in services:
            app_info = self.get_service_details(tenant, service)
            apps.append(app_info)
        all_data["apps"] = apps
        return json.dumps(all_data)
예제 #2
0
    def get_group_app_metadata(self, group_id, tenant):
        all_data = dict()
        compose_group_info = compose_repo.get_group_compose_by_group_id(
            group_id)
        compose_service_relation = None
        if compose_group_info:
            compose_service_relation = compose_relation_repo.get_compose_service_relation_by_compose_id(
                compose_group_info.compose_id)
        group_info = group_repo.get_group_by_id(group_id)

        service_group_relations = group_service_relation_repo.get_services_by_group(
            group_id)
        service_ids = [sgr.service_id for sgr in service_group_relations]
        services = service_repo.get_services_by_service_ids(*service_ids)
        all_data["compose_group_info"] = compose_group_info.to_dict(
        ) if compose_group_info else None
        all_data["compose_service_relation"] = [
            relation.to_dict() for relation in compose_service_relation
        ] if compose_service_relation else None
        all_data["group_info"] = group_info.to_dict()
        all_data["service_group_relation"] = [
            sgr.to_dict() for sgr in service_group_relations
        ]
        apps = []
        total_memory = 0
        for service in services:
            if service.service_source == "third_party" or service.create_status != "complete":
                continue
            total_memory += service.min_memory * service.min_node
            app_info = self.get_service_details(tenant, service)
            apps.append(app_info)
        all_data["apps"] = apps
        return total_memory, json.dumps(all_data)
예제 #3
0
    def get_group_app_metadata(self, group_id, tenant):
        all_data = dict()
        compose_group_info = compose_repo.get_group_compose_by_group_id(group_id)
        compose_service_relation = None
        if compose_group_info:
            compose_service_relation = compose_relation_repo.get_compose_service_relation_by_compose_id(
                compose_group_info.compose_id)
        group_info = group_repo.get_group_by_id(group_id)

        service_group_relations = group_service_relation_repo.get_services_by_group(group_id)
        service_ids = [sgr.service_id for sgr in service_group_relations]
        services = service_repo.get_services_by_service_ids(service_ids)

        all_data["compose_group_info"] = compose_group_info.to_dict() if compose_group_info else None
        all_data["compose_service_relation"] = [
            relation.to_dict() for relation in compose_service_relation] if compose_service_relation else None
        all_data["group_info"] = group_info.to_dict()
        all_data["service_group_relation"] = [sgr.to_dict() for sgr in service_group_relations]
        apps = []
        total_memory = 0
        plugin_ids = []
        for service in services:
            if service.service_source == "third_party" or service.create_status != "complete":
                continue
            total_memory += service.min_memory * service.min_node
            app_info, pids = self.get_service_details(tenant, service)
            plugin_ids.extend(pids)
            apps.append(app_info)
        all_data["apps"] = apps

        # plugin
        plugins = []
        plugin_build_versions = []
        plugin_config_groups = []
        plugin_config_items = []
        for plugin_id in plugin_ids:
            plugin = plugin_repo.get_plugin_by_plugin_id(tenant.tenant_id, plugin_id)
            if plugin is None:
                continue
            plugins.append(plugin.to_dict())
            bv = build_version_repo.get_last_ok_one(plugin_id, tenant.tenant_id)
            if bv is None:
                continue
            plugin_build_versions.append(bv.to_dict())
            pcgs = plugin_config_group_repo.list_by_plugin_id(plugin_id)
            if pcgs:
                plugin_config_groups.extend([p.to_dict() for p in pcgs])
            pcis = plugin_config_items_repo.list_by_plugin_id(plugin_id)
            if pcis:
                plugin_config_items.extend([p.to_dict() for p in pcis])
        all_data["plugin_info"] = {}
        all_data["plugin_info"]["plugins"] = plugins
        all_data["plugin_info"]["plugin_build_versions"] = plugin_build_versions
        all_data["plugin_info"]["plugin_config_groups"] = plugin_config_groups
        all_data["plugin_info"]["plugin_config_items"] = plugin_config_items

        return total_memory, json.dumps(all_data)
예제 #4
0
 def get_compose_services(self, compose_id):
     compse_service_relations = compose_relation_repo.get_compose_service_relation_by_compose_id(compose_id)
     service_ids = [csr.service_id for csr in compse_service_relations]
     service_ids = list(service_ids)
     return service_repo.get_services_by_service_ids(service_ids)