From 3317bc740444b6e95b5290c2ed0240564acbf194 Mon Sep 17 00:00:00 2001 From: zhouqunjie <450705171@qq.com> Date: Mon, 4 Apr 2022 17:36:54 +0800 Subject: [PATCH 1/3] refactor --- adaptor/cm_adaptor/cm_adaptor | 0 .../alibaba/eci/config_eci.conf | 26 --- .../container_api_adaptor/alibaba/eci/eci.go | 121 ----------- .../common/api/common_api.go | 99 --------- .../common/auth/aksk/akskConfig.go | 43 ---- .../common/auth/aksk/aksk_template.conf | 14 -- .../common/config/config.go | 133 ------------ .../common/config/config_common.conf | 45 ---- adaptor/container_api_adaptor/common/main.go | 29 --- .../huawei/cci/config_cci.conf | 39 ---- .../pkg/apis/networking.cci.io/v1beta1/doc.go | 4 - .../networking.cci.io/v1beta1/register.go | 51 ----- .../apis/networking.cci.io/v1beta1/types.go | 87 -------- .../v1beta1/zz_generated.deepcopy.go | 119 ---------- .../huawei/pkg/auth/aksk/aksk.go | 91 -------- .../huawei/pkg/auth/kubeconfig/kubeconfig.go | 16 -- .../huawei/pkg/auth/password/password.go | 45 ---- .../networking.cci.io/v1beta1/clientset.go | 90 -------- .../client/networking.cci.io/v1beta1/doc.go | 20 -- .../v1beta1/fake/clientset_generated.go | 82 ------- .../networking.cci.io/v1beta1/fake/doc.go | 20 -- .../v1beta1/fake/register.go | 56 ----- .../networking.cci.io/v1beta1/scheme/doc.go | 20 -- .../v1beta1/scheme/register.go | 56 ----- .../typed/networking.cci.io/v1beta1/doc.go | 20 -- .../networking.cci.io/v1beta1/fake/doc.go | 20 -- .../v1beta1/fake/fake_network.go | 140 ------------ .../fake/fake_networking.cci.io_client.go | 40 ---- .../v1beta1/generated_expansion.go | 21 -- .../networking.cci.io/v1beta1/network.go | 191 ---------------- .../v1beta1/networking.cci.io_client.go | 89 -------- .../huawei/resources/deployment/deployment.go | 77 ------- .../huawei/resources/namespace/namespace.go | 54 ----- .../huawei/resources/network/network.go | 58 ----- .../huawei/resources/pod/pod.go | 134 ------------ .../tencent/eks/config_eks.conf | 34 --- .../container_api_adaptor/tencent/eks/eks.go | 138 ------------ adaptor/func_api_adaptor/func_api_adaptor | 0 adaptor/pod_adaptor/service/poder/ali_eci.go | 203 ++++++++++++++++++ .../pod_adaptor/service/poder/huawei_cci.go | 135 ++++++++++++ .../pod_adaptor/service/poder/tencent_eks.go | 139 ++++++++++++ adaptor/vm_adaptor/vm_adaptor | 0 cm_bridge/cm_adaptor | 0 common/server/server.go | 2 + configs/config.yaml | 12 +- go.mod | 53 ----- idl/pbpod/pod.proto | 164 ++++++++++++++ lan_trans/idl/demo/demo.pb.gw.go | 10 +- lan_trans/idl/pbecs/ecs.pb.gw.go | 30 +-- main.go | 6 +- 50 files changed, 678 insertions(+), 2398 deletions(-) delete mode 100644 adaptor/cm_adaptor/cm_adaptor delete mode 100644 adaptor/container_api_adaptor/alibaba/eci/config_eci.conf delete mode 100644 adaptor/container_api_adaptor/alibaba/eci/eci.go delete mode 100644 adaptor/container_api_adaptor/common/api/common_api.go delete mode 100644 adaptor/container_api_adaptor/common/auth/aksk/akskConfig.go delete mode 100644 adaptor/container_api_adaptor/common/auth/aksk/aksk_template.conf delete mode 100644 adaptor/container_api_adaptor/common/config/config.go delete mode 100644 adaptor/container_api_adaptor/common/config/config_common.conf delete mode 100644 adaptor/container_api_adaptor/common/main.go delete mode 100644 adaptor/container_api_adaptor/huawei/cci/config_cci.conf delete mode 100644 adaptor/container_api_adaptor/huawei/pkg/apis/networking.cci.io/v1beta1/doc.go delete mode 100644 adaptor/container_api_adaptor/huawei/pkg/apis/networking.cci.io/v1beta1/register.go delete mode 100644 adaptor/container_api_adaptor/huawei/pkg/apis/networking.cci.io/v1beta1/types.go delete mode 100644 adaptor/container_api_adaptor/huawei/pkg/apis/networking.cci.io/v1beta1/zz_generated.deepcopy.go delete mode 100644 adaptor/container_api_adaptor/huawei/pkg/auth/aksk/aksk.go delete mode 100644 adaptor/container_api_adaptor/huawei/pkg/auth/kubeconfig/kubeconfig.go delete mode 100644 adaptor/container_api_adaptor/huawei/pkg/auth/password/password.go delete mode 100644 adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1/clientset.go delete mode 100644 adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1/doc.go delete mode 100644 adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1/fake/clientset_generated.go delete mode 100644 adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1/fake/doc.go delete mode 100644 adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1/fake/register.go delete mode 100644 adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1/scheme/doc.go delete mode 100644 adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1/scheme/register.go delete mode 100644 adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1/typed/networking.cci.io/v1beta1/doc.go delete mode 100644 adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1/typed/networking.cci.io/v1beta1/fake/doc.go delete mode 100644 adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1/typed/networking.cci.io/v1beta1/fake/fake_network.go delete mode 100644 adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1/typed/networking.cci.io/v1beta1/fake/fake_networking.cci.io_client.go delete mode 100644 adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1/typed/networking.cci.io/v1beta1/generated_expansion.go delete mode 100644 adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1/typed/networking.cci.io/v1beta1/network.go delete mode 100644 adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1/typed/networking.cci.io/v1beta1/networking.cci.io_client.go delete mode 100644 adaptor/container_api_adaptor/huawei/resources/deployment/deployment.go delete mode 100644 adaptor/container_api_adaptor/huawei/resources/namespace/namespace.go delete mode 100644 adaptor/container_api_adaptor/huawei/resources/network/network.go delete mode 100644 adaptor/container_api_adaptor/huawei/resources/pod/pod.go delete mode 100644 adaptor/container_api_adaptor/tencent/eks/config_eks.conf delete mode 100644 adaptor/container_api_adaptor/tencent/eks/eks.go delete mode 100644 adaptor/func_api_adaptor/func_api_adaptor create mode 100644 adaptor/pod_adaptor/service/poder/ali_eci.go create mode 100644 adaptor/pod_adaptor/service/poder/huawei_cci.go create mode 100644 adaptor/pod_adaptor/service/poder/tencent_eks.go delete mode 100644 adaptor/vm_adaptor/vm_adaptor delete mode 100644 cm_bridge/cm_adaptor delete mode 100644 go.mod create mode 100644 idl/pbpod/pod.proto diff --git a/adaptor/cm_adaptor/cm_adaptor b/adaptor/cm_adaptor/cm_adaptor deleted file mode 100644 index e69de29..0000000 diff --git a/adaptor/container_api_adaptor/alibaba/eci/config_eci.conf b/adaptor/container_api_adaptor/alibaba/eci/config_eci.conf deleted file mode 100644 index 3f3c6a0..0000000 --- a/adaptor/container_api_adaptor/alibaba/eci/config_eci.conf +++ /dev/null @@ -1,26 +0,0 @@ -[pod_create_conf] -region_id=cn-hangzhou -#容器实例名称(pod名) 对应阿里 ContainerGroupName(阿里必需) -container_group_name=pcm-test-ali-pod -#镜像地址 对应阿里 Container.Image(阿里必需) -container_image=registry-vpc.cn-hangzhou.aliyuncs.com/eci_open/nginx -#容器名称 对应阿里 Container.Name(阿里必需) -container_name=pcm-test-ali-container - -[pod_delete_conf] -# 地域id -region_id=cn-hangzhou -#容器实例ID -container_group_id=eci-bp1c3eqfq98nz2kbiooo - -[pod_list_conf] -# 地域id -region_id=cn-hangzhou - -[pod_update_conf] -# 地域id -region_id=cn-hangzhou -#容器实例ID -container_group_id=eci-bp1c3eqfq98nz2kbiooo -#可选 这里用重启策略做更新测试 -restart_policy=Never \ No newline at end of file diff --git a/adaptor/container_api_adaptor/alibaba/eci/eci.go b/adaptor/container_api_adaptor/alibaba/eci/eci.go deleted file mode 100644 index c81a7b3..0000000 --- a/adaptor/container_api_adaptor/alibaba/eci/eci.go +++ /dev/null @@ -1,121 +0,0 @@ -package eci - -import ( - "fmt" - "github.com/aliyun/alibaba-cloud-sdk-go/services/eci" - "gitlink.org.cn/JCCE/PCM/adaptor/container_api_adaptor/common/auth/aksk" - "gitlink.org.cn/JCCE/PCM/adaptor/container_api_adaptor/common/config" -) - -// CreateContainerGroup 创建 -func CreateContainerGroup(cloudStack string, akskPath string, configPath string) string { - - var client *eci.Client - configCommon, _ := config.PCMconfig(configPath) - configAksk, _ := aksk.AkskConfig(cloudStack, akskPath) - - //创建客户端 - client, _ = eci.NewClientWithAccessKey(configCommon.RegionId, configAksk.AccessKey, configAksk.SecretKey) - // 生成创建请求 - createContainerRequest := eci.CreateCreateContainerGroupRequest() - // 必需参数 - //区域ID - createContainerRequest.RegionId = configCommon.RegionId - //POD名称 - createContainerRequest.ContainerGroupName = configCommon.ContainerGroupName - //容器名称和镜像名称 - createContainerRequestContainer := make([]eci.CreateContainerGroupContainer, 1) - createContainerRequestContainer[0].Image = configCommon.ContainerImage - createContainerRequestContainer[0].Name = configCommon.ContainerName - createContainerRequest.Container = &createContainerRequestContainer - - client.GetConfig().MaxRetryTime = 0 - createContainerGroupResponse, err := client.CreateContainerGroup(createContainerRequest) - if err != nil { - panic(err) - } - containerGroupId := createContainerGroupResponse.ContainerGroupId - fmt.Println("Alibaba ContainerGroup created:", containerGroupId) - return containerGroupId -} - -// DescribeContainerGroup 查询Pod -func DescribeContainerGroup(cloudStack string, akskPath string, configPath string) eci.DescribeContainerGroupsContainerGroup0 { - var client *eci.Client - - configCommon, _ := config.PCMconfig(configPath) - configAksk, _ := aksk.AkskConfig(cloudStack, akskPath) - client, _ = eci.NewClientWithAccessKey(configCommon.RegionId, configAksk.AccessKey, configAksk.SecretKey) - - // 生成查询请求 - describeContainerGroupsRequest := eci.CreateDescribeContainerGroupsRequest() - describeContainerGroupsRequest.RegionId = configCommon.RegionIdList - describeContainerGroupsResponse, err := client.DescribeContainerGroups(describeContainerGroupsRequest) - if err != nil { - panic(err) - } - describeContainerGroupNumber := len(describeContainerGroupsResponse.ContainerGroups) - - //当前区域没有Pod情形的处理 - if describeContainerGroupsResponse.TotalCount != 1 && describeContainerGroupNumber != 1 { - fmt.Println("Invalid ContainerGroups count", describeContainerGroupsResponse.TotalCount, describeContainerGroupNumber) - panic("Invalid ContainerGroups count") - } - - fmt.Println("Alibaba ContainerGroup Name:", describeContainerGroupsResponse.ContainerGroups[0].ContainerGroupName, "\n", - "ContainerGroup Id:", describeContainerGroupsResponse.ContainerGroups[0].ContainerGroupId) - - return describeContainerGroupsResponse.ContainerGroups[0] -} - -// UpdateContainerGroup 更新Pod -func UpdateContainerGroup(cloudStack string, akskPath string, configPath string) string { - var client *eci.Client - - configCommon, _ := config.PCMconfig(configPath) - configAksk, _ := aksk.AkskConfig(cloudStack, akskPath) - - client, _ = eci.NewClientWithAccessKey(configCommon.RegionId, configAksk.AccessKey, configAksk.SecretKey) - - //生成更新请求 - updateContainerGroupRequest := eci.CreateUpdateContainerGroupRequest() - updateContainerGroupRequest.RegionId = configCommon.RegionIdUpdate - updateContainerGroupRequest.ContainerGroupId = configCommon.ContainerGroupIdUpdate - - //容器实体内容,这里测试可以修改配置文件中的重启策略 - updateContainerRequestContainer := make([]eci.UpdateContainerGroupContainer, 1) - updateContainerRequestContainer[0].Image = configCommon.ContainerImage - updateContainerRequestContainer[0].Name = configCommon.ContainerName - updateContainerGroupRequest.Container = &updateContainerRequestContainer - updateContainerGroupRequest.RestartPolicy = configCommon.RestartPolicyUpdate - - updateContainerGroupResponse, err := client.UpdateContainerGroup(updateContainerGroupRequest) - if err != nil { - panic(err) - } - requestId := updateContainerGroupResponse.RequestId - fmt.Println("Alibaba ContainerGroup: ", configCommon.ContainerGroupIdUpdate, " Updated with request ID:", requestId) - return requestId -} - -// DeleteContainerGroup 删除Pod -func DeleteContainerGroup(cloudStack string, akskPath string, configPath string) string { - var client *eci.Client - configCommon, _ := config.PCMconfig(configPath) - configAksk, _ := aksk.AkskConfig(cloudStack, akskPath) - client, _ = eci.NewClientWithAccessKey(configCommon.RegionId, configAksk.AccessKey, configAksk.SecretKey) - - //生成删除请求 - deleteContainerGroupRequest := eci.CreateDeleteContainerGroupRequest() - deleteContainerGroupRequest.RegionId = configCommon.RegionIdDelete - deleteContainerGroupRequest.ContainerGroupId = configCommon.ContainerGroupIdDelete - - deleteContainerGroupResponse, err := client.DeleteContainerGroup(deleteContainerGroupRequest) - if err != nil { - panic(err) - } - requestId := deleteContainerGroupResponse.RequestId - fmt.Println("Alibaba ContainerGroup: ", configCommon.ContainerGroupIdUpdate, " Deleted with request ID:", requestId) - - return requestId -} diff --git a/adaptor/container_api_adaptor/common/api/common_api.go b/adaptor/container_api_adaptor/common/api/common_api.go deleted file mode 100644 index 88fdad6..0000000 --- a/adaptor/container_api_adaptor/common/api/common_api.go +++ /dev/null @@ -1,99 +0,0 @@ -package api - -import ( - "gitlink.org.cn/JCCE/PCM/adaptor/container_api_adaptor/alibaba/eci" - cciAksk "gitlink.org.cn/JCCE/PCM/adaptor/container_api_adaptor/huawei/pkg/auth/aksk" - cci "gitlink.org.cn/JCCE/PCM/adaptor/container_api_adaptor/huawei/resources/pod" - "gitlink.org.cn/JCCE/PCM/adaptor/container_api_adaptor/tencent/eks" -) - -//CreatePod 创建Pod通用方法 -func CreatePod(cloudStack string, akskPath string, configPath string) { - switch cloudStack { - - case "alibaba": - eci.CreateContainerGroup(cloudStack, akskPath, configPath) - - case "huawei": - cs, err := cciAksk.NewClient(cloudStack, akskPath, configPath) - if err != nil { - panic(err) - } - _, err = cci.CreatePod(cs, configPath) - if err != nil { - return - } - - case "tencent": - eks.CreateEksInstance(cloudStack, akskPath, configPath) - } - -} - -// DeletePod 删除Pod 通用方法 -func DeletePod(cloudStack string, akskPath string, configPath string) { - - switch cloudStack { - - case "alibaba": - eci.DeleteContainerGroup(cloudStack, akskPath, configPath) - - case "huawei": - cs, err := cciAksk.NewClient(cloudStack, akskPath, configPath) - if err != nil { - panic(err) - } - err = cci.DeletePod(cs, configPath) - if err != nil { - return - } - - case "tencent": - eks.DeleteEksInstance(cloudStack, akskPath, configPath) - } -} - -//UpdatePod 更新Pod通用方法 -func UpdatePod(cloudStack string, akskPath string, configPath string) { - - switch cloudStack { - - case "alibaba": - eci.UpdateContainerGroup(cloudStack, akskPath, configPath) - - case "huawei": - cs, err := cciAksk.NewClient(cloudStack, akskPath, configPath) - if err != nil { - panic(err) - } - _, err = cci.UpdatePod(cs, configPath) - if err != nil { - return - } - case "tencent": - eks.UpdateEksInstance(cloudStack, akskPath, configPath) - } -} - -//ListPod 查询Pod通用方法 -func ListPod(cloudStack string, akskPath string, configPath string) { - - switch cloudStack { - - case "alibaba": - eci.DescribeContainerGroup(cloudStack, akskPath, configPath) - - case "huawei": - cs, err := cciAksk.NewClient(cloudStack, akskPath, configPath) - if err != nil { - panic(err) - } - _, err = cci.ListPod(cs, configPath) - if err != nil { - return - } - - case "tencent": - eks.ListEksInstance(cloudStack, akskPath, configPath) - } -} diff --git a/adaptor/container_api_adaptor/common/auth/aksk/akskConfig.go b/adaptor/container_api_adaptor/common/auth/aksk/akskConfig.go deleted file mode 100644 index 62a33c8..0000000 --- a/adaptor/container_api_adaptor/common/auth/aksk/akskConfig.go +++ /dev/null @@ -1,43 +0,0 @@ -package aksk - -import ( - "fmt" - "github.com/Unknwon/goconfig" - "os" -) - -type AkskContainerConfig struct { - AccessKey string - SecretKey string -} - -func AkskConfig(cloudStack string, akskPath string) (AkskContainerConfig, error) { - var cfg *goconfig.ConfigFile - config, err := goconfig.LoadConfigFile(akskPath) - if err != nil { - fmt.Println("get config file error:", err.Error()) - os.Exit(-1) - } - cfg = config - var accessKey string - var secretKey string - switch cloudStack { - - case "alibaba": - accessKey, _ = cfg.GetValue(cloudStack, "access_key") - secretKey, _ = cfg.GetValue(cloudStack, "secret_key") - - case "huawei": - accessKey, _ = cfg.GetValue(cloudStack, "access_key") - secretKey, _ = cfg.GetValue(cloudStack, "secret_key") - case "tencent": - accessKey, _ = cfg.GetValue(cloudStack, "access_key") - secretKey, _ = cfg.GetValue(cloudStack, "secret_key") - } - - var akskConfig = AkskContainerConfig{ - AccessKey: accessKey, - SecretKey: secretKey, - } - return akskConfig, nil -} diff --git a/adaptor/container_api_adaptor/common/auth/aksk/aksk_template.conf b/adaptor/container_api_adaptor/common/auth/aksk/aksk_template.conf deleted file mode 100644 index 7c900b4..0000000 --- a/adaptor/container_api_adaptor/common/auth/aksk/aksk_template.conf +++ /dev/null @@ -1,14 +0,0 @@ -#阿里 -[alibaba] -access_key = -secret_key = - -#华为 -[huawei] -access_key = -secret_key = - -#腾讯 -[tencent] -access_key = -secret_key = \ No newline at end of file diff --git a/adaptor/container_api_adaptor/common/config/config.go b/adaptor/container_api_adaptor/common/config/config.go deleted file mode 100644 index d121a02..0000000 --- a/adaptor/container_api_adaptor/common/config/config.go +++ /dev/null @@ -1,133 +0,0 @@ -package config - -import ( - "fmt" - "github.com/Unknwon/goconfig" - "os" - "strconv" -) - -type PCMContainerConfig struct { - RegionId string - ContainerGroupName string - ContainerImage string - ContainerName string - CpuPod string - MemoryPod string - CpuContainer string - MemoryContainer string - CpuPodFloat float64 - MemoryPodFloat float64 - CpuContainerFloat float64 - MemoryContainerFloat float64 - NameSpace string - SecurityGroupId string - SubnetId string - VpcId string - RegionIdDelete string - ContainerGroupIdDelete string - RegionIdList string - NamespaceUpdate string - RegionIdUpdate string - ContainerImageUpdate string - ContainerNameUpdate string - CpuPodUpdate string - MemoryPodUpdate string - ContainerGroupNameUpdate string - ContainerGroupIdUpdate string - RestartPolicyUpdate string - NamespaceDelete string - ContainerGroupNameDelete string -} - -func PCMconfig(configPath string) (PCMContainerConfig, error) { - - //加载配置文件 - var cfg *goconfig.ConfigFile - config, err := goconfig.LoadConfigFile(configPath) - if err != nil { - fmt.Println("get config file error:", err.Error()) - os.Exit(-1) - } - cfg = config - - //[创建]通用创建必需信息 - regionId, _ := cfg.GetValue("pod_create_conf", "region_id") - containerGroupName, _ := cfg.GetValue("pod_create_conf", "container_group_name") - containerImage, _ := cfg.GetValue("pod_create_conf", "container_image") - containerName, _ := cfg.GetValue("pod_create_conf", "container_name") - - //[创建]阿里创建必需(unique) - - //[创建]腾讯创建必需(unique) - cpuPod, _ := cfg.GetValue("pod_create_conf", "cpu_pod") - memoryPod, _ := cfg.GetValue("pod_create_conf", "memory_pod") - cpuPodFloat, _ := strconv.ParseFloat(cpuPod, 64) - memoryPodFloat, _ := strconv.ParseFloat(memoryPod, 64) - securityGroupId, _ := cfg.GetValue("pod_create_conf", "security_group_id") - subnetId, _ := cfg.GetValue("pod_create_conf", "subnet_id") - vpcId, _ := cfg.GetValue("pod_create_conf", "vpc_id") - - //[创建]华为创建必需(unique) - nameSpace, _ := cfg.GetValue("pod_create_conf", "namespace") - - //[创建]非必需参数 - cpuContainer, _ := cfg.GetValue("pod_create_conf", "cpu_container") - memoryContainer, _ := cfg.GetValue("pod_create_conf", "memory_container") - cpuContainerFloat, _ := strconv.ParseFloat(cpuContainer, 64) - memoryContainerFloat, _ := strconv.ParseFloat(memoryContainer, 64) - - //[删除]通用删除配置信息 - regionIdDelete, _ := cfg.GetValue("pod_delete_conf", "region_id") - containerGroupIdDelete, _ := cfg.GetValue("pod_delete_conf", "container_group_id") - nameSpaceDelete, _ := cfg.GetValue("pod_delete_conf", "namespace") - containerGroupNameDelete, _ := cfg.GetValue("pod_delete_conf", "container_group_name") - - //[查询]通用查询配置信息 - regionIdList, _ := cfg.GetValue("pod_list_conf", "region_id") - - //[更新]通用更新配置信息 - regionIdUpdate, _ := cfg.GetValue("pod_update_conf", "region_id") - namespaceUpdate, _ := cfg.GetValue("pod_update_conf", "namespace") - containerGroupIdUpdate, _ := cfg.GetValue("pod_update_conf", "container_group_id") - restartPolicyUpdate, _ := cfg.GetValue("pod_update_conf", "restart_policy") - ContainerNameUpdate, _ := cfg.GetValue("pod_update_conf", "container_name") - CpuPodUpdate, _ := cfg.GetValue("pod_update_conf", "cpu_pod") - MemoryPodUpdate, _ := cfg.GetValue("pod_update_conf", "memory_pod") - ContainerGroupNameUpdate, _ := cfg.GetValue("pod_update_conf", "container_group_name") - - var configCommon = PCMContainerConfig{ - RegionId: regionId, - ContainerGroupName: containerGroupName, - ContainerImage: containerImage, - ContainerName: containerName, - CpuPod: cpuPod, - MemoryPod: memoryPod, - CpuContainer: cpuContainer, - MemoryContainer: memoryContainer, - CpuPodFloat: cpuPodFloat, - MemoryPodFloat: memoryPodFloat, - CpuContainerFloat: cpuContainerFloat, - MemoryContainerFloat: memoryContainerFloat, - NameSpace: nameSpace, - SecurityGroupId: securityGroupId, - SubnetId: subnetId, - VpcId: vpcId, - RegionIdDelete: regionIdDelete, - ContainerGroupIdDelete: containerGroupIdDelete, - RegionIdList: regionIdList, - RegionIdUpdate: regionIdUpdate, - NamespaceUpdate: namespaceUpdate, - ContainerGroupIdUpdate: containerGroupIdUpdate, - RestartPolicyUpdate: restartPolicyUpdate, - ContainerImageUpdate: containerName, - ContainerNameUpdate: ContainerNameUpdate, - CpuPodUpdate: CpuPodUpdate, - MemoryPodUpdate: MemoryPodUpdate, - ContainerGroupNameUpdate: ContainerGroupNameUpdate, - NamespaceDelete: nameSpaceDelete, - ContainerGroupNameDelete: containerGroupNameDelete, - } - - return configCommon, nil -} diff --git a/adaptor/container_api_adaptor/common/config/config_common.conf b/adaptor/container_api_adaptor/common/config/config_common.conf deleted file mode 100644 index c8a9fb6..0000000 --- a/adaptor/container_api_adaptor/common/config/config_common.conf +++ /dev/null @@ -1,45 +0,0 @@ -[container_conf] -[pod_create_conf] -#测试账号ak -access_key = -secret_key = -#region -region_id= -#容器实例名称(pod名) -container_group_name= -#镜像地址 -container_image= -#容器名称 -container_name= -#namespace 华为CCI基于K8S namespace进行管理,需要单独提供namespace (华为必需) -namespace= -#Pod拥有核数 对应腾讯 Cpu(腾讯必需) -cpu_pod=1 -#Pod拥有内存大小 对应腾讯 Memory(腾讯必需) -memory_pod=2 -#安全组ID 对应腾讯 SecurityGroupIds(腾讯必需) -security_group_id= -#子网ID 对应腾讯 SubnetId(腾讯必需) -subnet_id= -#VPC ID 对应腾讯 VpcId(腾讯必需) -vpc_id= -##考虑多个函数分成不同的配置组 -##用户可以在请求中指定任务在各厂商调度比例 -##地域、厂商、用户AKSK等信息通过独立的配置文件进行导入 - -[pod_create_conf] -#可选项,框架可以不必过于细节 -ali_count=10000 -huawei_count=10000 -tencent_count=20000 - -hangzhou_count=20000 -shanghai_count=20000 - - -[pod_delete_conf] -[pod_update_conf] -[pod_list_conf] - - - diff --git a/adaptor/container_api_adaptor/common/main.go b/adaptor/container_api_adaptor/common/main.go deleted file mode 100644 index 075f5bc..0000000 --- a/adaptor/container_api_adaptor/common/main.go +++ /dev/null @@ -1,29 +0,0 @@ -package main - -func main() { - - aliConfigPath := "adaptor/container_api_adaptor/alibaba/eci/config_eci.conf" - huaweiConfigPath := "adaptor/container_api_adaptor/huawei/cci/config_cci.conf" - tencentConfigPath := "adaptor/container_api_adaptor/tencent/eks/config_eks.conf" - akskPath := "adaptor/container_api_adaptor/common/auth/aksk/aksk.conf" - println(aliConfigPath) - println(huaweiConfigPath) - println(tencentConfigPath) - println(akskPath) - - //api.CreatePod("alibaba", akskPath, aliConfigPath) - //api.ListPod("alibaba", akskPath, aliConfigPath) - //api.UpdatePod("alibaba", akskPath, aliConfigPath) - //api.DeletePod("alibaba", akskPath, aliConfigPath) - - //api.CreatePod("huawei", akskPath, huaweiConfigPath) - //api.ListPod("huawei", akskPath, huaweiConfigPath) - //api.UpdatePod("huawei", akskPath, huaweiConfigPath) - //api.DeletePod("huawei", akskPath, huaweiConfigPath) - - //api.CreatePod("tencent", akskPath, tencentConfigPath) - //api.ListPod("tencent", akskPath, tencentConfigPath) - //api.UpdatePod("tencent", akskPath, tencentConfigPath) - //api.DeletePod("tencent", akskPath, tencentConfigPath) - -} diff --git a/adaptor/container_api_adaptor/huawei/cci/config_cci.conf b/adaptor/container_api_adaptor/huawei/cci/config_cci.conf deleted file mode 100644 index cf35c08..0000000 --- a/adaptor/container_api_adaptor/huawei/cci/config_cci.conf +++ /dev/null @@ -1,39 +0,0 @@ -[pod_create_conf] -#region 对应华为 Region (华为创建Namespace必需) -region_id=cn-north-4 -#namespace 华为CCI基于K8S namespace进行管理,需要单独提供namespace 对应Pod.ObjectMeta.Namespace (华为必需) -namespace=test-k8s-client-namespace1 -#容器实例名称(pod名) 对应华为 Pod.ObjectMeta.Name (华为必需) -container_group_name=pcm-test-huawei-pod -#镜像地址 对应华为 Pod.PodSpec.Containers.Container.Image (华为必需) -container_image=library/nginx:stable-alpine-perl -#容器名称 对应华为 Pod.PodSpec.Containers.Container.Name (华为必需) -container_name=pcm-test-huawei-container -#Pod拥有核数 对应华为 Pod.PodSpec.Containers.Container.Resources.Limits.ResourceCPU (华为必需) -cpu_pod=500m -#Pod拥有内存大小 对应华为 Pod.PodSpec.Containers.Container.Resources.Limits.ResourceMemory (华为必需) -memory_pod=1024Mi - -[pod_delete_conf] -# 地域id -namespace=test-k8s-client-namespace1 -#容器实例名称(pod名) 对应华为 Pod.ObjectMeta.Name (华为必需) -container_group_name=pcm-test-huawei-pod - -[pod_list_conf] -# 地域id -region_id=cn-hangzhou - -[pod_update_conf] -#容器实例名称(pod名) 对应华为 Pod.ObjectMeta.Name (华为必需) -container_group_name=pcm-test-huawei-pod -#镜像地址 对应华为 Pod.PodSpec.Containers.Container.Image (华为必需) -container_image=library/nginx:stable-alpine-perl -#容器名称 对应华为 Pod.PodSpec.Containers.Container.Name (华为必需) -container_name=pcm-test-huawei-container-new -#Pod拥有核数 对应华为 Pod.PodSpec.Containers.Container.Resources.Limits.ResourceCPU (华为必需) -cpu_pod=500m -#Pod拥有内存大小 对应华为 Pod.PodSpec.Containers.Container.Resources.Limits.ResourceMemory (华为必需) -memory_pod=2048Mi -namespace=test-k8s-client-namespace1 -restart_policy=Always diff --git a/adaptor/container_api_adaptor/huawei/pkg/apis/networking.cci.io/v1beta1/doc.go b/adaptor/container_api_adaptor/huawei/pkg/apis/networking.cci.io/v1beta1/doc.go deleted file mode 100644 index 032b35d..0000000 --- a/adaptor/container_api_adaptor/huawei/pkg/apis/networking.cci.io/v1beta1/doc.go +++ /dev/null @@ -1,4 +0,0 @@ -// +k8s:deepcopy-gen=package -// +groupName=networking.cci.io -// +groupGoName=NetworkingCCI -package v1beta1 diff --git a/adaptor/container_api_adaptor/huawei/pkg/apis/networking.cci.io/v1beta1/register.go b/adaptor/container_api_adaptor/huawei/pkg/apis/networking.cci.io/v1beta1/register.go deleted file mode 100644 index 0dc2257..0000000 --- a/adaptor/container_api_adaptor/huawei/pkg/apis/networking.cci.io/v1beta1/register.go +++ /dev/null @@ -1,51 +0,0 @@ -/* -Copyright 2015 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -package v1beta1 - -import ( - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/runtime/schema" -) - -// GroupName is the group name use in this package -const GroupName = "networking.cci.io" - -// SchemeGroupVersion is group version used to register these objects -var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1beta1"} - -// Resource takes an unqualified resource and returns a Group qualified GroupResource -func Resource(resource string) schema.GroupResource { - return SchemeGroupVersion.WithResource(resource).GroupResource() -} - -var ( - // localSchemeBuilder and AddToScheme will stay in k8s.io/kubernetes. - SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) - localSchemeBuilder = &SchemeBuilder - AddToScheme = localSchemeBuilder.AddToScheme -) - -// Adds the list of known types to the given scheme. -func addKnownTypes(scheme *runtime.Scheme) error { - scheme.AddKnownTypes(SchemeGroupVersion, - &Network{}, - &NetworkList{}, - ) - // Add the watch version that applies - metav1.AddToGroupVersion(scheme, SchemeGroupVersion) - return nil -} diff --git a/adaptor/container_api_adaptor/huawei/pkg/apis/networking.cci.io/v1beta1/types.go b/adaptor/container_api_adaptor/huawei/pkg/apis/networking.cci.io/v1beta1/types.go deleted file mode 100644 index bef61bf..0000000 --- a/adaptor/container_api_adaptor/huawei/pkg/apis/networking.cci.io/v1beta1/types.go +++ /dev/null @@ -1,87 +0,0 @@ -/* -Copyright (c) 2017 OpenStack Foundation. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -package v1beta1 - -import ( - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - -// NetworkList is a list of network resource in container. -type NetworkList struct { - metav1.TypeMeta `json:",inline"` - // Standard list metadata. - // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata - // +optional - metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` - Items []Network `json:"items" protobuf:"bytes,2,rep,name=items"` -} - -// +genclient -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - -// Network is a network resource in container. -type Network struct { - metav1.TypeMeta `json:",inline"` - // +optional - metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` - // Spec defines the attributes on a network - // +optional - Spec NetworkSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"` - // Status describes the network status - // +optional - Status NetworkStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"` -} - -// NetworkSpec describes the attributes on a network resource. -type NetworkSpec struct { - // network type - NetworkType string `json:"networkType,omitempty" protobuf:"bytes,5,opt,name=networkType"` - // ID of the VPC to attach - AttachedVPC string `json:"attachedVPC,omitempty" protobuf:"bytes,4,opt,name=attachedVPC"` - // network ID - NetworkID string `json:"networkID,omitempty" protobuf:"bytes,7,opt,name=networkID"` - // Subnet ID - SubnetID string `json:"subnetID,omitempty" protobuf:"bytes,8,opt,name=subnetID"` - // available zone - AvailableZone string `json:"availableZone,omitempty" protobuf:"bytes,9,opt,name=availableZone"` - // The CIDR of the network - CIDR string `json:"cidr,omitempty" protobuf:"bytes,3,opt,name=cidr"` -} - -// NetworkStatus describes the status of a network -type NetworkStatus struct { - // State describes the network state - // +optional - State string `json:"state" protobuf:"bytes,1,opt,name=state"` - // Message describes why network is in current state - // +optional - Message string `json:"message,omitempty" protobuf:"bytes,2,opt,name=message"` -} - -const ( - // NetworkInitializing means the network is initializing - NetworkInitializing = "Initializing" - // NetworkPending means the network is processing - NetworkPending = "Pending" - // NetworkActive means the network is available - NetworkActive = "Active" - // NetworkFailed means the network is not available - NetworkFailed = "Failed" - // NetworkTerminating means the network is undergoing graceful termination - NetworkTerminating = "Terminating" -) diff --git a/adaptor/container_api_adaptor/huawei/pkg/apis/networking.cci.io/v1beta1/zz_generated.deepcopy.go b/adaptor/container_api_adaptor/huawei/pkg/apis/networking.cci.io/v1beta1/zz_generated.deepcopy.go deleted file mode 100644 index d35acf2..0000000 --- a/adaptor/container_api_adaptor/huawei/pkg/apis/networking.cci.io/v1beta1/zz_generated.deepcopy.go +++ /dev/null @@ -1,119 +0,0 @@ -//go:build !ignore_autogenerated -// +build !ignore_autogenerated - -/* -Copyright The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by deepcopy-gen. DO NOT EDIT. - -package v1beta1 - -import ( - runtime "k8s.io/apimachinery/pkg/runtime" -) - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Network) DeepCopyInto(out *Network) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - out.Spec = in.Spec - out.Status = in.Status - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Network. -func (in *Network) DeepCopy() *Network { - if in == nil { - return nil - } - out := new(Network) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *Network) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *NetworkList) DeepCopyInto(out *NetworkList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]Network, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkList. -func (in *NetworkList) DeepCopy() *NetworkList { - if in == nil { - return nil - } - out := new(NetworkList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *NetworkList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *NetworkSpec) DeepCopyInto(out *NetworkSpec) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkSpec. -func (in *NetworkSpec) DeepCopy() *NetworkSpec { - if in == nil { - return nil - } - out := new(NetworkSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *NetworkStatus) DeepCopyInto(out *NetworkStatus) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkStatus. -func (in *NetworkStatus) DeepCopy() *NetworkStatus { - if in == nil { - return nil - } - out := new(NetworkStatus) - in.DeepCopyInto(out) - return out -} diff --git a/adaptor/container_api_adaptor/huawei/pkg/auth/aksk/aksk.go b/adaptor/container_api_adaptor/huawei/pkg/auth/aksk/aksk.go deleted file mode 100644 index 06eeae3..0000000 --- a/adaptor/container_api_adaptor/huawei/pkg/auth/aksk/aksk.go +++ /dev/null @@ -1,91 +0,0 @@ -package aksk - -import ( - "fmt" - "gitlink.org.cn/JCCE/PCM/adaptor/container_api_adaptor/common/auth/aksk" - "gitlink.org.cn/JCCE/PCM/adaptor/container_api_adaptor/common/config" - clientset "gitlink.org.cn/JCCE/PCM/adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1" - "k8s.io/client-go/kubernetes" - "k8s.io/client-go/tools/clientcmd" - "k8s.io/client-go/tools/clientcmd/api" -) - -const ( - apiVersion = "client.authentication.k8s.io/v1beta1" - // 云容器实例 CCI,参考https://developer.huaweicloud.com/endpoint - //cciEndpoint = "https://cci.cn-north-4.myhuaweicloud.com" - // 统一身份认证服务 IAM,参考https://developer.huaweicloud.com/endpoint - iamEndpoint = "https://iam.myhuaweicloud.com" - // 地区和终端节点,参考https://developer.huaweicloud.com/endpoint - //projectName = "cn-north-4" - // 获取AK/SK参考: https://support.huaweicloud.com/devg-cci/cci_kubectl_01.html#cci_kubectl_01__section17023744719 - - //ak = "ATQTIWUT9K66VRMMXKVY" - //sk = "Wa0aixDVuhZOfDZGWvgIJQBHnyiDlGdgDn1Ai5Yy" - - DomainId = "0a4e7f245680f3040fdfc011720e50a0" //账号ID,可以在我的凭证获取 - ProjectId = "0a62ffb0d48026c12fbfc011b8d23f0b" //项目ID,可以在我的凭证获取 - SecurityGroupID = "5157f1d1-fe7d-47a1-beaf-aee027b99755" //安全组ID,可以在安全组控制台获取 - AvailableZone = "cn-north-4a" //az名称,例如cn-north-1a、cn-north-4a或cn-east-3a - VpcID = "0333b519-7903-49e8-908e-ed56216fe921" //虚拟私有云的ID,可在VPC控制台获取 - Cidr = "10.0.0.0/10" //子网网段,例如192.168.128.0/18 - NetworkID = "2a14ac3f-07f7-4479-9930-3ea06a888f54" //<子网的网络ID,可在VPC控制台 > 子网中获取> - SubnetID = "0dea26d7-2544-424c-b7aa-620b206fce35" //<子网ID,可在VPC控制台 > 子网获取> -) - -// NewClient 通过AK/SK认证创建Clientset -func NewClient(cloudStack string, akskPath string, configPath string) (*kubernetes.Clientset, error) { - - configAksk, _ := aksk.AkskConfig(cloudStack, akskPath) - configCommon, _ := config.PCMconfig(configPath) - - ak := configAksk.AccessKey - sk := configAksk.SecretKey - regionId := configCommon.RegionId - cciEndpoint := "https://cci." + regionId + ".myhuaweicloud.com" - - cciConfig, err := clientcmd.BuildConfigFromFlags(cciEndpoint, "") - if err != nil { - return nil, err - } - var optionArgs []string - optionArgs = append(optionArgs, fmt.Sprintf("--iam-endpoint=%s", iamEndpoint)) - optionArgs = append(optionArgs, fmt.Sprintf("--project-name=%s", regionId)) - optionArgs = append(optionArgs, fmt.Sprintf("--ak=%s", ak)) - optionArgs = append(optionArgs, fmt.Sprintf("--sk=%s", sk)) - cciConfig.ExecProvider = &api.ExecConfig{ - Command: "cci-iam-authenticator", - APIVersion: apiVersion, - Args: append([]string{"token"}, optionArgs...), - Env: make([]api.ExecEnvVar, 0), - } - return kubernetes.NewForConfig(cciConfig) -} - -func NewNetworkClient(cloudStack string, akskPath string, configPath string) (*clientset.Clientset, error) { - - configAksk, _ := aksk.AkskConfig(cloudStack, akskPath) - configCommon, _ := config.PCMconfig(configPath) - - ak := configAksk.AccessKey - sk := configAksk.SecretKey - regionId := configCommon.RegionId - cciEndpoint := "https://cci." + regionId + ".myhuaweicloud.com" - - configFromFlags, err := clientcmd.BuildConfigFromFlags(cciEndpoint, "") - if err != nil { - return nil, err - } - var optionArgs []string - optionArgs = append(optionArgs, fmt.Sprintf("--iam-endpoint=%s", iamEndpoint)) - optionArgs = append(optionArgs, fmt.Sprintf("--project-name=%s", regionId)) - optionArgs = append(optionArgs, fmt.Sprintf("--ak=%s", ak)) - optionArgs = append(optionArgs, fmt.Sprintf("--sk=%s", sk)) - configFromFlags.ExecProvider = &api.ExecConfig{ - Command: "cci-iam-authenticator", - APIVersion: apiVersion, - Args: append([]string{"token"}, optionArgs...), - Env: make([]api.ExecEnvVar, 0), - } - return clientset.NewForConfig(configFromFlags) -} diff --git a/adaptor/container_api_adaptor/huawei/pkg/auth/kubeconfig/kubeconfig.go b/adaptor/container_api_adaptor/huawei/pkg/auth/kubeconfig/kubeconfig.go deleted file mode 100644 index 0f26de6..0000000 --- a/adaptor/container_api_adaptor/huawei/pkg/auth/kubeconfig/kubeconfig.go +++ /dev/null @@ -1,16 +0,0 @@ -package kubeconfig - -import ( - "k8s.io/client-go/kubernetes" - "k8s.io/client-go/tools/clientcmd" -) - -// NewClient 通过kubeconfig配置文件创建Clientset -// kubeconfig配置文件需包含认证相关信息,具体请参考《cci-iam-authenticator使用参考》生成kubeconfig配置文件:https://support.huaweicloud.com/devg-cci/cci_kubectl_03.html -func NewClient() (*kubernetes.Clientset, error) { - config, err := clientcmd.BuildConfigFromFlags("", "/path/to/kubeconfig") - if err != nil { - return nil, err - } - return kubernetes.NewForConfig(config) -} diff --git a/adaptor/container_api_adaptor/huawei/pkg/auth/password/password.go b/adaptor/container_api_adaptor/huawei/pkg/auth/password/password.go deleted file mode 100644 index ce5adc2..0000000 --- a/adaptor/container_api_adaptor/huawei/pkg/auth/password/password.go +++ /dev/null @@ -1,45 +0,0 @@ -package password - -import ( - "fmt" - - "k8s.io/client-go/kubernetes" - "k8s.io/client-go/tools/clientcmd" - "k8s.io/client-go/tools/clientcmd/api" -) - -const ( - apiVersion = "client.authentication.k8s.io/v1beta1" - // 云容器实例 CCI,参考https://developer.huaweicloud.com/endpoint - cciEndpoint = "<例如华北-北京四: https://cci.cn-north-4.myhuaweicloud.com>" - // 统一身份认证服务 IAM,参考https://developer.huaweicloud.com/endpoint - iamEndpoint = "<例如华北-北京四: https://iam.cn-north-4.myhuaweicloud.com>" - // 地区和终端节点,参考https://developer.huaweicloud.com/endpoint - projectName = "<例如华北-北京四: cn-north-4>" - userName = "" - domainName = "" - password = "" -) - -// NewClient 通过username/password创建Clientset -func NewClient() (*kubernetes.Clientset, error) { - config, err := clientcmd.BuildConfigFromFlags(cciEndpoint, "") - if err != nil { - return nil, err - } - var optionArgs []string - optionArgs = append(optionArgs, fmt.Sprintf("--iam-endpoint=%s", iamEndpoint)) - optionArgs = append(optionArgs, fmt.Sprintf("--project-name=%s", projectName)) - optionArgs = append(optionArgs, fmt.Sprintf("--token-only=false")) - optionArgs = append(optionArgs, fmt.Sprintf("--domain-name=%s", domainName)) - optionArgs = append(optionArgs, fmt.Sprintf("--user-name=%s", userName)) - optionArgs = append(optionArgs, fmt.Sprintf("--password=%s", password)) - - config.ExecProvider = &api.ExecConfig{ - Command: "cci-iam-authenticator", - APIVersion: apiVersion, - Args: append([]string{"token"}, optionArgs...), - Env: make([]api.ExecEnvVar, 0), - } - return kubernetes.NewForConfig(config) -} diff --git a/adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1/clientset.go b/adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1/clientset.go deleted file mode 100644 index 395ea88..0000000 --- a/adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1/clientset.go +++ /dev/null @@ -1,90 +0,0 @@ -/* -Copyright The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -package v1beta1 - -import ( - networkingcciv1beta1 "gitlink.org.cn/JCCE/PCM/adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1/typed/networking.cci.io/v1beta1" - discovery "k8s.io/client-go/discovery" - rest "k8s.io/client-go/rest" - flowcontrol "k8s.io/client-go/util/flowcontrol" -) - -type Interface interface { - Discovery() discovery.DiscoveryInterface - NetworkingCCIV1beta1() networkingcciv1beta1.NetworkingCCIV1beta1Interface -} - -// Clientset contains the clients for groups. Each group has exactly one -// version included in a Clientset. -type Clientset struct { - *discovery.DiscoveryClient - networkingCCIV1beta1 *networkingcciv1beta1.NetworkingCCIV1beta1Client -} - -// NetworkingCCIV1beta1 retrieves the NetworkingCCIV1beta1Client -func (c *Clientset) NetworkingCCIV1beta1() networkingcciv1beta1.NetworkingCCIV1beta1Interface { - return c.networkingCCIV1beta1 -} - -// Discovery retrieves the DiscoveryClient -func (c *Clientset) Discovery() discovery.DiscoveryInterface { - if c == nil { - return nil - } - return c.DiscoveryClient -} - -// NewForConfig creates a new Clientset for the given config. -func NewForConfig(c *rest.Config) (*Clientset, error) { - configShallowCopy := *c - if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 { - configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst) - } - var cs Clientset - var err error - cs.networkingCCIV1beta1, err = networkingcciv1beta1.NewForConfig(&configShallowCopy) - if err != nil { - return nil, err - } - - cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfig(&configShallowCopy) - if err != nil { - return nil, err - } - return &cs, nil -} - -// NewForConfigOrDie creates a new Clientset for the given config and -// panics if there is an error in the config. -func NewForConfigOrDie(c *rest.Config) *Clientset { - var cs Clientset - cs.networkingCCIV1beta1 = networkingcciv1beta1.NewForConfigOrDie(c) - - cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c) - return &cs -} - -// New creates a new Clientset for the given RESTClient. -func New(c rest.Interface) *Clientset { - var cs Clientset - cs.networkingCCIV1beta1 = networkingcciv1beta1.New(c) - - cs.DiscoveryClient = discovery.NewDiscoveryClient(c) - return &cs -} diff --git a/adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1/doc.go b/adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1/doc.go deleted file mode 100644 index 5599560..0000000 --- a/adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1/doc.go +++ /dev/null @@ -1,20 +0,0 @@ -/* -Copyright The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -// This package has the automatically generated clientset. -package v1beta1 diff --git a/adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1/fake/clientset_generated.go b/adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1/fake/clientset_generated.go deleted file mode 100644 index a9e5d77..0000000 --- a/adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1/fake/clientset_generated.go +++ /dev/null @@ -1,82 +0,0 @@ -/* -Copyright The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -package fake - -import ( - clientset "gitlink.org.cn/JCCE/PCM/adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1" - networkingcciv1beta1 "gitlink.org.cn/JCCE/PCM/adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1/typed/networking.cci.io/v1beta1" - fakenetworkingcciv1beta1 "gitlink.org.cn/JCCE/PCM/adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1/typed/networking.cci.io/v1beta1/fake" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - "k8s.io/client-go/discovery" - fakediscovery "k8s.io/client-go/discovery/fake" - "k8s.io/client-go/testing" -) - -// NewSimpleClientset returns a clientset that will respond with the provided objects. -// It's backed by a very simple object tracker that processes creates, updates and deletions as-is, -// without applying any validations and/or defaults. It shouldn't be considered a replacement -// for a real clientset and is mostly useful in simple unit tests. -func NewSimpleClientset(objects ...runtime.Object) *Clientset { - o := testing.NewObjectTracker(scheme, codecs.UniversalDecoder()) - for _, obj := range objects { - if err := o.Add(obj); err != nil { - panic(err) - } - } - - cs := &Clientset{tracker: o} - cs.discovery = &fakediscovery.FakeDiscovery{Fake: &cs.Fake} - cs.AddReactor("*", "*", testing.ObjectReaction(o)) - cs.AddWatchReactor("*", func(action testing.Action) (handled bool, ret watch.Interface, err error) { - gvr := action.GetResource() - ns := action.GetNamespace() - watch, err := o.Watch(gvr, ns) - if err != nil { - return false, nil, err - } - return true, watch, nil - }) - - return cs -} - -// Clientset implements clientset.Interface. Meant to be embedded into a -// struct to get a default implementation. This makes faking out just the method -// you want to test easier. -type Clientset struct { - testing.Fake - discovery *fakediscovery.FakeDiscovery - tracker testing.ObjectTracker -} - -func (c *Clientset) Discovery() discovery.DiscoveryInterface { - return c.discovery -} - -func (c *Clientset) Tracker() testing.ObjectTracker { - return c.tracker -} - -var _ clientset.Interface = &Clientset{} - -// NetworkingCCIV1beta1 retrieves the NetworkingCCIV1beta1Client -func (c *Clientset) NetworkingCCIV1beta1() networkingcciv1beta1.NetworkingCCIV1beta1Interface { - return &fakenetworkingcciv1beta1.FakeNetworkingCCIV1beta1{Fake: &c.Fake} -} diff --git a/adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1/fake/doc.go b/adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1/fake/doc.go deleted file mode 100644 index 9b99e71..0000000 --- a/adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1/fake/doc.go +++ /dev/null @@ -1,20 +0,0 @@ -/* -Copyright The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -// This package has the automatically generated fake clientset. -package fake diff --git a/adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1/fake/register.go b/adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1/fake/register.go deleted file mode 100644 index 49f5cb5..0000000 --- a/adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1/fake/register.go +++ /dev/null @@ -1,56 +0,0 @@ -/* -Copyright The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -package fake - -import ( - networkingcciv1beta1 "gitlink.org.cn/JCCE/PCM/adaptor/container_api_adaptor/huawei/pkg/apis/networking.cci.io/v1beta1" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - runtime "k8s.io/apimachinery/pkg/runtime" - schema "k8s.io/apimachinery/pkg/runtime/schema" - serializer "k8s.io/apimachinery/pkg/runtime/serializer" - utilruntime "k8s.io/apimachinery/pkg/util/runtime" -) - -var scheme = runtime.NewScheme() -var codecs = serializer.NewCodecFactory(scheme) -var parameterCodec = runtime.NewParameterCodec(scheme) -var localSchemeBuilder = runtime.SchemeBuilder{ - networkingcciv1beta1.AddToScheme, -} - -// AddToScheme adds all types of this clientset into the given scheme. This allows composition -// of clientsets, like in: -// -// import ( -// "k8s.io/client-go/kubernetes" -// clientsetscheme "k8s.io/client-go/kubernetes/scheme" -// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" -// ) -// -// kclientset, _ := kubernetes.NewForConfig(c) -// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) -// -// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types -// correctly. -var AddToScheme = localSchemeBuilder.AddToScheme - -func init() { - v1.AddToGroupVersion(scheme, schema.GroupVersion{Version: "v1"}) - utilruntime.Must(AddToScheme(scheme)) -} diff --git a/adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1/scheme/doc.go b/adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1/scheme/doc.go deleted file mode 100644 index 7dc3756..0000000 --- a/adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1/scheme/doc.go +++ /dev/null @@ -1,20 +0,0 @@ -/* -Copyright The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -// This package contains the scheme of the automatically generated clientset. -package scheme diff --git a/adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1/scheme/register.go b/adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1/scheme/register.go deleted file mode 100644 index dadfd83..0000000 --- a/adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1/scheme/register.go +++ /dev/null @@ -1,56 +0,0 @@ -/* -Copyright The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -package scheme - -import ( - networkingcciv1beta1 "gitlink.org.cn/JCCE/PCM/adaptor/container_api_adaptor/huawei/pkg/apis/networking.cci.io/v1beta1" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - runtime "k8s.io/apimachinery/pkg/runtime" - schema "k8s.io/apimachinery/pkg/runtime/schema" - serializer "k8s.io/apimachinery/pkg/runtime/serializer" - utilruntime "k8s.io/apimachinery/pkg/util/runtime" -) - -var Scheme = runtime.NewScheme() -var Codecs = serializer.NewCodecFactory(Scheme) -var ParameterCodec = runtime.NewParameterCodec(Scheme) -var localSchemeBuilder = runtime.SchemeBuilder{ - networkingcciv1beta1.AddToScheme, -} - -// AddToScheme adds all types of this clientset into the given scheme. This allows composition -// of clientsets, like in: -// -// import ( -// "k8s.io/client-go/kubernetes" -// clientsetscheme "k8s.io/client-go/kubernetes/scheme" -// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" -// ) -// -// kclientset, _ := kubernetes.NewForConfig(c) -// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) -// -// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types -// correctly. -var AddToScheme = localSchemeBuilder.AddToScheme - -func init() { - v1.AddToGroupVersion(Scheme, schema.GroupVersion{Version: "v1"}) - utilruntime.Must(AddToScheme(Scheme)) -} diff --git a/adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1/typed/networking.cci.io/v1beta1/doc.go b/adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1/typed/networking.cci.io/v1beta1/doc.go deleted file mode 100644 index 7711019..0000000 --- a/adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1/typed/networking.cci.io/v1beta1/doc.go +++ /dev/null @@ -1,20 +0,0 @@ -/* -Copyright The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -// This package has the automatically generated typed clients. -package v1beta1 diff --git a/adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1/typed/networking.cci.io/v1beta1/fake/doc.go b/adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1/typed/networking.cci.io/v1beta1/fake/doc.go deleted file mode 100644 index 16f4439..0000000 --- a/adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1/typed/networking.cci.io/v1beta1/fake/doc.go +++ /dev/null @@ -1,20 +0,0 @@ -/* -Copyright The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -// Package fake has the automatically generated clients. -package fake diff --git a/adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1/typed/networking.cci.io/v1beta1/fake/fake_network.go b/adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1/typed/networking.cci.io/v1beta1/fake/fake_network.go deleted file mode 100644 index 1d67ad3..0000000 --- a/adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1/typed/networking.cci.io/v1beta1/fake/fake_network.go +++ /dev/null @@ -1,140 +0,0 @@ -/* -Copyright The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -package fake - -import ( - v1beta1 "gitlink.org.cn/JCCE/PCM/adaptor/container_api_adaptor/huawei/pkg/apis/networking.cci.io/v1beta1" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - labels "k8s.io/apimachinery/pkg/labels" - schema "k8s.io/apimachinery/pkg/runtime/schema" - types "k8s.io/apimachinery/pkg/types" - watch "k8s.io/apimachinery/pkg/watch" - testing "k8s.io/client-go/testing" -) - -// FakeNetworks implements NetworkInterface -type FakeNetworks struct { - Fake *FakeNetworkingCCIV1beta1 - ns string -} - -var networksResource = schema.GroupVersionResource{Group: "networking.cci.io", Version: "v1beta1", Resource: "networks"} - -var networksKind = schema.GroupVersionKind{Group: "networking.cci.io", Version: "v1beta1", Kind: "Network"} - -// Get takes name of the network, and returns the corresponding network object, and an error if there is any. -func (c *FakeNetworks) Get(name string, options v1.GetOptions) (result *v1beta1.Network, err error) { - obj, err := c.Fake. - Invokes(testing.NewGetAction(networksResource, c.ns, name), &v1beta1.Network{}) - - if obj == nil { - return nil, err - } - return obj.(*v1beta1.Network), err -} - -// List takes label and field selectors, and returns the list of Networks that match those selectors. -func (c *FakeNetworks) List(opts v1.ListOptions) (result *v1beta1.NetworkList, err error) { - obj, err := c.Fake. - Invokes(testing.NewListAction(networksResource, networksKind, c.ns, opts), &v1beta1.NetworkList{}) - - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &v1beta1.NetworkList{ListMeta: obj.(*v1beta1.NetworkList).ListMeta} - for _, item := range obj.(*v1beta1.NetworkList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -// Watch returns a watch.Interface that watches the requested networks. -func (c *FakeNetworks) Watch(opts v1.ListOptions) (watch.Interface, error) { - return c.Fake. - InvokesWatch(testing.NewWatchAction(networksResource, c.ns, opts)) - -} - -// Create takes the representation of a network and creates it. Returns the server's representation of the network, and an error, if there is any. -func (c *FakeNetworks) Create(network *v1beta1.Network) (result *v1beta1.Network, err error) { - obj, err := c.Fake. - Invokes(testing.NewCreateAction(networksResource, c.ns, network), &v1beta1.Network{}) - - if obj == nil { - return nil, err - } - return obj.(*v1beta1.Network), err -} - -// Update takes the representation of a network and updates it. Returns the server's representation of the network, and an error, if there is any. -func (c *FakeNetworks) Update(network *v1beta1.Network) (result *v1beta1.Network, err error) { - obj, err := c.Fake. - Invokes(testing.NewUpdateAction(networksResource, c.ns, network), &v1beta1.Network{}) - - if obj == nil { - return nil, err - } - return obj.(*v1beta1.Network), err -} - -// UpdateStatus was generated because the type contains a Status member. -// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *FakeNetworks) UpdateStatus(network *v1beta1.Network) (*v1beta1.Network, error) { - obj, err := c.Fake. - Invokes(testing.NewUpdateSubresourceAction(networksResource, "status", c.ns, network), &v1beta1.Network{}) - - if obj == nil { - return nil, err - } - return obj.(*v1beta1.Network), err -} - -// Delete takes name of the network and deletes it. Returns an error if one occurs. -func (c *FakeNetworks) Delete(name string, options *v1.DeleteOptions) error { - _, err := c.Fake. - Invokes(testing.NewDeleteAction(networksResource, c.ns, name), &v1beta1.Network{}) - - return err -} - -// DeleteCollection deletes a collection of objects. -func (c *FakeNetworks) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { - action := testing.NewDeleteCollectionAction(networksResource, c.ns, listOptions) - - _, err := c.Fake.Invokes(action, &v1beta1.NetworkList{}) - return err -} - -// Patch applies the patch and returns the patched network. -func (c *FakeNetworks) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.Network, err error) { - obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(networksResource, c.ns, name, pt, data, subresources...), &v1beta1.Network{}) - - if obj == nil { - return nil, err - } - return obj.(*v1beta1.Network), err -} diff --git a/adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1/typed/networking.cci.io/v1beta1/fake/fake_networking.cci.io_client.go b/adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1/typed/networking.cci.io/v1beta1/fake/fake_networking.cci.io_client.go deleted file mode 100644 index c2d4678..0000000 --- a/adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1/typed/networking.cci.io/v1beta1/fake/fake_networking.cci.io_client.go +++ /dev/null @@ -1,40 +0,0 @@ -/* -Copyright The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -package fake - -import ( - v1beta1 "gitlink.org.cn/JCCE/PCM/adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1/typed/networking.cci.io/v1beta1" - rest "k8s.io/client-go/rest" - testing "k8s.io/client-go/testing" -) - -type FakeNetworkingCCIV1beta1 struct { - *testing.Fake -} - -func (c *FakeNetworkingCCIV1beta1) Networks(namespace string) v1beta1.NetworkInterface { - return &FakeNetworks{c, namespace} -} - -// RESTClient returns a RESTClient that is used to communicate -// with API server by this client implementation. -func (c *FakeNetworkingCCIV1beta1) RESTClient() rest.Interface { - var ret *rest.RESTClient - return ret -} diff --git a/adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1/typed/networking.cci.io/v1beta1/generated_expansion.go b/adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1/typed/networking.cci.io/v1beta1/generated_expansion.go deleted file mode 100644 index 6cedf6f..0000000 --- a/adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1/typed/networking.cci.io/v1beta1/generated_expansion.go +++ /dev/null @@ -1,21 +0,0 @@ -/* -Copyright The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -package v1beta1 - -type NetworkExpansion interface{} diff --git a/adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1/typed/networking.cci.io/v1beta1/network.go b/adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1/typed/networking.cci.io/v1beta1/network.go deleted file mode 100644 index 416669f..0000000 --- a/adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1/typed/networking.cci.io/v1beta1/network.go +++ /dev/null @@ -1,191 +0,0 @@ -/* -Copyright The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -package v1beta1 - -import ( - "time" - - v1beta1 "gitlink.org.cn/JCCE/PCM/adaptor/container_api_adaptor/huawei/pkg/apis/networking.cci.io/v1beta1" - scheme "gitlink.org.cn/JCCE/PCM/adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1/scheme" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - types "k8s.io/apimachinery/pkg/types" - watch "k8s.io/apimachinery/pkg/watch" - rest "k8s.io/client-go/rest" -) - -// NetworksGetter has a method to return a NetworkInterface. -// A group's client should implement this interface. -type NetworksGetter interface { - Networks(namespace string) NetworkInterface -} - -// NetworkInterface has methods to work with Network resources. -type NetworkInterface interface { - Create(*v1beta1.Network) (*v1beta1.Network, error) - Update(*v1beta1.Network) (*v1beta1.Network, error) - UpdateStatus(*v1beta1.Network) (*v1beta1.Network, error) - Delete(name string, options *v1.DeleteOptions) error - DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error - Get(name string, options v1.GetOptions) (*v1beta1.Network, error) - List(opts v1.ListOptions) (*v1beta1.NetworkList, error) - Watch(opts v1.ListOptions) (watch.Interface, error) - Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.Network, err error) - NetworkExpansion -} - -// networks implements NetworkInterface -type networks struct { - client rest.Interface - ns string -} - -// newNetworks returns a Networks -func newNetworks(c *NetworkingCCIV1beta1Client, namespace string) *networks { - return &networks{ - client: c.RESTClient(), - ns: namespace, - } -} - -// Get takes name of the network, and returns the corresponding network object, and an error if there is any. -func (c *networks) Get(name string, options v1.GetOptions) (result *v1beta1.Network, err error) { - result = &v1beta1.Network{} - err = c.client.Get(). - Namespace(c.ns). - Resource("networks"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of Networks that match those selectors. -func (c *networks) List(opts v1.ListOptions) (result *v1beta1.NetworkList, err error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - result = &v1beta1.NetworkList{} - err = c.client.Get(). - Namespace(c.ns). - Resource("networks"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Do(). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested networks. -func (c *networks) Watch(opts v1.ListOptions) (watch.Interface, error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - opts.Watch = true - return c.client.Get(). - Namespace(c.ns). - Resource("networks"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Watch() -} - -// Create takes the representation of a network and creates it. Returns the server's representation of the network, and an error, if there is any. -func (c *networks) Create(network *v1beta1.Network) (result *v1beta1.Network, err error) { - result = &v1beta1.Network{} - err = c.client.Post(). - Namespace(c.ns). - Resource("networks"). - Body(network). - Do(). - Into(result) - return -} - -// Update takes the representation of a network and updates it. Returns the server's representation of the network, and an error, if there is any. -func (c *networks) Update(network *v1beta1.Network) (result *v1beta1.Network, err error) { - result = &v1beta1.Network{} - err = c.client.Put(). - Namespace(c.ns). - Resource("networks"). - Name(network.Name). - Body(network). - Do(). - Into(result) - return -} - -// UpdateStatus was generated because the type contains a Status member. -// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). - -func (c *networks) UpdateStatus(network *v1beta1.Network) (result *v1beta1.Network, err error) { - result = &v1beta1.Network{} - err = c.client.Put(). - Namespace(c.ns). - Resource("networks"). - Name(network.Name). - SubResource("status"). - Body(network). - Do(). - Into(result) - return -} - -// Delete takes name of the network and deletes it. Returns an error if one occurs. -func (c *networks) Delete(name string, options *v1.DeleteOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("networks"). - Name(name). - Body(options). - Do(). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *networks) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { - var timeout time.Duration - if listOptions.TimeoutSeconds != nil { - timeout = time.Duration(*listOptions.TimeoutSeconds) * time.Second - } - return c.client.Delete(). - Namespace(c.ns). - Resource("networks"). - VersionedParams(&listOptions, scheme.ParameterCodec). - Timeout(timeout). - Body(options). - Do(). - Error() -} - -// Patch applies the patch and returns the patched network. -func (c *networks) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.Network, err error) { - result = &v1beta1.Network{} - err = c.client.Patch(pt). - Namespace(c.ns). - Resource("networks"). - SubResource(subresources...). - Name(name). - Body(data). - Do(). - Into(result) - return -} diff --git a/adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1/typed/networking.cci.io/v1beta1/networking.cci.io_client.go b/adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1/typed/networking.cci.io/v1beta1/networking.cci.io_client.go deleted file mode 100644 index 4fb8ec2..0000000 --- a/adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1/typed/networking.cci.io/v1beta1/networking.cci.io_client.go +++ /dev/null @@ -1,89 +0,0 @@ -/* -Copyright The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -package v1beta1 - -import ( - v1beta1 "gitlink.org.cn/JCCE/PCM/adaptor/container_api_adaptor/huawei/pkg/apis/networking.cci.io/v1beta1" - "gitlink.org.cn/JCCE/PCM/adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1/scheme" - rest "k8s.io/client-go/rest" -) - -type NetworkingCCIV1beta1Interface interface { - RESTClient() rest.Interface - NetworksGetter -} - -// NetworkingCCIV1beta1Client is used to interact with features provided by the networking.cci.io group. -type NetworkingCCIV1beta1Client struct { - restClient rest.Interface -} - -func (c *NetworkingCCIV1beta1Client) Networks(namespace string) NetworkInterface { - return newNetworks(c, namespace) -} - -// NewForConfig creates a new NetworkingCCIV1beta1Client for the given config. -func NewForConfig(c *rest.Config) (*NetworkingCCIV1beta1Client, error) { - config := *c - if err := setConfigDefaults(&config); err != nil { - return nil, err - } - client, err := rest.RESTClientFor(&config) - if err != nil { - return nil, err - } - return &NetworkingCCIV1beta1Client{client}, nil -} - -// NewForConfigOrDie creates a new NetworkingCCIV1beta1Client for the given config and -// panics if there is an error in the config. -func NewForConfigOrDie(c *rest.Config) *NetworkingCCIV1beta1Client { - client, err := NewForConfig(c) - if err != nil { - panic(err) - } - return client -} - -// New creates a new NetworkingCCIV1beta1Client for the given RESTClient. -func New(c rest.Interface) *NetworkingCCIV1beta1Client { - return &NetworkingCCIV1beta1Client{c} -} - -func setConfigDefaults(config *rest.Config) error { - gv := v1beta1.SchemeGroupVersion - config.GroupVersion = &gv - config.APIPath = "/apis" - config.NegotiatedSerializer = scheme.Codecs.WithoutConversion() - - if config.UserAgent == "" { - config.UserAgent = rest.DefaultKubernetesUserAgent() - } - - return nil -} - -// RESTClient returns a RESTClient that is used to communicate -// with API server by this client implementation. -func (c *NetworkingCCIV1beta1Client) RESTClient() rest.Interface { - if c == nil { - return nil - } - return c.restClient -} diff --git a/adaptor/container_api_adaptor/huawei/resources/deployment/deployment.go b/adaptor/container_api_adaptor/huawei/resources/deployment/deployment.go deleted file mode 100644 index fb19902..0000000 --- a/adaptor/container_api_adaptor/huawei/resources/deployment/deployment.go +++ /dev/null @@ -1,77 +0,0 @@ -package deployment - -import ( - v1 "k8s.io/api/apps/v1" - corev1 "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/api/resource" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/client-go/kubernetes" -) - -const ( - app = "test-k8s-client-deployment" - namespace = "test-k8s-client-namespace1" -) - -// CreateDeployment 创建Deployment -// API参考:https://support.huaweicloud.com/api-cci/createAppsV1NamespacedDeployment.html -func CreateDeployment(client *kubernetes.Clientset) (*v1.Deployment, error) { - var replicas int32 = 2 - var priority int32 = 0 - - container := corev1.Container{ - Name: "container-0", - Image: "library/nginx:stable-alpine-perl", - Resources: corev1.ResourceRequirements{ - Requests: map[corev1.ResourceName]resource.Quantity{ - corev1.ResourceCPU: resource.MustParse("500m"), - corev1.ResourceMemory: resource.MustParse("1024Mi"), - }, - Limits: map[corev1.ResourceName]resource.Quantity{ - corev1.ResourceCPU: resource.MustParse("500m"), - corev1.ResourceMemory: resource.MustParse("1024Mi"), - }, - }, - } - - podTemplate := corev1.PodTemplateSpec{ - ObjectMeta: metav1.ObjectMeta{Labels: map[string]string{"app": app}}, - Spec: corev1.PodSpec{ - Priority: &priority, - ImagePullSecrets: []corev1.LocalObjectReference{{Name: "imagepull-secret"}}, - Containers: []corev1.Container{container}, - }, - } - - deployment := v1.Deployment{ - TypeMeta: metav1.TypeMeta{ - APIVersion: "apps/v1", - Kind: "Deployment", - }, - ObjectMeta: metav1.ObjectMeta{ - Name: app, - }, - Spec: v1.DeploymentSpec{ - Replicas: &replicas, - Selector: &metav1.LabelSelector{ - MatchLabels: map[string]string{ - "app": app, - }, - }, - Template: podTemplate, - }, - } - return client.AppsV1().Deployments(namespace).Create(&deployment) -} - -// DeleteDeployment 删除Deployment -// API参考:https://support.huaweicloud.com/api-cci/deleteAppsV1NamespacedDeployment.html -func DeleteDeployment(client *kubernetes.Clientset) error { - return client.AppsV1().Deployments(namespace).Delete(app, &metav1.DeleteOptions{}) -} - -// GetDeployment 查询Deployment -// API参考:https://support.huaweicloud.com/api-cci/readAppsV1NamespacedDeployment.html -func GetDeployment(client *kubernetes.Clientset) (*v1.Deployment, error) { - return client.AppsV1().Deployments(namespace).Get(app, metav1.GetOptions{}) -} diff --git a/adaptor/container_api_adaptor/huawei/resources/namespace/namespace.go b/adaptor/container_api_adaptor/huawei/resources/namespace/namespace.go deleted file mode 100644 index 8d9c13f..0000000 --- a/adaptor/container_api_adaptor/huawei/resources/namespace/namespace.go +++ /dev/null @@ -1,54 +0,0 @@ -package namespace - -import ( - "time" - - corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/util/wait" - "k8s.io/client-go/kubernetes" -) - -const ( - namespace = "test-k8s-client-namespace1" -) - -// CreateNamespace 创建命名空间 -// API参考:https://support.huaweicloud.com/api-cci/createCoreV1Namespace.html -func CreateNamespace(cs *kubernetes.Clientset) (*corev1.Namespace, error) { - namespace := &corev1.Namespace{ - TypeMeta: metav1.TypeMeta{}, - ObjectMeta: metav1.ObjectMeta{ - Name: namespace, - Annotations: map[string]string{ - "namespace.kubernetes.io/flavor": "general-computing", - "network.cci.io/warm-pool-size": "10", - }, - Labels: map[string]string{ - "rbac.authorization.cci.io/enable-k8s-rbac": "false", - }, - }, - } - return cs.CoreV1().Namespaces().Create(namespace) -} - -// DeleteNamespace 删除Namespace -// API参考:https://support.huaweicloud.com/api-cci/deleteCoreV1Namespace.html -func DeleteNamespace(cs *kubernetes.Clientset) error { - return cs.CoreV1().Namespaces().Delete(namespace, &metav1.DeleteOptions{}) -} - -// WaitNamespaceActive 查询Namespace状态,等待其状态变为"Active" -// API参考:https://support.huaweicloud.com/api-cci/readCoreV1Namespace.html -func WaitNamespaceActive(cs *kubernetes.Clientset) error { - return wait.Poll(time.Second*5, time.Second*30, func() (done bool, err error) { - ns, err := cs.CoreV1().Namespaces().Get(namespace, metav1.GetOptions{}) - if err != nil { - return false, err - } - if ns.Status.Phase == corev1.NamespaceActive { - return true, nil - } - return false, nil - }) -} diff --git a/adaptor/container_api_adaptor/huawei/resources/network/network.go b/adaptor/container_api_adaptor/huawei/resources/network/network.go deleted file mode 100644 index b645c42..0000000 --- a/adaptor/container_api_adaptor/huawei/resources/network/network.go +++ /dev/null @@ -1,58 +0,0 @@ -package network - -import ( - "gitlink.org.cn/JCCE/PCM/adaptor/container_api_adaptor/huawei/pkg/apis/networking.cci.io/v1beta1" - "gitlink.org.cn/JCCE/PCM/adaptor/container_api_adaptor/huawei/pkg/auth/aksk" - "time" - - clientset "gitlink.org.cn/JCCE/PCM/adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/util/wait" -) - -const ( - name = "test-k8s-client-namespace-cn-north-1-default-network" - namespace = "test-k8s-client-namespace1" -) - -// CreateNetwork 创建Network,并等待其状态变更为Active -// 参考《Namespace和Network》 https://support.huaweicloud.com/devg-cci/cci_05_0023.html -// API参考:https://support.huaweicloud.com/api-cci/createNetworkingCciIoV1beta1NamespacedNetwork.html -func CreateNetwork(cs *clientset.Clientset) (*v1beta1.Network, error) { - - network := &v1beta1.Network{ - ObjectMeta: metav1.ObjectMeta{ - Annotations: map[string]string{ - "network.alpha.kubernetes.io/default-security-group": aksk.SecurityGroupID, - "network.alpha.kubernetes.io/domain-id": aksk.DomainId, - "network.alpha.kubernetes.io/project-id": aksk.ProjectId, - }, - Name: name, - }, - Spec: v1beta1.NetworkSpec{ - AvailableZone: aksk.AvailableZone, - CIDR: aksk.Cidr, - AttachedVPC: aksk.VpcID, - NetworkID: aksk.NetworkID, - NetworkType: "underlay_neutron", - SubnetID: aksk.SubnetID, - }, - } - network, err := cs.NetworkingCCIV1beta1().Networks(namespace).Create(network) - if err != nil { - return nil, err - } - - // 查询Network状态,等待其状态变为"Active" - err = wait.Poll(time.Second*5, time.Second*30, func() (done bool, err error) { - network, err = cs.NetworkingCCIV1beta1().Networks(namespace).Get(name, metav1.GetOptions{}) - if err != nil { - return false, err - } - if network.Status.State == v1beta1.NetworkActive { - return true, nil - } - return false, nil - }) - return network, err -} diff --git a/adaptor/container_api_adaptor/huawei/resources/pod/pod.go b/adaptor/container_api_adaptor/huawei/resources/pod/pod.go deleted file mode 100644 index 9b3c14d..0000000 --- a/adaptor/container_api_adaptor/huawei/resources/pod/pod.go +++ /dev/null @@ -1,134 +0,0 @@ -package pod - -import ( - "fmt" - "gitlink.org.cn/JCCE/PCM/adaptor/container_api_adaptor/common/config" - corev1 "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/api/resource" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/client-go/kubernetes" -) - -// CreatePod 创建Pod -func CreatePod(client *kubernetes.Clientset, configPath string) (*corev1.Pod, error) { - - var configCommon config.PCMContainerConfig - configCommon, _ = config.PCMconfig(configPath) - - nameSpace := configCommon.NameSpace - podName := configCommon.ContainerGroupName - containerImage := configCommon.ContainerImage - containerName := configCommon.ContainerName - cpuPod := configCommon.CpuPod - memoryPod := configCommon.MemoryPod - pod := corev1.Pod{ - TypeMeta: metav1.TypeMeta{ - APIVersion: "core/V1", - Kind: "Pod", - }, - ObjectMeta: metav1.ObjectMeta{ - Name: podName, - Namespace: nameSpace, - Labels: map[string]string{"name": "testapi"}, - }, - Spec: corev1.PodSpec{ - RestartPolicy: corev1.RestartPolicyAlways, - Containers: []corev1.Container{ - { - Name: containerName, - Image: containerImage, - Resources: corev1.ResourceRequirements{ - Limits: map[corev1.ResourceName]resource.Quantity{ - corev1.ResourceCPU: resource.MustParse(cpuPod), - corev1.ResourceMemory: resource.MustParse(memoryPod), - }, - }, - }, - }, - }, - Status: corev1.PodStatus{}, - } - - fmt.Println("Huawei ContainerGroup created") - return client.CoreV1().Pods(nameSpace).Create(&pod) -} - -// ListPod 查询Namespace下Pod列表 -func ListPod(client *kubernetes.Clientset, configPath string) (*corev1.PodList, error) { - - var configCommon config.PCMContainerConfig - configCommon, _ = config.PCMconfig(configPath) - - nameSpace := configCommon.NameSpace - - podList, _ := client.CoreV1().Pods(nameSpace).List(metav1.ListOptions{}) - fmt.Println("Huawei ContainerGroup list", podList) - - return podList, nil -} - -// UpdatePod 更新指定Pod -/* -// 跨namespace目前有点问题 -*/ -func UpdatePod(client *kubernetes.Clientset, configPath string) (*corev1.Pod, error) { - - var configCommon config.PCMContainerConfig - configCommon, _ = config.PCMconfig(configPath) - - nameSpace := configCommon.NamespaceUpdate - podName := configCommon.ContainerGroupNameUpdate - containerImage := configCommon.ContainerImageUpdate - containerName := configCommon.ContainerNameUpdate - - pod := corev1.Pod{ - TypeMeta: metav1.TypeMeta{ - APIVersion: "core/V1", - Kind: "Pod", - }, - ObjectMeta: metav1.ObjectMeta{ - Name: podName, - Namespace: nameSpace, - Labels: map[string]string{"name": "pod-test2"}, - }, - Spec: corev1.PodSpec{ - RestartPolicy: corev1.RestartPolicyAlways, - Containers: []corev1.Container{ - { - Name: containerName, - Image: containerImage, - Resources: corev1.ResourceRequirements{ - Limits: map[corev1.ResourceName]resource.Quantity{ - corev1.ResourceLimitsCPU: resource.MustParse("500m"), - corev1.ResourceLimitsMemory: resource.MustParse("1Gi"), - }, - Requests: map[corev1.ResourceName]resource.Quantity{ - corev1.ResourceRequestsCPU: resource.MustParse("500m"), - corev1.ResourceRequestsMemory: resource.MustParse("1Gi"), - }, - }, - }, - }, - }, - Status: corev1.PodStatus{}, - } - - podNew, _ := client.CoreV1().Pods(nameSpace).Update(&pod) - fmt.Println("Huawei ContainerGroup updated", podNew) - - return podNew, nil -} - -// DeletePod 删除指定Pod -func DeletePod(client *kubernetes.Clientset, configPath string) error { - - var configCommon config.PCMContainerConfig - configCommon, _ = config.PCMconfig(configPath) - - nameSpace := configCommon.NameSpace - podName := configCommon.ContainerGroupName - - fmt.Println("Huawei ContainerGroup:", podName, " Deleted") - - return client.CoreV1().Pods(nameSpace).Delete(podName, &metav1.DeleteOptions{}) -} diff --git a/adaptor/container_api_adaptor/tencent/eks/config_eks.conf b/adaptor/container_api_adaptor/tencent/eks/config_eks.conf deleted file mode 100644 index 2b5d2e2..0000000 --- a/adaptor/container_api_adaptor/tencent/eks/config_eks.conf +++ /dev/null @@ -1,34 +0,0 @@ -[pod_create_conf] -#区域ID -region_id=ap-beijing -#容器实例名称(pod名) 对应腾讯EksCiName(腾讯必需) -container_group_name=pcm-test-tencent-pod -#镜像地址 对应腾讯 Container.Image(腾讯必需) -container_image=library/nginx:stable-alpine-perl -#容器名称 对应腾讯 Container.Name(腾讯必需) -container_name=pcm-test-tencent-container -#Pod拥有核数 对应腾讯 Cpu(腾讯必需) -cpu_pod=1 -#Pod拥有内存大小 对应腾讯 Memory(腾讯必需) -memory_pod=2 -#安全组ID 对应腾讯 SecurityGroupIds(腾讯必需) -security_group_id=sg-owzbdinl -#子网ID 对应腾讯 SubnetId(腾讯必需) -subnet_id=subnet-n4h73049 -#VPC ID 对应腾讯 VpcId(腾讯必需) -vpc_id=vpc-e8hdbla8 - -[pod_list_conf] -#区域ID -region_id=ap-beijing - -[pod_update_conf] -#区域ID -region_id=ap-beijing -#容器实例ID 对应腾讯EksCiName(腾讯必需) -container_group_id=eksci-pawu7qad -#容器实例名称(pod名) 对应腾讯EksCiName(腾讯必需) -container_group_name=eksci-pawu7qad - -[pod_delete_conf] -container_group_id=eksci-pawu7qad diff --git a/adaptor/container_api_adaptor/tencent/eks/eks.go b/adaptor/container_api_adaptor/tencent/eks/eks.go deleted file mode 100644 index ac7a576..0000000 --- a/adaptor/container_api_adaptor/tencent/eks/eks.go +++ /dev/null @@ -1,138 +0,0 @@ -package eks - -import ( - "fmt" - "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common" - "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/errors" - "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/profile" - tke "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke/v20180525" - "gitlink.org.cn/JCCE/PCM/adaptor/container_api_adaptor/common/auth/aksk" - pcmCommon "gitlink.org.cn/JCCE/PCM/adaptor/container_api_adaptor/common/config" -) - -func CreateEksInstance(cloudStack string, akskPath string, configPath string) { - - configCommon, _ := pcmCommon.PCMconfig(configPath) - configAksk, _ := aksk.AkskConfig(cloudStack, akskPath) - - credential := common.NewCredential( - configAksk.AccessKey, - configAksk.SecretKey, - ) - cpf := profile.NewClientProfile() - cpf.HttpProfile.Endpoint = "tke.tencentcloudapi.com" - client, _ := tke.NewClient(credential, configCommon.RegionId, cpf) - - request := tke.NewCreateEKSContainerInstancesRequest() - - eksCiName := &configCommon.ContainerGroupName - containerName := &configCommon.ContainerName - containerImage := &configCommon.ContainerImage - eksCpu := &configCommon.CpuPodFloat - eksMemory := &configCommon.MemoryPodFloat - securityGroupId := &configCommon.SecurityGroupId - securityGroupIds := make([]*string, 1) - securityGroupIds[0] = securityGroupId - subNetId := &configCommon.SubnetId - vpcId := &configCommon.VpcId - - request.EksCiName = eksCiName - container := make([]*tke.Container, 1) - container[0] = new(tke.Container) - container[0].Name = containerName - container[0].Image = containerImage - //container[0].Cpu = containerCpuPt - //container[0].Memory = containerMemoryPt - - request.Containers = container - request.Cpu = eksCpu - request.Memory = eksMemory - request.SecurityGroupIds = securityGroupIds - request.SubnetId = subNetId - request.VpcId = vpcId - - response, err := client.CreateEKSContainerInstances(request) - if _, ok := err.(*errors.TencentCloudSDKError); ok { - fmt.Printf("An API error has returned: %s", err) - return - } - if err != nil { - panic(err) - } - fmt.Printf("%s", response.ToJsonString()) -} - -func ListEksInstance(cloudStack string, akskPath string, configPath string) { - - configCommon, _ := pcmCommon.PCMconfig(configPath) - configAksk, _ := aksk.AkskConfig(cloudStack, akskPath) - - credential := common.NewCredential(configAksk.AccessKey, configAksk.SecretKey) - cpf := profile.NewClientProfile() - cpf.HttpProfile.Endpoint = "tke.tencentcloudapi.com" - client, _ := tke.NewClient(credential, configCommon.RegionId, cpf) - - request := tke.NewDescribeEKSContainerInstancesRequest() - - response, err := client.DescribeEKSContainerInstances(request) - if _, ok := err.(*errors.TencentCloudSDKError); ok { - fmt.Printf("An API error has returned: %s", err) - return - } - if err != nil { - panic(err) - } - fmt.Printf("%s", response.ToJsonString()) -} - -func UpdateEksInstance(cloudStack string, akskPath string, configPath string) { - - configCommon, _ := pcmCommon.PCMconfig(configPath) - configAksk, _ := aksk.AkskConfig(cloudStack, akskPath) - - credential := common.NewCredential(configAksk.AccessKey, configAksk.SecretKey) - cpf := profile.NewClientProfile() - cpf.HttpProfile.Endpoint = "tke.tencentcloudapi.com" - client, _ := tke.NewClient(credential, configCommon.RegionId, cpf) - - request := tke.NewUpdateEKSContainerInstanceRequest() - request.EksCiId = &configCommon.ContainerGroupIdUpdate - request.Name = &configCommon.ContainerGroupNameUpdate - - response, err := client.UpdateEKSContainerInstance(request) - if _, ok := err.(*errors.TencentCloudSDKError); ok { - fmt.Printf("An API error has returned: %s", err) - return - } - if err != nil { - panic(err) - } - fmt.Printf("%s", response.ToJsonString()) -} - -func DeleteEksInstance(cloudStack string, akskPath string, configPath string) { - - configCommon, _ := pcmCommon.PCMconfig(configPath) - configAksk, _ := aksk.AkskConfig(cloudStack, akskPath) - - credential := common.NewCredential(configAksk.AccessKey, configAksk.SecretKey) - cpf := profile.NewClientProfile() - cpf.HttpProfile.Endpoint = "tke.tencentcloudapi.com" - client, _ := tke.NewClient(credential, configCommon.RegionId, cpf) - - request := tke.NewDeleteEKSContainerInstancesRequest() - eksCiIds := make([]*string, 1) - eksCiIds[0] = &configCommon.ContainerGroupIdDelete - - request.EksCiIds = eksCiIds - - response, err := client.DeleteEKSContainerInstances(request) - if _, ok := err.(*errors.TencentCloudSDKError); ok { - fmt.Printf("An API error has returned: %s", err) - return - } - if err != nil { - panic(err) - } - fmt.Printf("%s", response.ToJsonString()) -} diff --git a/adaptor/func_api_adaptor/func_api_adaptor b/adaptor/func_api_adaptor/func_api_adaptor deleted file mode 100644 index e69de29..0000000 diff --git a/adaptor/pod_adaptor/service/poder/ali_eci.go b/adaptor/pod_adaptor/service/poder/ali_eci.go new file mode 100644 index 0000000..3daffea --- /dev/null +++ b/adaptor/pod_adaptor/service/poder/ali_eci.go @@ -0,0 +1,203 @@ +package poder + +import ( + "context" + "gitlink.org.cn/JCCE/PCM/common/tenanter" + "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbpod" + "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant" + "sync" + + alieci "github.com/aliyun/alibaba-cloud-sdk-go/services/eci" + "github.com/pkg/errors" +) + +var aliClientMutex sync.Mutex + +type AliEci struct { + cli *alieci.Client + region tenanter.Region + tenanter tenanter.Tenanter +} + +func newAliEciClient(region tenanter.Region, tenant tenanter.Tenanter) (Poder, error) { + var ( + client *alieci.Client + err error + ) + + switch t := tenant.(type) { + case *tenanter.AccessKeyTenant: + // 阿里云的sdk有一个 map 的并发问题,go test 加上-race 能检测出来,所以这里加一个锁 + aliClientMutex.Lock() + client, err = alieci.NewClientWithAccessKey(region.GetName(), t.GetId(), t.GetSecret()) + aliClientMutex.Unlock() + default: + } + + if err != nil { + return nil, errors.Wrap(err, "init ali ecs client error") + } + + return &AliEci{ + cli: client, + region: region, + tenanter: tenant, + }, nil +} + +func (eci *AliEci) ListPodDetail(ctx context.Context, req *pbpod.ListPodDetailReq) (*pbpod.ListPodDetailResp, error) { + request := alieci.CreateDescribeContainerGroupsRequest() + request.NextToken = req.NextToken + resp, err := eci.cli.DescribeContainerGroups(request) + if err != nil { + return nil, errors.Wrap(err, "Aliyun ListDetail error") + } + + var ecies = make([]*pbpod.PodInstance, len(resp.ContainerGroups)) + for k, v := range resp.ContainerGroups { + ecies[k] = &pbpod.PodInstance{ + Provider: pbtenant.CloudProvider_ali, + AccountName: eci.tenanter.AccountName(), + PodId: v.ContainerGroupId, + PodName: v.ContainerGroupName, + RegionName: eci.region.GetName(), + ContainerImage: v.Containers[k].Image, + ContainerName: v.Containers[k].Name, + CpuPod: v.Cpu, + MemoryPod: v.Memory, + SecurityGroupId: v.SecurityGroupId, + SubnetId: v.InternetIp, + VpcId: v.VpcId, + Namespace: "", + } + + } + + isFinished := false + if len(ecies) < int(req.PageSize) { + isFinished = true + } + + return &pbpod.ListPodDetailResp{ + Pods: ecies, + Finished: isFinished, + PageNumber: req.PageNumber + 1, + PageSize: req.PageSize, + NextToken: resp.NextToken, + RequestId: resp.RequestId, + }, nil +} + +// +//// CreateContainerGroup 创建 +//func CreateContainerGroup(cloudStack string, akskPath string, configPath string) string { +// +// var client *eci.Client +// configCommon, _ := config.PCMconfig(configPath) +// configAksk, _ := aksk.AkskConfig(cloudStack, akskPath) +// +// //创建客户端 +// client, _ = eci.NewClientWithAccessKey(configCommon.RegionId, configAksk.AccessKey, configAksk.SecretKey) +// // 生成创建请求 +// createContainerRequest := eci.CreateCreateContainerGroupRequest() +// // 必需参数 +// //区域ID +// createContainerRequest.RegionId = configCommon.RegionId +// //POD名称 +// createContainerRequest.ContainerGroupName = configCommon.ContainerGroupName +// //容器名称和镜像名称 +// createContainerRequestContainer := make([]eci.CreateContainerGroupContainer, 1) +// createContainerRequestContainer[0].Image = configCommon.ContainerImage +// createContainerRequestContainer[0].Name = configCommon.ContainerName +// createContainerRequest.Container = &createContainerRequestContainer +// +// client.GetConfig().MaxRetryTime = 0 +// createContainerGroupResponse, err := client.CreateContainerGroup(createContainerRequest) +// if err != nil { +// panic(err) +// } +// containerGroupId := createContainerGroupResponse.ContainerGroupId +// fmt.Println("Alibaba ContainerGroup created:", containerGroupId) +// return containerGroupId +//} +// +//// DescribeContainerGroup 查询Pod +//func DescribeContainerGroup(cloudStack string, akskPath string, configPath string) eci.DescribeContainerGroupsContainerGroup0 { +// var client *eci.Client +// +// configCommon, _ := config.PCMconfig(configPath) +// configAksk, _ := aksk.AkskConfig(cloudStack, akskPath) +// client, _ = eci.NewClientWithAccessKey(configCommon.RegionId, configAksk.AccessKey, configAksk.SecretKey) +// +// // 生成查询请求 +// describeContainerGroupsRequest := eci.CreateDescribeContainerGroupsRequest() +// describeContainerGroupsRequest.RegionId = configCommon.RegionIdList +// describeContainerGroupsResponse, err := client.DescribeContainerGroups(describeContainerGroupsRequest) +// if err != nil { +// panic(err) +// } +// describeContainerGroupNumber := len(describeContainerGroupsResponse.ContainerGroups) +// +// //当前区域没有Pod情形的处理 +// if describeContainerGroupsResponse.TotalCount != 1 && describeContainerGroupNumber != 1 { +// fmt.Println("Invalid ContainerGroups count", describeContainerGroupsResponse.TotalCount, describeContainerGroupNumber) +// panic("Invalid ContainerGroups count") +// } +// +// fmt.Println("Alibaba ContainerGroup Name:", describeContainerGroupsResponse.ContainerGroups[0].ContainerGroupName, "\n", +// "ContainerGroup Id:", describeContainerGroupsResponse.ContainerGroups[0].ContainerGroupId) +// +// return describeContainerGroupsResponse.ContainerGroups[0] +//} +// +//// UpdateContainerGroup 更新Pod +//func UpdateContainerGroup(cloudStack string, akskPath string, configPath string) string { +// var client *eci.Client +// +// configCommon, _ := config.PCMconfig(configPath) +// configAksk, _ := aksk.AkskConfig(cloudStack, akskPath) +// +// client, _ = eci.NewClientWithAccessKey(configCommon.RegionId, configAksk.AccessKey, configAksk.SecretKey) +// +// //生成更新请求 +// updateContainerGroupRequest := eci.CreateUpdateContainerGroupRequest() +// updateContainerGroupRequest.RegionId = configCommon.RegionIdUpdate +// updateContainerGroupRequest.ContainerGroupId = configCommon.ContainerGroupIdUpdate +// +// //容器实体内容,这里测试可以修改配置文件中的重启策略 +// updateContainerRequestContainer := make([]eci.UpdateContainerGroupContainer, 1) +// updateContainerRequestContainer[0].Image = configCommon.ContainerImage +// updateContainerRequestContainer[0].Name = configCommon.ContainerName +// updateContainerGroupRequest.Container = &updateContainerRequestContainer +// updateContainerGroupRequest.RestartPolicy = configCommon.RestartPolicyUpdate +// +// updateContainerGroupResponse, err := client.UpdateContainerGroup(updateContainerGroupRequest) +// if err != nil { +// panic(err) +// } +// requestId := updateContainerGroupResponse.RequestId +// fmt.Println("Alibaba ContainerGroup: ", configCommon.ContainerGroupIdUpdate, " Updated with request ID:", requestId) +// return requestId +//} +// +//// DeleteContainerGroup 删除Pod +//func DeleteContainerGroup(cloudStack string, akskPath string, configPath string) string { +// var client *eci.Client +// configCommon, _ := config.PCMconfig(configPath) +// configAksk, _ := aksk.AkskConfig(cloudStack, akskPath) +// client, _ = eci.NewClientWithAccessKey(configCommon.RegionId, configAksk.AccessKey, configAksk.SecretKey) +// +// //生成删除请求 +// deleteContainerGroupRequest := eci.CreateDeleteContainerGroupRequest() +// deleteContainerGroupRequest.RegionId = configCommon.RegionIdDelete +// deleteContainerGroupRequest.ContainerGroupId = configCommon.ContainerGroupIdDelete +// +// deleteContainerGroupResponse, err := client.DeleteContainerGroup(deleteContainerGroupRequest) +// if err != nil { +// panic(err) +// } +// requestId := deleteContainerGroupResponse.RequestId +// fmt.Println("Alibaba ContainerGroup: ", configCommon.ContainerGroupIdUpdate, " Deleted with request ID:", requestId) +// +// return requestId +//} diff --git a/adaptor/pod_adaptor/service/poder/huawei_cci.go b/adaptor/pod_adaptor/service/poder/huawei_cci.go new file mode 100644 index 0000000..733ed27 --- /dev/null +++ b/adaptor/pod_adaptor/service/poder/huawei_cci.go @@ -0,0 +1,135 @@ +package poder + +// +//import ( +// "fmt" +// "gitlink.org.cn/JCCE/PCM/adaptor/pod_adaptor/common/config" +// corev1 "k8s.io/api/core/v1" +// "k8s.io/apimachinery/pkg/api/resource" +// metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +// "k8s.io/client-go/kubernetes" +//) +// +//// CreatePod 创建Pod +//func CreatePod(client *kubernetes.Clientset, configPath string) (*corev1.Pod, error) { +// +// var configCommon config.PCMContainerConfig +// configCommon, _ = config.PCMconfig(configPath) +// +// nameSpace := configCommon.NameSpace +// podName := configCommon.ContainerGroupName +// containerImage := configCommon.ContainerImage +// containerName := configCommon.ContainerName +// cpuPod := configCommon.CpuPod +// memoryPod := configCommon.MemoryPod +// pod := corev1.Pod{ +// TypeMeta: metav1.TypeMeta{ +// APIVersion: "core/V1", +// Kind: "Pod", +// }, +// ObjectMeta: metav1.ObjectMeta{ +// Name: podName, +// Namespace: nameSpace, +// Labels: map[string]string{"name": "testapi"}, +// }, +// Spec: corev1.PodSpec{ +// RestartPolicy: corev1.RestartPolicyAlways, +// Containers: []corev1.Container{ +// { +// Name: containerName, +// Image: containerImage, +// Resources: corev1.ResourceRequirements{ +// Limits: map[corev1.ResourceName]resource.Quantity{ +// corev1.ResourceCPU: resource.MustParse(cpuPod), +// corev1.ResourceMemory: resource.MustParse(memoryPod), +// }, +// }, +// }, +// }, +// }, +// Status: corev1.PodStatus{}, +// } +// +// fmt.Println("Huawei ContainerGroup created") +// return client.CoreV1().Pods(nameSpace).Create(&pod) +//} +// +//// ListPod 查询Namespace下Pod列表 +//func ListPod(client *kubernetes.Clientset, configPath string) (*corev1.PodList, error) { +// +// var configCommon config.PCMContainerConfig +// configCommon, _ = config.PCMconfig(configPath) +// +// nameSpace := configCommon.NameSpace +// +// podList, _ := client.CoreV1().Pods(nameSpace).List(metav1.ListOptions{}) +// fmt.Println("Huawei ContainerGroup list", podList) +// +// return podList, nil +//} +// +//// UpdatePod 更新指定Pod +///* +//// 跨namespace目前有点问题 +//*/ +//func UpdatePod(client *kubernetes.Clientset, configPath string) (*corev1.Pod, error) { +// +// var configCommon config.PCMContainerConfig +// configCommon, _ = config.PCMconfig(configPath) +// +// nameSpace := configCommon.NamespaceUpdate +// podName := configCommon.ContainerGroupNameUpdate +// containerImage := configCommon.ContainerImageUpdate +// containerName := configCommon.ContainerNameUpdate +// +// pod := corev1.Pod{ +// TypeMeta: metav1.TypeMeta{ +// APIVersion: "core/V1", +// Kind: "Pod", +// }, +// ObjectMeta: metav1.ObjectMeta{ +// Name: podName, +// Namespace: nameSpace, +// Labels: map[string]string{"name": "pod-test2"}, +// }, +// Spec: corev1.PodSpec{ +// RestartPolicy: corev1.RestartPolicyAlways, +// Containers: []corev1.Container{ +// { +// Name: containerName, +// Image: containerImage, +// Resources: corev1.ResourceRequirements{ +// Limits: map[corev1.ResourceName]resource.Quantity{ +// corev1.ResourceLimitsCPU: resource.MustParse("500m"), +// corev1.ResourceLimitsMemory: resource.MustParse("1Gi"), +// }, +// Requests: map[corev1.ResourceName]resource.Quantity{ +// corev1.ResourceRequestsCPU: resource.MustParse("500m"), +// corev1.ResourceRequestsMemory: resource.MustParse("1Gi"), +// }, +// }, +// }, +// }, +// }, +// Status: corev1.PodStatus{}, +// } +// +// podNew, _ := client.CoreV1().Pods(nameSpace).Update(&pod) +// fmt.Println("Huawei ContainerGroup updated", podNew) +// +// return podNew, nil +//} +// +//// DeletePod 删除指定Pod +//func DeletePod(client *kubernetes.Clientset, configPath string) error { +// +// var configCommon config.PCMContainerConfig +// configCommon, _ = config.PCMconfig(configPath) +// +// nameSpace := configCommon.NameSpace +// podName := configCommon.ContainerGroupName +// +// fmt.Println("Huawei ContainerGroup:", podName, " Deleted") +// +// return client.CoreV1().Pods(nameSpace).Delete(podName, &metav1.DeleteOptions{}) +//} diff --git a/adaptor/pod_adaptor/service/poder/tencent_eks.go b/adaptor/pod_adaptor/service/poder/tencent_eks.go new file mode 100644 index 0000000..37723ed --- /dev/null +++ b/adaptor/pod_adaptor/service/poder/tencent_eks.go @@ -0,0 +1,139 @@ +package poder + +// +//import ( +// "fmt" +// "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common" +// "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/errors" +// "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/profile" +// tke "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke/v20180525" +// "gitlink.org.cn/JCCE/PCM/adaptor/pod_adaptor/common/auth/aksk" +// pcmCommon "gitlink.org.cn/JCCE/PCM/adaptor/pod_adaptor/common/config" +//) +// +//func CreateEksInstance(cloudStack string, akskPath string, configPath string) { +// +// configCommon, _ := pcmCommon.PCMconfig(configPath) +// configAksk, _ := aksk.AkskConfig(cloudStack, akskPath) +// +// credential := common.NewCredential( +// configAksk.AccessKey, +// configAksk.SecretKey, +// ) +// cpf := profile.NewClientProfile() +// cpf.HttpProfile.Endpoint = "tke.tencentcloudapi.com" +// client, _ := tke.NewClient(credential, configCommon.RegionId, cpf) +// +// request := tke.NewCreateEKSContainerInstancesRequest() +// +// eksCiName := &configCommon.ContainerGroupName +// containerName := &configCommon.ContainerName +// containerImage := &configCommon.ContainerImage +// eksCpu := &configCommon.CpuPodFloat +// eksMemory := &configCommon.MemoryPodFloat +// securityGroupId := &configCommon.SecurityGroupId +// securityGroupIds := make([]*string, 1) +// securityGroupIds[0] = securityGroupId +// subNetId := &configCommon.SubnetId +// vpcId := &configCommon.VpcId +// +// request.EksCiName = eksCiName +// container := make([]*tke.Container, 1) +// container[0] = new(tke.Container) +// container[0].Name = containerName +// container[0].Image = containerImage +// //container[0].Cpu = containerCpuPt +// //container[0].Memory = containerMemoryPt +// +// request.Containers = container +// request.Cpu = eksCpu +// request.Memory = eksMemory +// request.SecurityGroupIds = securityGroupIds +// request.SubnetId = subNetId +// request.VpcId = vpcId +// +// response, err := client.CreateEKSContainerInstances(request) +// if _, ok := err.(*errors.TencentCloudSDKError); ok { +// fmt.Printf("An API error has returned: %s", err) +// return +// } +// if err != nil { +// panic(err) +// } +// fmt.Printf("%s", response.ToJsonString()) +//} +// +//func ListEksInstance(cloudStack string, akskPath string, configPath string) { +// +// configCommon, _ := pcmCommon.PCMconfig(configPath) +// configAksk, _ := aksk.AkskConfig(cloudStack, akskPath) +// +// credential := common.NewCredential(configAksk.AccessKey, configAksk.SecretKey) +// cpf := profile.NewClientProfile() +// cpf.HttpProfile.Endpoint = "tke.tencentcloudapi.com" +// client, _ := tke.NewClient(credential, configCommon.RegionId, cpf) +// +// request := tke.NewDescribeEKSContainerInstancesRequest() +// +// response, err := client.DescribeEKSContainerInstances(request) +// if _, ok := err.(*errors.TencentCloudSDKError); ok { +// fmt.Printf("An API error has returned: %s", err) +// return +// } +// if err != nil { +// panic(err) +// } +// fmt.Printf("%s", response.ToJsonString()) +//} +// +//func UpdateEksInstance(cloudStack string, akskPath string, configPath string) { +// +// configCommon, _ := pcmCommon.PCMconfig(configPath) +// configAksk, _ := aksk.AkskConfig(cloudStack, akskPath) +// +// credential := common.NewCredential(configAksk.AccessKey, configAksk.SecretKey) +// cpf := profile.NewClientProfile() +// cpf.HttpProfile.Endpoint = "tke.tencentcloudapi.com" +// client, _ := tke.NewClient(credential, configCommon.RegionId, cpf) +// +// request := tke.NewUpdateEKSContainerInstanceRequest() +// request.EksCiId = &configCommon.ContainerGroupIdUpdate +// request.Name = &configCommon.ContainerGroupNameUpdate +// +// response, err := client.UpdateEKSContainerInstance(request) +// if _, ok := err.(*errors.TencentCloudSDKError); ok { +// fmt.Printf("An API error has returned: %s", err) +// return +// } +// if err != nil { +// panic(err) +// } +// fmt.Printf("%s", response.ToJsonString()) +//} +// +//func DeleteEksInstance(cloudStack string, akskPath string, configPath string) { +// +// configCommon, _ := pcmCommon.PCMconfig(configPath) +// configAksk, _ := aksk.AkskConfig(cloudStack, akskPath) +// +// credential := common.NewCredential(configAksk.AccessKey, configAksk.SecretKey) +// cpf := profile.NewClientProfile() +// cpf.HttpProfile.Endpoint = "tke.tencentcloudapi.com" +// client, _ := tke.NewClient(credential, configCommon.RegionId, cpf) +// +// request := tke.NewDeleteEKSContainerInstancesRequest() +// eksCiIds := make([]*string, 1) +// eksCiIds[0] = &configCommon.ContainerGroupIdDelete +// +// request.EksCiIds = eksCiIds +// +// response, err := client.DeleteEKSContainerInstances(request) +// if _, ok := err.(*errors.TencentCloudSDKError); ok { +// fmt.Printf("An API error has returned: %s", err) +// return +// } +// if err != nil { +// panic(err) +// } +// fmt.Printf("%s", response.ToJsonString()) +//} diff --git a/adaptor/vm_adaptor/vm_adaptor b/adaptor/vm_adaptor/vm_adaptor deleted file mode 100644 index e69de29..0000000 diff --git a/cm_bridge/cm_adaptor b/cm_bridge/cm_adaptor deleted file mode 100644 index e69de29..0000000 diff --git a/common/server/server.go b/common/server/server.go index 5965160..68d52bb 100644 --- a/common/server/server.go +++ b/common/server/server.go @@ -4,12 +4,14 @@ import ( "context" "gitlink.org.cn/JCCE/PCM/lan_trans/idl/demo" "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbecs" + "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbpod" ) type Server struct { // 使用unsafe可以强制让编译器检查是否实现了相关方法 demo.UnsafeDemoServiceServer pbecs.UnsafeEcsServiceServer + pbpod.UnsafePodServiceServer } func (s *Server) Echo(ctx context.Context, req *demo.StringMessage) (*demo.StringMessage, error) { diff --git a/configs/config.yaml b/configs/config.yaml index 27b43ac..35c9c9f 100644 --- a/configs/config.yaml +++ b/configs/config.yaml @@ -2,13 +2,13 @@ configs: # provider 0:阿里云 1:腾讯云 2:华为云 - provider: 0 name: "ali-PCM" - accessid: "" - accesssecret: "" + accessid: "LTAI5tSCnrhQAdbFhGyWkSL2" + accesssecret: "KN4tqu8lalQdo47SoUQBb88qOWjzYC" - provider: 1 name: "tencent-PCM" - accessid: "" - accesssecret: "" + accessid: "AKIDRefQxnhmuqTU1KRWFl58wQeCE0XoAeEZ" + accesssecret: "LUMVRmGj2kFrEahhZzA5pKvHNSMASntj" - provider: 2 name: "huawei-PCM" - accessid: "" - accesssecret: "" + accessid: "ATQTIWUT9K66VRMMXKVY" + accesssecret: "Wa0aixDVuhZOfDZGWvgIJQBHnyiDlGdgDn1Ai5Yy" diff --git a/go.mod b/go.mod deleted file mode 100644 index f1e37ae..0000000 --- a/go.mod +++ /dev/null @@ -1,53 +0,0 @@ -module gitlink.org.cn/JCCE/PCM - -go 1.17 - -require ( - github.com/Unknwon/goconfig v1.0.0 - github.com/aliyun/alibaba-cloud-sdk-go v1.61.1530 - github.com/go-yaml/yaml v2.1.0+incompatible - github.com/golang/glog v1.0.0 - github.com/grpc-ecosystem/grpc-gateway/v2 v2.10.0 - github.com/huaweicloud/huaweicloud-sdk-go-v3 v0.0.82 - github.com/pkg/errors v0.9.1 - github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.377 - github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm v1.0.377 - github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke v1.0.371 - google.golang.org/genproto v0.0.0-20220317150908-0efb43f6373e - google.golang.org/grpc v1.45.0 - google.golang.org/protobuf v1.28.0 - k8s.io/api v0.0.0-20190620084959-7cf5895f2711 - k8s.io/apimachinery v0.0.0-20190612205821-1799e75a0719 - k8s.io/client-go v0.0.0-20190620085101-78d2af792bab -) - -require ( - github.com/davecgh/go-spew v1.1.1 // indirect - github.com/evanphx/json-patch v0.0.0-20190203023257-5858425f7550 // indirect - github.com/gogo/protobuf v0.0.0-20171007142547-342cbe0a0415 // indirect - github.com/golang/protobuf v1.5.2 // indirect - github.com/google/gofuzz v1.0.0 // indirect - github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d // indirect - github.com/imdario/mergo v0.3.5 // indirect - github.com/jmespath/go-jmespath v0.4.0 // indirect - github.com/json-iterator/go v1.1.10 // indirect - github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect - github.com/modern-go/reflect2 v1.0.1 // indirect - github.com/smartystreets/goconvey v1.7.2 // indirect - github.com/spf13/pflag v1.0.1 // indirect - golang.org/x/crypto v0.0.0-20210920023735-84f357641f63 // indirect - golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd // indirect - golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a // indirect - golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect - golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect - golang.org/x/text v0.3.7 // indirect - golang.org/x/time v0.0.0-20191024005414-555d28b269f0 // indirect - google.golang.org/appengine v1.6.6 // indirect - gopkg.in/inf.v0 v0.9.0 // indirect - gopkg.in/ini.v1 v1.66.2 // indirect - gopkg.in/yaml.v2 v2.4.0 // indirect - k8s.io/klog v0.3.1 // indirect - k8s.io/kube-openapi v0.0.0-20190228160746-b3a7cee44a30 // indirect - k8s.io/utils v0.0.0-20190221042446-c2654d5206da // indirect - sigs.k8s.io/yaml v1.3.0 // indirect -) diff --git a/idl/pbpod/pod.proto b/idl/pbpod/pod.proto new file mode 100644 index 0000000..a95deaf --- /dev/null +++ b/idl/pbpod/pod.proto @@ -0,0 +1,164 @@ +syntax = "proto3"; +package pbpod; + +option go_package = "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbpod"; + +import "idl/pbtenant/tenant.proto"; +import "google/api/annotations.proto"; + +message PodInstance { + // 云类型 + pbtenant.CloudProvider provider = 1; + // 账号名称 + string account_name = 2; + // 实例id + string pod_id = 3; + // 实例名称 + string pod_name = 4; + // 地域,数据中心 + string region_name = 5; + // 镜像 + string container_image = 6; + // 容器名称 + string container_name = 7; + // vcpu数 + float cpu_pod = 8; + // 内存MB + float memory_pod = 9; + + //安全组ID 对应腾讯 SecurityGroupIds(腾讯必需) + string security_group_id = 10; + //子网ID 对应腾讯 SubnetId(腾讯必需) + string subnet_id = 11; + //VPC ID 对应腾讯 VpcId(腾讯必需) + string vpc_id = 12; + //名空间 + string namespace = 13; + +} + + +message CreatePodReq { + // 云类型 + pbtenant.CloudProvider provider = 1; + // 账号名称 + string account_name = 2; + // 实例id + string pod_id = 3; + // 实例名称 + string pod_name = 4; + // 地域,数据中心 + string region_name = 5; + // 镜像 + string container_image = 6; + // 容器名称 + string container_name = 7; + // v cpu数 + float cpu_pod = 8; + // 内存MB + float memory_pod = 9; + //安全组ID 对应腾讯 SecurityGroupIds(腾讯必需) + string security_group_id = 10; + //子网ID 对应腾讯 SubnetId(腾讯必需) + string subnet_id = 11; + //VPC ID 对应腾讯 VpcId(腾讯必需) + string vpc_id = 12; + //名空间 + string namespace = 13; +} + +message CreatePodResp { + // Pod集合 + repeated PodInstance pods = 1; + // 查询是否完成,如果为否-false,则可以将下面三个分页参数填入到请求中,继续查询 + bool finished = 2; + // 请求id,出现问题后提供给云厂商,排查问题 + string request_id = 3; +} + + +message ListPodDetailReq { + // 云名称 + pbtenant.CloudProvider provider = 1; + // 账户名称,根据config.yaml中的配置,默认为第一个配置的账户 + string account_name = 2; + // 区域Id,参考 tenant.proto 中的各个云的区域 + int32 region_id = 3; + // podID + int32 pod_id = 4; + // 分页相关参数,页码 + int32 page_number = 5; + // 分页相关参数,每页数量 + int32 page_size = 6; + // 分页相关参数,下一页的token + string next_token = 7; +} + +message ListPodDetailResp { + // Pod集合 + repeated PodInstance pods = 1; + // 查询是否完成,如果为否-false,则可以将下面三个分页参数填入到请求中,继续查询 + bool finished = 2; + // 分页相关参数,页码 + int32 page_number = 3; + // 分页相关参数,每页数量 + int32 page_size = 4; + // 分页相关参数,下一页的token + string next_token = 5; + // 请求id,出现问题后提供给云厂商,排查问题 + string request_id = 6; +} + +message ListPodReq { + // 云名称 + pbtenant.CloudProvider provider = 1; +} + +message ListPodResp { + // pod集合 + repeated PodInstance pods = 1; +} + +message ListPodAllReq{} + + +// Pod类产品接口 +// 阿里云 - ECI +// 腾讯云 - TKS +// 华为云 - CCI + +service PodService { + + // 创建Pod + rpc CreatePod(CreatePodReq) returns (CreatePodResp) { + option (google.api.http) = { + post : "/apis/pod/create" + body : "*" + }; + } + + + // 查询Pod明细 + rpc ListPodDetail(ListPodDetailReq) returns (ListPodDetailResp) { + option (google.api.http) = { + post : "/apis/pod/detail" + body : "*" + }; + } + + // 查询Pod全量 - 根据云类型 + rpc ListPod(ListPodReq) returns (ListPodResp) { + option (google.api.http) = { + post : "/apis/pod" + body : "*" + }; + } + + // 查询所有云的Pod + rpc ListPodAll(ListPodAllReq) returns (ListPodResp) { + option (google.api.http) = { + post : "/apis/pod/all" + body : "*" + }; + } +} \ No newline at end of file diff --git a/lan_trans/idl/demo/demo.pb.gw.go b/lan_trans/idl/demo/demo.pb.gw.go index 66ed1dc..5fedd6b 100644 --- a/lan_trans/idl/demo/demo.pb.gw.go +++ b/lan_trans/idl/demo/demo.pb.gw.go @@ -77,12 +77,13 @@ func RegisterDemoServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/demo.DemoService/Echo") + var err error + ctx, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/demo.DemoService/Echo", runtime.WithHTTPPathPattern("/apis/demo")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_DemoService_Echo_0(rctx, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_DemoService_Echo_0(ctx, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { @@ -139,12 +140,13 @@ func RegisterDemoServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req, "/demo.DemoService/Echo") + var err error + ctx, err = runtime.AnnotateContext(ctx, mux, req, "/demo.DemoService/Echo", runtime.WithHTTPPathPattern("/apis/demo")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_DemoService_Echo_0(rctx, inboundMarshaler, client, req, pathParams) + resp, md, err := request_DemoService_Echo_0(ctx, inboundMarshaler, client, req, pathParams) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) diff --git a/lan_trans/idl/pbecs/ecs.pb.gw.go b/lan_trans/idl/pbecs/ecs.pb.gw.go index 95d6355..425292e 100644 --- a/lan_trans/idl/pbecs/ecs.pb.gw.go +++ b/lan_trans/idl/pbecs/ecs.pb.gw.go @@ -145,12 +145,13 @@ func RegisterEcsServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/pbecs.EcsService/ListEcsDetail") + var err error + ctx, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/pbecs.EcsService/ListEcsDetail", runtime.WithHTTPPathPattern("/apis/ecs/detail")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_EcsService_ListEcsDetail_0(rctx, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_EcsService_ListEcsDetail_0(ctx, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { @@ -168,12 +169,13 @@ func RegisterEcsServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/pbecs.EcsService/ListEcs") + var err error + ctx, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/pbecs.EcsService/ListEcs", runtime.WithHTTPPathPattern("/apis/ecs")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_EcsService_ListEcs_0(rctx, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_EcsService_ListEcs_0(ctx, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { @@ -191,12 +193,13 @@ func RegisterEcsServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/pbecs.EcsService/ListEcsAll") + var err error + ctx, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/pbecs.EcsService/ListEcsAll", runtime.WithHTTPPathPattern("/apis/ecs/all")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_EcsService_ListEcsAll_0(rctx, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_EcsService_ListEcsAll_0(ctx, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { @@ -253,12 +256,13 @@ func RegisterEcsServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req, "/pbecs.EcsService/ListEcsDetail") + var err error + ctx, err = runtime.AnnotateContext(ctx, mux, req, "/pbecs.EcsService/ListEcsDetail", runtime.WithHTTPPathPattern("/apis/ecs/detail")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_EcsService_ListEcsDetail_0(rctx, inboundMarshaler, client, req, pathParams) + resp, md, err := request_EcsService_ListEcsDetail_0(ctx, inboundMarshaler, client, req, pathParams) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -273,12 +277,13 @@ func RegisterEcsServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req, "/pbecs.EcsService/ListEcs") + var err error + ctx, err = runtime.AnnotateContext(ctx, mux, req, "/pbecs.EcsService/ListEcs", runtime.WithHTTPPathPattern("/apis/ecs")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_EcsService_ListEcs_0(rctx, inboundMarshaler, client, req, pathParams) + resp, md, err := request_EcsService_ListEcs_0(ctx, inboundMarshaler, client, req, pathParams) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -293,12 +298,13 @@ func RegisterEcsServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req, "/pbecs.EcsService/ListEcsAll") + var err error + ctx, err = runtime.AnnotateContext(ctx, mux, req, "/pbecs.EcsService/ListEcsAll", runtime.WithHTTPPathPattern("/apis/ecs/all")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_EcsService_ListEcsAll_0(rctx, inboundMarshaler, client, req, pathParams) + resp, md, err := request_EcsService_ListEcsAll_0(ctx, inboundMarshaler, client, req, pathParams) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) diff --git a/main.go b/main.go index 1a4bef8..d5ceec9 100644 --- a/main.go +++ b/main.go @@ -7,6 +7,7 @@ import ( "gitlink.org.cn/JCCE/PCM/common/tenanter" "gitlink.org.cn/JCCE/PCM/lan_trans/idl/demo" "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbecs" + "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbpod" "net" "net/http" @@ -35,6 +36,8 @@ func run() error { return errors.Wrap(err, "RegisterDemoServiceHandlerFromEndpoint error") } else if err = pbecs.RegisterEcsServiceHandlerFromEndpoint(ctx, mux, *grpcServerEndpoint, opts); err != nil { return errors.Wrap(err, "RegisterEcsServiceHandlerFromEndpoint error") + } else if err = pbpod.RegisterPodServiceHandlerFromEndpoint(ctx, mux, *grpcServerEndpoint, opts); err != nil { + return errors.Wrap(err, "RegisterPodServiceHandlerFromEndpoint error") } // Start HTTP server (and proxy calls to gRPC server endpoint) @@ -43,7 +46,7 @@ func run() error { func main() { var configFile string - flag.StringVar(&configFile, "conf", "config.yaml", "configs/config.yaml") + flag.StringVar(&configFile, "conf", "configs/config.yaml", "config.yaml") flag.Parse() defer glog.Flush() @@ -65,6 +68,7 @@ func main() { s := grpc.NewServer() demo.RegisterDemoServiceServer(s, &server.Server{}) pbecs.RegisterEcsServiceServer(s, &server.Server{}) + pbpod.RegisterPodServiceServer(s, &server.Server{}) if err = s.Serve(lis); err != nil { glog.Fatalf("failed to serve: %v", err) From ebdd2416333263a15178683d98154f62208c9267 Mon Sep 17 00:00:00 2001 From: zhouqunjie <450705171@qq.com> Date: Mon, 4 Apr 2022 17:38:53 +0800 Subject: [PATCH 2/3] refactor --- adaptor/pod_adaptor/server/pod/list.go | 125 +++ adaptor/pod_adaptor/service/poder/poder.go | 45 ++ common/server/server_pod.go | 38 + go.mod | 53 ++ lan_trans/idl/pbpod/pod.pb.go | 745 ++++++++++++++++++ lan_trans/idl/pbpod/pod.pb.gw.go | 335 ++++++++ lan_trans/idl/pbpod/pod_grpc.pb.go | 183 +++++ .../openapiv2/idl/demo/demo.swagger.json | 96 +++ .../openapiv2/idl/pbecs/ecs.swagger.json | 331 ++++++++ .../openapiv2/idl/pbpod/pod.swagger.json | 314 ++++++++ .../idl/pbtenant/tenant.swagger.json | 43 + 11 files changed, 2308 insertions(+) create mode 100644 adaptor/pod_adaptor/server/pod/list.go create mode 100644 adaptor/pod_adaptor/service/poder/poder.go create mode 100644 common/server/server_pod.go create mode 100644 go.mod create mode 100644 lan_trans/idl/pbpod/pod.pb.go create mode 100644 lan_trans/idl/pbpod/pod.pb.gw.go create mode 100644 lan_trans/idl/pbpod/pod_grpc.pb.go create mode 100644 lan_trans/openapiv2/idl/demo/demo.swagger.json create mode 100644 lan_trans/openapiv2/idl/pbecs/ecs.swagger.json create mode 100644 lan_trans/openapiv2/idl/pbpod/pod.swagger.json create mode 100644 lan_trans/openapiv2/idl/pbtenant/tenant.swagger.json diff --git a/adaptor/pod_adaptor/server/pod/list.go b/adaptor/pod_adaptor/server/pod/list.go new file mode 100644 index 0000000..730a8d2 --- /dev/null +++ b/adaptor/pod_adaptor/server/pod/list.go @@ -0,0 +1,125 @@ +package pod + +import ( + "context" + "gitlink.org.cn/JCCE/PCM/adaptor/pod_adaptor/service/poder" + "gitlink.org.cn/JCCE/PCM/common/tenanter" + "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbpod" + "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant" + "sync" + + "github.com/golang/glog" + "github.com/pkg/errors" +) + +func ListPodDetail(ctx context.Context, req *pbpod.ListPodDetailReq) (*pbpod.ListPodDetailResp, error) { + var ( + pod poder.Poder + ) + + tenanters, err := tenanter.GetTenanters(req.Provider) + if err != nil { + return nil, errors.WithMessage(err, "getTenanters error") + } + + region, err := tenanter.NewRegion(req.Provider, req.RegionId) + if err != nil { + return nil, errors.WithMessagef(err, "provider %v regionId %v", req.Provider, req.RegionId) + } + + for _, tenanter := range tenanters { + if req.AccountName == "" || tenanter.AccountName() == req.AccountName { + if pod, err = poder.NewPodClient(req.Provider, region, tenanter); err != nil { + return nil, errors.WithMessage(err, "NewPodClient error") + } + break + } + } + + return pod.ListPodDetail(ctx, req) +} + +func ListPod(ctx context.Context, req *pbpod.ListPodReq) (*pbpod.ListPodResp, error) { + var ( + wg sync.WaitGroup + mutex sync.Mutex + pods []*pbpod.PodInstance + ) + + tenanters, err := tenanter.GetTenanters(req.Provider) + if err != nil { + return nil, errors.WithMessage(err, "getTenanters error") + } + + regions := tenanter.GetAllRegionIds(req.Provider) + + wg.Add(len(tenanters) * len(regions)) + for _, t := range tenanters { + for _, region := range regions { + go func(tenant tenanter.Tenanter, region tenanter.Region) { + defer wg.Done() + pod, err := poder.NewPodClient(req.Provider, region, tenant) + if err != nil { + glog.Errorf("New Pod Client error %v", err) + return + } + + request := &pbpod.ListPodDetailReq{ + Provider: req.Provider, + AccountName: tenant.AccountName(), + RegionId: region.GetId(), + PageNumber: 1, + PageSize: 100, + NextToken: "", + } + for { + resp, err := pod.ListPodDetail(ctx, request) + if err != nil { + glog.Errorf("ListDetail error %v", err) + return + } + mutex.Lock() + pods = append(pods, resp.Pods...) + mutex.Unlock() + if resp.Finished { + break + } + request.PageNumber, request.PageSize, request.NextToken = resp.PageNumber, resp.PageSize, resp.NextToken + } + }(t, region) + + } + } + wg.Wait() + + return &pbpod.ListPodResp{Pods: pods}, nil +} + +func ListPodAll(ctx context.Context) (*pbpod.ListPodResp, error) { + var ( + wg sync.WaitGroup + mutex sync.Mutex + pods []*pbpod.PodInstance + ) + + wg.Add(len(pbtenant.CloudProvider_name)) + for k := range pbtenant.CloudProvider_name { + go func(provider int32) { + defer wg.Done() + + resp, err := ListPod(ctx, &pbpod.ListPodReq{Provider: pbtenant.CloudProvider(provider)}) + if err != nil { + glog.Errorf("List error %v", err) + return + } + + mutex.Lock() + pods = append(pods, resp.Pods...) + mutex.Unlock() + }(k) + } + + wg.Wait() + + return &pbpod.ListPodResp{Pods: pods}, nil +} diff --git a/adaptor/pod_adaptor/service/poder/poder.go b/adaptor/pod_adaptor/service/poder/poder.go new file mode 100644 index 0000000..adf17d1 --- /dev/null +++ b/adaptor/pod_adaptor/service/poder/poder.go @@ -0,0 +1,45 @@ +package poder + +import ( + "context" + "gitlink.org.cn/JCCE/PCM/common/tenanter" + "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbpod" + "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant" + + "github.com/golang/glog" + "github.com/pkg/errors" +) + +var ( + ErrPodListNotSupported = errors.New("cloud not supported pod list") + ErrPoderPanic = errors.New("pod init panic") +) + +type Poder interface { + ListPodDetail(ctx context.Context, req *pbpod.ListPodDetailReq) (resp *pbpod.ListPodDetailResp, err error) +} + +func NewPodClient(provider pbtenant.CloudProvider, region tenanter.Region, tenant tenanter.Tenanter) (poder Poder, err error) { + // 部分sdk会在内部panic + defer func() { + if err1 := recover(); err1 != nil { + glog.Errorf("NewPodClient panic %v", err1) + err = errors.WithMessagef(ErrPoderPanic, "%v", err1) + } + }() + + switch provider { + case pbtenant.CloudProvider_ali: + return newAliEciClient(region, tenant) + case pbtenant.CloudProvider_tencent: + return nil, nil + case pbtenant.CloudProvider_huawei: + return nil, nil + //TODO aws + //case pbtenant.CloudProvider_aws: + // return newAwsPodClient(region, tenant) + } + + err = errors.WithMessagef(ErrPodListNotSupported, "cloud provider %v region %v", provider, region) + return +} diff --git a/common/server/server_pod.go b/common/server/server_pod.go new file mode 100644 index 0000000..5028f5d --- /dev/null +++ b/common/server/server_pod.go @@ -0,0 +1,38 @@ +package server + +import ( + "context" + "gitlink.org.cn/JCCE/PCM/adaptor/pod_adaptor/server/pod" + "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbpod" + + "github.com/golang/glog" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func (s *Server) ListPodDetail(ctx context.Context, req *pbpod.ListPodDetailReq) (*pbpod.ListPodDetailResp, error) { + resp, err := pod.ListPodDetail(ctx, req) + if err != nil { + glog.Errorf("ListPodDetail error %+v", err) + return nil, status.Errorf(codes.Internal, err.Error()) + } + return resp, nil +} + +func (s *Server) ListPod(ctx context.Context, req *pbpod.ListPodReq) (*pbpod.ListPodResp, error) { + resp, err := pod.ListPod(ctx, req) + if err != nil { + glog.Errorf("ListPod error %+v", err) + return nil, status.Errorf(codes.Internal, err.Error()) + } + return resp, nil +} + +func (s *Server) ListPodAll(ctx context.Context, req *pbpod.ListPodAllReq) (*pbpod.ListPodResp, error) { + resp, err := pod.ListPodAll(ctx) + if err != nil { + glog.Errorf("ListPodAll error %+v", err) + return nil, status.Errorf(codes.Internal, err.Error()) + } + return resp, nil +} diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..f1e37ae --- /dev/null +++ b/go.mod @@ -0,0 +1,53 @@ +module gitlink.org.cn/JCCE/PCM + +go 1.17 + +require ( + github.com/Unknwon/goconfig v1.0.0 + github.com/aliyun/alibaba-cloud-sdk-go v1.61.1530 + github.com/go-yaml/yaml v2.1.0+incompatible + github.com/golang/glog v1.0.0 + github.com/grpc-ecosystem/grpc-gateway/v2 v2.10.0 + github.com/huaweicloud/huaweicloud-sdk-go-v3 v0.0.82 + github.com/pkg/errors v0.9.1 + github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.377 + github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm v1.0.377 + github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke v1.0.371 + google.golang.org/genproto v0.0.0-20220317150908-0efb43f6373e + google.golang.org/grpc v1.45.0 + google.golang.org/protobuf v1.28.0 + k8s.io/api v0.0.0-20190620084959-7cf5895f2711 + k8s.io/apimachinery v0.0.0-20190612205821-1799e75a0719 + k8s.io/client-go v0.0.0-20190620085101-78d2af792bab +) + +require ( + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/evanphx/json-patch v0.0.0-20190203023257-5858425f7550 // indirect + github.com/gogo/protobuf v0.0.0-20171007142547-342cbe0a0415 // indirect + github.com/golang/protobuf v1.5.2 // indirect + github.com/google/gofuzz v1.0.0 // indirect + github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d // indirect + github.com/imdario/mergo v0.3.5 // indirect + github.com/jmespath/go-jmespath v0.4.0 // indirect + github.com/json-iterator/go v1.1.10 // indirect + github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect + github.com/modern-go/reflect2 v1.0.1 // indirect + github.com/smartystreets/goconvey v1.7.2 // indirect + github.com/spf13/pflag v1.0.1 // indirect + golang.org/x/crypto v0.0.0-20210920023735-84f357641f63 // indirect + golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd // indirect + golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a // indirect + golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect + golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect + golang.org/x/text v0.3.7 // indirect + golang.org/x/time v0.0.0-20191024005414-555d28b269f0 // indirect + google.golang.org/appengine v1.6.6 // indirect + gopkg.in/inf.v0 v0.9.0 // indirect + gopkg.in/ini.v1 v1.66.2 // indirect + gopkg.in/yaml.v2 v2.4.0 // indirect + k8s.io/klog v0.3.1 // indirect + k8s.io/kube-openapi v0.0.0-20190228160746-b3a7cee44a30 // indirect + k8s.io/utils v0.0.0-20190221042446-c2654d5206da // indirect + sigs.k8s.io/yaml v1.3.0 // indirect +) diff --git a/lan_trans/idl/pbpod/pod.pb.go b/lan_trans/idl/pbpod/pod.pb.go new file mode 100644 index 0000000..9fc1936 --- /dev/null +++ b/lan_trans/idl/pbpod/pod.pb.go @@ -0,0 +1,745 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.28.0 +// protoc (unknown) +// source: idl/pbpod/pod.proto + +package pbpod + +import ( + pbtenant "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant" + _ "google.golang.org/genproto/googleapis/api/annotations" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type PodInstance struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // 云类型 + Provider pbtenant.CloudProvider `protobuf:"varint,1,opt,name=provider,proto3,enum=pbtenant.CloudProvider" json:"provider,omitempty"` + // 账号名称 + AccountName string `protobuf:"bytes,2,opt,name=account_name,json=accountName,proto3" json:"account_name,omitempty"` + // 实例id + PodId string `protobuf:"bytes,3,opt,name=pod_id,json=podId,proto3" json:"pod_id,omitempty"` + // 实例名称 + PodName string `protobuf:"bytes,4,opt,name=pod_name,json=podName,proto3" json:"pod_name,omitempty"` + // 地域,数据中心 + RegionName string `protobuf:"bytes,5,opt,name=region_name,json=regionName,proto3" json:"region_name,omitempty"` + // 镜像 + ContainerImage string `protobuf:"bytes,6,opt,name=container_image,json=containerImage,proto3" json:"container_image,omitempty"` + // 容器名称 + ContainerName string `protobuf:"bytes,7,opt,name=container_name,json=containerName,proto3" json:"container_name,omitempty"` + // vcpu数 + CpuPod float32 `protobuf:"fixed32,8,opt,name=cpu_pod,json=cpuPod,proto3" json:"cpu_pod,omitempty"` + // 内存MB + MemoryPod float32 `protobuf:"fixed32,9,opt,name=memory_pod,json=memoryPod,proto3" json:"memory_pod,omitempty"` + //安全组ID 对应腾讯 SecurityGroupIds(腾讯必需) + SecurityGroupId string `protobuf:"bytes,10,opt,name=security_group_id,json=securityGroupId,proto3" json:"security_group_id,omitempty"` + //子网ID 对应腾讯 SubnetId(腾讯必需) + SubnetId string `protobuf:"bytes,11,opt,name=subnet_id,json=subnetId,proto3" json:"subnet_id,omitempty"` + //VPC ID 对应腾讯 VpcId(腾讯必需) + VpcId string `protobuf:"bytes,12,opt,name=vpc_id,json=vpcId,proto3" json:"vpc_id,omitempty"` + //名空间 + Namespace string `protobuf:"bytes,13,opt,name=namespace,proto3" json:"namespace,omitempty"` +} + +func (x *PodInstance) Reset() { + *x = PodInstance{} + if protoimpl.UnsafeEnabled { + mi := &file_idl_pbpod_pod_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PodInstance) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PodInstance) ProtoMessage() {} + +func (x *PodInstance) ProtoReflect() protoreflect.Message { + mi := &file_idl_pbpod_pod_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PodInstance.ProtoReflect.Descriptor instead. +func (*PodInstance) Descriptor() ([]byte, []int) { + return file_idl_pbpod_pod_proto_rawDescGZIP(), []int{0} +} + +func (x *PodInstance) GetProvider() pbtenant.CloudProvider { + if x != nil { + return x.Provider + } + return pbtenant.CloudProvider(0) +} + +func (x *PodInstance) GetAccountName() string { + if x != nil { + return x.AccountName + } + return "" +} + +func (x *PodInstance) GetPodId() string { + if x != nil { + return x.PodId + } + return "" +} + +func (x *PodInstance) GetPodName() string { + if x != nil { + return x.PodName + } + return "" +} + +func (x *PodInstance) GetRegionName() string { + if x != nil { + return x.RegionName + } + return "" +} + +func (x *PodInstance) GetContainerImage() string { + if x != nil { + return x.ContainerImage + } + return "" +} + +func (x *PodInstance) GetContainerName() string { + if x != nil { + return x.ContainerName + } + return "" +} + +func (x *PodInstance) GetCpuPod() float32 { + if x != nil { + return x.CpuPod + } + return 0 +} + +func (x *PodInstance) GetMemoryPod() float32 { + if x != nil { + return x.MemoryPod + } + return 0 +} + +func (x *PodInstance) GetSecurityGroupId() string { + if x != nil { + return x.SecurityGroupId + } + return "" +} + +func (x *PodInstance) GetSubnetId() string { + if x != nil { + return x.SubnetId + } + return "" +} + +func (x *PodInstance) GetVpcId() string { + if x != nil { + return x.VpcId + } + return "" +} + +func (x *PodInstance) GetNamespace() string { + if x != nil { + return x.Namespace + } + return "" +} + +type ListPodDetailReq struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // 云名称 + Provider pbtenant.CloudProvider `protobuf:"varint,1,opt,name=provider,proto3,enum=pbtenant.CloudProvider" json:"provider,omitempty"` + // 账户名称,根据config.yaml中的配置,默认为第一个配置的账户 + AccountName string `protobuf:"bytes,2,opt,name=account_name,json=accountName,proto3" json:"account_name,omitempty"` + // 区域Id,参考 tenant.proto 中的各个云的区域 + RegionId int32 `protobuf:"varint,3,opt,name=region_id,json=regionId,proto3" json:"region_id,omitempty"` + // podID + PodId int32 `protobuf:"varint,4,opt,name=pod_id,json=podId,proto3" json:"pod_id,omitempty"` + // 分页相关参数,页码 + PageNumber int32 `protobuf:"varint,5,opt,name=page_number,json=pageNumber,proto3" json:"page_number,omitempty"` + // 分页相关参数,每页数量 + PageSize int32 `protobuf:"varint,6,opt,name=page_size,json=pageSize,proto3" json:"page_size,omitempty"` + // 分页相关参数,下一页的token + NextToken string `protobuf:"bytes,7,opt,name=next_token,json=nextToken,proto3" json:"next_token,omitempty"` +} + +func (x *ListPodDetailReq) Reset() { + *x = ListPodDetailReq{} + if protoimpl.UnsafeEnabled { + mi := &file_idl_pbpod_pod_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ListPodDetailReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListPodDetailReq) ProtoMessage() {} + +func (x *ListPodDetailReq) ProtoReflect() protoreflect.Message { + mi := &file_idl_pbpod_pod_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ListPodDetailReq.ProtoReflect.Descriptor instead. +func (*ListPodDetailReq) Descriptor() ([]byte, []int) { + return file_idl_pbpod_pod_proto_rawDescGZIP(), []int{1} +} + +func (x *ListPodDetailReq) GetProvider() pbtenant.CloudProvider { + if x != nil { + return x.Provider + } + return pbtenant.CloudProvider(0) +} + +func (x *ListPodDetailReq) GetAccountName() string { + if x != nil { + return x.AccountName + } + return "" +} + +func (x *ListPodDetailReq) GetRegionId() int32 { + if x != nil { + return x.RegionId + } + return 0 +} + +func (x *ListPodDetailReq) GetPodId() int32 { + if x != nil { + return x.PodId + } + return 0 +} + +func (x *ListPodDetailReq) GetPageNumber() int32 { + if x != nil { + return x.PageNumber + } + return 0 +} + +func (x *ListPodDetailReq) GetPageSize() int32 { + if x != nil { + return x.PageSize + } + return 0 +} + +func (x *ListPodDetailReq) GetNextToken() string { + if x != nil { + return x.NextToken + } + return "" +} + +type ListPodDetailResp struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Pod集合 + Pods []*PodInstance `protobuf:"bytes,1,rep,name=pods,proto3" json:"pods,omitempty"` + // 查询是否完成,如果为否-false,则可以将下面三个分页参数填入到请求中,继续查询 + Finished bool `protobuf:"varint,2,opt,name=finished,proto3" json:"finished,omitempty"` + // 分页相关参数,页码 + PageNumber int32 `protobuf:"varint,3,opt,name=page_number,json=pageNumber,proto3" json:"page_number,omitempty"` + // 分页相关参数,每页数量 + PageSize int32 `protobuf:"varint,4,opt,name=page_size,json=pageSize,proto3" json:"page_size,omitempty"` + // 分页相关参数,下一页的token + NextToken string `protobuf:"bytes,5,opt,name=next_token,json=nextToken,proto3" json:"next_token,omitempty"` + // 请求id,出现问题后提供给云厂商,排查问题 + RequestId string `protobuf:"bytes,6,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"` +} + +func (x *ListPodDetailResp) Reset() { + *x = ListPodDetailResp{} + if protoimpl.UnsafeEnabled { + mi := &file_idl_pbpod_pod_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ListPodDetailResp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListPodDetailResp) ProtoMessage() {} + +func (x *ListPodDetailResp) ProtoReflect() protoreflect.Message { + mi := &file_idl_pbpod_pod_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ListPodDetailResp.ProtoReflect.Descriptor instead. +func (*ListPodDetailResp) Descriptor() ([]byte, []int) { + return file_idl_pbpod_pod_proto_rawDescGZIP(), []int{2} +} + +func (x *ListPodDetailResp) GetPods() []*PodInstance { + if x != nil { + return x.Pods + } + return nil +} + +func (x *ListPodDetailResp) GetFinished() bool { + if x != nil { + return x.Finished + } + return false +} + +func (x *ListPodDetailResp) GetPageNumber() int32 { + if x != nil { + return x.PageNumber + } + return 0 +} + +func (x *ListPodDetailResp) GetPageSize() int32 { + if x != nil { + return x.PageSize + } + return 0 +} + +func (x *ListPodDetailResp) GetNextToken() string { + if x != nil { + return x.NextToken + } + return "" +} + +func (x *ListPodDetailResp) GetRequestId() string { + if x != nil { + return x.RequestId + } + return "" +} + +type ListPodReq struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // 云名称 + Provider pbtenant.CloudProvider `protobuf:"varint,1,opt,name=provider,proto3,enum=pbtenant.CloudProvider" json:"provider,omitempty"` +} + +func (x *ListPodReq) Reset() { + *x = ListPodReq{} + if protoimpl.UnsafeEnabled { + mi := &file_idl_pbpod_pod_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ListPodReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListPodReq) ProtoMessage() {} + +func (x *ListPodReq) ProtoReflect() protoreflect.Message { + mi := &file_idl_pbpod_pod_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ListPodReq.ProtoReflect.Descriptor instead. +func (*ListPodReq) Descriptor() ([]byte, []int) { + return file_idl_pbpod_pod_proto_rawDescGZIP(), []int{3} +} + +func (x *ListPodReq) GetProvider() pbtenant.CloudProvider { + if x != nil { + return x.Provider + } + return pbtenant.CloudProvider(0) +} + +type ListPodResp struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // pod集合 + Pods []*PodInstance `protobuf:"bytes,1,rep,name=pods,proto3" json:"pods,omitempty"` +} + +func (x *ListPodResp) Reset() { + *x = ListPodResp{} + if protoimpl.UnsafeEnabled { + mi := &file_idl_pbpod_pod_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ListPodResp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListPodResp) ProtoMessage() {} + +func (x *ListPodResp) ProtoReflect() protoreflect.Message { + mi := &file_idl_pbpod_pod_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ListPodResp.ProtoReflect.Descriptor instead. +func (*ListPodResp) Descriptor() ([]byte, []int) { + return file_idl_pbpod_pod_proto_rawDescGZIP(), []int{4} +} + +func (x *ListPodResp) GetPods() []*PodInstance { + if x != nil { + return x.Pods + } + return nil +} + +type ListPodAllReq struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *ListPodAllReq) Reset() { + *x = ListPodAllReq{} + if protoimpl.UnsafeEnabled { + mi := &file_idl_pbpod_pod_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ListPodAllReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListPodAllReq) ProtoMessage() {} + +func (x *ListPodAllReq) ProtoReflect() protoreflect.Message { + mi := &file_idl_pbpod_pod_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ListPodAllReq.ProtoReflect.Descriptor instead. +func (*ListPodAllReq) Descriptor() ([]byte, []int) { + return file_idl_pbpod_pod_proto_rawDescGZIP(), []int{5} +} + +var File_idl_pbpod_pod_proto protoreflect.FileDescriptor + +var file_idl_pbpod_pod_proto_rawDesc = []byte{ + 0x0a, 0x13, 0x69, 0x64, 0x6c, 0x2f, 0x70, 0x62, 0x70, 0x6f, 0x64, 0x2f, 0x70, 0x6f, 0x64, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x05, 0x70, 0x62, 0x70, 0x6f, 0x64, 0x1a, 0x19, 0x69, 0x64, + 0x6c, 0x2f, 0x70, 0x62, 0x74, 0x65, 0x6e, 0x61, 0x6e, 0x74, 0x2f, 0x74, 0x65, 0x6e, 0x61, 0x6e, + 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, + 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xbe, 0x03, 0x0a, 0x0b, 0x50, 0x6f, 0x64, 0x49, 0x6e, 0x73, + 0x74, 0x61, 0x6e, 0x63, 0x65, 0x12, 0x33, 0x0a, 0x08, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, + 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x17, 0x2e, 0x70, 0x62, 0x74, 0x65, 0x6e, 0x61, + 0x6e, 0x74, 0x2e, 0x43, 0x6c, 0x6f, 0x75, 0x64, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, + 0x52, 0x08, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x12, 0x21, 0x0a, 0x0c, 0x61, 0x63, + 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x0b, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x15, 0x0a, + 0x06, 0x70, 0x6f, 0x64, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x70, + 0x6f, 0x64, 0x49, 0x64, 0x12, 0x19, 0x0a, 0x08, 0x70, 0x6f, 0x64, 0x5f, 0x6e, 0x61, 0x6d, 0x65, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x70, 0x6f, 0x64, 0x4e, 0x61, 0x6d, 0x65, 0x12, + 0x1f, 0x0a, 0x0b, 0x72, 0x65, 0x67, 0x69, 0x6f, 0x6e, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x05, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x72, 0x65, 0x67, 0x69, 0x6f, 0x6e, 0x4e, 0x61, 0x6d, 0x65, + 0x12, 0x27, 0x0a, 0x0f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x5f, 0x69, 0x6d, + 0x61, 0x67, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x63, 0x6f, 0x6e, 0x74, 0x61, + 0x69, 0x6e, 0x65, 0x72, 0x49, 0x6d, 0x61, 0x67, 0x65, 0x12, 0x25, 0x0a, 0x0e, 0x63, 0x6f, 0x6e, + 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0d, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, + 0x12, 0x17, 0x0a, 0x07, 0x63, 0x70, 0x75, 0x5f, 0x70, 0x6f, 0x64, 0x18, 0x08, 0x20, 0x01, 0x28, + 0x02, 0x52, 0x06, 0x63, 0x70, 0x75, 0x50, 0x6f, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x6d, 0x65, 0x6d, + 0x6f, 0x72, 0x79, 0x5f, 0x70, 0x6f, 0x64, 0x18, 0x09, 0x20, 0x01, 0x28, 0x02, 0x52, 0x09, 0x6d, + 0x65, 0x6d, 0x6f, 0x72, 0x79, 0x50, 0x6f, 0x64, 0x12, 0x2a, 0x0a, 0x11, 0x73, 0x65, 0x63, 0x75, + 0x72, 0x69, 0x74, 0x79, 0x5f, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x5f, 0x69, 0x64, 0x18, 0x0a, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x0f, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x47, 0x72, 0x6f, + 0x75, 0x70, 0x49, 0x64, 0x12, 0x1b, 0x0a, 0x09, 0x73, 0x75, 0x62, 0x6e, 0x65, 0x74, 0x5f, 0x69, + 0x64, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x73, 0x75, 0x62, 0x6e, 0x65, 0x74, 0x49, + 0x64, 0x12, 0x15, 0x0a, 0x06, 0x76, 0x70, 0x63, 0x5f, 0x69, 0x64, 0x18, 0x0c, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x05, 0x76, 0x70, 0x63, 0x49, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x6e, 0x61, 0x6d, 0x65, + 0x73, 0x70, 0x61, 0x63, 0x65, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6e, 0x61, 0x6d, + 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x22, 0xfb, 0x01, 0x0a, 0x10, 0x4c, 0x69, 0x73, 0x74, 0x50, + 0x6f, 0x64, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x71, 0x12, 0x33, 0x0a, 0x08, 0x70, + 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x17, 0x2e, + 0x70, 0x62, 0x74, 0x65, 0x6e, 0x61, 0x6e, 0x74, 0x2e, 0x43, 0x6c, 0x6f, 0x75, 0x64, 0x50, 0x72, + 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, + 0x12, 0x21, 0x0a, 0x0c, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x6e, 0x61, 0x6d, 0x65, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x4e, + 0x61, 0x6d, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x72, 0x65, 0x67, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x72, 0x65, 0x67, 0x69, 0x6f, 0x6e, 0x49, 0x64, + 0x12, 0x15, 0x0a, 0x06, 0x70, 0x6f, 0x64, 0x5f, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, + 0x52, 0x05, 0x70, 0x6f, 0x64, 0x49, 0x64, 0x12, 0x1f, 0x0a, 0x0b, 0x70, 0x61, 0x67, 0x65, 0x5f, + 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x70, 0x61, + 0x67, 0x65, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x61, 0x67, 0x65, + 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x70, 0x61, 0x67, + 0x65, 0x53, 0x69, 0x7a, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x74, 0x6f, + 0x6b, 0x65, 0x6e, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6e, 0x65, 0x78, 0x74, 0x54, + 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0xd3, 0x01, 0x0a, 0x11, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x6f, 0x64, + 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x12, 0x26, 0x0a, 0x04, 0x70, 0x6f, + 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x70, 0x62, 0x70, 0x6f, 0x64, + 0x2e, 0x50, 0x6f, 0x64, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x04, 0x70, 0x6f, + 0x64, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x66, 0x69, 0x6e, 0x69, 0x73, 0x68, 0x65, 0x64, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x66, 0x69, 0x6e, 0x69, 0x73, 0x68, 0x65, 0x64, 0x12, 0x1f, + 0x0a, 0x0b, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x05, 0x52, 0x0a, 0x70, 0x61, 0x67, 0x65, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, + 0x1b, 0x0a, 0x09, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x04, 0x20, 0x01, + 0x28, 0x05, 0x52, 0x08, 0x70, 0x61, 0x67, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x12, 0x1d, 0x0a, 0x0a, + 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x09, 0x6e, 0x65, 0x78, 0x74, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x1d, 0x0a, 0x0a, 0x72, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x22, 0x41, 0x0a, 0x0a, 0x4c, 0x69, + 0x73, 0x74, 0x50, 0x6f, 0x64, 0x52, 0x65, 0x71, 0x12, 0x33, 0x0a, 0x08, 0x70, 0x72, 0x6f, 0x76, + 0x69, 0x64, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x17, 0x2e, 0x70, 0x62, 0x74, + 0x65, 0x6e, 0x61, 0x6e, 0x74, 0x2e, 0x43, 0x6c, 0x6f, 0x75, 0x64, 0x50, 0x72, 0x6f, 0x76, 0x69, + 0x64, 0x65, 0x72, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x22, 0x35, 0x0a, + 0x0b, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x6f, 0x64, 0x52, 0x65, 0x73, 0x70, 0x12, 0x26, 0x0a, 0x04, + 0x70, 0x6f, 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x70, 0x62, 0x70, + 0x6f, 0x64, 0x2e, 0x50, 0x6f, 0x64, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x04, + 0x70, 0x6f, 0x64, 0x73, 0x22, 0x0f, 0x0a, 0x0d, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x6f, 0x64, 0x41, + 0x6c, 0x6c, 0x52, 0x65, 0x71, 0x32, 0x87, 0x02, 0x0a, 0x0a, 0x50, 0x6f, 0x64, 0x53, 0x65, 0x72, + 0x76, 0x69, 0x63, 0x65, 0x12, 0x5f, 0x0a, 0x0d, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x6f, 0x64, 0x44, + 0x65, 0x74, 0x61, 0x69, 0x6c, 0x12, 0x17, 0x2e, 0x70, 0x62, 0x70, 0x6f, 0x64, 0x2e, 0x4c, 0x69, + 0x73, 0x74, 0x50, 0x6f, 0x64, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x71, 0x1a, 0x18, + 0x2e, 0x70, 0x62, 0x70, 0x6f, 0x64, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x6f, 0x64, 0x44, 0x65, + 0x74, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x22, 0x1b, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x15, + 0x22, 0x10, 0x2f, 0x61, 0x70, 0x69, 0x73, 0x2f, 0x70, 0x6f, 0x64, 0x2f, 0x64, 0x65, 0x74, 0x61, + 0x69, 0x6c, 0x3a, 0x01, 0x2a, 0x12, 0x46, 0x0a, 0x07, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x6f, 0x64, + 0x12, 0x11, 0x2e, 0x70, 0x62, 0x70, 0x6f, 0x64, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x6f, 0x64, + 0x52, 0x65, 0x71, 0x1a, 0x12, 0x2e, 0x70, 0x62, 0x70, 0x6f, 0x64, 0x2e, 0x4c, 0x69, 0x73, 0x74, + 0x50, 0x6f, 0x64, 0x52, 0x65, 0x73, 0x70, 0x22, 0x14, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0e, 0x22, + 0x09, 0x2f, 0x61, 0x70, 0x69, 0x73, 0x2f, 0x70, 0x6f, 0x64, 0x3a, 0x01, 0x2a, 0x12, 0x50, 0x0a, + 0x0a, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x6f, 0x64, 0x41, 0x6c, 0x6c, 0x12, 0x14, 0x2e, 0x70, 0x62, + 0x70, 0x6f, 0x64, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x6f, 0x64, 0x41, 0x6c, 0x6c, 0x52, 0x65, + 0x71, 0x1a, 0x12, 0x2e, 0x70, 0x62, 0x70, 0x6f, 0x64, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x6f, + 0x64, 0x52, 0x65, 0x73, 0x70, 0x22, 0x18, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x12, 0x22, 0x0d, 0x2f, + 0x61, 0x70, 0x69, 0x73, 0x2f, 0x70, 0x6f, 0x64, 0x2f, 0x61, 0x6c, 0x6c, 0x3a, 0x01, 0x2a, 0x42, + 0x2d, 0x5a, 0x2b, 0x67, 0x69, 0x74, 0x6c, 0x69, 0x6e, 0x6b, 0x2e, 0x6f, 0x72, 0x67, 0x2e, 0x63, + 0x6e, 0x2f, 0x4a, 0x43, 0x43, 0x45, 0x2f, 0x50, 0x43, 0x4d, 0x2f, 0x6c, 0x61, 0x6e, 0x5f, 0x74, + 0x72, 0x61, 0x6e, 0x73, 0x2f, 0x69, 0x64, 0x6c, 0x2f, 0x70, 0x62, 0x70, 0x6f, 0x64, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_idl_pbpod_pod_proto_rawDescOnce sync.Once + file_idl_pbpod_pod_proto_rawDescData = file_idl_pbpod_pod_proto_rawDesc +) + +func file_idl_pbpod_pod_proto_rawDescGZIP() []byte { + file_idl_pbpod_pod_proto_rawDescOnce.Do(func() { + file_idl_pbpod_pod_proto_rawDescData = protoimpl.X.CompressGZIP(file_idl_pbpod_pod_proto_rawDescData) + }) + return file_idl_pbpod_pod_proto_rawDescData +} + +var file_idl_pbpod_pod_proto_msgTypes = make([]protoimpl.MessageInfo, 6) +var file_idl_pbpod_pod_proto_goTypes = []interface{}{ + (*PodInstance)(nil), // 0: pbpod.PodInstance + (*ListPodDetailReq)(nil), // 1: pbpod.ListPodDetailReq + (*ListPodDetailResp)(nil), // 2: pbpod.ListPodDetailResp + (*ListPodReq)(nil), // 3: pbpod.ListPodReq + (*ListPodResp)(nil), // 4: pbpod.ListPodResp + (*ListPodAllReq)(nil), // 5: pbpod.ListPodAllReq + (pbtenant.CloudProvider)(0), // 6: pbtenant.CloudProvider +} +var file_idl_pbpod_pod_proto_depIdxs = []int32{ + 6, // 0: pbpod.PodInstance.provider:type_name -> pbtenant.CloudProvider + 6, // 1: pbpod.ListPodDetailReq.provider:type_name -> pbtenant.CloudProvider + 0, // 2: pbpod.ListPodDetailResp.pods:type_name -> pbpod.PodInstance + 6, // 3: pbpod.ListPodReq.provider:type_name -> pbtenant.CloudProvider + 0, // 4: pbpod.ListPodResp.pods:type_name -> pbpod.PodInstance + 1, // 5: pbpod.PodService.ListPodDetail:input_type -> pbpod.ListPodDetailReq + 3, // 6: pbpod.PodService.ListPod:input_type -> pbpod.ListPodReq + 5, // 7: pbpod.PodService.ListPodAll:input_type -> pbpod.ListPodAllReq + 2, // 8: pbpod.PodService.ListPodDetail:output_type -> pbpod.ListPodDetailResp + 4, // 9: pbpod.PodService.ListPod:output_type -> pbpod.ListPodResp + 4, // 10: pbpod.PodService.ListPodAll:output_type -> pbpod.ListPodResp + 8, // [8:11] is the sub-list for method output_type + 5, // [5:8] is the sub-list for method input_type + 5, // [5:5] is the sub-list for extension type_name + 5, // [5:5] is the sub-list for extension extendee + 0, // [0:5] is the sub-list for field type_name +} + +func init() { file_idl_pbpod_pod_proto_init() } +func file_idl_pbpod_pod_proto_init() { + if File_idl_pbpod_pod_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_idl_pbpod_pod_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PodInstance); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_idl_pbpod_pod_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ListPodDetailReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_idl_pbpod_pod_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ListPodDetailResp); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_idl_pbpod_pod_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ListPodReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_idl_pbpod_pod_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ListPodResp); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_idl_pbpod_pod_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ListPodAllReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_idl_pbpod_pod_proto_rawDesc, + NumEnums: 0, + NumMessages: 6, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_idl_pbpod_pod_proto_goTypes, + DependencyIndexes: file_idl_pbpod_pod_proto_depIdxs, + MessageInfos: file_idl_pbpod_pod_proto_msgTypes, + }.Build() + File_idl_pbpod_pod_proto = out.File + file_idl_pbpod_pod_proto_rawDesc = nil + file_idl_pbpod_pod_proto_goTypes = nil + file_idl_pbpod_pod_proto_depIdxs = nil +} diff --git a/lan_trans/idl/pbpod/pod.pb.gw.go b/lan_trans/idl/pbpod/pod.pb.gw.go new file mode 100644 index 0000000..9aa4fef --- /dev/null +++ b/lan_trans/idl/pbpod/pod.pb.gw.go @@ -0,0 +1,335 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: idl/pbpod/pod.proto + +/* +Package pbpod is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package pbpod + +import ( + "context" + "io" + "net/http" + + "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" + "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" + "google.golang.org/protobuf/proto" +) + +// Suppress "imported and not used" errors +var _ codes.Code +var _ io.Reader +var _ status.Status +var _ = runtime.String +var _ = utilities.NewDoubleArray +var _ = metadata.Join + +func request_PodService_ListPodDetail_0(ctx context.Context, marshaler runtime.Marshaler, client PodServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq ListPodDetailReq + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.ListPodDetail(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_PodService_ListPodDetail_0(ctx context.Context, marshaler runtime.Marshaler, server PodServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq ListPodDetailReq + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.ListPodDetail(ctx, &protoReq) + return msg, metadata, err + +} + +func request_PodService_ListPod_0(ctx context.Context, marshaler runtime.Marshaler, client PodServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq ListPodReq + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.ListPod(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_PodService_ListPod_0(ctx context.Context, marshaler runtime.Marshaler, server PodServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq ListPodReq + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.ListPod(ctx, &protoReq) + return msg, metadata, err + +} + +func request_PodService_ListPodAll_0(ctx context.Context, marshaler runtime.Marshaler, client PodServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq ListPodAllReq + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.ListPodAll(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_PodService_ListPodAll_0(ctx context.Context, marshaler runtime.Marshaler, server PodServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq ListPodAllReq + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.ListPodAll(ctx, &protoReq) + return msg, metadata, err + +} + +// RegisterPodServiceHandlerServer registers the http handlers for service PodService to "mux". +// UnaryRPC :call PodServiceServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterPodServiceHandlerFromEndpoint instead. +func RegisterPodServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server PodServiceServer) error { + + mux.Handle("POST", pattern_PodService_ListPodDetail_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + ctx, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/pbpod.PodService/ListPodDetail", runtime.WithHTTPPathPattern("/apis/pod/detail")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_PodService_ListPodDetail_0(ctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_PodService_ListPodDetail_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_PodService_ListPod_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + ctx, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/pbpod.PodService/ListPod", runtime.WithHTTPPathPattern("/apis/pod")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_PodService_ListPod_0(ctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_PodService_ListPod_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_PodService_ListPodAll_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + ctx, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/pbpod.PodService/ListPodAll", runtime.WithHTTPPathPattern("/apis/pod/all")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_PodService_ListPodAll_0(ctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_PodService_ListPodAll_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterPodServiceHandlerFromEndpoint is same as RegisterPodServiceHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterPodServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.Dial(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterPodServiceHandler(ctx, mux, conn) +} + +// RegisterPodServiceHandler registers the http handlers for service PodService to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterPodServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterPodServiceHandlerClient(ctx, mux, NewPodServiceClient(conn)) +} + +// RegisterPodServiceHandlerClient registers the http handlers for service PodService +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "PodServiceClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "PodServiceClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "PodServiceClient" to call the correct interceptors. +func RegisterPodServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client PodServiceClient) error { + + mux.Handle("POST", pattern_PodService_ListPodDetail_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + ctx, err = runtime.AnnotateContext(ctx, mux, req, "/pbpod.PodService/ListPodDetail", runtime.WithHTTPPathPattern("/apis/pod/detail")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_PodService_ListPodDetail_0(ctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_PodService_ListPodDetail_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_PodService_ListPod_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + ctx, err = runtime.AnnotateContext(ctx, mux, req, "/pbpod.PodService/ListPod", runtime.WithHTTPPathPattern("/apis/pod")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_PodService_ListPod_0(ctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_PodService_ListPod_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_PodService_ListPodAll_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + ctx, err = runtime.AnnotateContext(ctx, mux, req, "/pbpod.PodService/ListPodAll", runtime.WithHTTPPathPattern("/apis/pod/all")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_PodService_ListPodAll_0(ctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_PodService_ListPodAll_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_PodService_ListPodDetail_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"apis", "pod", "detail"}, "")) + + pattern_PodService_ListPod_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"apis", "pod"}, "")) + + pattern_PodService_ListPodAll_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"apis", "pod", "all"}, "")) +) + +var ( + forward_PodService_ListPodDetail_0 = runtime.ForwardResponseMessage + + forward_PodService_ListPod_0 = runtime.ForwardResponseMessage + + forward_PodService_ListPodAll_0 = runtime.ForwardResponseMessage +) diff --git a/lan_trans/idl/pbpod/pod_grpc.pb.go b/lan_trans/idl/pbpod/pod_grpc.pb.go new file mode 100644 index 0000000..c279997 --- /dev/null +++ b/lan_trans/idl/pbpod/pod_grpc.pb.go @@ -0,0 +1,183 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.2.0 +// - protoc (unknown) +// source: idl/pbpod/pod.proto + +package pbpod + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.32.0 or later. +const _ = grpc.SupportPackageIsVersion7 + +// PodServiceClient is the client API for PodService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type PodServiceClient interface { + // 查询ECS明细 - 支持云类型、区域、账户、分页等过滤条件 + ListPodDetail(ctx context.Context, in *ListPodDetailReq, opts ...grpc.CallOption) (*ListPodDetailResp, error) + // 查询Pod全量 - 根据云类型 + ListPod(ctx context.Context, in *ListPodReq, opts ...grpc.CallOption) (*ListPodResp, error) + // 查询所有云的Pod + ListPodAll(ctx context.Context, in *ListPodAllReq, opts ...grpc.CallOption) (*ListPodResp, error) +} + +type podServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewPodServiceClient(cc grpc.ClientConnInterface) PodServiceClient { + return &podServiceClient{cc} +} + +func (c *podServiceClient) ListPodDetail(ctx context.Context, in *ListPodDetailReq, opts ...grpc.CallOption) (*ListPodDetailResp, error) { + out := new(ListPodDetailResp) + err := c.cc.Invoke(ctx, "/pbpod.PodService/ListPodDetail", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *podServiceClient) ListPod(ctx context.Context, in *ListPodReq, opts ...grpc.CallOption) (*ListPodResp, error) { + out := new(ListPodResp) + err := c.cc.Invoke(ctx, "/pbpod.PodService/ListPod", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *podServiceClient) ListPodAll(ctx context.Context, in *ListPodAllReq, opts ...grpc.CallOption) (*ListPodResp, error) { + out := new(ListPodResp) + err := c.cc.Invoke(ctx, "/pbpod.PodService/ListPodAll", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// PodServiceServer is the server API for PodService service. +// All implementations must embed UnimplementedPodServiceServer +// for forward compatibility +type PodServiceServer interface { + // 查询ECS明细 - 支持云类型、区域、账户、分页等过滤条件 + ListPodDetail(context.Context, *ListPodDetailReq) (*ListPodDetailResp, error) + // 查询Pod全量 - 根据云类型 + ListPod(context.Context, *ListPodReq) (*ListPodResp, error) + // 查询所有云的Pod + ListPodAll(context.Context, *ListPodAllReq) (*ListPodResp, error) + mustEmbedUnimplementedPodServiceServer() +} + +// UnimplementedPodServiceServer must be embedded to have forward compatible implementations. +type UnimplementedPodServiceServer struct { +} + +func (UnimplementedPodServiceServer) ListPodDetail(context.Context, *ListPodDetailReq) (*ListPodDetailResp, error) { + return nil, status.Errorf(codes.Unimplemented, "method ListPodDetail not implemented") +} +func (UnimplementedPodServiceServer) ListPod(context.Context, *ListPodReq) (*ListPodResp, error) { + return nil, status.Errorf(codes.Unimplemented, "method ListPod not implemented") +} +func (UnimplementedPodServiceServer) ListPodAll(context.Context, *ListPodAllReq) (*ListPodResp, error) { + return nil, status.Errorf(codes.Unimplemented, "method ListPodAll not implemented") +} +func (UnimplementedPodServiceServer) mustEmbedUnimplementedPodServiceServer() {} + +// UnsafePodServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to PodServiceServer will +// result in compilation errors. +type UnsafePodServiceServer interface { + mustEmbedUnimplementedPodServiceServer() +} + +func RegisterPodServiceServer(s grpc.ServiceRegistrar, srv PodServiceServer) { + s.RegisterService(&PodService_ServiceDesc, srv) +} + +func _PodService_ListPodDetail_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ListPodDetailReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(PodServiceServer).ListPodDetail(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/pbpod.PodService/ListPodDetail", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(PodServiceServer).ListPodDetail(ctx, req.(*ListPodDetailReq)) + } + return interceptor(ctx, in, info, handler) +} + +func _PodService_ListPod_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ListPodReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(PodServiceServer).ListPod(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/pbpod.PodService/ListPod", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(PodServiceServer).ListPod(ctx, req.(*ListPodReq)) + } + return interceptor(ctx, in, info, handler) +} + +func _PodService_ListPodAll_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ListPodAllReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(PodServiceServer).ListPodAll(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/pbpod.PodService/ListPodAll", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(PodServiceServer).ListPodAll(ctx, req.(*ListPodAllReq)) + } + return interceptor(ctx, in, info, handler) +} + +// PodService_ServiceDesc is the grpc.ServiceDesc for PodService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var PodService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "pbpod.PodService", + HandlerType: (*PodServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "ListPodDetail", + Handler: _PodService_ListPodDetail_Handler, + }, + { + MethodName: "ListPod", + Handler: _PodService_ListPod_Handler, + }, + { + MethodName: "ListPodAll", + Handler: _PodService_ListPodAll_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "idl/pbpod/pod.proto", +} diff --git a/lan_trans/openapiv2/idl/demo/demo.swagger.json b/lan_trans/openapiv2/idl/demo/demo.swagger.json new file mode 100644 index 0000000..d7db3be --- /dev/null +++ b/lan_trans/openapiv2/idl/demo/demo.swagger.json @@ -0,0 +1,96 @@ +{ + "swagger": "2.0", + "info": { + "title": "idl/demo/demo.proto", + "version": "version not set" + }, + "tags": [ + { + "name": "DemoService" + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "paths": { + "/apis/demo": { + "post": { + "summary": "Echo 样例接口", + "operationId": "DemoService_Echo", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/demoStringMessage" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/demoStringMessage" + } + } + ], + "tags": [ + "DemoService" + ], + "deprecated": true, + "security": [], + "externalDocs": { + "description": "Find out more about the interface", + "url": "https://github.com/grpc-ecosystem/grpc-gateway" + } + } + } + }, + "definitions": { + "demoStringMessage": { + "type": "object", + "properties": { + "value": { + "type": "string" + } + } + }, + "protobufAny": { + "type": "object", + "properties": { + "@type": { + "type": "string" + } + }, + "additionalProperties": {} + }, + "rpcStatus": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + }, + "details": { + "type": "array", + "items": { + "$ref": "#/definitions/protobufAny" + } + } + } + } + } +} diff --git a/lan_trans/openapiv2/idl/pbecs/ecs.swagger.json b/lan_trans/openapiv2/idl/pbecs/ecs.swagger.json new file mode 100644 index 0000000..84a423e --- /dev/null +++ b/lan_trans/openapiv2/idl/pbecs/ecs.swagger.json @@ -0,0 +1,331 @@ +{ + "swagger": "2.0", + "info": { + "title": "idl/pbecs/ecs.proto", + "version": "version not set" + }, + "tags": [ + { + "name": "EcsService" + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "paths": { + "/apis/ecs": { + "post": { + "summary": "查询ECS全量 - 根据云类型", + "operationId": "EcsService_ListEcs", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/pbecsListResp" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/pbecsListReq" + } + } + ], + "tags": [ + "EcsService" + ] + } + }, + "/apis/ecs/all": { + "post": { + "summary": "查询所有云的ECS", + "operationId": "EcsService_ListEcsAll", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/pbecsListResp" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/pbecsListAllReq" + } + } + ], + "tags": [ + "EcsService" + ] + } + }, + "/apis/ecs/detail": { + "post": { + "summary": "查询ECS明细 - 支持云类型、区域、账户、分页等过滤条件", + "operationId": "EcsService_ListEcsDetail", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/pbecsListDetailResp" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/pbecsListDetailReq" + } + } + ], + "tags": [ + "EcsService" + ] + } + } + }, + "definitions": { + "pbecsEcsInstance": { + "type": "object", + "properties": { + "provider": { + "$ref": "#/definitions/pbtenantCloudProvider", + "title": "云类型" + }, + "accountName": { + "type": "string", + "title": "账号名称" + }, + "instanceId": { + "type": "string", + "title": "实例id" + }, + "instanceName": { + "type": "string", + "title": "实例名称" + }, + "regionName": { + "type": "string", + "title": "地域,数据中心" + }, + "publicIps": { + "type": "array", + "items": { + "type": "string" + }, + "title": "公网ip" + }, + "instanceType": { + "type": "string", + "title": "实例类型" + }, + "cpu": { + "type": "integer", + "format": "int32", + "title": "vcpu数" + }, + "memory": { + "type": "integer", + "format": "int32", + "title": "内存MB" + }, + "description": { + "type": "string", + "title": "实例描述" + }, + "status": { + "type": "string", + "title": "状态" + }, + "creationTime": { + "type": "string", + "title": "创建时间,ISO8601" + }, + "expireTime": { + "type": "string", + "title": "过期时间" + }, + "innerIps": { + "type": "array", + "items": { + "type": "string" + }, + "title": "内网ip" + }, + "vpcId": { + "type": "string", + "title": "vcp id" + }, + "resourceGroupId": { + "type": "string", + "title": "资源组id" + }, + "chargeType": { + "type": "string", + "title": "收费类型" + } + } + }, + "pbecsListAllReq": { + "type": "object" + }, + "pbecsListDetailReq": { + "type": "object", + "properties": { + "provider": { + "$ref": "#/definitions/pbtenantCloudProvider", + "title": "云名称" + }, + "accountName": { + "type": "string", + "title": "账户名称,根据config.yaml中的配置,默认为第一个配置的账户" + }, + "regionId": { + "type": "integer", + "format": "int32", + "title": "区域Id,参考 tenant.proto 中的各个云的区域" + }, + "pageNumber": { + "type": "integer", + "format": "int32", + "title": "分页相关参数,页码" + }, + "pageSize": { + "type": "integer", + "format": "int32", + "title": "分页相关参数,每页数量" + }, + "nextToken": { + "type": "string", + "title": "分页相关参数,下一页的token" + } + } + }, + "pbecsListDetailResp": { + "type": "object", + "properties": { + "ecses": { + "type": "array", + "items": { + "$ref": "#/definitions/pbecsEcsInstance" + }, + "title": "Ecs 机器集合" + }, + "finished": { + "type": "boolean", + "title": "查询是否完成,如果为否-false,则可以将下面三个分页参数填入到请求中,继续查询" + }, + "pageNumber": { + "type": "integer", + "format": "int32", + "title": "分页相关参数,页码" + }, + "pageSize": { + "type": "integer", + "format": "int32", + "title": "分页相关参数,每页数量" + }, + "nextToken": { + "type": "string", + "title": "分页相关参数,下一页的token" + }, + "requestId": { + "type": "string", + "title": "请求id,出现问题后提供给云厂商,排查问题" + } + } + }, + "pbecsListReq": { + "type": "object", + "properties": { + "provider": { + "$ref": "#/definitions/pbtenantCloudProvider", + "title": "云名称" + } + } + }, + "pbecsListResp": { + "type": "object", + "properties": { + "ecses": { + "type": "array", + "items": { + "$ref": "#/definitions/pbecsEcsInstance" + }, + "title": "Ecs 机器集合" + } + } + }, + "pbtenantCloudProvider": { + "type": "string", + "enum": [ + "ali", + "tencent", + "huawei", + "aws" + ], + "default": "ali", + "description": "- ali: 0 - 阿里云\n - tencent: 1 - 腾讯云\n - huawei: 2 - 华为云\n - aws: 3 - 亚马逊云", + "title": "云提供商" + }, + "protobufAny": { + "type": "object", + "properties": { + "@type": { + "type": "string" + } + }, + "additionalProperties": {} + }, + "rpcStatus": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + }, + "details": { + "type": "array", + "items": { + "$ref": "#/definitions/protobufAny" + } + } + } + } + } +} diff --git a/lan_trans/openapiv2/idl/pbpod/pod.swagger.json b/lan_trans/openapiv2/idl/pbpod/pod.swagger.json new file mode 100644 index 0000000..32148b8 --- /dev/null +++ b/lan_trans/openapiv2/idl/pbpod/pod.swagger.json @@ -0,0 +1,314 @@ +{ + "swagger": "2.0", + "info": { + "title": "idl/pbpod/pod.proto", + "version": "version not set" + }, + "tags": [ + { + "name": "PodService" + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "paths": { + "/apis/pod": { + "post": { + "summary": "查询Pod全量 - 根据云类型", + "operationId": "PodService_ListPod", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/pbpodListPodResp" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/pbpodListPodReq" + } + } + ], + "tags": [ + "PodService" + ] + } + }, + "/apis/pod/all": { + "post": { + "summary": "查询所有云的Pod", + "operationId": "PodService_ListPodAll", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/pbpodListPodResp" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/pbpodListPodAllReq" + } + } + ], + "tags": [ + "PodService" + ] + } + }, + "/apis/pod/detail": { + "post": { + "summary": "查询ECS明细 - 支持云类型、区域、账户、分页等过滤条件", + "operationId": "PodService_ListPodDetail", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/pbpodListPodDetailResp" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/pbpodListPodDetailReq" + } + } + ], + "tags": [ + "PodService" + ] + } + } + }, + "definitions": { + "pbpodListPodAllReq": { + "type": "object" + }, + "pbpodListPodDetailReq": { + "type": "object", + "properties": { + "provider": { + "$ref": "#/definitions/pbtenantCloudProvider", + "title": "云名称" + }, + "accountName": { + "type": "string", + "title": "账户名称,根据config.yaml中的配置,默认为第一个配置的账户" + }, + "regionId": { + "type": "integer", + "format": "int32", + "title": "区域Id,参考 tenant.proto 中的各个云的区域" + }, + "podId": { + "type": "integer", + "format": "int32", + "title": "podID" + }, + "pageNumber": { + "type": "integer", + "format": "int32", + "title": "分页相关参数,页码" + }, + "pageSize": { + "type": "integer", + "format": "int32", + "title": "分页相关参数,每页数量" + }, + "nextToken": { + "type": "string", + "title": "分页相关参数,下一页的token" + } + } + }, + "pbpodListPodDetailResp": { + "type": "object", + "properties": { + "pods": { + "type": "array", + "items": { + "$ref": "#/definitions/pbpodPodInstance" + }, + "title": "Pod集合" + }, + "finished": { + "type": "boolean", + "title": "查询是否完成,如果为否-false,则可以将下面三个分页参数填入到请求中,继续查询" + }, + "pageNumber": { + "type": "integer", + "format": "int32", + "title": "分页相关参数,页码" + }, + "pageSize": { + "type": "integer", + "format": "int32", + "title": "分页相关参数,每页数量" + }, + "nextToken": { + "type": "string", + "title": "分页相关参数,下一页的token" + }, + "requestId": { + "type": "string", + "title": "请求id,出现问题后提供给云厂商,排查问题" + } + } + }, + "pbpodListPodReq": { + "type": "object", + "properties": { + "provider": { + "$ref": "#/definitions/pbtenantCloudProvider", + "title": "云名称" + } + } + }, + "pbpodListPodResp": { + "type": "object", + "properties": { + "pods": { + "type": "array", + "items": { + "$ref": "#/definitions/pbpodPodInstance" + }, + "title": "pod集合" + } + } + }, + "pbpodPodInstance": { + "type": "object", + "properties": { + "provider": { + "$ref": "#/definitions/pbtenantCloudProvider", + "title": "云类型" + }, + "accountName": { + "type": "string", + "title": "账号名称" + }, + "podId": { + "type": "string", + "title": "实例id" + }, + "podName": { + "type": "string", + "title": "实例名称" + }, + "regionName": { + "type": "string", + "title": "地域,数据中心" + }, + "containerImage": { + "type": "string", + "title": "镜像" + }, + "containerName": { + "type": "string", + "title": "容器名称" + }, + "cpuPod": { + "type": "number", + "format": "float", + "title": "vcpu数" + }, + "memoryPod": { + "type": "number", + "format": "float", + "title": "内存MB" + }, + "securityGroupId": { + "type": "string", + "title": "安全组ID 对应腾讯 SecurityGroupIds(腾讯必需)" + }, + "subnetId": { + "type": "string", + "title": "子网ID 对应腾讯 SubnetId(腾讯必需)" + }, + "vpcId": { + "type": "string", + "title": "VPC ID 对应腾讯 VpcId(腾讯必需)" + }, + "namespace": { + "type": "string", + "title": "名空间" + } + } + }, + "pbtenantCloudProvider": { + "type": "string", + "enum": [ + "ali", + "tencent", + "huawei", + "aws" + ], + "default": "ali", + "description": "- ali: 0 - 阿里云\n - tencent: 1 - 腾讯云\n - huawei: 2 - 华为云\n - aws: 3 - 亚马逊云", + "title": "云提供商" + }, + "protobufAny": { + "type": "object", + "properties": { + "@type": { + "type": "string" + } + }, + "additionalProperties": {} + }, + "rpcStatus": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + }, + "details": { + "type": "array", + "items": { + "$ref": "#/definitions/protobufAny" + } + } + } + } + } +} diff --git a/lan_trans/openapiv2/idl/pbtenant/tenant.swagger.json b/lan_trans/openapiv2/idl/pbtenant/tenant.swagger.json new file mode 100644 index 0000000..0a73b35 --- /dev/null +++ b/lan_trans/openapiv2/idl/pbtenant/tenant.swagger.json @@ -0,0 +1,43 @@ +{ + "swagger": "2.0", + "info": { + "title": "idl/pbtenant/tenant.proto", + "version": "version not set" + }, + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "paths": {}, + "definitions": { + "protobufAny": { + "type": "object", + "properties": { + "@type": { + "type": "string" + } + }, + "additionalProperties": {} + }, + "rpcStatus": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + }, + "details": { + "type": "array", + "items": { + "$ref": "#/definitions/protobufAny" + } + } + } + } + } +} From 250bf6b4d45944c1bb955bdeebc85e284405f194 Mon Sep 17 00:00:00 2001 From: zhouqunjie <450705171@qq.com> Date: Tue, 5 Apr 2022 12:22:47 +0800 Subject: [PATCH 3/3] pod ali create&list --- adaptor/pod_adaptor/server/pod/list.go | 27 + adaptor/pod_adaptor/service/poder/ali_eci.go | 61 +- adaptor/pod_adaptor/service/poder/poder.go | 1 + common/server/server_pod.go | 9 + idl/pbpod/pod.proto | 4 +- lan_trans/idl/pbpod/pod.pb.go | 538 ++++++++++++++---- lan_trans/idl/pbpod/pod.pb.gw.go | 83 +++ lan_trans/idl/pbpod/pod_grpc.pb.go | 42 +- .../openapiv2/idl/pbpod/pod.swagger.json | 120 +++- 9 files changed, 722 insertions(+), 163 deletions(-) diff --git a/adaptor/pod_adaptor/server/pod/list.go b/adaptor/pod_adaptor/server/pod/list.go index 730a8d2..145648b 100644 --- a/adaptor/pod_adaptor/server/pod/list.go +++ b/adaptor/pod_adaptor/server/pod/list.go @@ -12,6 +12,33 @@ import ( "github.com/pkg/errors" ) +func CreatePod(ctx context.Context, req *pbpod.CreatePodReq) (*pbpod.CreatePodResp, error) { + var ( + pod poder.Poder + ) + + tenanters, err := tenanter.GetTenanters(req.Provider) + if err != nil { + return nil, errors.WithMessage(err, "getTenanters error") + } + + region, err := tenanter.NewRegion(req.Provider, req.RegionId) + if err != nil { + return nil, errors.WithMessagef(err, "provider %v regionId %v", req.Provider, req.RegionId) + } + + for _, tenanter := range tenanters { + if req.AccountName == "" || tenanter.AccountName() == req.AccountName { + if pod, err = poder.NewPodClient(req.Provider, region, tenanter); err != nil { + return nil, errors.WithMessage(err, "NewPodClient error") + } + break + } + } + + return pod.CreatePod(ctx, req) +} + func ListPodDetail(ctx context.Context, req *pbpod.ListPodDetailReq) (*pbpod.ListPodDetailResp, error) { var ( pod poder.Poder diff --git a/adaptor/pod_adaptor/service/poder/ali_eci.go b/adaptor/pod_adaptor/service/poder/ali_eci.go index 3daffea..5102011 100644 --- a/adaptor/pod_adaptor/service/poder/ali_eci.go +++ b/adaptor/pod_adaptor/service/poder/ali_eci.go @@ -45,6 +45,33 @@ func newAliEciClient(region tenanter.Region, tenant tenanter.Tenanter) (Poder, e }, nil } +func (eci *AliEci) CreatePod(ctx context.Context, req *pbpod.CreatePodReq) (*pbpod.CreatePodResp, error) { + request := alieci.CreateCreateContainerGroupRequest() + + request.RegionId = eci.region.GetName() + request.ContainerGroupName = req.PodName + requestContainer := make([]alieci.CreateContainerGroupContainer, 1) + requestContainer[0].Image = req.ContainerImage + requestContainer[0].Name = req.ContainerName + request.Container = &requestContainer + + resp, err := eci.cli.CreateContainerGroup(request) + if err != nil { + return nil, errors.Wrap(err, "Aliyun CreatePod error") + } + + isFinished := false + if len(resp.ContainerGroupId) > 0 { + isFinished = true + } + + return &pbpod.CreatePodResp{ + Pods: nil, + Finished: isFinished, + RequestId: resp.RequestId, + }, nil +} + func (eci *AliEci) ListPodDetail(ctx context.Context, req *pbpod.ListPodDetailReq) (*pbpod.ListPodDetailResp, error) { request := alieci.CreateDescribeContainerGroupsRequest() request.NextToken = req.NextToken @@ -60,7 +87,7 @@ func (eci *AliEci) ListPodDetail(ctx context.Context, req *pbpod.ListPodDetailRe AccountName: eci.tenanter.AccountName(), PodId: v.ContainerGroupId, PodName: v.ContainerGroupName, - RegionName: eci.region.GetName(), + RegionId: 0, ContainerImage: v.Containers[k].Image, ContainerName: v.Containers[k].Name, CpuPod: v.Cpu, @@ -88,38 +115,6 @@ func (eci *AliEci) ListPodDetail(ctx context.Context, req *pbpod.ListPodDetailRe }, nil } -// -//// CreateContainerGroup 创建 -//func CreateContainerGroup(cloudStack string, akskPath string, configPath string) string { -// -// var client *eci.Client -// configCommon, _ := config.PCMconfig(configPath) -// configAksk, _ := aksk.AkskConfig(cloudStack, akskPath) -// -// //创建客户端 -// client, _ = eci.NewClientWithAccessKey(configCommon.RegionId, configAksk.AccessKey, configAksk.SecretKey) -// // 生成创建请求 -// createContainerRequest := eci.CreateCreateContainerGroupRequest() -// // 必需参数 -// //区域ID -// createContainerRequest.RegionId = configCommon.RegionId -// //POD名称 -// createContainerRequest.ContainerGroupName = configCommon.ContainerGroupName -// //容器名称和镜像名称 -// createContainerRequestContainer := make([]eci.CreateContainerGroupContainer, 1) -// createContainerRequestContainer[0].Image = configCommon.ContainerImage -// createContainerRequestContainer[0].Name = configCommon.ContainerName -// createContainerRequest.Container = &createContainerRequestContainer -// -// client.GetConfig().MaxRetryTime = 0 -// createContainerGroupResponse, err := client.CreateContainerGroup(createContainerRequest) -// if err != nil { -// panic(err) -// } -// containerGroupId := createContainerGroupResponse.ContainerGroupId -// fmt.Println("Alibaba ContainerGroup created:", containerGroupId) -// return containerGroupId -//} // //// DescribeContainerGroup 查询Pod //func DescribeContainerGroup(cloudStack string, akskPath string, configPath string) eci.DescribeContainerGroupsContainerGroup0 { diff --git a/adaptor/pod_adaptor/service/poder/poder.go b/adaptor/pod_adaptor/service/poder/poder.go index adf17d1..9f03f5e 100644 --- a/adaptor/pod_adaptor/service/poder/poder.go +++ b/adaptor/pod_adaptor/service/poder/poder.go @@ -17,6 +17,7 @@ var ( type Poder interface { ListPodDetail(ctx context.Context, req *pbpod.ListPodDetailReq) (resp *pbpod.ListPodDetailResp, err error) + CreatePod(ctx context.Context, req *pbpod.CreatePodReq) (resp *pbpod.CreatePodResp, err error) } func NewPodClient(provider pbtenant.CloudProvider, region tenanter.Region, tenant tenanter.Tenanter) (poder Poder, err error) { diff --git a/common/server/server_pod.go b/common/server/server_pod.go index 5028f5d..8f4ed67 100644 --- a/common/server/server_pod.go +++ b/common/server/server_pod.go @@ -10,6 +10,15 @@ import ( "google.golang.org/grpc/status" ) +func (s *Server) CreatePod(ctx context.Context, req *pbpod.CreatePodReq) (*pbpod.CreatePodResp, error) { + resp, err := pod.CreatePod(ctx, req) + if err != nil { + glog.Errorf("CreatePod error %+v", err) + return nil, status.Errorf(codes.Internal, err.Error()) + } + return resp, nil +} + func (s *Server) ListPodDetail(ctx context.Context, req *pbpod.ListPodDetailReq) (*pbpod.ListPodDetailResp, error) { resp, err := pod.ListPodDetail(ctx, req) if err != nil { diff --git a/idl/pbpod/pod.proto b/idl/pbpod/pod.proto index a95deaf..da73f60 100644 --- a/idl/pbpod/pod.proto +++ b/idl/pbpod/pod.proto @@ -16,7 +16,7 @@ message PodInstance { // 实例名称 string pod_name = 4; // 地域,数据中心 - string region_name = 5; + int32 region_id = 5; // 镜像 string container_image = 6; // 容器名称 @@ -48,7 +48,7 @@ message CreatePodReq { // 实例名称 string pod_name = 4; // 地域,数据中心 - string region_name = 5; + int32 region_id = 5; // 镜像 string container_image = 6; // 容器名称 diff --git a/lan_trans/idl/pbpod/pod.pb.go b/lan_trans/idl/pbpod/pod.pb.go index 9fc1936..3209d87 100644 --- a/lan_trans/idl/pbpod/pod.pb.go +++ b/lan_trans/idl/pbpod/pod.pb.go @@ -36,7 +36,7 @@ type PodInstance struct { // 实例名称 PodName string `protobuf:"bytes,4,opt,name=pod_name,json=podName,proto3" json:"pod_name,omitempty"` // 地域,数据中心 - RegionName string `protobuf:"bytes,5,opt,name=region_name,json=regionName,proto3" json:"region_name,omitempty"` + RegionId int32 `protobuf:"varint,5,opt,name=region_id,json=regionId,proto3" json:"region_id,omitempty"` // 镜像 ContainerImage string `protobuf:"bytes,6,opt,name=container_image,json=containerImage,proto3" json:"container_image,omitempty"` // 容器名称 @@ -115,11 +115,11 @@ func (x *PodInstance) GetPodName() string { return "" } -func (x *PodInstance) GetRegionName() string { +func (x *PodInstance) GetRegionId() int32 { if x != nil { - return x.RegionName + return x.RegionId } - return "" + return 0 } func (x *PodInstance) GetContainerImage() string { @@ -178,6 +178,228 @@ func (x *PodInstance) GetNamespace() string { return "" } +type CreatePodReq struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // 云类型 + Provider pbtenant.CloudProvider `protobuf:"varint,1,opt,name=provider,proto3,enum=pbtenant.CloudProvider" json:"provider,omitempty"` + // 账号名称 + AccountName string `protobuf:"bytes,2,opt,name=account_name,json=accountName,proto3" json:"account_name,omitempty"` + // 实例id + PodId string `protobuf:"bytes,3,opt,name=pod_id,json=podId,proto3" json:"pod_id,omitempty"` + // 实例名称 + PodName string `protobuf:"bytes,4,opt,name=pod_name,json=podName,proto3" json:"pod_name,omitempty"` + // 地域,数据中心 + RegionId int32 `protobuf:"varint,5,opt,name=region_id,json=regionId,proto3" json:"region_id,omitempty"` + // 镜像 + ContainerImage string `protobuf:"bytes,6,opt,name=container_image,json=containerImage,proto3" json:"container_image,omitempty"` + // 容器名称 + ContainerName string `protobuf:"bytes,7,opt,name=container_name,json=containerName,proto3" json:"container_name,omitempty"` + // v cpu数 + CpuPod float32 `protobuf:"fixed32,8,opt,name=cpu_pod,json=cpuPod,proto3" json:"cpu_pod,omitempty"` + // 内存MB + MemoryPod float32 `protobuf:"fixed32,9,opt,name=memory_pod,json=memoryPod,proto3" json:"memory_pod,omitempty"` + //安全组ID 对应腾讯 SecurityGroupIds(腾讯必需) + SecurityGroupId string `protobuf:"bytes,10,opt,name=security_group_id,json=securityGroupId,proto3" json:"security_group_id,omitempty"` + //子网ID 对应腾讯 SubnetId(腾讯必需) + SubnetId string `protobuf:"bytes,11,opt,name=subnet_id,json=subnetId,proto3" json:"subnet_id,omitempty"` + //VPC ID 对应腾讯 VpcId(腾讯必需) + VpcId string `protobuf:"bytes,12,opt,name=vpc_id,json=vpcId,proto3" json:"vpc_id,omitempty"` + //名空间 + Namespace string `protobuf:"bytes,13,opt,name=namespace,proto3" json:"namespace,omitempty"` +} + +func (x *CreatePodReq) Reset() { + *x = CreatePodReq{} + if protoimpl.UnsafeEnabled { + mi := &file_idl_pbpod_pod_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CreatePodReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreatePodReq) ProtoMessage() {} + +func (x *CreatePodReq) ProtoReflect() protoreflect.Message { + mi := &file_idl_pbpod_pod_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CreatePodReq.ProtoReflect.Descriptor instead. +func (*CreatePodReq) Descriptor() ([]byte, []int) { + return file_idl_pbpod_pod_proto_rawDescGZIP(), []int{1} +} + +func (x *CreatePodReq) GetProvider() pbtenant.CloudProvider { + if x != nil { + return x.Provider + } + return pbtenant.CloudProvider(0) +} + +func (x *CreatePodReq) GetAccountName() string { + if x != nil { + return x.AccountName + } + return "" +} + +func (x *CreatePodReq) GetPodId() string { + if x != nil { + return x.PodId + } + return "" +} + +func (x *CreatePodReq) GetPodName() string { + if x != nil { + return x.PodName + } + return "" +} + +func (x *CreatePodReq) GetRegionId() int32 { + if x != nil { + return x.RegionId + } + return 0 +} + +func (x *CreatePodReq) GetContainerImage() string { + if x != nil { + return x.ContainerImage + } + return "" +} + +func (x *CreatePodReq) GetContainerName() string { + if x != nil { + return x.ContainerName + } + return "" +} + +func (x *CreatePodReq) GetCpuPod() float32 { + if x != nil { + return x.CpuPod + } + return 0 +} + +func (x *CreatePodReq) GetMemoryPod() float32 { + if x != nil { + return x.MemoryPod + } + return 0 +} + +func (x *CreatePodReq) GetSecurityGroupId() string { + if x != nil { + return x.SecurityGroupId + } + return "" +} + +func (x *CreatePodReq) GetSubnetId() string { + if x != nil { + return x.SubnetId + } + return "" +} + +func (x *CreatePodReq) GetVpcId() string { + if x != nil { + return x.VpcId + } + return "" +} + +func (x *CreatePodReq) GetNamespace() string { + if x != nil { + return x.Namespace + } + return "" +} + +type CreatePodResp struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Pod集合 + Pods []*PodInstance `protobuf:"bytes,1,rep,name=pods,proto3" json:"pods,omitempty"` + // 查询是否完成,如果为否-false,则可以将下面三个分页参数填入到请求中,继续查询 + Finished bool `protobuf:"varint,2,opt,name=finished,proto3" json:"finished,omitempty"` + // 请求id,出现问题后提供给云厂商,排查问题 + RequestId string `protobuf:"bytes,3,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"` +} + +func (x *CreatePodResp) Reset() { + *x = CreatePodResp{} + if protoimpl.UnsafeEnabled { + mi := &file_idl_pbpod_pod_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CreatePodResp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreatePodResp) ProtoMessage() {} + +func (x *CreatePodResp) ProtoReflect() protoreflect.Message { + mi := &file_idl_pbpod_pod_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CreatePodResp.ProtoReflect.Descriptor instead. +func (*CreatePodResp) Descriptor() ([]byte, []int) { + return file_idl_pbpod_pod_proto_rawDescGZIP(), []int{2} +} + +func (x *CreatePodResp) GetPods() []*PodInstance { + if x != nil { + return x.Pods + } + return nil +} + +func (x *CreatePodResp) GetFinished() bool { + if x != nil { + return x.Finished + } + return false +} + +func (x *CreatePodResp) GetRequestId() string { + if x != nil { + return x.RequestId + } + return "" +} + type ListPodDetailReq struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -202,7 +424,7 @@ type ListPodDetailReq struct { func (x *ListPodDetailReq) Reset() { *x = ListPodDetailReq{} if protoimpl.UnsafeEnabled { - mi := &file_idl_pbpod_pod_proto_msgTypes[1] + mi := &file_idl_pbpod_pod_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -215,7 +437,7 @@ func (x *ListPodDetailReq) String() string { func (*ListPodDetailReq) ProtoMessage() {} func (x *ListPodDetailReq) ProtoReflect() protoreflect.Message { - mi := &file_idl_pbpod_pod_proto_msgTypes[1] + mi := &file_idl_pbpod_pod_proto_msgTypes[3] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -228,7 +450,7 @@ func (x *ListPodDetailReq) ProtoReflect() protoreflect.Message { // Deprecated: Use ListPodDetailReq.ProtoReflect.Descriptor instead. func (*ListPodDetailReq) Descriptor() ([]byte, []int) { - return file_idl_pbpod_pod_proto_rawDescGZIP(), []int{1} + return file_idl_pbpod_pod_proto_rawDescGZIP(), []int{3} } func (x *ListPodDetailReq) GetProvider() pbtenant.CloudProvider { @@ -302,7 +524,7 @@ type ListPodDetailResp struct { func (x *ListPodDetailResp) Reset() { *x = ListPodDetailResp{} if protoimpl.UnsafeEnabled { - mi := &file_idl_pbpod_pod_proto_msgTypes[2] + mi := &file_idl_pbpod_pod_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -315,7 +537,7 @@ func (x *ListPodDetailResp) String() string { func (*ListPodDetailResp) ProtoMessage() {} func (x *ListPodDetailResp) ProtoReflect() protoreflect.Message { - mi := &file_idl_pbpod_pod_proto_msgTypes[2] + mi := &file_idl_pbpod_pod_proto_msgTypes[4] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -328,7 +550,7 @@ func (x *ListPodDetailResp) ProtoReflect() protoreflect.Message { // Deprecated: Use ListPodDetailResp.ProtoReflect.Descriptor instead. func (*ListPodDetailResp) Descriptor() ([]byte, []int) { - return file_idl_pbpod_pod_proto_rawDescGZIP(), []int{2} + return file_idl_pbpod_pod_proto_rawDescGZIP(), []int{4} } func (x *ListPodDetailResp) GetPods() []*PodInstance { @@ -385,7 +607,7 @@ type ListPodReq struct { func (x *ListPodReq) Reset() { *x = ListPodReq{} if protoimpl.UnsafeEnabled { - mi := &file_idl_pbpod_pod_proto_msgTypes[3] + mi := &file_idl_pbpod_pod_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -398,7 +620,7 @@ func (x *ListPodReq) String() string { func (*ListPodReq) ProtoMessage() {} func (x *ListPodReq) ProtoReflect() protoreflect.Message { - mi := &file_idl_pbpod_pod_proto_msgTypes[3] + mi := &file_idl_pbpod_pod_proto_msgTypes[5] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -411,7 +633,7 @@ func (x *ListPodReq) ProtoReflect() protoreflect.Message { // Deprecated: Use ListPodReq.ProtoReflect.Descriptor instead. func (*ListPodReq) Descriptor() ([]byte, []int) { - return file_idl_pbpod_pod_proto_rawDescGZIP(), []int{3} + return file_idl_pbpod_pod_proto_rawDescGZIP(), []int{5} } func (x *ListPodReq) GetProvider() pbtenant.CloudProvider { @@ -433,7 +655,7 @@ type ListPodResp struct { func (x *ListPodResp) Reset() { *x = ListPodResp{} if protoimpl.UnsafeEnabled { - mi := &file_idl_pbpod_pod_proto_msgTypes[4] + mi := &file_idl_pbpod_pod_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -446,7 +668,7 @@ func (x *ListPodResp) String() string { func (*ListPodResp) ProtoMessage() {} func (x *ListPodResp) ProtoReflect() protoreflect.Message { - mi := &file_idl_pbpod_pod_proto_msgTypes[4] + mi := &file_idl_pbpod_pod_proto_msgTypes[6] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -459,7 +681,7 @@ func (x *ListPodResp) ProtoReflect() protoreflect.Message { // Deprecated: Use ListPodResp.ProtoReflect.Descriptor instead. func (*ListPodResp) Descriptor() ([]byte, []int) { - return file_idl_pbpod_pod_proto_rawDescGZIP(), []int{4} + return file_idl_pbpod_pod_proto_rawDescGZIP(), []int{6} } func (x *ListPodResp) GetPods() []*PodInstance { @@ -478,7 +700,7 @@ type ListPodAllReq struct { func (x *ListPodAllReq) Reset() { *x = ListPodAllReq{} if protoimpl.UnsafeEnabled { - mi := &file_idl_pbpod_pod_proto_msgTypes[5] + mi := &file_idl_pbpod_pod_proto_msgTypes[7] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -491,7 +713,7 @@ func (x *ListPodAllReq) String() string { func (*ListPodAllReq) ProtoMessage() {} func (x *ListPodAllReq) ProtoReflect() protoreflect.Message { - mi := &file_idl_pbpod_pod_proto_msgTypes[5] + mi := &file_idl_pbpod_pod_proto_msgTypes[7] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -504,7 +726,7 @@ func (x *ListPodAllReq) ProtoReflect() protoreflect.Message { // Deprecated: Use ListPodAllReq.ProtoReflect.Descriptor instead. func (*ListPodAllReq) Descriptor() ([]byte, []int) { - return file_idl_pbpod_pod_proto_rawDescGZIP(), []int{5} + return file_idl_pbpod_pod_proto_rawDescGZIP(), []int{7} } var File_idl_pbpod_pod_proto protoreflect.FileDescriptor @@ -515,7 +737,7 @@ var file_idl_pbpod_pod_proto_rawDesc = []byte{ 0x6c, 0x2f, 0x70, 0x62, 0x74, 0x65, 0x6e, 0x61, 0x6e, 0x74, 0x2f, 0x74, 0x65, 0x6e, 0x61, 0x6e, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xbe, 0x03, 0x0a, 0x0b, 0x50, 0x6f, 0x64, 0x49, 0x6e, 0x73, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xba, 0x03, 0x0a, 0x0b, 0x50, 0x6f, 0x64, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x12, 0x33, 0x0a, 0x08, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x17, 0x2e, 0x70, 0x62, 0x74, 0x65, 0x6e, 0x61, 0x6e, 0x74, 0x2e, 0x43, 0x6c, 0x6f, 0x75, 0x64, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, @@ -525,83 +747,123 @@ var file_idl_pbpod_pod_proto_rawDesc = []byte{ 0x06, 0x70, 0x6f, 0x64, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x70, 0x6f, 0x64, 0x49, 0x64, 0x12, 0x19, 0x0a, 0x08, 0x70, 0x6f, 0x64, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x70, 0x6f, 0x64, 0x4e, 0x61, 0x6d, 0x65, 0x12, - 0x1f, 0x0a, 0x0b, 0x72, 0x65, 0x67, 0x69, 0x6f, 0x6e, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x05, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x72, 0x65, 0x67, 0x69, 0x6f, 0x6e, 0x4e, 0x61, 0x6d, 0x65, - 0x12, 0x27, 0x0a, 0x0f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x5f, 0x69, 0x6d, - 0x61, 0x67, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x63, 0x6f, 0x6e, 0x74, 0x61, - 0x69, 0x6e, 0x65, 0x72, 0x49, 0x6d, 0x61, 0x67, 0x65, 0x12, 0x25, 0x0a, 0x0e, 0x63, 0x6f, 0x6e, - 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x0d, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, - 0x12, 0x17, 0x0a, 0x07, 0x63, 0x70, 0x75, 0x5f, 0x70, 0x6f, 0x64, 0x18, 0x08, 0x20, 0x01, 0x28, - 0x02, 0x52, 0x06, 0x63, 0x70, 0x75, 0x50, 0x6f, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x6d, 0x65, 0x6d, - 0x6f, 0x72, 0x79, 0x5f, 0x70, 0x6f, 0x64, 0x18, 0x09, 0x20, 0x01, 0x28, 0x02, 0x52, 0x09, 0x6d, - 0x65, 0x6d, 0x6f, 0x72, 0x79, 0x50, 0x6f, 0x64, 0x12, 0x2a, 0x0a, 0x11, 0x73, 0x65, 0x63, 0x75, - 0x72, 0x69, 0x74, 0x79, 0x5f, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x5f, 0x69, 0x64, 0x18, 0x0a, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x0f, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x47, 0x72, 0x6f, - 0x75, 0x70, 0x49, 0x64, 0x12, 0x1b, 0x0a, 0x09, 0x73, 0x75, 0x62, 0x6e, 0x65, 0x74, 0x5f, 0x69, - 0x64, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x73, 0x75, 0x62, 0x6e, 0x65, 0x74, 0x49, - 0x64, 0x12, 0x15, 0x0a, 0x06, 0x76, 0x70, 0x63, 0x5f, 0x69, 0x64, 0x18, 0x0c, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x05, 0x76, 0x70, 0x63, 0x49, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x6e, 0x61, 0x6d, 0x65, - 0x73, 0x70, 0x61, 0x63, 0x65, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6e, 0x61, 0x6d, - 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x22, 0xfb, 0x01, 0x0a, 0x10, 0x4c, 0x69, 0x73, 0x74, 0x50, - 0x6f, 0x64, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x71, 0x12, 0x33, 0x0a, 0x08, 0x70, - 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x17, 0x2e, - 0x70, 0x62, 0x74, 0x65, 0x6e, 0x61, 0x6e, 0x74, 0x2e, 0x43, 0x6c, 0x6f, 0x75, 0x64, 0x50, 0x72, - 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, - 0x12, 0x21, 0x0a, 0x0c, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x6e, 0x61, 0x6d, 0x65, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x4e, - 0x61, 0x6d, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x72, 0x65, 0x67, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x72, 0x65, 0x67, 0x69, 0x6f, 0x6e, 0x49, 0x64, - 0x12, 0x15, 0x0a, 0x06, 0x70, 0x6f, 0x64, 0x5f, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, - 0x52, 0x05, 0x70, 0x6f, 0x64, 0x49, 0x64, 0x12, 0x1f, 0x0a, 0x0b, 0x70, 0x61, 0x67, 0x65, 0x5f, - 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x70, 0x61, - 0x67, 0x65, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x61, 0x67, 0x65, - 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x70, 0x61, 0x67, - 0x65, 0x53, 0x69, 0x7a, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x74, 0x6f, - 0x6b, 0x65, 0x6e, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6e, 0x65, 0x78, 0x74, 0x54, - 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0xd3, 0x01, 0x0a, 0x11, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x6f, 0x64, - 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x12, 0x26, 0x0a, 0x04, 0x70, 0x6f, + 0x1b, 0x0a, 0x09, 0x72, 0x65, 0x67, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x05, 0x20, 0x01, + 0x28, 0x05, 0x52, 0x08, 0x72, 0x65, 0x67, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x27, 0x0a, 0x0f, + 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x5f, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x18, + 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, + 0x49, 0x6d, 0x61, 0x67, 0x65, 0x12, 0x25, 0x0a, 0x0e, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, + 0x65, 0x72, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x63, + 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x17, 0x0a, 0x07, + 0x63, 0x70, 0x75, 0x5f, 0x70, 0x6f, 0x64, 0x18, 0x08, 0x20, 0x01, 0x28, 0x02, 0x52, 0x06, 0x63, + 0x70, 0x75, 0x50, 0x6f, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x6d, 0x65, 0x6d, 0x6f, 0x72, 0x79, 0x5f, + 0x70, 0x6f, 0x64, 0x18, 0x09, 0x20, 0x01, 0x28, 0x02, 0x52, 0x09, 0x6d, 0x65, 0x6d, 0x6f, 0x72, + 0x79, 0x50, 0x6f, 0x64, 0x12, 0x2a, 0x0a, 0x11, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, + 0x5f, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x5f, 0x69, 0x64, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x0f, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x49, 0x64, + 0x12, 0x1b, 0x0a, 0x09, 0x73, 0x75, 0x62, 0x6e, 0x65, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x0b, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x08, 0x73, 0x75, 0x62, 0x6e, 0x65, 0x74, 0x49, 0x64, 0x12, 0x15, 0x0a, + 0x06, 0x76, 0x70, 0x63, 0x5f, 0x69, 0x64, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, + 0x70, 0x63, 0x49, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, + 0x65, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, + 0x63, 0x65, 0x22, 0xbb, 0x03, 0x0a, 0x0c, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x6f, 0x64, + 0x52, 0x65, 0x71, 0x12, 0x33, 0x0a, 0x08, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x17, 0x2e, 0x70, 0x62, 0x74, 0x65, 0x6e, 0x61, 0x6e, 0x74, + 0x2e, 0x43, 0x6c, 0x6f, 0x75, 0x64, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x52, 0x08, + 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x12, 0x21, 0x0a, 0x0c, 0x61, 0x63, 0x63, 0x6f, + 0x75, 0x6e, 0x74, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, + 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x15, 0x0a, 0x06, 0x70, + 0x6f, 0x64, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x70, 0x6f, 0x64, + 0x49, 0x64, 0x12, 0x19, 0x0a, 0x08, 0x70, 0x6f, 0x64, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x04, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x70, 0x6f, 0x64, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x1b, 0x0a, + 0x09, 0x72, 0x65, 0x67, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, + 0x52, 0x08, 0x72, 0x65, 0x67, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x27, 0x0a, 0x0f, 0x63, 0x6f, + 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x5f, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x18, 0x06, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x0e, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x49, 0x6d, + 0x61, 0x67, 0x65, 0x12, 0x25, 0x0a, 0x0e, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, + 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x63, 0x6f, 0x6e, + 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x17, 0x0a, 0x07, 0x63, 0x70, + 0x75, 0x5f, 0x70, 0x6f, 0x64, 0x18, 0x08, 0x20, 0x01, 0x28, 0x02, 0x52, 0x06, 0x63, 0x70, 0x75, + 0x50, 0x6f, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x6d, 0x65, 0x6d, 0x6f, 0x72, 0x79, 0x5f, 0x70, 0x6f, + 0x64, 0x18, 0x09, 0x20, 0x01, 0x28, 0x02, 0x52, 0x09, 0x6d, 0x65, 0x6d, 0x6f, 0x72, 0x79, 0x50, + 0x6f, 0x64, 0x12, 0x2a, 0x0a, 0x11, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x5f, 0x67, + 0x72, 0x6f, 0x75, 0x70, 0x5f, 0x69, 0x64, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x73, + 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x49, 0x64, 0x12, 0x1b, + 0x0a, 0x09, 0x73, 0x75, 0x62, 0x6e, 0x65, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x0b, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x08, 0x73, 0x75, 0x62, 0x6e, 0x65, 0x74, 0x49, 0x64, 0x12, 0x15, 0x0a, 0x06, 0x76, + 0x70, 0x63, 0x5f, 0x69, 0x64, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x70, 0x63, + 0x49, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x18, + 0x0d, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, + 0x22, 0x72, 0x0a, 0x0d, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x6f, 0x64, 0x52, 0x65, 0x73, + 0x70, 0x12, 0x26, 0x0a, 0x04, 0x70, 0x6f, 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x12, 0x2e, 0x70, 0x62, 0x70, 0x6f, 0x64, 0x2e, 0x50, 0x6f, 0x64, 0x49, 0x6e, 0x73, 0x74, 0x61, + 0x6e, 0x63, 0x65, 0x52, 0x04, 0x70, 0x6f, 0x64, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x66, 0x69, 0x6e, + 0x69, 0x73, 0x68, 0x65, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x66, 0x69, 0x6e, + 0x69, 0x73, 0x68, 0x65, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x49, 0x64, 0x22, 0xfb, 0x01, 0x0a, 0x10, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x6f, 0x64, + 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x71, 0x12, 0x33, 0x0a, 0x08, 0x70, 0x72, 0x6f, + 0x76, 0x69, 0x64, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x17, 0x2e, 0x70, 0x62, + 0x74, 0x65, 0x6e, 0x61, 0x6e, 0x74, 0x2e, 0x43, 0x6c, 0x6f, 0x75, 0x64, 0x50, 0x72, 0x6f, 0x76, + 0x69, 0x64, 0x65, 0x72, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x12, 0x21, + 0x0a, 0x0c, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x4e, 0x61, 0x6d, + 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x72, 0x65, 0x67, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x72, 0x65, 0x67, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x15, + 0x0a, 0x06, 0x70, 0x6f, 0x64, 0x5f, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, + 0x70, 0x6f, 0x64, 0x49, 0x64, 0x12, 0x1f, 0x0a, 0x0b, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x6e, 0x75, + 0x6d, 0x62, 0x65, 0x72, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x70, 0x61, 0x67, 0x65, + 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x73, + 0x69, 0x7a, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x70, 0x61, 0x67, 0x65, 0x53, + 0x69, 0x7a, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x74, 0x6f, 0x6b, 0x65, + 0x6e, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6e, 0x65, 0x78, 0x74, 0x54, 0x6f, 0x6b, + 0x65, 0x6e, 0x22, 0xd3, 0x01, 0x0a, 0x11, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x6f, 0x64, 0x44, 0x65, + 0x74, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x12, 0x26, 0x0a, 0x04, 0x70, 0x6f, 0x64, 0x73, + 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x70, 0x62, 0x70, 0x6f, 0x64, 0x2e, 0x50, + 0x6f, 0x64, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x04, 0x70, 0x6f, 0x64, 0x73, + 0x12, 0x1a, 0x0a, 0x08, 0x66, 0x69, 0x6e, 0x69, 0x73, 0x68, 0x65, 0x64, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x08, 0x52, 0x08, 0x66, 0x69, 0x6e, 0x69, 0x73, 0x68, 0x65, 0x64, 0x12, 0x1f, 0x0a, 0x0b, + 0x70, 0x61, 0x67, 0x65, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x05, 0x52, 0x0a, 0x70, 0x61, 0x67, 0x65, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x1b, 0x0a, + 0x09, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, + 0x52, 0x08, 0x70, 0x61, 0x67, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x6e, 0x65, + 0x78, 0x74, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, + 0x6e, 0x65, 0x78, 0x74, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x22, 0x41, 0x0a, 0x0a, 0x4c, 0x69, 0x73, 0x74, + 0x50, 0x6f, 0x64, 0x52, 0x65, 0x71, 0x12, 0x33, 0x0a, 0x08, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, + 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x17, 0x2e, 0x70, 0x62, 0x74, 0x65, 0x6e, + 0x61, 0x6e, 0x74, 0x2e, 0x43, 0x6c, 0x6f, 0x75, 0x64, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, + 0x72, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x22, 0x35, 0x0a, 0x0b, 0x4c, + 0x69, 0x73, 0x74, 0x50, 0x6f, 0x64, 0x52, 0x65, 0x73, 0x70, 0x12, 0x26, 0x0a, 0x04, 0x70, 0x6f, 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x70, 0x62, 0x70, 0x6f, 0x64, 0x2e, 0x50, 0x6f, 0x64, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x04, 0x70, 0x6f, - 0x64, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x66, 0x69, 0x6e, 0x69, 0x73, 0x68, 0x65, 0x64, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x66, 0x69, 0x6e, 0x69, 0x73, 0x68, 0x65, 0x64, 0x12, 0x1f, - 0x0a, 0x0b, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x05, 0x52, 0x0a, 0x70, 0x61, 0x67, 0x65, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, - 0x1b, 0x0a, 0x09, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x04, 0x20, 0x01, - 0x28, 0x05, 0x52, 0x08, 0x70, 0x61, 0x67, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x12, 0x1d, 0x0a, 0x0a, - 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x09, 0x6e, 0x65, 0x78, 0x74, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x1d, 0x0a, 0x0a, 0x72, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x22, 0x41, 0x0a, 0x0a, 0x4c, 0x69, - 0x73, 0x74, 0x50, 0x6f, 0x64, 0x52, 0x65, 0x71, 0x12, 0x33, 0x0a, 0x08, 0x70, 0x72, 0x6f, 0x76, - 0x69, 0x64, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x17, 0x2e, 0x70, 0x62, 0x74, - 0x65, 0x6e, 0x61, 0x6e, 0x74, 0x2e, 0x43, 0x6c, 0x6f, 0x75, 0x64, 0x50, 0x72, 0x6f, 0x76, 0x69, - 0x64, 0x65, 0x72, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x22, 0x35, 0x0a, - 0x0b, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x6f, 0x64, 0x52, 0x65, 0x73, 0x70, 0x12, 0x26, 0x0a, 0x04, - 0x70, 0x6f, 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x70, 0x62, 0x70, - 0x6f, 0x64, 0x2e, 0x50, 0x6f, 0x64, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x04, - 0x70, 0x6f, 0x64, 0x73, 0x22, 0x0f, 0x0a, 0x0d, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x6f, 0x64, 0x41, - 0x6c, 0x6c, 0x52, 0x65, 0x71, 0x32, 0x87, 0x02, 0x0a, 0x0a, 0x50, 0x6f, 0x64, 0x53, 0x65, 0x72, - 0x76, 0x69, 0x63, 0x65, 0x12, 0x5f, 0x0a, 0x0d, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x6f, 0x64, 0x44, - 0x65, 0x74, 0x61, 0x69, 0x6c, 0x12, 0x17, 0x2e, 0x70, 0x62, 0x70, 0x6f, 0x64, 0x2e, 0x4c, 0x69, - 0x73, 0x74, 0x50, 0x6f, 0x64, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x71, 0x1a, 0x18, - 0x2e, 0x70, 0x62, 0x70, 0x6f, 0x64, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x6f, 0x64, 0x44, 0x65, - 0x74, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x22, 0x1b, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x15, - 0x22, 0x10, 0x2f, 0x61, 0x70, 0x69, 0x73, 0x2f, 0x70, 0x6f, 0x64, 0x2f, 0x64, 0x65, 0x74, 0x61, - 0x69, 0x6c, 0x3a, 0x01, 0x2a, 0x12, 0x46, 0x0a, 0x07, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x6f, 0x64, - 0x12, 0x11, 0x2e, 0x70, 0x62, 0x70, 0x6f, 0x64, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x6f, 0x64, - 0x52, 0x65, 0x71, 0x1a, 0x12, 0x2e, 0x70, 0x62, 0x70, 0x6f, 0x64, 0x2e, 0x4c, 0x69, 0x73, 0x74, - 0x50, 0x6f, 0x64, 0x52, 0x65, 0x73, 0x70, 0x22, 0x14, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0e, 0x22, - 0x09, 0x2f, 0x61, 0x70, 0x69, 0x73, 0x2f, 0x70, 0x6f, 0x64, 0x3a, 0x01, 0x2a, 0x12, 0x50, 0x0a, - 0x0a, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x6f, 0x64, 0x41, 0x6c, 0x6c, 0x12, 0x14, 0x2e, 0x70, 0x62, - 0x70, 0x6f, 0x64, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x6f, 0x64, 0x41, 0x6c, 0x6c, 0x52, 0x65, - 0x71, 0x1a, 0x12, 0x2e, 0x70, 0x62, 0x70, 0x6f, 0x64, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x6f, - 0x64, 0x52, 0x65, 0x73, 0x70, 0x22, 0x18, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x12, 0x22, 0x0d, 0x2f, - 0x61, 0x70, 0x69, 0x73, 0x2f, 0x70, 0x6f, 0x64, 0x2f, 0x61, 0x6c, 0x6c, 0x3a, 0x01, 0x2a, 0x42, - 0x2d, 0x5a, 0x2b, 0x67, 0x69, 0x74, 0x6c, 0x69, 0x6e, 0x6b, 0x2e, 0x6f, 0x72, 0x67, 0x2e, 0x63, - 0x6e, 0x2f, 0x4a, 0x43, 0x43, 0x45, 0x2f, 0x50, 0x43, 0x4d, 0x2f, 0x6c, 0x61, 0x6e, 0x5f, 0x74, - 0x72, 0x61, 0x6e, 0x73, 0x2f, 0x69, 0x64, 0x6c, 0x2f, 0x70, 0x62, 0x70, 0x6f, 0x64, 0x62, 0x06, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x64, 0x73, 0x22, 0x0f, 0x0a, 0x0d, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x6f, 0x64, 0x41, 0x6c, 0x6c, + 0x52, 0x65, 0x71, 0x32, 0xdc, 0x02, 0x0a, 0x0a, 0x50, 0x6f, 0x64, 0x53, 0x65, 0x72, 0x76, 0x69, + 0x63, 0x65, 0x12, 0x53, 0x0a, 0x09, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x6f, 0x64, 0x12, + 0x13, 0x2e, 0x70, 0x62, 0x70, 0x6f, 0x64, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x6f, + 0x64, 0x52, 0x65, 0x71, 0x1a, 0x14, 0x2e, 0x70, 0x62, 0x70, 0x6f, 0x64, 0x2e, 0x43, 0x72, 0x65, + 0x61, 0x74, 0x65, 0x50, 0x6f, 0x64, 0x52, 0x65, 0x73, 0x70, 0x22, 0x1b, 0x82, 0xd3, 0xe4, 0x93, + 0x02, 0x15, 0x22, 0x10, 0x2f, 0x61, 0x70, 0x69, 0x73, 0x2f, 0x70, 0x6f, 0x64, 0x2f, 0x63, 0x72, + 0x65, 0x61, 0x74, 0x65, 0x3a, 0x01, 0x2a, 0x12, 0x5f, 0x0a, 0x0d, 0x4c, 0x69, 0x73, 0x74, 0x50, + 0x6f, 0x64, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x12, 0x17, 0x2e, 0x70, 0x62, 0x70, 0x6f, 0x64, + 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x6f, 0x64, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x52, 0x65, + 0x71, 0x1a, 0x18, 0x2e, 0x70, 0x62, 0x70, 0x6f, 0x64, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x6f, + 0x64, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x22, 0x1b, 0x82, 0xd3, 0xe4, + 0x93, 0x02, 0x15, 0x22, 0x10, 0x2f, 0x61, 0x70, 0x69, 0x73, 0x2f, 0x70, 0x6f, 0x64, 0x2f, 0x64, + 0x65, 0x74, 0x61, 0x69, 0x6c, 0x3a, 0x01, 0x2a, 0x12, 0x46, 0x0a, 0x07, 0x4c, 0x69, 0x73, 0x74, + 0x50, 0x6f, 0x64, 0x12, 0x11, 0x2e, 0x70, 0x62, 0x70, 0x6f, 0x64, 0x2e, 0x4c, 0x69, 0x73, 0x74, + 0x50, 0x6f, 0x64, 0x52, 0x65, 0x71, 0x1a, 0x12, 0x2e, 0x70, 0x62, 0x70, 0x6f, 0x64, 0x2e, 0x4c, + 0x69, 0x73, 0x74, 0x50, 0x6f, 0x64, 0x52, 0x65, 0x73, 0x70, 0x22, 0x14, 0x82, 0xd3, 0xe4, 0x93, + 0x02, 0x0e, 0x22, 0x09, 0x2f, 0x61, 0x70, 0x69, 0x73, 0x2f, 0x70, 0x6f, 0x64, 0x3a, 0x01, 0x2a, + 0x12, 0x50, 0x0a, 0x0a, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x6f, 0x64, 0x41, 0x6c, 0x6c, 0x12, 0x14, + 0x2e, 0x70, 0x62, 0x70, 0x6f, 0x64, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x6f, 0x64, 0x41, 0x6c, + 0x6c, 0x52, 0x65, 0x71, 0x1a, 0x12, 0x2e, 0x70, 0x62, 0x70, 0x6f, 0x64, 0x2e, 0x4c, 0x69, 0x73, + 0x74, 0x50, 0x6f, 0x64, 0x52, 0x65, 0x73, 0x70, 0x22, 0x18, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x12, + 0x22, 0x0d, 0x2f, 0x61, 0x70, 0x69, 0x73, 0x2f, 0x70, 0x6f, 0x64, 0x2f, 0x61, 0x6c, 0x6c, 0x3a, + 0x01, 0x2a, 0x42, 0x2d, 0x5a, 0x2b, 0x67, 0x69, 0x74, 0x6c, 0x69, 0x6e, 0x6b, 0x2e, 0x6f, 0x72, + 0x67, 0x2e, 0x63, 0x6e, 0x2f, 0x4a, 0x43, 0x43, 0x45, 0x2f, 0x50, 0x43, 0x4d, 0x2f, 0x6c, 0x61, + 0x6e, 0x5f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x2f, 0x69, 0x64, 0x6c, 0x2f, 0x70, 0x62, 0x70, 0x6f, + 0x64, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -616,33 +878,39 @@ func file_idl_pbpod_pod_proto_rawDescGZIP() []byte { return file_idl_pbpod_pod_proto_rawDescData } -var file_idl_pbpod_pod_proto_msgTypes = make([]protoimpl.MessageInfo, 6) +var file_idl_pbpod_pod_proto_msgTypes = make([]protoimpl.MessageInfo, 8) var file_idl_pbpod_pod_proto_goTypes = []interface{}{ (*PodInstance)(nil), // 0: pbpod.PodInstance - (*ListPodDetailReq)(nil), // 1: pbpod.ListPodDetailReq - (*ListPodDetailResp)(nil), // 2: pbpod.ListPodDetailResp - (*ListPodReq)(nil), // 3: pbpod.ListPodReq - (*ListPodResp)(nil), // 4: pbpod.ListPodResp - (*ListPodAllReq)(nil), // 5: pbpod.ListPodAllReq - (pbtenant.CloudProvider)(0), // 6: pbtenant.CloudProvider + (*CreatePodReq)(nil), // 1: pbpod.CreatePodReq + (*CreatePodResp)(nil), // 2: pbpod.CreatePodResp + (*ListPodDetailReq)(nil), // 3: pbpod.ListPodDetailReq + (*ListPodDetailResp)(nil), // 4: pbpod.ListPodDetailResp + (*ListPodReq)(nil), // 5: pbpod.ListPodReq + (*ListPodResp)(nil), // 6: pbpod.ListPodResp + (*ListPodAllReq)(nil), // 7: pbpod.ListPodAllReq + (pbtenant.CloudProvider)(0), // 8: pbtenant.CloudProvider } var file_idl_pbpod_pod_proto_depIdxs = []int32{ - 6, // 0: pbpod.PodInstance.provider:type_name -> pbtenant.CloudProvider - 6, // 1: pbpod.ListPodDetailReq.provider:type_name -> pbtenant.CloudProvider - 0, // 2: pbpod.ListPodDetailResp.pods:type_name -> pbpod.PodInstance - 6, // 3: pbpod.ListPodReq.provider:type_name -> pbtenant.CloudProvider - 0, // 4: pbpod.ListPodResp.pods:type_name -> pbpod.PodInstance - 1, // 5: pbpod.PodService.ListPodDetail:input_type -> pbpod.ListPodDetailReq - 3, // 6: pbpod.PodService.ListPod:input_type -> pbpod.ListPodReq - 5, // 7: pbpod.PodService.ListPodAll:input_type -> pbpod.ListPodAllReq - 2, // 8: pbpod.PodService.ListPodDetail:output_type -> pbpod.ListPodDetailResp - 4, // 9: pbpod.PodService.ListPod:output_type -> pbpod.ListPodResp - 4, // 10: pbpod.PodService.ListPodAll:output_type -> pbpod.ListPodResp - 8, // [8:11] is the sub-list for method output_type - 5, // [5:8] is the sub-list for method input_type - 5, // [5:5] is the sub-list for extension type_name - 5, // [5:5] is the sub-list for extension extendee - 0, // [0:5] is the sub-list for field type_name + 8, // 0: pbpod.PodInstance.provider:type_name -> pbtenant.CloudProvider + 8, // 1: pbpod.CreatePodReq.provider:type_name -> pbtenant.CloudProvider + 0, // 2: pbpod.CreatePodResp.pods:type_name -> pbpod.PodInstance + 8, // 3: pbpod.ListPodDetailReq.provider:type_name -> pbtenant.CloudProvider + 0, // 4: pbpod.ListPodDetailResp.pods:type_name -> pbpod.PodInstance + 8, // 5: pbpod.ListPodReq.provider:type_name -> pbtenant.CloudProvider + 0, // 6: pbpod.ListPodResp.pods:type_name -> pbpod.PodInstance + 1, // 7: pbpod.PodService.CreatePod:input_type -> pbpod.CreatePodReq + 3, // 8: pbpod.PodService.ListPodDetail:input_type -> pbpod.ListPodDetailReq + 5, // 9: pbpod.PodService.ListPod:input_type -> pbpod.ListPodReq + 7, // 10: pbpod.PodService.ListPodAll:input_type -> pbpod.ListPodAllReq + 2, // 11: pbpod.PodService.CreatePod:output_type -> pbpod.CreatePodResp + 4, // 12: pbpod.PodService.ListPodDetail:output_type -> pbpod.ListPodDetailResp + 6, // 13: pbpod.PodService.ListPod:output_type -> pbpod.ListPodResp + 6, // 14: pbpod.PodService.ListPodAll:output_type -> pbpod.ListPodResp + 11, // [11:15] is the sub-list for method output_type + 7, // [7:11] is the sub-list for method input_type + 7, // [7:7] is the sub-list for extension type_name + 7, // [7:7] is the sub-list for extension extendee + 0, // [0:7] is the sub-list for field type_name } func init() { file_idl_pbpod_pod_proto_init() } @@ -664,7 +932,7 @@ func file_idl_pbpod_pod_proto_init() { } } file_idl_pbpod_pod_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ListPodDetailReq); i { + switch v := v.(*CreatePodReq); i { case 0: return &v.state case 1: @@ -676,7 +944,7 @@ func file_idl_pbpod_pod_proto_init() { } } file_idl_pbpod_pod_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ListPodDetailResp); i { + switch v := v.(*CreatePodResp); i { case 0: return &v.state case 1: @@ -688,7 +956,7 @@ func file_idl_pbpod_pod_proto_init() { } } file_idl_pbpod_pod_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ListPodReq); i { + switch v := v.(*ListPodDetailReq); i { case 0: return &v.state case 1: @@ -700,7 +968,7 @@ func file_idl_pbpod_pod_proto_init() { } } file_idl_pbpod_pod_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ListPodResp); i { + switch v := v.(*ListPodDetailResp); i { case 0: return &v.state case 1: @@ -712,6 +980,30 @@ func file_idl_pbpod_pod_proto_init() { } } file_idl_pbpod_pod_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ListPodReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_idl_pbpod_pod_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ListPodResp); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_idl_pbpod_pod_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ListPodAllReq); i { case 0: return &v.state @@ -730,7 +1022,7 @@ func file_idl_pbpod_pod_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_idl_pbpod_pod_proto_rawDesc, NumEnums: 0, - NumMessages: 6, + NumMessages: 8, NumExtensions: 0, NumServices: 1, }, diff --git a/lan_trans/idl/pbpod/pod.pb.gw.go b/lan_trans/idl/pbpod/pod.pb.gw.go index 9aa4fef..2fbe381 100644 --- a/lan_trans/idl/pbpod/pod.pb.gw.go +++ b/lan_trans/idl/pbpod/pod.pb.gw.go @@ -31,6 +31,40 @@ var _ = runtime.String var _ = utilities.NewDoubleArray var _ = metadata.Join +func request_PodService_CreatePod_0(ctx context.Context, marshaler runtime.Marshaler, client PodServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq CreatePodReq + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.CreatePod(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_PodService_CreatePod_0(ctx context.Context, marshaler runtime.Marshaler, server PodServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq CreatePodReq + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.CreatePod(ctx, &protoReq) + return msg, metadata, err + +} + func request_PodService_ListPodDetail_0(ctx context.Context, marshaler runtime.Marshaler, client PodServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq ListPodDetailReq var metadata runtime.ServerMetadata @@ -139,6 +173,30 @@ func local_request_PodService_ListPodAll_0(ctx context.Context, marshaler runtim // Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterPodServiceHandlerFromEndpoint instead. func RegisterPodServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server PodServiceServer) error { + mux.Handle("POST", pattern_PodService_CreatePod_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + ctx, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/pbpod.PodService/CreatePod", runtime.WithHTTPPathPattern("/apis/pod/create")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_PodService_CreatePod_0(ctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_PodService_CreatePod_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("POST", pattern_PodService_ListPodDetail_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -252,6 +310,27 @@ func RegisterPodServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn // "PodServiceClient" to call the correct interceptors. func RegisterPodServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client PodServiceClient) error { + mux.Handle("POST", pattern_PodService_CreatePod_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + ctx, err = runtime.AnnotateContext(ctx, mux, req, "/pbpod.PodService/CreatePod", runtime.WithHTTPPathPattern("/apis/pod/create")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_PodService_CreatePod_0(ctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_PodService_CreatePod_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("POST", pattern_PodService_ListPodDetail_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -319,6 +398,8 @@ func RegisterPodServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, } var ( + pattern_PodService_CreatePod_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"apis", "pod", "create"}, "")) + pattern_PodService_ListPodDetail_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"apis", "pod", "detail"}, "")) pattern_PodService_ListPod_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"apis", "pod"}, "")) @@ -327,6 +408,8 @@ var ( ) var ( + forward_PodService_CreatePod_0 = runtime.ForwardResponseMessage + forward_PodService_ListPodDetail_0 = runtime.ForwardResponseMessage forward_PodService_ListPod_0 = runtime.ForwardResponseMessage diff --git a/lan_trans/idl/pbpod/pod_grpc.pb.go b/lan_trans/idl/pbpod/pod_grpc.pb.go index c279997..f68f345 100644 --- a/lan_trans/idl/pbpod/pod_grpc.pb.go +++ b/lan_trans/idl/pbpod/pod_grpc.pb.go @@ -22,7 +22,9 @@ const _ = grpc.SupportPackageIsVersion7 // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. type PodServiceClient interface { - // 查询ECS明细 - 支持云类型、区域、账户、分页等过滤条件 + // 创建Pod + CreatePod(ctx context.Context, in *CreatePodReq, opts ...grpc.CallOption) (*CreatePodResp, error) + // 查询Pod明细 ListPodDetail(ctx context.Context, in *ListPodDetailReq, opts ...grpc.CallOption) (*ListPodDetailResp, error) // 查询Pod全量 - 根据云类型 ListPod(ctx context.Context, in *ListPodReq, opts ...grpc.CallOption) (*ListPodResp, error) @@ -38,6 +40,15 @@ func NewPodServiceClient(cc grpc.ClientConnInterface) PodServiceClient { return &podServiceClient{cc} } +func (c *podServiceClient) CreatePod(ctx context.Context, in *CreatePodReq, opts ...grpc.CallOption) (*CreatePodResp, error) { + out := new(CreatePodResp) + err := c.cc.Invoke(ctx, "/pbpod.PodService/CreatePod", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *podServiceClient) ListPodDetail(ctx context.Context, in *ListPodDetailReq, opts ...grpc.CallOption) (*ListPodDetailResp, error) { out := new(ListPodDetailResp) err := c.cc.Invoke(ctx, "/pbpod.PodService/ListPodDetail", in, out, opts...) @@ -69,7 +80,9 @@ func (c *podServiceClient) ListPodAll(ctx context.Context, in *ListPodAllReq, op // All implementations must embed UnimplementedPodServiceServer // for forward compatibility type PodServiceServer interface { - // 查询ECS明细 - 支持云类型、区域、账户、分页等过滤条件 + // 创建Pod + CreatePod(context.Context, *CreatePodReq) (*CreatePodResp, error) + // 查询Pod明细 ListPodDetail(context.Context, *ListPodDetailReq) (*ListPodDetailResp, error) // 查询Pod全量 - 根据云类型 ListPod(context.Context, *ListPodReq) (*ListPodResp, error) @@ -82,6 +95,9 @@ type PodServiceServer interface { type UnimplementedPodServiceServer struct { } +func (UnimplementedPodServiceServer) CreatePod(context.Context, *CreatePodReq) (*CreatePodResp, error) { + return nil, status.Errorf(codes.Unimplemented, "method CreatePod not implemented") +} func (UnimplementedPodServiceServer) ListPodDetail(context.Context, *ListPodDetailReq) (*ListPodDetailResp, error) { return nil, status.Errorf(codes.Unimplemented, "method ListPodDetail not implemented") } @@ -104,6 +120,24 @@ func RegisterPodServiceServer(s grpc.ServiceRegistrar, srv PodServiceServer) { s.RegisterService(&PodService_ServiceDesc, srv) } +func _PodService_CreatePod_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(CreatePodReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(PodServiceServer).CreatePod(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/pbpod.PodService/CreatePod", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(PodServiceServer).CreatePod(ctx, req.(*CreatePodReq)) + } + return interceptor(ctx, in, info, handler) +} + func _PodService_ListPodDetail_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(ListPodDetailReq) if err := dec(in); err != nil { @@ -165,6 +199,10 @@ var PodService_ServiceDesc = grpc.ServiceDesc{ ServiceName: "pbpod.PodService", HandlerType: (*PodServiceServer)(nil), Methods: []grpc.MethodDesc{ + { + MethodName: "CreatePod", + Handler: _PodService_CreatePod_Handler, + }, { MethodName: "ListPodDetail", Handler: _PodService_ListPodDetail_Handler, diff --git a/lan_trans/openapiv2/idl/pbpod/pod.swagger.json b/lan_trans/openapiv2/idl/pbpod/pod.swagger.json index 32148b8..22339bf 100644 --- a/lan_trans/openapiv2/idl/pbpod/pod.swagger.json +++ b/lan_trans/openapiv2/idl/pbpod/pod.swagger.json @@ -82,9 +82,42 @@ ] } }, + "/apis/pod/create": { + "post": { + "summary": "创建Pod", + "operationId": "PodService_CreatePod", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/pbpodCreatePodResp" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/pbpodCreatePodReq" + } + } + ], + "tags": [ + "PodService" + ] + } + }, "/apis/pod/detail": { "post": { - "summary": "查询ECS明细 - 支持云类型、区域、账户、分页等过滤条件", + "summary": "查询Pod明细", "operationId": "PodService_ListPodDetail", "responses": { "200": { @@ -117,6 +150,86 @@ } }, "definitions": { + "pbpodCreatePodReq": { + "type": "object", + "properties": { + "provider": { + "$ref": "#/definitions/pbtenantCloudProvider", + "title": "云类型" + }, + "accountName": { + "type": "string", + "title": "账号名称" + }, + "podId": { + "type": "string", + "title": "实例id" + }, + "podName": { + "type": "string", + "title": "实例名称" + }, + "regionId": { + "type": "integer", + "format": "int32", + "title": "地域,数据中心" + }, + "containerImage": { + "type": "string", + "title": "镜像" + }, + "containerName": { + "type": "string", + "title": "容器名称" + }, + "cpuPod": { + "type": "number", + "format": "float", + "title": "v cpu数" + }, + "memoryPod": { + "type": "number", + "format": "float", + "title": "内存MB" + }, + "securityGroupId": { + "type": "string", + "title": "安全组ID 对应腾讯 SecurityGroupIds(腾讯必需)" + }, + "subnetId": { + "type": "string", + "title": "子网ID 对应腾讯 SubnetId(腾讯必需)" + }, + "vpcId": { + "type": "string", + "title": "VPC ID 对应腾讯 VpcId(腾讯必需)" + }, + "namespace": { + "type": "string", + "title": "名空间" + } + } + }, + "pbpodCreatePodResp": { + "type": "object", + "properties": { + "pods": { + "type": "array", + "items": { + "$ref": "#/definitions/pbpodPodInstance" + }, + "title": "Pod集合" + }, + "finished": { + "type": "boolean", + "title": "查询是否完成,如果为否-false,则可以将下面三个分页参数填入到请求中,继续查询" + }, + "requestId": { + "type": "string", + "title": "请求id,出现问题后提供给云厂商,排查问题" + } + } + }, "pbpodListPodAllReq": { "type": "object" }, @@ -231,8 +344,9 @@ "type": "string", "title": "实例名称" }, - "regionName": { - "type": "string", + "regionId": { + "type": "integer", + "format": "int32", "title": "地域,数据中心" }, "containerImage": {