From 22091c4cb0eb866037e2a36756c5ca7ef61cff48 Mon Sep 17 00:00:00 2001 From: devad Date: Mon, 28 Mar 2022 17:52:17 +0800 Subject: [PATCH 1/8] :see_no_evil: Add gitignore Signed-off-by: devad --- .gitignore | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..63d4779 --- /dev/null +++ b/.gitignore @@ -0,0 +1,32 @@ +# Binaries for programs and plugins +*.exe +*.exe~ +*.dll +*.so +*.dylib +PCM + +# Test binary, built with `go test -c` +*.test + +# Output of the go coverage tool, specifically when used with LiteIDE +*.out +coverage.txt + +# Dependency directories (remove the comment below to include it) +vendor/ + +# buf for protobuf +buf.lock + +# idea project +.idea/ +.vscode/ + +# remove go sum +go.sum + +# config file +aksk.conf + +log/ \ No newline at end of file From 58865b6bab48a1a7138a80394e8826c45f134006 Mon Sep 17 00:00:00 2001 From: devad Date: Tue, 29 Mar 2022 20:04:17 +0800 Subject: [PATCH 2/8] add proto buf --- go.mod | 22 ++++++++++++---------- lan_trans/ali_java.proto | 0 lan_trans/buf.gen.yaml | 6 ++++++ lan_trans/idl/buf.yaml | 12 ++++++++++++ lan_trans/idl/demo/demo.proto | 35 +++++++++++++++++++++++++++++++++++ 5 files changed, 65 insertions(+), 10 deletions(-) delete mode 100644 lan_trans/ali_java.proto create mode 100644 lan_trans/buf.gen.yaml create mode 100644 lan_trans/idl/buf.yaml create mode 100644 lan_trans/idl/demo/demo.proto diff --git a/go.mod b/go.mod index 5a2e863..216a88a 100644 --- a/go.mod +++ b/go.mod @@ -16,7 +16,8 @@ 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.2.0 // indirect + github.com/golang/protobuf v1.5.2 // indirect + github.com/google/go-cmp v0.5.7 // indirect github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf // indirect github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d // indirect github.com/imdario/mergo v0.3.5 // indirect @@ -26,18 +27,19 @@ require ( 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-20190308221718-c2843e01d9a2 // indirect - golang.org/x/net v0.0.0-20190311183353-d8887717615a // indirect - golang.org/x/oauth2 v0.0.0-20190402181905-9f3314589c9a // indirect - golang.org/x/sys v0.0.0-20190312061237-fead79001313 // indirect - golang.org/x/text v0.3.1-0.20181227161524-e6919f6577db // indirect - golang.org/x/time v0.0.0-20161028155119-f51c12702a4d // indirect - google.golang.org/appengine v1.5.0 // indirect + golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 // 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/text v0.3.7 // indirect + golang.org/x/time v0.0.0-20191024005414-555d28b269f0 // indirect + google.golang.org/appengine v1.6.6 // indirect + google.golang.org/protobuf v1.28.0 // indirect gopkg.in/inf.v0 v0.9.0 // indirect gopkg.in/ini.v1 v1.66.2 // indirect - gopkg.in/yaml.v2 v2.2.1 // 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.1.0 // indirect + sigs.k8s.io/yaml v1.3.0 // indirect ) diff --git a/lan_trans/ali_java.proto b/lan_trans/ali_java.proto deleted file mode 100644 index e69de29..0000000 diff --git a/lan_trans/buf.gen.yaml b/lan_trans/buf.gen.yaml new file mode 100644 index 0000000..aa5792b --- /dev/null +++ b/lan_trans/buf.gen.yaml @@ -0,0 +1,6 @@ +version: v1 +plugins: + - name: cpp + out: gen/proto/cpp + - name: java + out: gen/proto/java \ No newline at end of file diff --git a/lan_trans/idl/buf.yaml b/lan_trans/idl/buf.yaml new file mode 100644 index 0000000..1aaf4fc --- /dev/null +++ b/lan_trans/idl/buf.yaml @@ -0,0 +1,12 @@ +version: v1 +breaking: + use: + - FILE +lint: + use: + - DEFAULT +# ignore: +# - google/type/datetime.proto +deps: + - buf.build/googleapis/googleapis + - buf.build/grpc-ecosystem/grpc-gateway \ No newline at end of file diff --git a/lan_trans/idl/demo/demo.proto b/lan_trans/idl/demo/demo.proto new file mode 100644 index 0000000..19b132b --- /dev/null +++ b/lan_trans/idl/demo/demo.proto @@ -0,0 +1,35 @@ +syntax = "proto3"; +package demo; + +option go_package = "gitlink.org.cn/JCCE/PCM/lan_trans/gen/proto/demo"; + +import "google/api/annotations.proto"; +import "protoc-gen-openapiv2/options/annotations.proto"; + +enum OurTeam { + // github: devad + devad = 0; +} + +message StringMessage { string value = 1; } + +// 样例服务 +service DemoService { + + // Echo 样例接口 + rpc Echo(StringMessage) returns (StringMessage) { + option (google.api.http) = { + post : "/apis/demo" + body : "*" + }; + + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { + deprecated : true // For testing purposes. + external_docs : { + url : "https://github.com/grpc-ecosystem/grpc-gateway" + description : "Find out more about the interface" + } + security : {} + }; + } +} From 1c603f035da55e31d06c794d861867579212eaf5 Mon Sep 17 00:00:00 2001 From: devad Date: Wed, 30 Mar 2022 18:27:09 +0800 Subject: [PATCH 3/8] add proto demo Signed-off-by: devad --- .gitignore | 1 + .../container_api_adaptor/alibaba/eci/eci.go | 4 +- .../common/api/common_api.go | 8 +-- .../huawei/pkg/auth/aksk/aksk.go | 6 +- .../networking.cci.io/v1beta1/clientset.go | 2 +- .../v1beta1/fake/clientset_generated.go | 6 +- .../v1beta1/fake/register.go | 2 +- .../v1beta1/scheme/register.go | 2 +- .../v1beta1/fake/fake_network.go | 2 +- .../fake/fake_networking.cci.io_client.go | 2 +- .../networking.cci.io/v1beta1/network.go | 4 +- .../v1beta1/networking.cci.io_client.go | 4 +- .../huawei/resources/network/network.go | 6 +- .../huawei/resources/pod/pod.go | 2 +- .../container_api_adaptor/tencent/eks/eks.go | 4 +- gen.sh | 5 ++ go.mod | 10 ++- internal/server/server.go | 17 +++++ lan_trans/buf.gen.yaml | 18 ++++-- lan_trans/{idl => }/buf.yaml | 1 + lan_trans/idl/demo/demo.proto | 2 +- main.go | 64 +++++++++++++++++++ swagger.sh | 13 ++++ 23 files changed, 150 insertions(+), 35 deletions(-) create mode 100755 gen.sh create mode 100644 internal/server/server.go rename lan_trans/{idl => }/buf.yaml (70%) create mode 100644 main.go create mode 100755 swagger.sh diff --git a/.gitignore b/.gitignore index 63d4779..9b3a010 100644 --- a/.gitignore +++ b/.gitignore @@ -28,5 +28,6 @@ go.sum # config file aksk.conf +config.yaml log/ \ 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 index 758cb97..c81a7b3 100644 --- a/adaptor/container_api_adaptor/alibaba/eci/eci.go +++ b/adaptor/container_api_adaptor/alibaba/eci/eci.go @@ -1,10 +1,10 @@ package eci import ( - "PCM/adaptor/container_api_adaptor/common/auth/aksk" - "PCM/adaptor/container_api_adaptor/common/config" "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 创建 diff --git a/adaptor/container_api_adaptor/common/api/common_api.go b/adaptor/container_api_adaptor/common/api/common_api.go index 8c0be12..88fdad6 100644 --- a/adaptor/container_api_adaptor/common/api/common_api.go +++ b/adaptor/container_api_adaptor/common/api/common_api.go @@ -1,10 +1,10 @@ package api import ( - "PCM/adaptor/container_api_adaptor/alibaba/eci" - cciAksk "PCM/adaptor/container_api_adaptor/huawei/pkg/auth/aksk" - cci "PCM/adaptor/container_api_adaptor/huawei/resources/pod" - "PCM/adaptor/container_api_adaptor/tencent/eks" + "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通用方法 diff --git a/adaptor/container_api_adaptor/huawei/pkg/auth/aksk/aksk.go b/adaptor/container_api_adaptor/huawei/pkg/auth/aksk/aksk.go index 0b67934..06eeae3 100644 --- a/adaptor/container_api_adaptor/huawei/pkg/auth/aksk/aksk.go +++ b/adaptor/container_api_adaptor/huawei/pkg/auth/aksk/aksk.go @@ -1,10 +1,10 @@ package aksk import ( - "PCM/adaptor/container_api_adaptor/common/auth/aksk" - "PCM/adaptor/container_api_adaptor/common/config" - clientset "PCM/adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1" "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" 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 index f30ca91..395ea88 100644 --- 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 @@ -19,7 +19,7 @@ limitations under the License. package v1beta1 import ( - networkingcciv1beta1 "PCM/adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1/typed/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" discovery "k8s.io/client-go/discovery" rest "k8s.io/client-go/rest" flowcontrol "k8s.io/client-go/util/flowcontrol" 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 index 354797a..a9e5d77 100644 --- 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 @@ -19,9 +19,9 @@ limitations under the License. package fake import ( - clientset "PCM/adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1" - networkingcciv1beta1 "PCM/adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1/typed/networking.cci.io/v1beta1" - fakenetworkingcciv1beta1 "PCM/adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1/typed/networking.cci.io/v1beta1/fake" + 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" 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 index ffcc031..49f5cb5 100644 --- 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 @@ -19,7 +19,7 @@ limitations under the License. package fake import ( - networkingcciv1beta1 "PCM/adaptor/container_api_adaptor/huawei/pkg/apis/networking.cci.io/v1beta1" + 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" 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 index 736cdbb..dadfd83 100644 --- 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 @@ -19,7 +19,7 @@ limitations under the License. package scheme import ( - networkingcciv1beta1 "PCM/adaptor/container_api_adaptor/huawei/pkg/apis/networking.cci.io/v1beta1" + 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" 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 index d1e3780..1d67ad3 100644 --- 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 @@ -19,7 +19,7 @@ limitations under the License. package fake import ( - v1beta1 "PCM/adaptor/container_api_adaptor/huawei/pkg/apis/networking.cci.io/v1beta1" + 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" 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 index 4ae9804..c2d4678 100644 --- 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 @@ -19,7 +19,7 @@ limitations under the License. package fake import ( - v1beta1 "PCM/adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1/typed/networking.cci.io/v1beta1" + 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" ) 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 index a1449c8..416669f 100644 --- 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 @@ -21,8 +21,8 @@ package v1beta1 import ( "time" - v1beta1 "PCM/adaptor/container_api_adaptor/huawei/pkg/apis/networking.cci.io/v1beta1" - scheme "PCM/adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1/scheme" + 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" 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 index 0baf369..4fb8ec2 100644 --- 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 @@ -19,8 +19,8 @@ limitations under the License. package v1beta1 import ( - v1beta1 "PCM/adaptor/container_api_adaptor/huawei/pkg/apis/networking.cci.io/v1beta1" - "PCM/adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1/scheme" + 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" ) diff --git a/adaptor/container_api_adaptor/huawei/resources/network/network.go b/adaptor/container_api_adaptor/huawei/resources/network/network.go index e5cff4d..b645c42 100644 --- a/adaptor/container_api_adaptor/huawei/resources/network/network.go +++ b/adaptor/container_api_adaptor/huawei/resources/network/network.go @@ -1,11 +1,11 @@ package network import ( - "PCM/adaptor/container_api_adaptor/huawei/pkg/apis/networking.cci.io/v1beta1" - "PCM/adaptor/container_api_adaptor/huawei/pkg/auth/aksk" + "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 "PCM/adaptor/container_api_adaptor/huawei/pkg/client/networking.cci.io/v1beta1" + 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" ) diff --git a/adaptor/container_api_adaptor/huawei/resources/pod/pod.go b/adaptor/container_api_adaptor/huawei/resources/pod/pod.go index 00a50a0..9b3c14d 100644 --- a/adaptor/container_api_adaptor/huawei/resources/pod/pod.go +++ b/adaptor/container_api_adaptor/huawei/resources/pod/pod.go @@ -1,8 +1,8 @@ package pod import ( - "PCM/adaptor/container_api_adaptor/common/config" "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" diff --git a/adaptor/container_api_adaptor/tencent/eks/eks.go b/adaptor/container_api_adaptor/tencent/eks/eks.go index 57e21fd..ac7a576 100644 --- a/adaptor/container_api_adaptor/tencent/eks/eks.go +++ b/adaptor/container_api_adaptor/tencent/eks/eks.go @@ -1,13 +1,13 @@ package eks import ( - "PCM/adaptor/container_api_adaptor/common/auth/aksk" - pcmCommon "PCM/adaptor/container_api_adaptor/common/config" "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) { diff --git a/gen.sh b/gen.sh new file mode 100755 index 0000000..112801d --- /dev/null +++ b/gen.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +rm -rf lan_trans/gen/* +buf mod update +buf generate \ No newline at end of file diff --git a/go.mod b/go.mod index 216a88a..0a73e49 100644 --- a/go.mod +++ b/go.mod @@ -1,12 +1,18 @@ -module PCM +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/golang/glog v1.0.0 + github.com/grpc-ecosystem/grpc-gateway/v2 v2.10.0 + github.com/pkg/errors v0.9.1 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.371 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 @@ -17,7 +23,6 @@ require ( 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/go-cmp v0.5.7 // indirect github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf // indirect github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d // indirect github.com/imdario/mergo v0.3.5 // indirect @@ -34,7 +39,6 @@ require ( 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 - google.golang.org/protobuf v1.28.0 // 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 diff --git a/internal/server/server.go b/internal/server/server.go new file mode 100644 index 0000000..79add48 --- /dev/null +++ b/internal/server/server.go @@ -0,0 +1,17 @@ +package server + +import ( + "context" + "gitlink.org.cn/JCCE/PCM/lan_trans/gen/idl/demo" +) + +type Server struct { + // 使用unsafe可以强制让编译器检查是否实现了相关方法 + demo.UnsafeDemoServiceServer +} + +func (s *Server) Echo(ctx context.Context, req *demo.StringMessage) (*demo.StringMessage, error) { + return &demo.StringMessage{ + Value: "Welcome to JCCE PCM", + }, nil +} diff --git a/lan_trans/buf.gen.yaml b/lan_trans/buf.gen.yaml index aa5792b..f777899 100644 --- a/lan_trans/buf.gen.yaml +++ b/lan_trans/buf.gen.yaml @@ -1,6 +1,16 @@ version: v1 plugins: - - name: cpp - out: gen/proto/cpp - - name: java - out: gen/proto/java \ No newline at end of file + - name: go + out: gen + opt: + - paths=source_relative + - name: go-grpc + out: gen + opt: + - paths=source_relative + - name: grpc-gateway + out: gen + opt: + - paths=source_relative + - name: openapiv2 + out: gen/openapiv2 \ No newline at end of file diff --git a/lan_trans/idl/buf.yaml b/lan_trans/buf.yaml similarity index 70% rename from lan_trans/idl/buf.yaml rename to lan_trans/buf.yaml index 1aaf4fc..ea7eb01 100644 --- a/lan_trans/idl/buf.yaml +++ b/lan_trans/buf.yaml @@ -1,4 +1,5 @@ version: v1 +name: buf.build/JCCE/PCM breaking: use: - FILE diff --git a/lan_trans/idl/demo/demo.proto b/lan_trans/idl/demo/demo.proto index 19b132b..e3e6b9c 100644 --- a/lan_trans/idl/demo/demo.proto +++ b/lan_trans/idl/demo/demo.proto @@ -1,7 +1,7 @@ syntax = "proto3"; package demo; -option go_package = "gitlink.org.cn/JCCE/PCM/lan_trans/gen/proto/demo"; +option go_package = "gitlink.org.cn/JCCE/PCM/lan_trans/gen/idl/demo"; import "google/api/annotations.proto"; import "protoc-gen-openapiv2/options/annotations.proto"; diff --git a/main.go b/main.go new file mode 100644 index 0000000..9903fbe --- /dev/null +++ b/main.go @@ -0,0 +1,64 @@ +package main + +import ( + "context" + "flag" + "github.com/golang/glog" + "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" + "github.com/pkg/errors" + "gitlink.org.cn/JCCE/PCM/internal/server" + "gitlink.org.cn/JCCE/PCM/lan_trans/gen/idl/demo" + "google.golang.org/grpc" + "net" + "net/http" +) + +var ( + // command-line options: + // gRPC server endpoint + grpcServerEndpoint = flag.String("grpc-server-endpoint", ":9090", ":8081") +) + +func run() error { + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + + // Register gRPC server endpoint + // Note: Make sure the gRPC server is running properly and accessible + mux := runtime.NewServeMux() + opts := []grpc.DialOption{grpc.WithInsecure()} + + if err := demo.RegisterDemoServiceHandlerFromEndpoint(ctx, mux, *grpcServerEndpoint, opts); err != nil { + return errors.Wrap(err, "RegisterDemoServiceHandlerFromEndpoint error") + } + + // Start HTTP server (and proxy calls to gRPC server endpoint) + return http.ListenAndServe(":8081", mux) +} + +func main() { + var configFile string + flag.StringVar(&configFile, "conf", "config.yaml", "config.yaml") + flag.Parse() + defer glog.Flush() + + glog.Infof("load tenant from file finished") + + go func() { + lis, err := net.Listen("tcp", ":9090") + if err != nil { + glog.Fatalf("failed to listen: %v", err) + } + + s := grpc.NewServer() + demo.RegisterDemoServiceServer(s, &server.Server{}) + + if err = s.Serve(lis); err != nil { + glog.Fatalf("failed to serve: %v", err) + } + }() + + if err := run(); err != nil { + glog.Fatal(err) + } +} diff --git a/swagger.sh b/swagger.sh new file mode 100755 index 0000000..6212fa9 --- /dev/null +++ b/swagger.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +# 请先保证swagger的安装,可参考 https://goswagger.io/install.html + +swagger mixin lan_trans/gen/openapiv2/idl/*/*.json -o lan_trans/gen/swagger.json + +rm -rf lan_trans/gen/openapiv2 + +# 将机器的sshkey保存到公有云机器121.41.88.120上 +#scp -P 22 gen/swagger.json root@121.41.88.120:/root/doc + +# 服务端运行的docker +# docker run --name swagger -d --rm -p 80:80 -v /root/doc:/usr/share/nginx/html/swagger -e SPEC_URL=swagger/swagger.json redocly/redoc From 87e1dc9f8ec0cd23ef543b91934cc95777db693f Mon Sep 17 00:00:00 2001 From: devad Date: Thu, 31 Mar 2022 13:03:19 +0800 Subject: [PATCH 4/8] refactor Signed-off-by: devad --- .golangci.yml | 64 ++ adaptor/vm_adaptor/server/ecs/list.go | 125 +++ adaptor/vm_adaptor/server/ecs/list_test.go | 82 ++ adaptor/vm_adaptor/server/ecs/main_test.go | 32 + adaptor/vm_adaptor/service/ecser/ali.go | 95 ++ adaptor/vm_adaptor/service/ecser/aws.go | 98 ++ adaptor/vm_adaptor/service/ecser/ecser.go | 45 + .../vm_adaptor/service/ecser/ecser_test.go | 66 ++ adaptor/vm_adaptor/service/ecser/google.go | 111 +++ adaptor/vm_adaptor/service/ecser/huawei.go | 106 +++ adaptor/vm_adaptor/service/ecser/main_test.go | 32 + adaptor/vm_adaptor/service/ecser/tencent.go | 95 ++ buf.gen.yaml | 24 + lan_trans/buf.yaml => buf.yaml | 0 cm_bridge/cm_adaptor | 0 {internal => common}/server/server.go | 4 +- common/server/server_ecs.go | 38 + common/tenanter/access_key.go | 35 + common/tenanter/main_test.go | 36 + common/tenanter/region.go | 130 +++ common/tenanter/region_test.go | 29 + common/tenanter/tenanter.go | 101 ++ common/tenanter/tenanter_test.go | 29 + go.mod | 26 +- {lan_trans/idl => idl}/demo/demo.proto | 0 idl/pbecs/ecs.proto | 119 +++ idl/pbtenant/tenant.proto | 155 +++ lan_trans/buf.gen.yaml | 16 - lan_trans/idl/demo/demo.pb.go | 213 +++++ lan_trans/idl/demo/demo.pb.gw.go | 167 ++++ lan_trans/idl/demo/demo_grpc.pb.go | 107 +++ lan_trans/idl/pbecs/ecs.pb.go | 776 +++++++++++++++ lan_trans/idl/pbecs/ecs.pb.gw.go | 329 +++++++ lan_trans/idl/pbecs/ecs_grpc.pb.go | 183 ++++ lan_trans/idl/pbtenant/tenant.pb.go | 896 ++++++++++++++++++ lan_trans/idl/pbtenant/tenant_grpc.pb.go | 65 ++ lan_trans/swagger.json | 384 ++++++++ main.go | 21 +- swagger.sh | 4 +- unittest.sh | 14 + 40 files changed, 4824 insertions(+), 28 deletions(-) create mode 100644 .golangci.yml create mode 100644 adaptor/vm_adaptor/server/ecs/list.go create mode 100644 adaptor/vm_adaptor/server/ecs/list_test.go create mode 100644 adaptor/vm_adaptor/server/ecs/main_test.go create mode 100644 adaptor/vm_adaptor/service/ecser/ali.go create mode 100644 adaptor/vm_adaptor/service/ecser/aws.go create mode 100644 adaptor/vm_adaptor/service/ecser/ecser.go create mode 100644 adaptor/vm_adaptor/service/ecser/ecser_test.go create mode 100644 adaptor/vm_adaptor/service/ecser/google.go create mode 100644 adaptor/vm_adaptor/service/ecser/huawei.go create mode 100644 adaptor/vm_adaptor/service/ecser/main_test.go create mode 100644 adaptor/vm_adaptor/service/ecser/tencent.go create mode 100644 buf.gen.yaml rename lan_trans/buf.yaml => buf.yaml (100%) create mode 100644 cm_bridge/cm_adaptor rename {internal => common}/server/server.go (73%) create mode 100644 common/server/server_ecs.go create mode 100644 common/tenanter/access_key.go create mode 100644 common/tenanter/main_test.go create mode 100644 common/tenanter/region.go create mode 100644 common/tenanter/region_test.go create mode 100644 common/tenanter/tenanter.go create mode 100644 common/tenanter/tenanter_test.go rename {lan_trans/idl => idl}/demo/demo.proto (100%) create mode 100644 idl/pbecs/ecs.proto create mode 100644 idl/pbtenant/tenant.proto delete mode 100644 lan_trans/buf.gen.yaml create mode 100644 lan_trans/idl/demo/demo.pb.go create mode 100644 lan_trans/idl/demo/demo.pb.gw.go create mode 100644 lan_trans/idl/demo/demo_grpc.pb.go create mode 100644 lan_trans/idl/pbecs/ecs.pb.go create mode 100644 lan_trans/idl/pbecs/ecs.pb.gw.go create mode 100644 lan_trans/idl/pbecs/ecs_grpc.pb.go create mode 100644 lan_trans/idl/pbtenant/tenant.pb.go create mode 100644 lan_trans/idl/pbtenant/tenant_grpc.pb.go create mode 100644 lan_trans/swagger.json create mode 100755 unittest.sh diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..1429db2 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,64 @@ +# This files contains all configuration options for analysis running. +# More details please refer to: https://golangci-lint.run/usage/configuration/ + +run: + # timeout for analysis, e.g. 30s, 5m, default is 1m + timeout: 5m + + # which dirs to skip: issues from them won't be reported; + # can use regexp here: generated.*, regexp is applied on full path; + # default value is empty list, but default dirs are skipped independently + # from this option's value (see skip-dirs-use-default). + # "/" will be replaced by current OS file path separator to properly work + # on Windows. + skip-dirs: + - hack/tools/preferredimports # This code is directly lifted from the Kubernetes codebase, skip checking + + # default is true. Enables skipping of directories: + # vendor$, third_party$, testdata$, examples$, Godeps$, builtin$ + skip-dirs-use-default: true + + # One of 'readonly' and 'vendor'. + # - readonly: the go command is disallowed from the implicit automatic updating of go.mod described above. + # Instead, it fails when any changes to go.mod are needed. This setting is most useful to check + # that go.mod does not need updates, such as in a continuous integration and testing system. + # - vendor: the go command assumes that the vendor directory holds the correct copies of dependencies and ignores + # the dependency descriptions in go.mod. + modules-download-mode: readonly +linters: + enable: + # linters maintained by golang.org + - gofmt + - goimports + - govet + # linters default enabled by golangci-lint . + - deadcode + - errcheck + - gosimple + - ineffassign + - staticcheck + - structcheck + - typecheck + - unused + - varcheck + # other linters supported by golangci-lint. + - gocyclo + - gosec + - whitespace + - revive + +linters-settings: + goimports: + local-prefixes: github.com/karmada-io/karmada + gocyclo: + # minimal cyclomatic complexity to report + min-complexity: 15 + +issues: + # The list of ids of default excludes to include or disable. By default it's empty. + include: + # disable excluding of issues about comments from revive + # see https://golangci-lint.run/usage/configuration/#command-line-options for more info + - EXC0012 + - EXC0013 + - EXC0014 diff --git a/adaptor/vm_adaptor/server/ecs/list.go b/adaptor/vm_adaptor/server/ecs/list.go new file mode 100644 index 0000000..e73fc49 --- /dev/null +++ b/adaptor/vm_adaptor/server/ecs/list.go @@ -0,0 +1,125 @@ +package ecs + +import ( + "context" + "gitlink.org.cn/JCCE/PCM/adaptor/vm_adaptor/service/ecser" + "gitlink.org.cn/JCCE/PCM/common/tenanter" + "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbecs" + "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant" + "sync" + + "github.com/golang/glog" + "github.com/pkg/errors" +) + +func ListDetail(ctx context.Context, req *pbecs.ListDetailReq) (*pbecs.ListDetailResp, error) { + var ( + ecs ecser.Ecser + ) + + 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 ecs, err = ecser.NewEcsClient(req.Provider, region, tenanter); err != nil { + return nil, errors.WithMessage(err, "NewEcsClient error") + } + break + } + } + + return ecs.ListDetail(ctx, req) +} + +func List(ctx context.Context, req *pbecs.ListReq) (*pbecs.ListResp, error) { + var ( + wg sync.WaitGroup + mutex sync.Mutex + ecses []*pbecs.EcsInstance + ) + + 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() + ecs, err := ecser.NewEcsClient(req.Provider, region, tenant) + if err != nil { + glog.Errorf("New Ecs Client error %v", err) + return + } + + request := &pbecs.ListDetailReq{ + Provider: req.Provider, + AccountName: tenant.AccountName(), + RegionId: region.GetId(), + PageNumber: 1, + PageSize: 100, + NextToken: "", + } + for { + resp, err := ecs.ListDetail(ctx, request) + if err != nil { + glog.Errorf("ListDetail error %v", err) + return + } + mutex.Lock() + ecses = append(ecses, resp.Ecses...) + mutex.Unlock() + if resp.Finished { + break + } + request.PageNumber, request.PageSize, request.NextToken = resp.PageNumber, resp.PageSize, resp.NextToken + } + }(t, region) + + } + } + wg.Wait() + + return &pbecs.ListResp{Ecses: ecses}, nil +} + +func ListAll(ctx context.Context) (*pbecs.ListResp, error) { + var ( + wg sync.WaitGroup + mutex sync.Mutex + ecses []*pbecs.EcsInstance + ) + + wg.Add(len(pbtenant.CloudProvider_name)) + for k := range pbtenant.CloudProvider_name { + go func(provider int32) { + defer wg.Done() + + resp, err := List(ctx, &pbecs.ListReq{Provider: pbtenant.CloudProvider(provider)}) + if err != nil { + glog.Errorf("List error %v", err) + return + } + + mutex.Lock() + ecses = append(ecses, resp.Ecses...) + mutex.Unlock() + }(k) + } + + wg.Wait() + + return &pbecs.ListResp{Ecses: ecses}, nil +} diff --git a/adaptor/vm_adaptor/server/ecs/list_test.go b/adaptor/vm_adaptor/server/ecs/list_test.go new file mode 100644 index 0000000..f775105 --- /dev/null +++ b/adaptor/vm_adaptor/server/ecs/list_test.go @@ -0,0 +1,82 @@ +package ecs + +import ( + "context" + "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbecs" + "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant" + "testing" +) + +func TestListDetail(t *testing.T) { + type args struct { + req *pbecs.ListDetailReq + } + tests := []struct { + name string + args args + wantErr bool + }{ + {name: "ali", args: args{req: &pbecs.ListDetailReq{Provider: pbtenant.CloudProvider_ali, RegionId: int32(pbtenant.AliRegionId_ali_cn_hangzhou), PageNumber: 1, PageSize: 10}}, wantErr: false}, + {name: "tencent", args: args{req: &pbecs.ListDetailReq{Provider: pbtenant.CloudProvider_tencent, RegionId: int32(pbtenant.TencentRegionId_tc_ap_beijing), PageNumber: 1, PageSize: 10}}, wantErr: false}, + {name: "aws", args: args{req: &pbecs.ListDetailReq{Provider: pbtenant.CloudProvider_aws, RegionId: int32(pbtenant.AwsRegionId_aws_us_east_2), PageNumber: 1, PageSize: 10}}, wantErr: false}, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + got, err := ListDetail(context.Background(), tt.args.req) + if (err != nil) != tt.wantErr { + t.Errorf("ListDetail() error = %+v, wantErr %v", err, tt.wantErr) + return + } + t.Log(got) + }) + } +} + +func TestList(t *testing.T) { + type args struct { + req *pbecs.ListReq + } + tests := []struct { + name string + args args + wantErr bool + }{ + {name: "ali", args: args{req: &pbecs.ListReq{Provider: pbtenant.CloudProvider_ali}}, wantErr: false}, + {name: "tencent", args: args{req: &pbecs.ListReq{Provider: pbtenant.CloudProvider_tencent}}, wantErr: false}, + {name: "huawei", args: args{req: &pbecs.ListReq{Provider: pbtenant.CloudProvider_huawei}}, wantErr: false}, + {name: "aws", args: args{req: &pbecs.ListReq{Provider: pbtenant.CloudProvider_aws}}, wantErr: false}, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + got, err := List(context.Background(), tt.args.req) + if (err != nil) != tt.wantErr { + t.Errorf("List() error = %+v, wantErr %v", err, tt.wantErr) + return + } + t.Log(got) + }) + } +} + +func TestListAll(t *testing.T) { + type args struct { + req *pbecs.ListAllReq + } + tests := []struct { + name string + args args + wantErr bool + }{ + {name: "all", args: args{req: &pbecs.ListAllReq{}}, wantErr: false}, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + got, err := ListAll(context.Background()) + if (err != nil) != tt.wantErr { + t.Errorf("ListAll() error = %+v, wantErr %v", err, tt.wantErr) + return + } + t.Log(got) + }) + } +} diff --git a/adaptor/vm_adaptor/server/ecs/main_test.go b/adaptor/vm_adaptor/server/ecs/main_test.go new file mode 100644 index 0000000..5aa3f06 --- /dev/null +++ b/adaptor/vm_adaptor/server/ecs/main_test.go @@ -0,0 +1,32 @@ +package ecs + +import ( + "gitlink.org.cn/JCCE/PCM/common/tenanter" + "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant" + "os" + "testing" +) + +var ( + aliTenant, tcTenant, hwTenant, awsTenant []tenanter.Tenanter +) + +func TestMain(m *testing.M) { + err := tenanter.LoadCloudConfigs("../../../config.yaml") + if err != nil { + panic(err) + } + if aliTenant, err = tenanter.GetTenanters(pbtenant.CloudProvider_ali); err != nil { + panic("get aliTenant failed") + } + if tcTenant, err = tenanter.GetTenanters(pbtenant.CloudProvider_tencent); err != nil { + panic("get tcTenant failed") + } + if hwTenant, err = tenanter.GetTenanters(pbtenant.CloudProvider_huawei); err != nil { + panic("get hwTenant failed") + } + if awsTenant, err = tenanter.GetTenanters(pbtenant.CloudProvider_aws); err != nil { + panic("get awsTenant failed") + } + os.Exit(m.Run()) +} diff --git a/adaptor/vm_adaptor/service/ecser/ali.go b/adaptor/vm_adaptor/service/ecser/ali.go new file mode 100644 index 0000000..aa0197d --- /dev/null +++ b/adaptor/vm_adaptor/service/ecser/ali.go @@ -0,0 +1,95 @@ +package ecser + +import ( + "context" + "gitlink.org.cn/JCCE/PCM/common/tenanter" + "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbecs" + "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant" + "sync" + + "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" + aliecs "github.com/aliyun/alibaba-cloud-sdk-go/services/ecs" + "github.com/pkg/errors" +) + +var aliClientMutex sync.Mutex + +type AliEcs struct { + cli *aliecs.Client + region tenanter.Region + tenanter tenanter.Tenanter +} + +func newAliEcsClient(region tenanter.Region, tenant tenanter.Tenanter) (Ecser, error) { + var ( + client *aliecs.Client + err error + ) + + switch t := tenant.(type) { + case *tenanter.AccessKeyTenant: + // 阿里云的sdk有一个 map 的并发问题,go test 加上-race 能检测出来,所以这里加一个锁 + aliClientMutex.Lock() + client, err = aliecs.NewClientWithAccessKey(region.GetName(), t.GetId(), t.GetSecret()) + aliClientMutex.Unlock() + default: + } + + if err != nil { + return nil, errors.Wrap(err, "init ali ecs client error") + } + + return &AliEcs{ + cli: client, + region: region, + tenanter: tenant, + }, nil +} + +func (ecs *AliEcs) ListDetail(ctx context.Context, req *pbecs.ListDetailReq) (*pbecs.ListDetailResp, error) { + request := aliecs.CreateDescribeInstancesRequest() + request.PageNumber = requests.NewInteger(int(req.PageNumber)) + request.PageSize = requests.NewInteger(int(req.PageSize)) + request.NextToken = req.NextToken + resp, err := ecs.cli.DescribeInstances(request) + if err != nil { + return nil, errors.Wrap(err, "Aliyun ListDetail error") + } + + var ecses = make([]*pbecs.EcsInstance, len(resp.Instances.Instance)) + for k, v := range resp.Instances.Instance { + ecses[k] = &pbecs.EcsInstance{ + Provider: pbtenant.CloudProvider_ali, + AccountName: ecs.tenanter.AccountName(), + InstanceId: v.InstanceId, + InstanceName: v.InstanceName, + RegionName: ecs.region.GetName(), + PublicIps: v.PublicIpAddress.IpAddress, + InstanceType: v.InstanceType, + Cpu: int32(v.Cpu), + Memory: int32(v.Memory), + Description: v.Description, + Status: v.Status, + CreationTime: v.CreationTime, + ExpireTime: v.ExpiredTime, + InnerIps: v.InnerIpAddress.IpAddress, + VpcId: v.VpcAttributes.VpcId, + ResourceGroupId: v.ResourceGroupId, + ChargeType: v.InstanceChargeType, + } + } + + isFinished := false + if len(ecses) < int(req.PageSize) { + isFinished = true + } + + return &pbecs.ListDetailResp{ + Ecses: ecses, + Finished: isFinished, + PageNumber: req.PageNumber + 1, + PageSize: req.PageSize, + NextToken: resp.NextToken, + RequestId: resp.RequestId, + }, nil +} diff --git a/adaptor/vm_adaptor/service/ecser/aws.go b/adaptor/vm_adaptor/service/ecser/aws.go new file mode 100644 index 0000000..bfca04e --- /dev/null +++ b/adaptor/vm_adaptor/service/ecser/aws.go @@ -0,0 +1,98 @@ +package ecser + +//TODO aws +// +//import ( +// "context" +// +// "github.com/aws/aws-sdk-go-v2/config" +// "github.com/aws/aws-sdk-go-v2/credentials" +// awsec2 "github.com/aws/aws-sdk-go-v2/service/ec2" +// "github.com/pkg/errors" +// +// "gitlink.org.cn/JCCE/PCM/common/tenanter" +// +// "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbecs" +// "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant" +//) +// +//type AwsEcs struct { +// cli *awsec2.Client +// region tenanter.Region +// tenanter tenanter.Tenanter +//} +// +//func newAwsEcsClient(region tenanter.Region, tenant tenanter.Tenanter) (Ecser, error) { +// var ( +// client *awsec2.Client +// err error +// ) +// +// switch t := tenant.(type) { +// case *tenanter.AccessKeyTenant: +// cfg, err := config.LoadDefaultConfig(context.TODO(), +// config.WithCredentialsProvider(credentials.NewStaticCredentialsProvider(t.GetId(), t.GetSecret(), "")), +// config.WithRegion(region.GetName()), +// ) +// if err != nil { +// return nil, errors.Wrap(err, "LoadDefaultConfig aws ecs client error") +// } +// client = awsec2.NewFromConfig(cfg) +// default: +// } +// +// if err != nil { +// return nil, errors.Wrap(err, "init aws ec2 client error") +// } +// return &AwsEcs{ +// cli: client, +// region: region, +// tenanter: tenant, +// }, nil +//} +// +//func (ecs *AwsEcs) ListDetail(ctx context.Context, req *pbecs.ListDetailReq) (*pbecs.ListDetailResp, error) { +// request := new(awsec2.DescribeInstancesInput) +// request.MaxResults = req.PageSize +// request.NextToken = &req.NextToken +// +// resp, err := ecs.cli.DescribeInstances(ctx, request) +// if err != nil { +// return nil, errors.Wrap(err, "Aws ListDetail error") +// } +// +// var ecses []*pbecs.EcsInstance +// for _, v := range resp.Reservations { +// for _, v2 := range v.Instances { +// ecses = append(ecses, &pbecs.EcsInstance{ +// Provider: pbtenant.CloudProvider_aws, +// AccountName: ecs.tenanter.AccountName(), +// InstanceId: *v2.InstanceId, +// InstanceName: "", +// RegionName: ecs.region.GetName(), +// PublicIps: []string{*v2.PublicIpAddress}, +// InstanceType: string(v2.InstanceType), +// Cpu: v2.CpuOptions.CoreCount, +// Memory: 0, +// Description: "", +// Status: string(v2.State.Name), +// CreationTime: "", +// ExpireTime: "", +// }) +// } +// +// } +// +// if resp.NextToken != nil { +// return &pbecs.ListDetailResp{ +// Ecses: ecses, +// Finished: false, +// NextToken: *resp.NextToken, +// }, nil +// } +// return &pbecs.ListDetailResp{ +// Ecses: ecses, +// Finished: true, +// NextToken: "", +// }, nil +//} diff --git a/adaptor/vm_adaptor/service/ecser/ecser.go b/adaptor/vm_adaptor/service/ecser/ecser.go new file mode 100644 index 0000000..b96f3ad --- /dev/null +++ b/adaptor/vm_adaptor/service/ecser/ecser.go @@ -0,0 +1,45 @@ +package ecser + +import ( + "context" + "gitlink.org.cn/JCCE/PCM/common/tenanter" + "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbecs" + "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant" + + "github.com/golang/glog" + "github.com/pkg/errors" +) + +var ( + ErrEcsListNotSupported = errors.New("cloud not supported ecs list") + ErrEcserPanic = errors.New("ecs init panic") +) + +type Ecser interface { + ListDetail(ctx context.Context, req *pbecs.ListDetailReq) (resp *pbecs.ListDetailResp, err error) +} + +func NewEcsClient(provider pbtenant.CloudProvider, region tenanter.Region, tenant tenanter.Tenanter) (ecser Ecser, err error) { + // 部分sdk会在内部panic + defer func() { + if err1 := recover(); err1 != nil { + glog.Errorf("NewEcsClient panic %v", err1) + err = errors.WithMessagef(ErrEcserPanic, "%v", err1) + } + }() + + switch provider { + case pbtenant.CloudProvider_ali: + return newAliEcsClient(region, tenant) + case pbtenant.CloudProvider_tencent: + return newTencentCvmClient(region, tenant) + case pbtenant.CloudProvider_huawei: + return newHuaweiEcsClient(region, tenant) + //TODO aws + //case pbtenant.CloudProvider_aws: + // return newAwsEcsClient(region, tenant) + } + + err = errors.WithMessagef(ErrEcsListNotSupported, "cloud provider %v region %v", provider, region) + return +} diff --git a/adaptor/vm_adaptor/service/ecser/ecser_test.go b/adaptor/vm_adaptor/service/ecser/ecser_test.go new file mode 100644 index 0000000..482a212 --- /dev/null +++ b/adaptor/vm_adaptor/service/ecser/ecser_test.go @@ -0,0 +1,66 @@ +package ecser + +import ( + "context" + "testing" +) + +func TestEcser_ListDetail(t *testing.T) { + region, _ := tenanter.NewRegion(pbtenant.CloudProvider_ali, int32(pbtenant.AliRegionId_ali_cn_hangzhou)) + ali, _ := NewEcsClient(pbtenant.CloudProvider_ali, region, aliTenant[0]) + aliFailed, _ := NewEcsClient(pbtenant.CloudProvider_ali, region, tenanter.NewTenantWithAccessKey("empty", "", "")) + + region, _ = tenanter.NewRegion(pbtenant.CloudProvider_tencent, int32(pbtenant.TencentRegionId_tc_ap_beijing)) + tc, _ := NewEcsClient(pbtenant.CloudProvider_tencent, region, tcTenant[0]) + tcFailed, _ := NewEcsClient(pbtenant.CloudProvider_tencent, region, tenanter.NewTenantWithAccessKey("empty", "", "")) + + region, _ = tenanter.NewRegion(pbtenant.CloudProvider_huawei, int32(pbtenant.HuaweiRegionId_hw_cn_southwest_2)) + hw, _ := NewEcsClient(pbtenant.CloudProvider_huawei, region, hwTenant[0]) + // hwFailed, _ := newHuaweiEcsClient(int32(pbtenant.HuaweiRegionId_hw_cn_north_1), tenanter.NewTenantWithAccessKey("empty", "", "", "")) + + region, _ = tenanter.NewRegion(pbtenant.CloudProvider_aws, int32(pbtenant.AwsRegionId_aws_us_east_2)) + aws, _ := NewEcsClient(pbtenant.CloudProvider_aws, region, awsTenant[0]) + + // google, _ := NewGoogleEcsClient(tenanter.NewTenantWithAccessKey("", "")) + + type args struct { + req *pbecs.ListDetailReq + } + tests := []struct { + name string + fields Ecser + args args + wantErr bool + }{ + {name: "ali wrong cli", fields: aliFailed, args: args{&pbecs.ListDetailReq{PageNumber: 1, PageSize: 1}}, wantErr: true}, + {name: "ali wrong page number", fields: ali, args: args{&pbecs.ListDetailReq{PageNumber: 0, PageSize: 1}}, wantErr: true}, + {name: "ali wrong page size", fields: ali, args: args{&pbecs.ListDetailReq{PageNumber: 1, PageSize: 0}}, wantErr: true}, + {name: "ali right cli", fields: ali, args: args{&pbecs.ListDetailReq{PageNumber: 1, PageSize: 10}}, wantErr: false}, + + {name: "tc wrong cli", fields: tcFailed, args: args{&pbecs.ListDetailReq{PageNumber: 1, PageSize: 1}}, wantErr: true}, + {name: "tc wrong page number", fields: tc, args: args{&pbecs.ListDetailReq{PageNumber: 0, PageSize: 1}}, wantErr: true}, + {name: "tc wrong page size", fields: tc, args: args{&pbecs.ListDetailReq{PageNumber: 1, PageSize: 0}}, wantErr: true}, + {name: "tc right cli", fields: tc, args: args{&pbecs.ListDetailReq{PageNumber: 1, PageSize: 10}}, wantErr: false}, + + // {name: "hw wrong cli", fields: hwFailed, args: args{pageNumber: 1, pageSize: 1}, wantErr: true}, + {name: "hw right cli", fields: hw, args: args{&pbecs.ListDetailReq{PageNumber: 1, PageSize: 10}}, wantErr: false}, + + {name: "aws right cli", fields: aws, args: args{&pbecs.ListDetailReq{PageNumber: 1, PageSize: 10}}, wantErr: false}, + + // {name: "right cli", fields: google, args: args{pageNumber: 1, pageSize: 10}, wantErr: false}, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + resp, err := tt.fields.ListDetail(context.Background(), tt.args.req) + if (err != nil) != tt.wantErr { + t.Errorf("ListDetail() error = %+v, wantErr %v", err, tt.wantErr) + return + } + t.Logf("%+v", err) + if err == nil { + t.Log(resp) + } + }) + } +} diff --git a/adaptor/vm_adaptor/service/ecser/google.go b/adaptor/vm_adaptor/service/ecser/google.go new file mode 100644 index 0000000..12ee9a7 --- /dev/null +++ b/adaptor/vm_adaptor/service/ecser/google.go @@ -0,0 +1,111 @@ +package ecser + +// +// import ( +// "context" +// "fmt" +// +// "github.com/cloud-fitter/cloud-fitter/gen/idl/pbecs" +// "github.com/cloud-fitter/cloud-fitter/internal/tenanter" +// "github.com/pkg/errors" +// "google.golang.org/api/compute/v1" +// "google.golang.org/api/option" +// ) +// +// // Google当前存在2个问题: +// // 1. 权限的最佳实践 +// // 2. 国内无法直接访问google认证的接口 +// type GoogleEcs struct { +// cli *compute.Service +// } +// +// func NewGoogleEcsClient(tenant tenanter.Tenanter) (Ecser, error) { +// var client *compute.Service +// +// // rName, err := tenanter.GetAwsRegionName(regionId) +// // if err != nil { +// // return nil, err +// // } +// +// client, err := compute.NewService(context.Background(), option.WithCredentialsFile("/Users/didi/Study/cloud-fitter/google_auth.json")) +// if err != nil { +// return nil, errors.WithMessage(err, "new compute service error") +// } +// +// // // Project ID for this request. +// // project := "my-project" // TODO: Update placeholder value. +// // +// // // The name of the zone for this request. +// // zone := "my-zone" // TODO: Update placeholder value. +// // +// // req := computeService.Instances.ListDetail(project, zone) +// // if err := req.Pages(ctx, func(page *compute.InstanceList) error { +// // for _, instance := range page.Items { +// // // TODO: Change code below to process each `instance` resource: +// // fmt.Printf("%#v\n", instance) +// // } +// // return nil +// // }); err != nil { +// // log.Fatal(err) +// // } +// +// // switch t := tenant.(type) { +// // case *tenanter.AccessKeyTenant: +// // auth := basic.NewCredentialsBuilder().WithAk(t.GetId()).WithSk(t.GetSecret()).Build() +// // hcClient := hwecs.EcsClientBuilder().WithRegion(region.ValueOf(rName)).WithCredential(auth).Build() +// // client = hwecs.NewEcsClient(hcClient) +// // default: +// // } +// +// if err != nil { +// return nil, errors.Wrap(err, "init google ecs client error") +// } +// return &GoogleEcs{cli: client}, nil +// } +// +// // func (ecs *GoogleEcs) ECSStatistic() (*pbecs.ECSStatisticRespList, error) { +// // return nil, nil +// // } +// +// func (ecs *GoogleEcs) ListDetail(pageNumber, pageSize int) (*pbecs.ListResp, error) { +// // req := new(model.ListServersDetailsRequest) +// // offset := int32((pageNumber - 1) * pageSize) +// // req.Offset = &offset +// // limit := int32(pageSize) +// // req.Limit = &limit +// // +// // resp, err := ecs.cli.ListServersDetails(req) +// // if err != nil { +// // return nil, errors.Wrap(err, "Google ListDetail error") +// // } +// +// // Project ID for this request. +// project := "focused-stacker-311609" // TODO: Update placeholder value. +// +// // The name of the zone for this request. +// zone := "asia-east2-a" // TODO: Update placeholder value. +// +// req := ecs.cli.Instances.ListDetail(project, zone) +// var ecses []*pbecs.EcsInstance +// if err := req.Pages(context.Background(), func(page *compute.InstanceList) error { +// for _, instance := range page.Items { +// ecses = append(ecses, &pbecs.EcsInstance{ +// InstanceId: fmt.Sprint(instance.Id), +// InstanceName: instance.AccountName, +// RegionId: "", +// ZoneId: "", +// PublicIps: nil, +// Status: "", +// CreationTime: "", +// Description: "", +// }) +// } +// return nil +// }); err != nil { +// return nil, err +// } +// +// return &pbecs.ListResp{ +// Ecses: ecses, +// }, nil +// } diff --git a/adaptor/vm_adaptor/service/ecser/huawei.go b/adaptor/vm_adaptor/service/ecser/huawei.go new file mode 100644 index 0000000..756ffd5 --- /dev/null +++ b/adaptor/vm_adaptor/service/ecser/huawei.go @@ -0,0 +1,106 @@ +package ecser + +import ( + "context" + "gitlink.org.cn/JCCE/PCM/common/tenanter" + "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbecs" + "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant" + + "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" + hwecs "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/ecs/v2" + "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/ecs/v2/model" + hwregion "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/ecs/v2/region" + hwiam "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/iam/v3" + iammodel "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/iam/v3/model" + iamregion "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/iam/v3/region" + "github.com/pkg/errors" +) + +type HuaweiEcs struct { + cli *hwecs.EcsClient + region tenanter.Region + tenanter tenanter.Tenanter +} + +func newHuaweiEcsClient(region tenanter.Region, tenant tenanter.Tenanter) (Ecser, error) { + var ( + client *hwecs.EcsClient + err error + ) + + switch t := tenant.(type) { + case *tenanter.AccessKeyTenant: + auth := basic.NewCredentialsBuilder().WithAk(t.GetId()).WithSk(t.GetSecret()).Build() + rName := region.GetName() + cli := hwiam.IamClientBuilder().WithRegion(iamregion.ValueOf(rName)).WithCredential(auth).Build() + c := hwiam.NewIamClient(cli) + request := new(iammodel.KeystoneListProjectsRequest) + request.Name = &rName + r, err := c.KeystoneListProjects(request) + if err != nil || len(*r.Projects) == 0 { + return nil, errors.Wrapf(err, "Huawei KeystoneListProjects regionName %s", rName) + } + projectId := (*r.Projects)[0].Id + + auth = basic.NewCredentialsBuilder().WithAk(t.GetId()).WithSk(t.GetSecret()).WithProjectId(projectId).Build() + hcClient := hwecs.EcsClientBuilder().WithRegion(hwregion.ValueOf(rName)).WithCredential(auth).Build() + client = hwecs.NewEcsClient(hcClient) + default: + } + + if err != nil { + return nil, errors.Wrap(err, "init huawei ecs client error") + } + return &HuaweiEcs{ + cli: client, + region: region, + tenanter: tenant, + }, nil +} + +func (ecs *HuaweiEcs) ListDetail(ctx context.Context, req *pbecs.ListDetailReq) (*pbecs.ListDetailResp, error) { + request := new(model.ListServersDetailsRequest) + offset := (req.PageNumber - 1) * req.PageSize + request.Offset = &offset + limit := req.PageSize + request.Limit = &limit + + resp, err := ecs.cli.ListServersDetails(request) + if err != nil { + return nil, errors.Wrap(err, "Huawei ListDetail error") + } + + servers := *resp.Servers + var ecses = make([]*pbecs.EcsInstance, len(servers)) + for k, v := range servers { + ecses[k] = &pbecs.EcsInstance{ + Provider: pbtenant.CloudProvider_huawei, + AccountName: ecs.tenanter.AccountName(), + InstanceId: v.Id, + InstanceName: v.Name, + RegionName: ecs.region.GetName(), + InstanceType: v.Flavor.Name, + PublicIps: []string{v.AccessIPv4}, + // Cpu: v.Flavor.Vcpus, + // Memory: v.Flavor.Ram, + Description: *v.Description, + Status: v.Status, + CreationTime: v.Created, + ExpireTime: v.OSSRVUSGterminatedAt, + } + } + + isFinished := false + if len(ecses) < int(req.PageSize) { + isFinished = true + } + + return &pbecs.ListDetailResp{ + Ecses: ecses, + Finished: isFinished, + NextToken: "", + PageNumber: req.PageNumber + 1, + PageSize: req.PageSize, + RequestId: "", + }, nil +} diff --git a/adaptor/vm_adaptor/service/ecser/main_test.go b/adaptor/vm_adaptor/service/ecser/main_test.go new file mode 100644 index 0000000..2477e03 --- /dev/null +++ b/adaptor/vm_adaptor/service/ecser/main_test.go @@ -0,0 +1,32 @@ +package ecser + +import ( + "gitlink.org.cn/JCCE/PCM/common/tenanter" + "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant" + "os" + "testing" +) + +var ( + aliTenant, tcTenant, hwTenant, awsTenant []tenanter.Tenanter +) + +func TestMain(m *testing.M) { + err := tenanter.LoadCloudConfigs("../../../config.yaml") + if err != nil { + panic(err) + } + if aliTenant, err = tenanter.GetTenanters(pbtenant.CloudProvider_ali); err != nil { + panic("get aliTenant failed") + } + if tcTenant, err = tenanter.GetTenanters(pbtenant.CloudProvider_tencent); err != nil { + panic("get tcTenant failed") + } + if hwTenant, err = tenanter.GetTenanters(pbtenant.CloudProvider_huawei); err != nil { + panic("get hwTenant failed") + } + if awsTenant, err = tenanter.GetTenanters(pbtenant.CloudProvider_aws); err != nil { + panic("get awsTenant failed") + } + os.Exit(m.Run()) +} diff --git a/adaptor/vm_adaptor/service/ecser/tencent.go b/adaptor/vm_adaptor/service/ecser/tencent.go new file mode 100644 index 0000000..5463e86 --- /dev/null +++ b/adaptor/vm_adaptor/service/ecser/tencent.go @@ -0,0 +1,95 @@ +package ecser + +import ( + "context" + "gitlink.org.cn/JCCE/PCM/common/tenanter" + + "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbecs" + "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant" + + "github.com/pkg/errors" + "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common" + "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/profile" + cvm "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm/v20170312" +) + +type TencentCvm struct { + cli *cvm.Client + region tenanter.Region + tenanter tenanter.Tenanter +} + +func newTencentCvmClient(region tenanter.Region, tenant tenanter.Tenanter) (Ecser, error) { + var ( + client *cvm.Client + err error + ) + + switch t := tenant.(type) { + case *tenanter.AccessKeyTenant: + client, err = cvm.NewClient(common.NewCredential(t.GetId(), t.GetSecret()), region.GetName(), profile.NewClientProfile()) + default: + } + + if err != nil { + return nil, errors.Wrap(err, "init tencent cvm client error") + } + return &TencentCvm{ + cli: client, + region: region, + tenanter: tenant, + }, nil +} + +func (ecs *TencentCvm) ListDetail(ctx context.Context, req *pbecs.ListDetailReq) (*pbecs.ListDetailResp, error) { + request := cvm.NewDescribeInstancesRequest() + request.Offset = common.Int64Ptr(int64((req.PageNumber - 1) * req.PageSize)) + request.Limit = common.Int64Ptr(int64(req.PageSize)) + resp, err := ecs.cli.DescribeInstances(request) + if err != nil { + return nil, errors.Wrap(err, "Tencent ListDetail error") + } + + var ecses = make([]*pbecs.EcsInstance, len(resp.Response.InstanceSet)) + for k, v := range resp.Response.InstanceSet { + ecses[k] = &pbecs.EcsInstance{ + Provider: pbtenant.CloudProvider_tencent, + AccountName: ecs.tenanter.AccountName(), + InstanceId: *v.InstanceId, + InstanceName: *v.InstanceName, + RegionName: ecs.region.GetName(), + PublicIps: make([]string, len(v.PublicIpAddresses)), + InstanceType: *v.InstanceType, + Cpu: int32(*v.CPU), + Memory: int32(*v.Memory), + Description: "", + Status: *v.InstanceState, + CreationTime: *v.CreatedTime, + ExpireTime: *v.ExpiredTime, + InnerIps: make([]string, len(v.PrivateIpAddresses)), + VpcId: *v.VirtualPrivateCloud.VpcId, + ResourceGroupId: "", + ChargeType: *v.InstanceChargeType, + } + for k1, v1 := range v.PublicIpAddresses { + ecses[k].PublicIps[k1] = *v1 + } + for k1, v1 := range v.PrivateIpAddresses { + ecses[k].InnerIps[k1] = *v1 + } + } + + isFinished := false + if len(ecses) < int(req.PageSize) { + isFinished = true + } + + return &pbecs.ListDetailResp{ + Ecses: ecses, + Finished: isFinished, + NextToken: "", + PageNumber: req.PageNumber + 1, + PageSize: req.PageSize, + RequestId: *resp.Response.RequestId, + }, nil +} diff --git a/buf.gen.yaml b/buf.gen.yaml new file mode 100644 index 0000000..21c9cb5 --- /dev/null +++ b/buf.gen.yaml @@ -0,0 +1,24 @@ +version: v1 +plugins: + - name: go + out: lan_trans + opt: + - paths=source_relative +# - name: java +# out: lan_trans +# opt: +# - paths=source_relative + - name: go-grpc + out: lan_trans + opt: + - paths=source_relative +# - name: java-grpc +# out: gen +# opt: +# - paths=source_relative + - name: grpc-gateway + out: lan_trans + opt: + - paths=source_relative + - name: openapiv2 + out: lan_trans/openapiv2 \ No newline at end of file diff --git a/lan_trans/buf.yaml b/buf.yaml similarity index 100% rename from lan_trans/buf.yaml rename to buf.yaml diff --git a/cm_bridge/cm_adaptor b/cm_bridge/cm_adaptor new file mode 100644 index 0000000..e69de29 diff --git a/internal/server/server.go b/common/server/server.go similarity index 73% rename from internal/server/server.go rename to common/server/server.go index 79add48..5965160 100644 --- a/internal/server/server.go +++ b/common/server/server.go @@ -2,12 +2,14 @@ package server import ( "context" - "gitlink.org.cn/JCCE/PCM/lan_trans/gen/idl/demo" + "gitlink.org.cn/JCCE/PCM/lan_trans/idl/demo" + "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbecs" ) type Server struct { // 使用unsafe可以强制让编译器检查是否实现了相关方法 demo.UnsafeDemoServiceServer + pbecs.UnsafeEcsServiceServer } func (s *Server) Echo(ctx context.Context, req *demo.StringMessage) (*demo.StringMessage, error) { diff --git a/common/server/server_ecs.go b/common/server/server_ecs.go new file mode 100644 index 0000000..0cb931d --- /dev/null +++ b/common/server/server_ecs.go @@ -0,0 +1,38 @@ +package server + +import ( + "context" + "gitlink.org.cn/JCCE/PCM/adaptor/vm_adaptor/server/ecs" + "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbecs" + + "github.com/golang/glog" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func (s *Server) ListEcsDetail(ctx context.Context, req *pbecs.ListDetailReq) (*pbecs.ListDetailResp, error) { + resp, err := ecs.ListDetail(ctx, req) + if err != nil { + glog.Errorf("ListEcsDetail error %+v", err) + return nil, status.Errorf(codes.Internal, err.Error()) + } + return resp, nil +} + +func (s *Server) ListEcs(ctx context.Context, req *pbecs.ListReq) (*pbecs.ListResp, error) { + resp, err := ecs.List(ctx, req) + if err != nil { + glog.Errorf("ListEcs error %+v", err) + return nil, status.Errorf(codes.Internal, err.Error()) + } + return resp, nil +} + +func (s *Server) ListEcsAll(ctx context.Context, req *pbecs.ListAllReq) (*pbecs.ListResp, error) { + resp, err := ecs.ListAll(ctx) + if err != nil { + glog.Errorf("ListEcsAll error %+v", err) + return nil, status.Errorf(codes.Internal, err.Error()) + } + return resp, nil +} diff --git a/common/tenanter/access_key.go b/common/tenanter/access_key.go new file mode 100644 index 0000000..f4425d3 --- /dev/null +++ b/common/tenanter/access_key.go @@ -0,0 +1,35 @@ +package tenanter + +type AccessKeyTenant struct { + name string + id string + secret string +} + +func NewTenantWithAccessKey(name, accessKeyId, accessKeySecret string) Tenanter { + return &AccessKeyTenant{ + name: name, + id: accessKeyId, + secret: accessKeySecret, + } +} + +func (tenant *AccessKeyTenant) AccountName() string { + return tenant.name +} + +func (tenant *AccessKeyTenant) Clone() Tenanter { + return &AccessKeyTenant{ + id: tenant.id, + secret: tenant.secret, + name: tenant.name, + } +} + +func (tenant *AccessKeyTenant) GetId() string { + return tenant.id +} + +func (tenant *AccessKeyTenant) GetSecret() string { + return tenant.secret +} diff --git a/common/tenanter/main_test.go b/common/tenanter/main_test.go new file mode 100644 index 0000000..2a52f72 --- /dev/null +++ b/common/tenanter/main_test.go @@ -0,0 +1,36 @@ +package tenanter + +import ( + "os" + "testing" + + "PCM/lan_trans/go/idl/pbtenant" +) + +var ( + aliTenant []Tenanter + tcTenant []Tenanter + hwTenant []Tenanter + awsTenant []Tenanter +) + +func TestMain(m *testing.M) { + err := LoadCloudConfigs("../../config.yaml") + if err != nil { + panic(err) + } + + if aliTenant, err = GetTenanters(pbtenant.CloudProvider_ali); err != nil { + panic("get aliTenant failed") + } + if tcTenant, err = GetTenanters(pbtenant.CloudProvider_tencent); err != nil { + panic("get tcTenantr failed") + } + if hwTenant, err = GetTenanters(pbtenant.CloudProvider_huawei); err != nil { + panic("get hwTenant failed") + } + if awsTenant, err = GetTenanters(pbtenant.CloudProvider_aws); err != nil { + panic("get awsTenant failed") + } + os.Exit(m.Run()) +} diff --git a/common/tenanter/region.go b/common/tenanter/region.go new file mode 100644 index 0000000..cfb9ed9 --- /dev/null +++ b/common/tenanter/region.go @@ -0,0 +1,130 @@ +package tenanter + +import ( + "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant" + "strings" + + "github.com/pkg/errors" +) + +var ( + ErrNoExistAliRegionId = errors.New("region id not exist in ali") + ErrNoExistTencentRegionId = errors.New("region id not exist in tencent") + ErrNoExistHuaweiRegionId = errors.New("region id not exist in huawei") + ErrNoExistAwsRegionId = errors.New("region id not exist in aws") +) + +type Region interface { + GetId() int32 + GetName() string +} + +type region struct { + provider pbtenant.CloudProvider + regionId int32 + regionName string +} + +func NewRegion(provider pbtenant.CloudProvider, regionId int32) (Region, error) { + r := ®ion{ + provider: provider, + regionId: regionId, + } + var err error + + switch provider { + case pbtenant.CloudProvider_ali: + r.regionName, err = getAliRegionName(regionId) + case pbtenant.CloudProvider_tencent: + r.regionName, err = getTencentRegionName(regionId) + case pbtenant.CloudProvider_huawei: + r.regionName, err = getHuaweiRegionName(regionId) + case pbtenant.CloudProvider_aws: + r.regionName, err = getAwsRegionName(regionId) + } + + return r, err +} + +func (r *region) GetName() string { + return r.regionName +} + +func (r *region) GetId() int32 { + return r.regionId +} + +func GetAllRegionIds(provider pbtenant.CloudProvider) (regions []Region) { + switch provider { + case pbtenant.CloudProvider_ali: + for rId := range pbtenant.AliRegionId_name { + if rId != int32(pbtenant.AliRegionId_ali_all) { + region, _ := NewRegion(provider, rId) + regions = append(regions, region) + } + } + case pbtenant.CloudProvider_tencent: + for rId := range pbtenant.TencentRegionId_name { + if rId != int32(pbtenant.TencentRegionId_tc_all) { + region, _ := NewRegion(provider, rId) + regions = append(regions, region) + } + } + case pbtenant.CloudProvider_huawei: + for rId := range pbtenant.HuaweiRegionId_name { + if rId != int32(pbtenant.HuaweiRegionId_hw_all) { + region, _ := NewRegion(provider, rId) + regions = append(regions, region) + } + } + case pbtenant.CloudProvider_aws: + for rId := range pbtenant.AwsRegionId_name { + if rId != int32(pbtenant.AwsRegionId_aws_all) { + region, _ := NewRegion(provider, rId) + regions = append(regions, region) + } + } + } + + return +} + +// prefix ali_ +func getAliRegionName(regionId int32) (string, error) { + name, ok := pbtenant.AliRegionId_name[regionId] + if !ok || regionId == int32(pbtenant.AliRegionId_ali_all) { + return "", errors.WithMessagef(ErrNoExistAliRegionId, "input region id is %d", regionId) + } + region := strings.ReplaceAll(name, "_", "-") + return region[4:], nil +} + +// prefix tc_ +func getTencentRegionName(regionId int32) (string, error) { + name, ok := pbtenant.TencentRegionId_name[regionId] + if !ok || regionId == int32(pbtenant.TencentRegionId_tc_all) { + return "", errors.WithMessagef(ErrNoExistTencentRegionId, "input region id is %d", regionId) + } + region := strings.ReplaceAll(name, "_", "-") + return region[3:], nil +} + +// prefix hw_ +func getHuaweiRegionName(regionId int32) (string, error) { + name, ok := pbtenant.HuaweiRegionId_name[regionId] + if !ok || regionId == int32(pbtenant.HuaweiRegionId_hw_all) { + return "", errors.WithMessagef(ErrNoExistHuaweiRegionId, "input region id is %d", regionId) + } + region := strings.ReplaceAll(name, "_", "-") + return region[3:], nil +} + +// prefix aws_ +func getAwsRegionName(regionId int32) (string, error) { + name, ok := pbtenant.AwsRegionId_name[regionId] + if !ok || regionId == int32(pbtenant.AwsRegionId_aws_all) { + return "", errors.WithMessagef(ErrNoExistAwsRegionId, "input region id is %d", regionId) + } + region := strings.ReplaceAll(name, "_", "-") + return region[4:], nil +} diff --git a/common/tenanter/region_test.go b/common/tenanter/region_test.go new file mode 100644 index 0000000..da8a712 --- /dev/null +++ b/common/tenanter/region_test.go @@ -0,0 +1,29 @@ +package tenanter + +import ( + "testing" + + "PCM/lan_trans/go/idl/pbtenant" +) + +func TestGetAllRegionIds(t *testing.T) { + type args struct { + provider pbtenant.CloudProvider + } + tests := []struct { + name string + args args + }{ + {name: "ali", args: args{provider: pbtenant.CloudProvider_ali}}, + {name: "tencent", args: args{provider: pbtenant.CloudProvider_tencent}}, + {name: "huawei", args: args{provider: pbtenant.CloudProvider_huawei}}, + {name: "aws", args: args{provider: pbtenant.CloudProvider_aws}}, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if gotRegions := GetAllRegionIds(tt.args.provider); len(gotRegions) == 0 { + t.Errorf("GetAllRegionIds() = %v, want >0", gotRegions) + } + }) + } +} diff --git a/common/tenanter/tenanter.go b/common/tenanter/tenanter.go new file mode 100644 index 0000000..a565156 --- /dev/null +++ b/common/tenanter/tenanter.go @@ -0,0 +1,101 @@ +package tenanter + +import ( + "encoding/json" + "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant" + "io/ioutil" + "os" + "sync" + + "github.com/go-yaml/yaml" + "github.com/pkg/errors" +) + +const osEnvKey = "CLOUD_FITTER_CONFIGS" + +var ( + ErrLoadTenanterFromFile = errors.New("load tenanter from file failed") + ErrLoadTenanterFromOsEnv = errors.New("load tenanter from os env failed") + ErrLoadTenanterFileEmpty = errors.New("load tenanter from file failed") + ErrNoTenanters = errors.New("no tenanters for the cloud") +) + +type Tenanter interface { + AccountName() string + Clone() Tenanter +} + +var gStore = globalStore{stores: make(map[pbtenant.CloudProvider][]Tenanter)} + +type globalStore struct { + sync.Mutex + stores map[pbtenant.CloudProvider][]Tenanter +} + +func LoadCloudConfigs(configFile string) error { + if err := LoadCloudConfigsFromFile(configFile); errors.Is(err, ErrLoadTenanterFileEmpty) { + return LoadCloudConfigsFromOsEnv() + } + return nil +} + +func LoadCloudConfigsFromFile(configFile string) error { + b, err := ioutil.ReadFile(configFile) + if err != nil { + return ErrLoadTenanterFileEmpty + } + + var configs = new(pbtenant.CloudConfigs) + if err = yaml.Unmarshal(b, configs); err != nil { + return errors.WithMessage(ErrLoadTenanterFromFile, err.Error()) + } + + return load(configs) +} + +func LoadCloudConfigsFromOsEnv() error { + data := os.Getenv(osEnvKey) + var configs = new(pbtenant.CloudConfigs) + if err := json.Unmarshal([]byte(data), configs); err != nil { + return errors.WithMessage(ErrLoadTenanterFromOsEnv, err.Error()) + } + + return load(configs) +} + +func ShowConfigJson() ([]byte, error) { + data := os.Getenv(osEnvKey) + var configs = new(pbtenant.CloudConfigs) + if err := yaml.Unmarshal([]byte(data), configs); err != nil { + return nil, errors.WithMessage(ErrLoadTenanterFromFile, err.Error()) + } + + return json.Marshal(configs) +} + +func load(configs *pbtenant.CloudConfigs) error { + gStore.Lock() + defer gStore.Unlock() + + for _, c := range configs.Configs { + if c.AccessId != "" && c.AccessSecret != "" { + gStore.stores[c.Provider] = append(gStore.stores[c.Provider], NewTenantWithAccessKey(c.Name, c.AccessId, c.AccessSecret)) + } + } + return nil +} + +func GetTenanters(provider pbtenant.CloudProvider) ([]Tenanter, error) { + gStore.Lock() + defer gStore.Unlock() + + if len(gStore.stores[provider]) == 0 { + return nil, errors.WithMessagef(ErrNoTenanters, "cloud is %v", provider) + } + + var tenanters = make([]Tenanter, len(gStore.stores[provider])) + for k := range gStore.stores[provider] { + tenanters[k] = gStore.stores[provider][k].Clone() + } + return tenanters, nil +} diff --git a/common/tenanter/tenanter_test.go b/common/tenanter/tenanter_test.go new file mode 100644 index 0000000..1c9b350 --- /dev/null +++ b/common/tenanter/tenanter_test.go @@ -0,0 +1,29 @@ +package tenanter + +import ( + "testing" +) + +func TestShowConfigJson(t *testing.T) { + type args struct { + } + tests := []struct { + name string + args args + wantErr bool + }{ + {name: "right", args: args{}, wantErr: false}, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + got, err := ShowConfigJson() + if (err != nil) != tt.wantErr { + t.Errorf("ShowConfigJson() error = %v, wantErr %v", err, tt.wantErr) + return + } + if err == nil { + t.Log(string(got)) + } + }) + } +} diff --git a/go.mod b/go.mod index 0a73e49..fd57a01 100644 --- a/go.mod +++ b/go.mod @@ -5,10 +5,16 @@ go 1.17 require ( github.com/Unknwon/goconfig v1.0.0 github.com/aliyun/alibaba-cloud-sdk-go v1.61.1530 + github.com/aws/aws-sdk-go-v2/config v1.15.3 + github.com/aws/aws-sdk-go-v2/credentials v1.11.2 + github.com/aws/aws-sdk-go-v2/service/ec2 v1.34.0 + 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.371 + 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 @@ -19,23 +25,33 @@ require ( ) require ( + github.com/aws/aws-sdk-go-v2 v1.16.2 // indirect + github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.3 // indirect + github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.9 // indirect + github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.3 // indirect + github.com/aws/aws-sdk-go-v2/internal/ini v1.3.10 // indirect + github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.3 // indirect + github.com/aws/aws-sdk-go-v2/service/sso v1.11.3 // indirect + github.com/aws/aws-sdk-go-v2/service/sts v1.16.3 // indirect + github.com/aws/smithy-go v1.11.2 // indirect 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 v0.0.0-20170612174753-24818f796faf // 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.0.0-20180206201540-c2b33e8439af // indirect - github.com/json-iterator/go v1.1.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-20200622213623-75b288015ac9 // 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 diff --git a/lan_trans/idl/demo/demo.proto b/idl/demo/demo.proto similarity index 100% rename from lan_trans/idl/demo/demo.proto rename to idl/demo/demo.proto diff --git a/idl/pbecs/ecs.proto b/idl/pbecs/ecs.proto new file mode 100644 index 0000000..0ee855d --- /dev/null +++ b/idl/pbecs/ecs.proto @@ -0,0 +1,119 @@ +syntax = "proto3"; +package pbecs; + +option go_package = "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbecs"; + +import "idl/pbtenant/tenant.proto"; +import "google/api/annotations.proto"; + +message EcsInstance { + // 云类型 + pbtenant.CloudProvider provider = 1; + // 账号名称 + string account_name = 2; + // 实例id + string instance_id = 3; + // 实例名称 + string instance_name = 4; + // 地域,数据中心 + string region_name = 5; + // 公网ip + repeated string public_ips = 6; + // 实例类型 + string instance_type = 7; + // vcpu数 + int32 cpu = 8; + // 内存MB + int32 memory = 9; + // 实例描述 + string description = 10; + // 状态 + string status = 11; + // 创建时间,ISO8601 + string creation_time = 12; + // 过期时间 + string expire_time = 13; + // 内网ip + repeated string inner_ips = 14; + // vcp id + string vpc_id = 15; + // 资源组id + string resource_group_id = 16; + // 收费类型 + string charge_type = 17; +} + +message ListDetailReq { + // 云名称 + pbtenant.CloudProvider provider = 1; + // 账户名称,根据config.yaml中的配置,默认为第一个配置的账户 + string account_name = 2; + // 区域Id,参考 tenant.proto 中的各个云的区域 + int32 region_id = 3; + // 分页相关参数,页码 + int32 page_number = 4; + // 分页相关参数,每页数量 + int32 page_size = 5; + // 分页相关参数,下一页的token + string next_token = 6; +} + +message ListDetailResp { + // Ecs 机器集合 + repeated EcsInstance ecses = 1; + // 查询是否完成,如果为否-false,则可以将下面三个分页参数填入到请求中,继续查询 + bool finished = 2; + // 分页相关参数,页码 + int32 page_number = 3; + // 分页相关参数,每页数量 + int32 page_size = 4; + // 分页相关参数,下一页的token + string next_token = 5; + // 请求id,出现问题后提供给云厂商,排查问题 + string request_id = 6; +} + +message ListReq { + // 云名称 + pbtenant.CloudProvider provider = 1; +} + +message ListResp { + // Ecs 机器集合 + repeated EcsInstance ecses = 1; +} + +message ListAllReq{} + + +// ECS类产品接口 +// 阿里云 - ECS +// 腾讯云 - CVM +// 华为云 - ECS +// 亚马逊云 - EC2 +service EcsService { + + // 查询ECS明细 - 支持云类型、区域、账户、分页等过滤条件 + rpc ListEcsDetail(ListDetailReq) returns (ListDetailResp) { + option (google.api.http) = { + post : "/apis/ecs/detail" + body : "*" + }; + } + + // 查询ECS全量 - 根据云类型 + rpc ListEcs(ListReq) returns (ListResp) { + option (google.api.http) = { + post : "/apis/ecs" + body : "*" + }; + } + + // 查询所有云的ECS + rpc ListEcsAll(ListAllReq) returns (ListResp) { + option (google.api.http) = { + post : "/apis/ecs/all" + body : "*" + }; + } +} \ No newline at end of file diff --git a/idl/pbtenant/tenant.proto b/idl/pbtenant/tenant.proto new file mode 100644 index 0000000..801b611 --- /dev/null +++ b/idl/pbtenant/tenant.proto @@ -0,0 +1,155 @@ +syntax = "proto3"; +package pbtenant; + +option go_package = "gitlink.org.cn/JCCE/PCM/lan_trans/idl/pbtenant"; + +import "google/api/annotations.proto"; +import "protoc-gen-openapiv2/options/annotations.proto"; + +// 云提供商 +enum CloudProvider { + // 0 - 阿里云 + ali = 0; + // 1 - 腾讯云 + tencent = 1; + // 2 - 华为云 + huawei = 2; + // 3 - 亚马逊云 + aws = 3; +} + +// 云产品 +enum CloudProduct { + // 0 - 所有产品 + product_all = 0; + // 1 - ECS类产品:阿里云ECS,腾讯云CVM,华为云ECS,亚马逊EC2 + product_ecs = 1; + // 2 - RDS类产品:阿里云RDS,腾讯云CDB + product_rds = 2; + // 3 - Domain类产品:阿里云Domain + product_domain = 3; + // 4 - OSS类产品:阿里云OSS + product_oss = 4; +} + +// 云配置信息 +message CloudConfigs { + // 云配置 + repeated CloudConfig configs = 1; +} + +message CloudConfig { + // 云服务提供商,具体参考 CloudProvider 的定义 + CloudProvider provider = 1; + // 账户名称,由用户自定义,必须全局唯一,方便多个系统之间的维护 + string name = 2; + // 认证方式1:与 access_secret 结合使用,两者均非空时生效 + string access_id = 3; + // 认证方式1:与 access_id 结合使用,两者均非空时生效 + string access_secret = 4; +} + +// 阿里云区域,需要将对应的 _ 转化为 - +enum AliRegionId { + ali_all = 0; + ali_cn_qingdao = 1; // 青岛 + ali_cn_beijing = 2; // 北京 + ali_cn_zhangjiakou = 3; // 张家口 + ali_cn_huhehaote = 4; // 呼和浩特 + ali_cn_wulanchabu = 5; // 乌兰察布 + ali_cn_hangzhou = 6; // 杭州 + ali_cn_shanghai = 7; // 上海 + ali_cn_shenzhen = 8; // 深圳 + ali_cn_heyuan = 9; // 河源 + ali_cn_guangzhou = 10; // 广州 + ali_cn_chengdu = 11; // 成都 + ali_cn_hongkong = 12; // 中国香港-香港 + ali_ap_southeast_1 = 13; // 亚太东南1-新加坡 + ali_ap_southeast_2 = 14; // 亚太东南2-悉尼 + ali_ap_southeast_3 = 15; // 亚太东南3-吉隆坡 + ali_ap_southeast_5 = 16; // 亚太东南5-雅加达 + ali_ap_south_1 = 17; // 亚太南部1-孟买 + ali_ap_northeast_1 = 18; // 亚太东北1-东京 + ali_us_west_1 = 19; // 美国西部1-硅谷 + ali_us_east_1 = 20; // 美国东部1-弗吉尼亚 + ali_eu_central_1 = 21; // 欧洲中部1-法兰克福 + ali_eu_west_1 = 22; // 英国(伦敦)-伦敦 + ali_me_east_1 = 23; // 中东东部1-迪拜 +} + +// 腾讯云区域,需要将对应的 _ 转化为 - +enum TencentRegionId { + tc_all = 0; + tc_ap_bangkok = 1; // 曼谷 + tc_ap_beijing = 2; // 北京 + tc_ap_chengdu = 3; // 成都 + tc_ap_chongqing = 4; // 重庆 + tc_ap_guangzhou = 5; // 广州 + tc_ap_guangzhou_open = 6; // 广州Open + tc_ap_hongkong = 7; // 中国香港 + tc_ap_mumbai = 8; // 孟买 + tc_ap_seoul = 9; // 首尔 + tc_ap_shanghai = 10; // 上海 + tc_ap_shanghai_fsi = 11; // 上海金融 + tc_ap_shenzhen_fsi = 12; // 深圳金融 + tc_ap_singapore = 13; // 新加坡 + tc_ap_tokyo = 14; // 东京 + tc_eu_frankfurt = 15; // 法兰克福 + tc_eu_moscow = 16; // 莫斯科 + tc_na_ashburn = 17; // 阿什本 + tc_na_siliconvalley = 18; // 硅谷 + tc_na_toronto = 19; // 多伦多 +} + +// 华为云区域,需要将对应的 _ 转化为 - +enum HuaweiRegionId { + hw_all = 0; + hw_cn_north_1 = 1; + hw_cn_north_4 = 2; + hw_cn_south_1 = 3; + hw_cn_east_2 = 4; + hw_cn_east_3 = 5; + hw_cn_southwest_2 = 6; + hw_ap_southeast_1 = 7; + hw_ap_southeast_2 = 8; + hw_ap_southeast_3 = 9; + hw_af_south_1 = 10; +} + +// 亚马逊云区域,需要将对应的 _ 转化为 - +enum AwsRegionId { + aws_all = 0; + aws_us_east_2 = 1; // US East (Ohio) + aws_us_east_1 = 2; // US East (N. Virginia) + aws_us_west_1 = 3; // US West (N. California) + aws_us_west_2 = 4; // US West (Oregon) + aws_af_south_1 = 5; // Africa (Cape Town) + aws_ap_east_1 = 6; // Asia Pacific (Hong Kong) + aws_ap_south_1 = 7; // Asia Pacific (Mumbai) + aws_ap_northeast_3 = 8; // Asia Pacific (Osaka) + aws_ap_northeast_2 = 9; // Asia Pacific (Seoul) + aws_ap_northeast_1 = 10; // Asia Pacific (Singapore) + aws_ap_southeast_2 = 11; // Asia Pacific (Sydney) + aws_ap_southeast_1 = 12; // Asia Pacific (Tokyo) + aws_ca_central_1 = 13; // Canada (Central) + aws_eu_central_1 = 14; // Europe (Frankfurt) + aws_eu_west_1 = 15; // Europe (Ireland) + aws_eu_west_2 = 16; // Europe (London) + aws_eu_south_1 = 17; // Europe (Milan) + aws_eu_west_3 = 18; // Europe (Paris) + aws_eu_north_1 = 19; // Europe (Stockholm) + aws_me_south_1 = 20; // Middle East (Bahrain) + aws_sa_east_1 = 21; // South America (São Paulo) +} + +service TenantService { + + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_tag) = { + description : "所有云租户的认证服务" + external_docs : { + url : "https://gitlink.org.cn/JCCE/PCM" + description: "Find out more about CloudFitter" + } + }; + +} diff --git a/lan_trans/buf.gen.yaml b/lan_trans/buf.gen.yaml deleted file mode 100644 index f777899..0000000 --- a/lan_trans/buf.gen.yaml +++ /dev/null @@ -1,16 +0,0 @@ -version: v1 -plugins: - - name: go - out: gen - opt: - - paths=source_relative - - name: go-grpc - out: gen - opt: - - paths=source_relative - - name: grpc-gateway - out: gen - opt: - - paths=source_relative - - name: openapiv2 - out: gen/openapiv2 \ No newline at end of file diff --git a/lan_trans/idl/demo/demo.pb.go b/lan_trans/idl/demo/demo.pb.go new file mode 100644 index 0000000..cfcfdf5 --- /dev/null +++ b/lan_trans/idl/demo/demo.pb.go @@ -0,0 +1,213 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.28.0 +// protoc (unknown) +// source: idl/demo/demo.proto + +package demo + +import ( + _ "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/options" + _ "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 OurTeam int32 + +const ( + // github: devad + OurTeam_devad OurTeam = 0 +) + +// Enum value maps for OurTeam. +var ( + OurTeam_name = map[int32]string{ + 0: "devad", + } + OurTeam_value = map[string]int32{ + "devad": 0, + } +) + +func (x OurTeam) Enum() *OurTeam { + p := new(OurTeam) + *p = x + return p +} + +func (x OurTeam) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (OurTeam) Descriptor() protoreflect.EnumDescriptor { + return file_idl_demo_demo_proto_enumTypes[0].Descriptor() +} + +func (OurTeam) Type() protoreflect.EnumType { + return &file_idl_demo_demo_proto_enumTypes[0] +} + +func (x OurTeam) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use OurTeam.Descriptor instead. +func (OurTeam) EnumDescriptor() ([]byte, []int) { + return file_idl_demo_demo_proto_rawDescGZIP(), []int{0} +} + +type StringMessage struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Value string `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty"` +} + +func (x *StringMessage) Reset() { + *x = StringMessage{} + if protoimpl.UnsafeEnabled { + mi := &file_idl_demo_demo_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *StringMessage) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*StringMessage) ProtoMessage() {} + +func (x *StringMessage) ProtoReflect() protoreflect.Message { + mi := &file_idl_demo_demo_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 StringMessage.ProtoReflect.Descriptor instead. +func (*StringMessage) Descriptor() ([]byte, []int) { + return file_idl_demo_demo_proto_rawDescGZIP(), []int{0} +} + +func (x *StringMessage) GetValue() string { + if x != nil { + return x.Value + } + return "" +} + +var File_idl_demo_demo_proto protoreflect.FileDescriptor + +var file_idl_demo_demo_proto_rawDesc = []byte{ + 0x0a, 0x13, 0x69, 0x64, 0x6c, 0x2f, 0x64, 0x65, 0x6d, 0x6f, 0x2f, 0x64, 0x65, 0x6d, 0x6f, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x04, 0x64, 0x65, 0x6d, 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, 0x1a, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x63, 0x2d, 0x67, 0x65, 0x6e, 0x2d, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2f, + 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x25, 0x0a, 0x0d, 0x53, 0x74, 0x72, + 0x69, 0x6e, 0x67, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, + 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, + 0x2a, 0x14, 0x0a, 0x07, 0x4f, 0x75, 0x72, 0x54, 0x65, 0x61, 0x6d, 0x12, 0x09, 0x0a, 0x05, 0x64, + 0x65, 0x76, 0x61, 0x64, 0x10, 0x00, 0x32, 0xb3, 0x01, 0x0a, 0x0b, 0x44, 0x65, 0x6d, 0x6f, 0x53, + 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0xa3, 0x01, 0x0a, 0x04, 0x45, 0x63, 0x68, 0x6f, 0x12, + 0x13, 0x2e, 0x64, 0x65, 0x6d, 0x6f, 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x4d, 0x65, 0x73, + 0x73, 0x61, 0x67, 0x65, 0x1a, 0x13, 0x2e, 0x64, 0x65, 0x6d, 0x6f, 0x2e, 0x53, 0x74, 0x72, 0x69, + 0x6e, 0x67, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x71, 0x92, 0x41, 0x59, 0x22, 0x53, + 0x0a, 0x21, 0x46, 0x69, 0x6e, 0x64, 0x20, 0x6f, 0x75, 0x74, 0x20, 0x6d, 0x6f, 0x72, 0x65, 0x20, + 0x61, 0x62, 0x6f, 0x75, 0x74, 0x20, 0x74, 0x68, 0x65, 0x20, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x66, + 0x61, 0x63, 0x65, 0x12, 0x2e, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x67, 0x69, 0x74, + 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x65, 0x63, 0x6f, + 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x67, 0x61, 0x74, 0x65, + 0x77, 0x61, 0x79, 0x58, 0x01, 0x62, 0x00, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0f, 0x22, 0x0a, 0x2f, + 0x61, 0x70, 0x69, 0x73, 0x2f, 0x64, 0x65, 0x6d, 0x6f, 0x3a, 0x01, 0x2a, 0x42, 0x30, 0x5a, 0x2e, + 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, 0x67, 0x65, 0x6e, 0x2f, 0x69, 0x64, 0x6c, 0x2f, 0x64, 0x65, 0x6d, 0x6f, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_idl_demo_demo_proto_rawDescOnce sync.Once + file_idl_demo_demo_proto_rawDescData = file_idl_demo_demo_proto_rawDesc +) + +func file_idl_demo_demo_proto_rawDescGZIP() []byte { + file_idl_demo_demo_proto_rawDescOnce.Do(func() { + file_idl_demo_demo_proto_rawDescData = protoimpl.X.CompressGZIP(file_idl_demo_demo_proto_rawDescData) + }) + return file_idl_demo_demo_proto_rawDescData +} + +var file_idl_demo_demo_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_idl_demo_demo_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_idl_demo_demo_proto_goTypes = []interface{}{ + (OurTeam)(0), // 0: demo.OurTeam + (*StringMessage)(nil), // 1: demo.StringMessage +} +var file_idl_demo_demo_proto_depIdxs = []int32{ + 1, // 0: demo.DemoService.Echo:input_type -> demo.StringMessage + 1, // 1: demo.DemoService.Echo:output_type -> demo.StringMessage + 1, // [1:2] is the sub-list for method output_type + 0, // [0:1] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_idl_demo_demo_proto_init() } +func file_idl_demo_demo_proto_init() { + if File_idl_demo_demo_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_idl_demo_demo_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*StringMessage); 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_demo_demo_proto_rawDesc, + NumEnums: 1, + NumMessages: 1, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_idl_demo_demo_proto_goTypes, + DependencyIndexes: file_idl_demo_demo_proto_depIdxs, + EnumInfos: file_idl_demo_demo_proto_enumTypes, + MessageInfos: file_idl_demo_demo_proto_msgTypes, + }.Build() + File_idl_demo_demo_proto = out.File + file_idl_demo_demo_proto_rawDesc = nil + file_idl_demo_demo_proto_goTypes = nil + file_idl_demo_demo_proto_depIdxs = nil +} diff --git a/lan_trans/idl/demo/demo.pb.gw.go b/lan_trans/idl/demo/demo.pb.gw.go new file mode 100644 index 0000000..66ed1dc --- /dev/null +++ b/lan_trans/idl/demo/demo.pb.gw.go @@ -0,0 +1,167 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: idl/demo/demo.proto + +/* +Package demo is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package demo + +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_DemoService_Echo_0(ctx context.Context, marshaler runtime.Marshaler, client DemoServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq StringMessage + 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.Echo(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_DemoService_Echo_0(ctx context.Context, marshaler runtime.Marshaler, server DemoServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq StringMessage + 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.Echo(ctx, &protoReq) + return msg, metadata, err + +} + +// RegisterDemoServiceHandlerServer registers the http handlers for service DemoService to "mux". +// UnaryRPC :call DemoServiceServer 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 RegisterDemoServiceHandlerFromEndpoint instead. +func RegisterDemoServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server DemoServiceServer) error { + + mux.Handle("POST", pattern_DemoService_Echo_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) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/demo.DemoService/Echo") + 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) + 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_DemoService_Echo_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterDemoServiceHandlerFromEndpoint is same as RegisterDemoServiceHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterDemoServiceHandlerFromEndpoint(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 RegisterDemoServiceHandler(ctx, mux, conn) +} + +// RegisterDemoServiceHandler registers the http handlers for service DemoService to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterDemoServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterDemoServiceHandlerClient(ctx, mux, NewDemoServiceClient(conn)) +} + +// RegisterDemoServiceHandlerClient registers the http handlers for service DemoService +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "DemoServiceClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "DemoServiceClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "DemoServiceClient" to call the correct interceptors. +func RegisterDemoServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client DemoServiceClient) error { + + mux.Handle("POST", pattern_DemoService_Echo_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) + rctx, err := runtime.AnnotateContext(ctx, mux, req, "/demo.DemoService/Echo") + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_DemoService_Echo_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_DemoService_Echo_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_DemoService_Echo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"apis", "demo"}, "")) +) + +var ( + forward_DemoService_Echo_0 = runtime.ForwardResponseMessage +) diff --git a/lan_trans/idl/demo/demo_grpc.pb.go b/lan_trans/idl/demo/demo_grpc.pb.go new file mode 100644 index 0000000..84d085a --- /dev/null +++ b/lan_trans/idl/demo/demo_grpc.pb.go @@ -0,0 +1,107 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.2.0 +// - protoc (unknown) +// source: idl/demo/demo.proto + +package demo + +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 + +// DemoServiceClient is the client API for DemoService 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 DemoServiceClient interface { + // Echo 样例接口 + Echo(ctx context.Context, in *StringMessage, opts ...grpc.CallOption) (*StringMessage, error) +} + +type demoServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewDemoServiceClient(cc grpc.ClientConnInterface) DemoServiceClient { + return &demoServiceClient{cc} +} + +func (c *demoServiceClient) Echo(ctx context.Context, in *StringMessage, opts ...grpc.CallOption) (*StringMessage, error) { + out := new(StringMessage) + err := c.cc.Invoke(ctx, "/demo.DemoService/Echo", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// DemoServiceServer is the server API for DemoService service. +// All implementations must embed UnimplementedDemoServiceServer +// for forward compatibility +type DemoServiceServer interface { + // Echo 样例接口 + Echo(context.Context, *StringMessage) (*StringMessage, error) + mustEmbedUnimplementedDemoServiceServer() +} + +// UnimplementedDemoServiceServer must be embedded to have forward compatible implementations. +type UnimplementedDemoServiceServer struct { +} + +func (UnimplementedDemoServiceServer) Echo(context.Context, *StringMessage) (*StringMessage, error) { + return nil, status.Errorf(codes.Unimplemented, "method Echo not implemented") +} +func (UnimplementedDemoServiceServer) mustEmbedUnimplementedDemoServiceServer() {} + +// UnsafeDemoServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to DemoServiceServer will +// result in compilation errors. +type UnsafeDemoServiceServer interface { + mustEmbedUnimplementedDemoServiceServer() +} + +func RegisterDemoServiceServer(s grpc.ServiceRegistrar, srv DemoServiceServer) { + s.RegisterService(&DemoService_ServiceDesc, srv) +} + +func _DemoService_Echo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(StringMessage) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(DemoServiceServer).Echo(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/demo.DemoService/Echo", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(DemoServiceServer).Echo(ctx, req.(*StringMessage)) + } + return interceptor(ctx, in, info, handler) +} + +// DemoService_ServiceDesc is the grpc.ServiceDesc for DemoService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var DemoService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "demo.DemoService", + HandlerType: (*DemoServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Echo", + Handler: _DemoService_Echo_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "idl/demo/demo.proto", +} diff --git a/lan_trans/idl/pbecs/ecs.pb.go b/lan_trans/idl/pbecs/ecs.pb.go new file mode 100644 index 0000000..49d8db8 --- /dev/null +++ b/lan_trans/idl/pbecs/ecs.pb.go @@ -0,0 +1,776 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.28.0 +// protoc (unknown) +// source: idl/pbecs/ecs.proto + +package pbecs + +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 EcsInstance 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 + InstanceId string `protobuf:"bytes,3,opt,name=instance_id,json=instanceId,proto3" json:"instance_id,omitempty"` + // 实例名称 + InstanceName string `protobuf:"bytes,4,opt,name=instance_name,json=instanceName,proto3" json:"instance_name,omitempty"` + // 地域,数据中心 + RegionName string `protobuf:"bytes,5,opt,name=region_name,json=regionName,proto3" json:"region_name,omitempty"` + // 公网ip + PublicIps []string `protobuf:"bytes,6,rep,name=public_ips,json=publicIps,proto3" json:"public_ips,omitempty"` + // 实例类型 + InstanceType string `protobuf:"bytes,7,opt,name=instance_type,json=instanceType,proto3" json:"instance_type,omitempty"` + // vcpu数 + Cpu int32 `protobuf:"varint,8,opt,name=cpu,proto3" json:"cpu,omitempty"` + // 内存MB + Memory int32 `protobuf:"varint,9,opt,name=memory,proto3" json:"memory,omitempty"` + // 实例描述 + Description string `protobuf:"bytes,10,opt,name=description,proto3" json:"description,omitempty"` + // 状态 + Status string `protobuf:"bytes,11,opt,name=status,proto3" json:"status,omitempty"` + // 创建时间,ISO8601 + CreationTime string `protobuf:"bytes,12,opt,name=creation_time,json=creationTime,proto3" json:"creation_time,omitempty"` + // 过期时间 + ExpireTime string `protobuf:"bytes,13,opt,name=expire_time,json=expireTime,proto3" json:"expire_time,omitempty"` + // 内网ip + InnerIps []string `protobuf:"bytes,14,rep,name=inner_ips,json=innerIps,proto3" json:"inner_ips,omitempty"` + // vcp id + VpcId string `protobuf:"bytes,15,opt,name=vpc_id,json=vpcId,proto3" json:"vpc_id,omitempty"` + // 资源组id + ResourceGroupId string `protobuf:"bytes,16,opt,name=resource_group_id,json=resourceGroupId,proto3" json:"resource_group_id,omitempty"` + // 收费类型 + ChargeType string `protobuf:"bytes,17,opt,name=charge_type,json=chargeType,proto3" json:"charge_type,omitempty"` +} + +func (x *EcsInstance) Reset() { + *x = EcsInstance{} + if protoimpl.UnsafeEnabled { + mi := &file_idl_pbecs_ecs_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *EcsInstance) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*EcsInstance) ProtoMessage() {} + +func (x *EcsInstance) ProtoReflect() protoreflect.Message { + mi := &file_idl_pbecs_ecs_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 EcsInstance.ProtoReflect.Descriptor instead. +func (*EcsInstance) Descriptor() ([]byte, []int) { + return file_idl_pbecs_ecs_proto_rawDescGZIP(), []int{0} +} + +func (x *EcsInstance) GetProvider() pbtenant.CloudProvider { + if x != nil { + return x.Provider + } + return pbtenant.CloudProvider(0) +} + +func (x *EcsInstance) GetAccountName() string { + if x != nil { + return x.AccountName + } + return "" +} + +func (x *EcsInstance) GetInstanceId() string { + if x != nil { + return x.InstanceId + } + return "" +} + +func (x *EcsInstance) GetInstanceName() string { + if x != nil { + return x.InstanceName + } + return "" +} + +func (x *EcsInstance) GetRegionName() string { + if x != nil { + return x.RegionName + } + return "" +} + +func (x *EcsInstance) GetPublicIps() []string { + if x != nil { + return x.PublicIps + } + return nil +} + +func (x *EcsInstance) GetInstanceType() string { + if x != nil { + return x.InstanceType + } + return "" +} + +func (x *EcsInstance) GetCpu() int32 { + if x != nil { + return x.Cpu + } + return 0 +} + +func (x *EcsInstance) GetMemory() int32 { + if x != nil { + return x.Memory + } + return 0 +} + +func (x *EcsInstance) GetDescription() string { + if x != nil { + return x.Description + } + return "" +} + +func (x *EcsInstance) GetStatus() string { + if x != nil { + return x.Status + } + return "" +} + +func (x *EcsInstance) GetCreationTime() string { + if x != nil { + return x.CreationTime + } + return "" +} + +func (x *EcsInstance) GetExpireTime() string { + if x != nil { + return x.ExpireTime + } + return "" +} + +func (x *EcsInstance) GetInnerIps() []string { + if x != nil { + return x.InnerIps + } + return nil +} + +func (x *EcsInstance) GetVpcId() string { + if x != nil { + return x.VpcId + } + return "" +} + +func (x *EcsInstance) GetResourceGroupId() string { + if x != nil { + return x.ResourceGroupId + } + return "" +} + +func (x *EcsInstance) GetChargeType() string { + if x != nil { + return x.ChargeType + } + return "" +} + +type ListDetailReq 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"` + // 分页相关参数,页码 + PageNumber int32 `protobuf:"varint,4,opt,name=page_number,json=pageNumber,proto3" json:"page_number,omitempty"` + // 分页相关参数,每页数量 + PageSize int32 `protobuf:"varint,5,opt,name=page_size,json=pageSize,proto3" json:"page_size,omitempty"` + // 分页相关参数,下一页的token + NextToken string `protobuf:"bytes,6,opt,name=next_token,json=nextToken,proto3" json:"next_token,omitempty"` +} + +func (x *ListDetailReq) Reset() { + *x = ListDetailReq{} + if protoimpl.UnsafeEnabled { + mi := &file_idl_pbecs_ecs_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ListDetailReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListDetailReq) ProtoMessage() {} + +func (x *ListDetailReq) ProtoReflect() protoreflect.Message { + mi := &file_idl_pbecs_ecs_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 ListDetailReq.ProtoReflect.Descriptor instead. +func (*ListDetailReq) Descriptor() ([]byte, []int) { + return file_idl_pbecs_ecs_proto_rawDescGZIP(), []int{1} +} + +func (x *ListDetailReq) GetProvider() pbtenant.CloudProvider { + if x != nil { + return x.Provider + } + return pbtenant.CloudProvider(0) +} + +func (x *ListDetailReq) GetAccountName() string { + if x != nil { + return x.AccountName + } + return "" +} + +func (x *ListDetailReq) GetRegionId() int32 { + if x != nil { + return x.RegionId + } + return 0 +} + +func (x *ListDetailReq) GetPageNumber() int32 { + if x != nil { + return x.PageNumber + } + return 0 +} + +func (x *ListDetailReq) GetPageSize() int32 { + if x != nil { + return x.PageSize + } + return 0 +} + +func (x *ListDetailReq) GetNextToken() string { + if x != nil { + return x.NextToken + } + return "" +} + +type ListDetailResp struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Ecs 机器集合 + Ecses []*EcsInstance `protobuf:"bytes,1,rep,name=ecses,proto3" json:"ecses,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 *ListDetailResp) Reset() { + *x = ListDetailResp{} + if protoimpl.UnsafeEnabled { + mi := &file_idl_pbecs_ecs_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ListDetailResp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListDetailResp) ProtoMessage() {} + +func (x *ListDetailResp) ProtoReflect() protoreflect.Message { + mi := &file_idl_pbecs_ecs_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 ListDetailResp.ProtoReflect.Descriptor instead. +func (*ListDetailResp) Descriptor() ([]byte, []int) { + return file_idl_pbecs_ecs_proto_rawDescGZIP(), []int{2} +} + +func (x *ListDetailResp) GetEcses() []*EcsInstance { + if x != nil { + return x.Ecses + } + return nil +} + +func (x *ListDetailResp) GetFinished() bool { + if x != nil { + return x.Finished + } + return false +} + +func (x *ListDetailResp) GetPageNumber() int32 { + if x != nil { + return x.PageNumber + } + return 0 +} + +func (x *ListDetailResp) GetPageSize() int32 { + if x != nil { + return x.PageSize + } + return 0 +} + +func (x *ListDetailResp) GetNextToken() string { + if x != nil { + return x.NextToken + } + return "" +} + +func (x *ListDetailResp) GetRequestId() string { + if x != nil { + return x.RequestId + } + return "" +} + +type ListReq 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 *ListReq) Reset() { + *x = ListReq{} + if protoimpl.UnsafeEnabled { + mi := &file_idl_pbecs_ecs_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ListReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListReq) ProtoMessage() {} + +func (x *ListReq) ProtoReflect() protoreflect.Message { + mi := &file_idl_pbecs_ecs_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 ListReq.ProtoReflect.Descriptor instead. +func (*ListReq) Descriptor() ([]byte, []int) { + return file_idl_pbecs_ecs_proto_rawDescGZIP(), []int{3} +} + +func (x *ListReq) GetProvider() pbtenant.CloudProvider { + if x != nil { + return x.Provider + } + return pbtenant.CloudProvider(0) +} + +type ListResp struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Ecs 机器集合 + Ecses []*EcsInstance `protobuf:"bytes,1,rep,name=ecses,proto3" json:"ecses,omitempty"` +} + +func (x *ListResp) Reset() { + *x = ListResp{} + if protoimpl.UnsafeEnabled { + mi := &file_idl_pbecs_ecs_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ListResp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListResp) ProtoMessage() {} + +func (x *ListResp) ProtoReflect() protoreflect.Message { + mi := &file_idl_pbecs_ecs_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 ListResp.ProtoReflect.Descriptor instead. +func (*ListResp) Descriptor() ([]byte, []int) { + return file_idl_pbecs_ecs_proto_rawDescGZIP(), []int{4} +} + +func (x *ListResp) GetEcses() []*EcsInstance { + if x != nil { + return x.Ecses + } + return nil +} + +type ListAllReq struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *ListAllReq) Reset() { + *x = ListAllReq{} + if protoimpl.UnsafeEnabled { + mi := &file_idl_pbecs_ecs_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ListAllReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListAllReq) ProtoMessage() {} + +func (x *ListAllReq) ProtoReflect() protoreflect.Message { + mi := &file_idl_pbecs_ecs_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 ListAllReq.ProtoReflect.Descriptor instead. +func (*ListAllReq) Descriptor() ([]byte, []int) { + return file_idl_pbecs_ecs_proto_rawDescGZIP(), []int{5} +} + +var File_idl_pbecs_ecs_proto protoreflect.FileDescriptor + +var file_idl_pbecs_ecs_proto_rawDesc = []byte{ + 0x0a, 0x13, 0x69, 0x64, 0x6c, 0x2f, 0x70, 0x62, 0x65, 0x63, 0x73, 0x2f, 0x65, 0x63, 0x73, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x05, 0x70, 0x62, 0x65, 0x63, 0x73, 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, 0xbb, 0x04, 0x0a, 0x0b, 0x45, 0x63, 0x73, 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, 0x1f, 0x0a, + 0x0b, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x0a, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x49, 0x64, 0x12, 0x23, + 0x0a, 0x0d, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, + 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 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, 0x1d, 0x0a, 0x0a, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x5f, 0x69, + 0x70, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x09, 0x52, 0x09, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, + 0x49, 0x70, 0x73, 0x12, 0x23, 0x0a, 0x0d, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x5f, + 0x74, 0x79, 0x70, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x69, 0x6e, 0x73, 0x74, + 0x61, 0x6e, 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x63, 0x70, 0x75, 0x18, + 0x08, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x63, 0x70, 0x75, 0x12, 0x16, 0x0a, 0x06, 0x6d, 0x65, + 0x6d, 0x6f, 0x72, 0x79, 0x18, 0x09, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x6d, 0x65, 0x6d, 0x6f, + 0x72, 0x79, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, + 0x6e, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, + 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x0b, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x23, 0x0a, 0x0d, + 0x63, 0x72, 0x65, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x0c, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x0c, 0x63, 0x72, 0x65, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x69, 0x6d, + 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x65, 0x78, 0x70, 0x69, 0x72, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, + 0x18, 0x0d, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x65, 0x78, 0x70, 0x69, 0x72, 0x65, 0x54, 0x69, + 0x6d, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x69, 0x6e, 0x6e, 0x65, 0x72, 0x5f, 0x69, 0x70, 0x73, 0x18, + 0x0e, 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, 0x69, 0x6e, 0x6e, 0x65, 0x72, 0x49, 0x70, 0x73, 0x12, + 0x15, 0x0a, 0x06, 0x76, 0x70, 0x63, 0x5f, 0x69, 0x64, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x05, 0x76, 0x70, 0x63, 0x49, 0x64, 0x12, 0x2a, 0x0a, 0x11, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, + 0x63, 0x65, 0x5f, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x5f, 0x69, 0x64, 0x18, 0x10, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, + 0x49, 0x64, 0x12, 0x1f, 0x0a, 0x0b, 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, 0x5f, 0x74, 0x79, 0x70, + 0x65, 0x18, 0x11, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, 0x54, + 0x79, 0x70, 0x65, 0x22, 0xe1, 0x01, 0x0a, 0x0d, 0x4c, 0x69, 0x73, 0x74, 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, 0x1f, 0x0a, 0x0b, 0x70, 0x61, + 0x67, 0x65, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x04, 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, 0x05, 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, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6e, 0x65, + 0x78, 0x74, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0xd2, 0x01, 0x0a, 0x0e, 0x4c, 0x69, 0x73, 0x74, + 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x12, 0x28, 0x0a, 0x05, 0x65, 0x63, + 0x73, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x70, 0x62, 0x65, 0x63, + 0x73, 0x2e, 0x45, 0x63, 0x73, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x05, 0x65, + 0x63, 0x73, 0x65, 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, 0x3e, 0x0a, 0x07, + 0x4c, 0x69, 0x73, 0x74, 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, 0x34, 0x0a, 0x08, + 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x28, 0x0a, 0x05, 0x65, 0x63, 0x73, 0x65, + 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x70, 0x62, 0x65, 0x63, 0x73, 0x2e, + 0x45, 0x63, 0x73, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x05, 0x65, 0x63, 0x73, + 0x65, 0x73, 0x22, 0x0c, 0x0a, 0x0a, 0x4c, 0x69, 0x73, 0x74, 0x41, 0x6c, 0x6c, 0x52, 0x65, 0x71, + 0x32, 0xf5, 0x01, 0x0a, 0x0a, 0x45, 0x63, 0x73, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, + 0x59, 0x0a, 0x0d, 0x4c, 0x69, 0x73, 0x74, 0x45, 0x63, 0x73, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, + 0x12, 0x14, 0x2e, 0x70, 0x62, 0x65, 0x63, 0x73, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x44, 0x65, 0x74, + 0x61, 0x69, 0x6c, 0x52, 0x65, 0x71, 0x1a, 0x15, 0x2e, 0x70, 0x62, 0x65, 0x63, 0x73, 0x2e, 0x4c, + 0x69, 0x73, 0x74, 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, 0x65, 0x63, 0x73, + 0x2f, 0x64, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x3a, 0x01, 0x2a, 0x12, 0x40, 0x0a, 0x07, 0x4c, 0x69, + 0x73, 0x74, 0x45, 0x63, 0x73, 0x12, 0x0e, 0x2e, 0x70, 0x62, 0x65, 0x63, 0x73, 0x2e, 0x4c, 0x69, + 0x73, 0x74, 0x52, 0x65, 0x71, 0x1a, 0x0f, 0x2e, 0x70, 0x62, 0x65, 0x63, 0x73, 0x2e, 0x4c, 0x69, + 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x22, 0x14, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0e, 0x22, 0x09, + 0x2f, 0x61, 0x70, 0x69, 0x73, 0x2f, 0x65, 0x63, 0x73, 0x3a, 0x01, 0x2a, 0x12, 0x4a, 0x0a, 0x0a, + 0x4c, 0x69, 0x73, 0x74, 0x45, 0x63, 0x73, 0x41, 0x6c, 0x6c, 0x12, 0x11, 0x2e, 0x70, 0x62, 0x65, + 0x63, 0x73, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x41, 0x6c, 0x6c, 0x52, 0x65, 0x71, 0x1a, 0x0f, 0x2e, + 0x70, 0x62, 0x65, 0x63, 0x73, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x22, 0x18, + 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x12, 0x22, 0x0d, 0x2f, 0x61, 0x70, 0x69, 0x73, 0x2f, 0x65, 0x63, + 0x73, 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, 0x65, 0x63, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_idl_pbecs_ecs_proto_rawDescOnce sync.Once + file_idl_pbecs_ecs_proto_rawDescData = file_idl_pbecs_ecs_proto_rawDesc +) + +func file_idl_pbecs_ecs_proto_rawDescGZIP() []byte { + file_idl_pbecs_ecs_proto_rawDescOnce.Do(func() { + file_idl_pbecs_ecs_proto_rawDescData = protoimpl.X.CompressGZIP(file_idl_pbecs_ecs_proto_rawDescData) + }) + return file_idl_pbecs_ecs_proto_rawDescData +} + +var file_idl_pbecs_ecs_proto_msgTypes = make([]protoimpl.MessageInfo, 6) +var file_idl_pbecs_ecs_proto_goTypes = []interface{}{ + (*EcsInstance)(nil), // 0: pbecs.EcsInstance + (*ListDetailReq)(nil), // 1: pbecs.ListDetailReq + (*ListDetailResp)(nil), // 2: pbecs.ListDetailResp + (*ListReq)(nil), // 3: pbecs.ListReq + (*ListResp)(nil), // 4: pbecs.ListResp + (*ListAllReq)(nil), // 5: pbecs.ListAllReq + (pbtenant.CloudProvider)(0), // 6: pbtenant.CloudProvider +} +var file_idl_pbecs_ecs_proto_depIdxs = []int32{ + 6, // 0: pbecs.EcsInstance.provider:type_name -> pbtenant.CloudProvider + 6, // 1: pbecs.ListDetailReq.provider:type_name -> pbtenant.CloudProvider + 0, // 2: pbecs.ListDetailResp.ecses:type_name -> pbecs.EcsInstance + 6, // 3: pbecs.ListReq.provider:type_name -> pbtenant.CloudProvider + 0, // 4: pbecs.ListResp.ecses:type_name -> pbecs.EcsInstance + 1, // 5: pbecs.EcsService.ListEcsDetail:input_type -> pbecs.ListDetailReq + 3, // 6: pbecs.EcsService.ListEcs:input_type -> pbecs.ListReq + 5, // 7: pbecs.EcsService.ListEcsAll:input_type -> pbecs.ListAllReq + 2, // 8: pbecs.EcsService.ListEcsDetail:output_type -> pbecs.ListDetailResp + 4, // 9: pbecs.EcsService.ListEcs:output_type -> pbecs.ListResp + 4, // 10: pbecs.EcsService.ListEcsAll:output_type -> pbecs.ListResp + 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_pbecs_ecs_proto_init() } +func file_idl_pbecs_ecs_proto_init() { + if File_idl_pbecs_ecs_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_idl_pbecs_ecs_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*EcsInstance); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_idl_pbecs_ecs_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ListDetailReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_idl_pbecs_ecs_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ListDetailResp); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_idl_pbecs_ecs_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ListReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_idl_pbecs_ecs_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ListResp); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_idl_pbecs_ecs_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ListAllReq); 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_pbecs_ecs_proto_rawDesc, + NumEnums: 0, + NumMessages: 6, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_idl_pbecs_ecs_proto_goTypes, + DependencyIndexes: file_idl_pbecs_ecs_proto_depIdxs, + MessageInfos: file_idl_pbecs_ecs_proto_msgTypes, + }.Build() + File_idl_pbecs_ecs_proto = out.File + file_idl_pbecs_ecs_proto_rawDesc = nil + file_idl_pbecs_ecs_proto_goTypes = nil + file_idl_pbecs_ecs_proto_depIdxs = nil +} diff --git a/lan_trans/idl/pbecs/ecs.pb.gw.go b/lan_trans/idl/pbecs/ecs.pb.gw.go new file mode 100644 index 0000000..95d6355 --- /dev/null +++ b/lan_trans/idl/pbecs/ecs.pb.gw.go @@ -0,0 +1,329 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: idl/pbecs/ecs.proto + +/* +Package pbecs is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package pbecs + +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_EcsService_ListEcsDetail_0(ctx context.Context, marshaler runtime.Marshaler, client EcsServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq ListDetailReq + 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.ListEcsDetail(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_EcsService_ListEcsDetail_0(ctx context.Context, marshaler runtime.Marshaler, server EcsServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq ListDetailReq + 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.ListEcsDetail(ctx, &protoReq) + return msg, metadata, err + +} + +func request_EcsService_ListEcs_0(ctx context.Context, marshaler runtime.Marshaler, client EcsServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq ListReq + 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.ListEcs(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_EcsService_ListEcs_0(ctx context.Context, marshaler runtime.Marshaler, server EcsServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq ListReq + 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.ListEcs(ctx, &protoReq) + return msg, metadata, err + +} + +func request_EcsService_ListEcsAll_0(ctx context.Context, marshaler runtime.Marshaler, client EcsServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq ListAllReq + 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.ListEcsAll(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_EcsService_ListEcsAll_0(ctx context.Context, marshaler runtime.Marshaler, server EcsServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq ListAllReq + 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.ListEcsAll(ctx, &protoReq) + return msg, metadata, err + +} + +// RegisterEcsServiceHandlerServer registers the http handlers for service EcsService to "mux". +// UnaryRPC :call EcsServiceServer 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 RegisterEcsServiceHandlerFromEndpoint instead. +func RegisterEcsServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server EcsServiceServer) error { + + mux.Handle("POST", pattern_EcsService_ListEcsDetail_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) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/pbecs.EcsService/ListEcsDetail") + 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) + 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_EcsService_ListEcsDetail_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_EcsService_ListEcs_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) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/pbecs.EcsService/ListEcs") + 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) + 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_EcsService_ListEcs_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_EcsService_ListEcsAll_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) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/pbecs.EcsService/ListEcsAll") + 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) + 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_EcsService_ListEcsAll_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterEcsServiceHandlerFromEndpoint is same as RegisterEcsServiceHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterEcsServiceHandlerFromEndpoint(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 RegisterEcsServiceHandler(ctx, mux, conn) +} + +// RegisterEcsServiceHandler registers the http handlers for service EcsService to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterEcsServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterEcsServiceHandlerClient(ctx, mux, NewEcsServiceClient(conn)) +} + +// RegisterEcsServiceHandlerClient registers the http handlers for service EcsService +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "EcsServiceClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "EcsServiceClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "EcsServiceClient" to call the correct interceptors. +func RegisterEcsServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client EcsServiceClient) error { + + mux.Handle("POST", pattern_EcsService_ListEcsDetail_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) + rctx, err := runtime.AnnotateContext(ctx, mux, req, "/pbecs.EcsService/ListEcsDetail") + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_EcsService_ListEcsDetail_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_EcsService_ListEcsDetail_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_EcsService_ListEcs_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) + rctx, err := runtime.AnnotateContext(ctx, mux, req, "/pbecs.EcsService/ListEcs") + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_EcsService_ListEcs_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_EcsService_ListEcs_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_EcsService_ListEcsAll_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) + rctx, err := runtime.AnnotateContext(ctx, mux, req, "/pbecs.EcsService/ListEcsAll") + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_EcsService_ListEcsAll_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_EcsService_ListEcsAll_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_EcsService_ListEcsDetail_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"apis", "ecs", "detail"}, "")) + + pattern_EcsService_ListEcs_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"apis", "ecs"}, "")) + + pattern_EcsService_ListEcsAll_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"apis", "ecs", "all"}, "")) +) + +var ( + forward_EcsService_ListEcsDetail_0 = runtime.ForwardResponseMessage + + forward_EcsService_ListEcs_0 = runtime.ForwardResponseMessage + + forward_EcsService_ListEcsAll_0 = runtime.ForwardResponseMessage +) diff --git a/lan_trans/idl/pbecs/ecs_grpc.pb.go b/lan_trans/idl/pbecs/ecs_grpc.pb.go new file mode 100644 index 0000000..228a13c --- /dev/null +++ b/lan_trans/idl/pbecs/ecs_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/pbecs/ecs.proto + +package pbecs + +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 + +// EcsServiceClient is the client API for EcsService 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 EcsServiceClient interface { + // 查询ECS明细 - 支持云类型、区域、账户、分页等过滤条件 + ListEcsDetail(ctx context.Context, in *ListDetailReq, opts ...grpc.CallOption) (*ListDetailResp, error) + // 查询ECS全量 - 根据云类型 + ListEcs(ctx context.Context, in *ListReq, opts ...grpc.CallOption) (*ListResp, error) + // 查询所有云的ECS + ListEcsAll(ctx context.Context, in *ListAllReq, opts ...grpc.CallOption) (*ListResp, error) +} + +type ecsServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewEcsServiceClient(cc grpc.ClientConnInterface) EcsServiceClient { + return &ecsServiceClient{cc} +} + +func (c *ecsServiceClient) ListEcsDetail(ctx context.Context, in *ListDetailReq, opts ...grpc.CallOption) (*ListDetailResp, error) { + out := new(ListDetailResp) + err := c.cc.Invoke(ctx, "/pbecs.EcsService/ListEcsDetail", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *ecsServiceClient) ListEcs(ctx context.Context, in *ListReq, opts ...grpc.CallOption) (*ListResp, error) { + out := new(ListResp) + err := c.cc.Invoke(ctx, "/pbecs.EcsService/ListEcs", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *ecsServiceClient) ListEcsAll(ctx context.Context, in *ListAllReq, opts ...grpc.CallOption) (*ListResp, error) { + out := new(ListResp) + err := c.cc.Invoke(ctx, "/pbecs.EcsService/ListEcsAll", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// EcsServiceServer is the server API for EcsService service. +// All implementations must embed UnimplementedEcsServiceServer +// for forward compatibility +type EcsServiceServer interface { + // 查询ECS明细 - 支持云类型、区域、账户、分页等过滤条件 + ListEcsDetail(context.Context, *ListDetailReq) (*ListDetailResp, error) + // 查询ECS全量 - 根据云类型 + ListEcs(context.Context, *ListReq) (*ListResp, error) + // 查询所有云的ECS + ListEcsAll(context.Context, *ListAllReq) (*ListResp, error) + mustEmbedUnimplementedEcsServiceServer() +} + +// UnimplementedEcsServiceServer must be embedded to have forward compatible implementations. +type UnimplementedEcsServiceServer struct { +} + +func (UnimplementedEcsServiceServer) ListEcsDetail(context.Context, *ListDetailReq) (*ListDetailResp, error) { + return nil, status.Errorf(codes.Unimplemented, "method ListEcsDetail not implemented") +} +func (UnimplementedEcsServiceServer) ListEcs(context.Context, *ListReq) (*ListResp, error) { + return nil, status.Errorf(codes.Unimplemented, "method ListEcs not implemented") +} +func (UnimplementedEcsServiceServer) ListEcsAll(context.Context, *ListAllReq) (*ListResp, error) { + return nil, status.Errorf(codes.Unimplemented, "method ListEcsAll not implemented") +} +func (UnimplementedEcsServiceServer) mustEmbedUnimplementedEcsServiceServer() {} + +// UnsafeEcsServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to EcsServiceServer will +// result in compilation errors. +type UnsafeEcsServiceServer interface { + mustEmbedUnimplementedEcsServiceServer() +} + +func RegisterEcsServiceServer(s grpc.ServiceRegistrar, srv EcsServiceServer) { + s.RegisterService(&EcsService_ServiceDesc, srv) +} + +func _EcsService_ListEcsDetail_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ListDetailReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(EcsServiceServer).ListEcsDetail(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/pbecs.EcsService/ListEcsDetail", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(EcsServiceServer).ListEcsDetail(ctx, req.(*ListDetailReq)) + } + return interceptor(ctx, in, info, handler) +} + +func _EcsService_ListEcs_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ListReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(EcsServiceServer).ListEcs(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/pbecs.EcsService/ListEcs", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(EcsServiceServer).ListEcs(ctx, req.(*ListReq)) + } + return interceptor(ctx, in, info, handler) +} + +func _EcsService_ListEcsAll_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ListAllReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(EcsServiceServer).ListEcsAll(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/pbecs.EcsService/ListEcsAll", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(EcsServiceServer).ListEcsAll(ctx, req.(*ListAllReq)) + } + return interceptor(ctx, in, info, handler) +} + +// EcsService_ServiceDesc is the grpc.ServiceDesc for EcsService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var EcsService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "pbecs.EcsService", + HandlerType: (*EcsServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "ListEcsDetail", + Handler: _EcsService_ListEcsDetail_Handler, + }, + { + MethodName: "ListEcs", + Handler: _EcsService_ListEcs_Handler, + }, + { + MethodName: "ListEcsAll", + Handler: _EcsService_ListEcsAll_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "idl/pbecs/ecs.proto", +} diff --git a/lan_trans/idl/pbtenant/tenant.pb.go b/lan_trans/idl/pbtenant/tenant.pb.go new file mode 100644 index 0000000..23b4c6a --- /dev/null +++ b/lan_trans/idl/pbtenant/tenant.pb.go @@ -0,0 +1,896 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.28.0 +// protoc (unknown) +// source: idl/pbtenant/tenant.proto + +package pbtenant + +import ( + _ "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/options" + _ "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 CloudProvider int32 + +const ( + // 0 - 阿里云 + CloudProvider_ali CloudProvider = 0 + // 1 - 腾讯云 + CloudProvider_tencent CloudProvider = 1 + // 2 - 华为云 + CloudProvider_huawei CloudProvider = 2 + // 3 - 亚马逊云 + CloudProvider_aws CloudProvider = 3 +) + +// Enum value maps for CloudProvider. +var ( + CloudProvider_name = map[int32]string{ + 0: "ali", + 1: "tencent", + 2: "huawei", + 3: "aws", + } + CloudProvider_value = map[string]int32{ + "ali": 0, + "tencent": 1, + "huawei": 2, + "aws": 3, + } +) + +func (x CloudProvider) Enum() *CloudProvider { + p := new(CloudProvider) + *p = x + return p +} + +func (x CloudProvider) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (CloudProvider) Descriptor() protoreflect.EnumDescriptor { + return file_idl_pbtenant_tenant_proto_enumTypes[0].Descriptor() +} + +func (CloudProvider) Type() protoreflect.EnumType { + return &file_idl_pbtenant_tenant_proto_enumTypes[0] +} + +func (x CloudProvider) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use CloudProvider.Descriptor instead. +func (CloudProvider) EnumDescriptor() ([]byte, []int) { + return file_idl_pbtenant_tenant_proto_rawDescGZIP(), []int{0} +} + +// 云产品 +type CloudProduct int32 + +const ( + // 0 - 所有产品 + CloudProduct_product_all CloudProduct = 0 + // 1 - ECS类产品:阿里云ECS,腾讯云CVM,华为云ECS,亚马逊EC2 + CloudProduct_product_ecs CloudProduct = 1 + // 2 - RDS类产品:阿里云RDS,腾讯云CDB + CloudProduct_product_rds CloudProduct = 2 + // 3 - Domain类产品:阿里云Domain + CloudProduct_product_domain CloudProduct = 3 + // 4 - OSS类产品:阿里云OSS + CloudProduct_product_oss CloudProduct = 4 +) + +// Enum value maps for CloudProduct. +var ( + CloudProduct_name = map[int32]string{ + 0: "product_all", + 1: "product_ecs", + 2: "product_rds", + 3: "product_domain", + 4: "product_oss", + } + CloudProduct_value = map[string]int32{ + "product_all": 0, + "product_ecs": 1, + "product_rds": 2, + "product_domain": 3, + "product_oss": 4, + } +) + +func (x CloudProduct) Enum() *CloudProduct { + p := new(CloudProduct) + *p = x + return p +} + +func (x CloudProduct) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (CloudProduct) Descriptor() protoreflect.EnumDescriptor { + return file_idl_pbtenant_tenant_proto_enumTypes[1].Descriptor() +} + +func (CloudProduct) Type() protoreflect.EnumType { + return &file_idl_pbtenant_tenant_proto_enumTypes[1] +} + +func (x CloudProduct) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use CloudProduct.Descriptor instead. +func (CloudProduct) EnumDescriptor() ([]byte, []int) { + return file_idl_pbtenant_tenant_proto_rawDescGZIP(), []int{1} +} + +// 阿里云区域,需要将对应的 _ 转化为 - +type AliRegionId int32 + +const ( + AliRegionId_ali_all AliRegionId = 0 + AliRegionId_ali_cn_qingdao AliRegionId = 1 // 青岛 + AliRegionId_ali_cn_beijing AliRegionId = 2 // 北京 + AliRegionId_ali_cn_zhangjiakou AliRegionId = 3 // 张家口 + AliRegionId_ali_cn_huhehaote AliRegionId = 4 // 呼和浩特 + AliRegionId_ali_cn_wulanchabu AliRegionId = 5 // 乌兰察布 + AliRegionId_ali_cn_hangzhou AliRegionId = 6 // 杭州 + AliRegionId_ali_cn_shanghai AliRegionId = 7 // 上海 + AliRegionId_ali_cn_shenzhen AliRegionId = 8 // 深圳 + AliRegionId_ali_cn_heyuan AliRegionId = 9 // 河源 + AliRegionId_ali_cn_guangzhou AliRegionId = 10 // 广州 + AliRegionId_ali_cn_chengdu AliRegionId = 11 // 成都 + AliRegionId_ali_cn_hongkong AliRegionId = 12 // 中国香港-香港 + AliRegionId_ali_ap_southeast_1 AliRegionId = 13 // 亚太东南1-新加坡 + AliRegionId_ali_ap_southeast_2 AliRegionId = 14 // 亚太东南2-悉尼 + AliRegionId_ali_ap_southeast_3 AliRegionId = 15 // 亚太东南3-吉隆坡 + AliRegionId_ali_ap_southeast_5 AliRegionId = 16 // 亚太东南5-雅加达 + AliRegionId_ali_ap_south_1 AliRegionId = 17 // 亚太南部1-孟买 + AliRegionId_ali_ap_northeast_1 AliRegionId = 18 // 亚太东北1-东京 + AliRegionId_ali_us_west_1 AliRegionId = 19 // 美国西部1-硅谷 + AliRegionId_ali_us_east_1 AliRegionId = 20 // 美国东部1-弗吉尼亚 + AliRegionId_ali_eu_central_1 AliRegionId = 21 // 欧洲中部1-法兰克福 + AliRegionId_ali_eu_west_1 AliRegionId = 22 // 英国(伦敦)-伦敦 + AliRegionId_ali_me_east_1 AliRegionId = 23 // 中东东部1-迪拜 +) + +// Enum value maps for AliRegionId. +var ( + AliRegionId_name = map[int32]string{ + 0: "ali_all", + 1: "ali_cn_qingdao", + 2: "ali_cn_beijing", + 3: "ali_cn_zhangjiakou", + 4: "ali_cn_huhehaote", + 5: "ali_cn_wulanchabu", + 6: "ali_cn_hangzhou", + 7: "ali_cn_shanghai", + 8: "ali_cn_shenzhen", + 9: "ali_cn_heyuan", + 10: "ali_cn_guangzhou", + 11: "ali_cn_chengdu", + 12: "ali_cn_hongkong", + 13: "ali_ap_southeast_1", + 14: "ali_ap_southeast_2", + 15: "ali_ap_southeast_3", + 16: "ali_ap_southeast_5", + 17: "ali_ap_south_1", + 18: "ali_ap_northeast_1", + 19: "ali_us_west_1", + 20: "ali_us_east_1", + 21: "ali_eu_central_1", + 22: "ali_eu_west_1", + 23: "ali_me_east_1", + } + AliRegionId_value = map[string]int32{ + "ali_all": 0, + "ali_cn_qingdao": 1, + "ali_cn_beijing": 2, + "ali_cn_zhangjiakou": 3, + "ali_cn_huhehaote": 4, + "ali_cn_wulanchabu": 5, + "ali_cn_hangzhou": 6, + "ali_cn_shanghai": 7, + "ali_cn_shenzhen": 8, + "ali_cn_heyuan": 9, + "ali_cn_guangzhou": 10, + "ali_cn_chengdu": 11, + "ali_cn_hongkong": 12, + "ali_ap_southeast_1": 13, + "ali_ap_southeast_2": 14, + "ali_ap_southeast_3": 15, + "ali_ap_southeast_5": 16, + "ali_ap_south_1": 17, + "ali_ap_northeast_1": 18, + "ali_us_west_1": 19, + "ali_us_east_1": 20, + "ali_eu_central_1": 21, + "ali_eu_west_1": 22, + "ali_me_east_1": 23, + } +) + +func (x AliRegionId) Enum() *AliRegionId { + p := new(AliRegionId) + *p = x + return p +} + +func (x AliRegionId) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (AliRegionId) Descriptor() protoreflect.EnumDescriptor { + return file_idl_pbtenant_tenant_proto_enumTypes[2].Descriptor() +} + +func (AliRegionId) Type() protoreflect.EnumType { + return &file_idl_pbtenant_tenant_proto_enumTypes[2] +} + +func (x AliRegionId) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use AliRegionId.Descriptor instead. +func (AliRegionId) EnumDescriptor() ([]byte, []int) { + return file_idl_pbtenant_tenant_proto_rawDescGZIP(), []int{2} +} + +// 腾讯云区域,需要将对应的 _ 转化为 - +type TencentRegionId int32 + +const ( + TencentRegionId_tc_all TencentRegionId = 0 + TencentRegionId_tc_ap_bangkok TencentRegionId = 1 // 曼谷 + TencentRegionId_tc_ap_beijing TencentRegionId = 2 // 北京 + TencentRegionId_tc_ap_chengdu TencentRegionId = 3 // 成都 + TencentRegionId_tc_ap_chongqing TencentRegionId = 4 // 重庆 + TencentRegionId_tc_ap_guangzhou TencentRegionId = 5 // 广州 + TencentRegionId_tc_ap_guangzhou_open TencentRegionId = 6 // 广州Open + TencentRegionId_tc_ap_hongkong TencentRegionId = 7 // 中国香港 + TencentRegionId_tc_ap_mumbai TencentRegionId = 8 // 孟买 + TencentRegionId_tc_ap_seoul TencentRegionId = 9 // 首尔 + TencentRegionId_tc_ap_shanghai TencentRegionId = 10 // 上海 + TencentRegionId_tc_ap_shanghai_fsi TencentRegionId = 11 // 上海金融 + TencentRegionId_tc_ap_shenzhen_fsi TencentRegionId = 12 // 深圳金融 + TencentRegionId_tc_ap_singapore TencentRegionId = 13 // 新加坡 + TencentRegionId_tc_ap_tokyo TencentRegionId = 14 // 东京 + TencentRegionId_tc_eu_frankfurt TencentRegionId = 15 // 法兰克福 + TencentRegionId_tc_eu_moscow TencentRegionId = 16 // 莫斯科 + TencentRegionId_tc_na_ashburn TencentRegionId = 17 // 阿什本 + TencentRegionId_tc_na_siliconvalley TencentRegionId = 18 // 硅谷 + TencentRegionId_tc_na_toronto TencentRegionId = 19 // 多伦多 +) + +// Enum value maps for TencentRegionId. +var ( + TencentRegionId_name = map[int32]string{ + 0: "tc_all", + 1: "tc_ap_bangkok", + 2: "tc_ap_beijing", + 3: "tc_ap_chengdu", + 4: "tc_ap_chongqing", + 5: "tc_ap_guangzhou", + 6: "tc_ap_guangzhou_open", + 7: "tc_ap_hongkong", + 8: "tc_ap_mumbai", + 9: "tc_ap_seoul", + 10: "tc_ap_shanghai", + 11: "tc_ap_shanghai_fsi", + 12: "tc_ap_shenzhen_fsi", + 13: "tc_ap_singapore", + 14: "tc_ap_tokyo", + 15: "tc_eu_frankfurt", + 16: "tc_eu_moscow", + 17: "tc_na_ashburn", + 18: "tc_na_siliconvalley", + 19: "tc_na_toronto", + } + TencentRegionId_value = map[string]int32{ + "tc_all": 0, + "tc_ap_bangkok": 1, + "tc_ap_beijing": 2, + "tc_ap_chengdu": 3, + "tc_ap_chongqing": 4, + "tc_ap_guangzhou": 5, + "tc_ap_guangzhou_open": 6, + "tc_ap_hongkong": 7, + "tc_ap_mumbai": 8, + "tc_ap_seoul": 9, + "tc_ap_shanghai": 10, + "tc_ap_shanghai_fsi": 11, + "tc_ap_shenzhen_fsi": 12, + "tc_ap_singapore": 13, + "tc_ap_tokyo": 14, + "tc_eu_frankfurt": 15, + "tc_eu_moscow": 16, + "tc_na_ashburn": 17, + "tc_na_siliconvalley": 18, + "tc_na_toronto": 19, + } +) + +func (x TencentRegionId) Enum() *TencentRegionId { + p := new(TencentRegionId) + *p = x + return p +} + +func (x TencentRegionId) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (TencentRegionId) Descriptor() protoreflect.EnumDescriptor { + return file_idl_pbtenant_tenant_proto_enumTypes[3].Descriptor() +} + +func (TencentRegionId) Type() protoreflect.EnumType { + return &file_idl_pbtenant_tenant_proto_enumTypes[3] +} + +func (x TencentRegionId) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use TencentRegionId.Descriptor instead. +func (TencentRegionId) EnumDescriptor() ([]byte, []int) { + return file_idl_pbtenant_tenant_proto_rawDescGZIP(), []int{3} +} + +// 华为云区域,需要将对应的 _ 转化为 - +type HuaweiRegionId int32 + +const ( + HuaweiRegionId_hw_all HuaweiRegionId = 0 + HuaweiRegionId_hw_cn_north_1 HuaweiRegionId = 1 + HuaweiRegionId_hw_cn_north_4 HuaweiRegionId = 2 + HuaweiRegionId_hw_cn_south_1 HuaweiRegionId = 3 + HuaweiRegionId_hw_cn_east_2 HuaweiRegionId = 4 + HuaweiRegionId_hw_cn_east_3 HuaweiRegionId = 5 + HuaweiRegionId_hw_cn_southwest_2 HuaweiRegionId = 6 + HuaweiRegionId_hw_ap_southeast_1 HuaweiRegionId = 7 + HuaweiRegionId_hw_ap_southeast_2 HuaweiRegionId = 8 + HuaweiRegionId_hw_ap_southeast_3 HuaweiRegionId = 9 + HuaweiRegionId_hw_af_south_1 HuaweiRegionId = 10 +) + +// Enum value maps for HuaweiRegionId. +var ( + HuaweiRegionId_name = map[int32]string{ + 0: "hw_all", + 1: "hw_cn_north_1", + 2: "hw_cn_north_4", + 3: "hw_cn_south_1", + 4: "hw_cn_east_2", + 5: "hw_cn_east_3", + 6: "hw_cn_southwest_2", + 7: "hw_ap_southeast_1", + 8: "hw_ap_southeast_2", + 9: "hw_ap_southeast_3", + 10: "hw_af_south_1", + } + HuaweiRegionId_value = map[string]int32{ + "hw_all": 0, + "hw_cn_north_1": 1, + "hw_cn_north_4": 2, + "hw_cn_south_1": 3, + "hw_cn_east_2": 4, + "hw_cn_east_3": 5, + "hw_cn_southwest_2": 6, + "hw_ap_southeast_1": 7, + "hw_ap_southeast_2": 8, + "hw_ap_southeast_3": 9, + "hw_af_south_1": 10, + } +) + +func (x HuaweiRegionId) Enum() *HuaweiRegionId { + p := new(HuaweiRegionId) + *p = x + return p +} + +func (x HuaweiRegionId) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (HuaweiRegionId) Descriptor() protoreflect.EnumDescriptor { + return file_idl_pbtenant_tenant_proto_enumTypes[4].Descriptor() +} + +func (HuaweiRegionId) Type() protoreflect.EnumType { + return &file_idl_pbtenant_tenant_proto_enumTypes[4] +} + +func (x HuaweiRegionId) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use HuaweiRegionId.Descriptor instead. +func (HuaweiRegionId) EnumDescriptor() ([]byte, []int) { + return file_idl_pbtenant_tenant_proto_rawDescGZIP(), []int{4} +} + +// 亚马逊云区域,需要将对应的 _ 转化为 - +type AwsRegionId int32 + +const ( + AwsRegionId_aws_all AwsRegionId = 0 + AwsRegionId_aws_us_east_2 AwsRegionId = 1 // US East (Ohio) + AwsRegionId_aws_us_east_1 AwsRegionId = 2 // US East (N. Virginia) + AwsRegionId_aws_us_west_1 AwsRegionId = 3 // US West (N. California) + AwsRegionId_aws_us_west_2 AwsRegionId = 4 // US West (Oregon) + AwsRegionId_aws_af_south_1 AwsRegionId = 5 // Africa (Cape Town) + AwsRegionId_aws_ap_east_1 AwsRegionId = 6 // Asia Pacific (Hong Kong) + AwsRegionId_aws_ap_south_1 AwsRegionId = 7 // Asia Pacific (Mumbai) + AwsRegionId_aws_ap_northeast_3 AwsRegionId = 8 // Asia Pacific (Osaka) + AwsRegionId_aws_ap_northeast_2 AwsRegionId = 9 // Asia Pacific (Seoul) + AwsRegionId_aws_ap_northeast_1 AwsRegionId = 10 // Asia Pacific (Singapore) + AwsRegionId_aws_ap_southeast_2 AwsRegionId = 11 // Asia Pacific (Sydney) + AwsRegionId_aws_ap_southeast_1 AwsRegionId = 12 // Asia Pacific (Tokyo) + AwsRegionId_aws_ca_central_1 AwsRegionId = 13 // Canada (Central) + AwsRegionId_aws_eu_central_1 AwsRegionId = 14 // Europe (Frankfurt) + AwsRegionId_aws_eu_west_1 AwsRegionId = 15 // Europe (Ireland) + AwsRegionId_aws_eu_west_2 AwsRegionId = 16 // Europe (London) + AwsRegionId_aws_eu_south_1 AwsRegionId = 17 // Europe (Milan) + AwsRegionId_aws_eu_west_3 AwsRegionId = 18 // Europe (Paris) + AwsRegionId_aws_eu_north_1 AwsRegionId = 19 // Europe (Stockholm) + AwsRegionId_aws_me_south_1 AwsRegionId = 20 // Middle East (Bahrain) + AwsRegionId_aws_sa_east_1 AwsRegionId = 21 // South America (São Paulo) +) + +// Enum value maps for AwsRegionId. +var ( + AwsRegionId_name = map[int32]string{ + 0: "aws_all", + 1: "aws_us_east_2", + 2: "aws_us_east_1", + 3: "aws_us_west_1", + 4: "aws_us_west_2", + 5: "aws_af_south_1", + 6: "aws_ap_east_1", + 7: "aws_ap_south_1", + 8: "aws_ap_northeast_3", + 9: "aws_ap_northeast_2", + 10: "aws_ap_northeast_1", + 11: "aws_ap_southeast_2", + 12: "aws_ap_southeast_1", + 13: "aws_ca_central_1", + 14: "aws_eu_central_1", + 15: "aws_eu_west_1", + 16: "aws_eu_west_2", + 17: "aws_eu_south_1", + 18: "aws_eu_west_3", + 19: "aws_eu_north_1", + 20: "aws_me_south_1", + 21: "aws_sa_east_1", + } + AwsRegionId_value = map[string]int32{ + "aws_all": 0, + "aws_us_east_2": 1, + "aws_us_east_1": 2, + "aws_us_west_1": 3, + "aws_us_west_2": 4, + "aws_af_south_1": 5, + "aws_ap_east_1": 6, + "aws_ap_south_1": 7, + "aws_ap_northeast_3": 8, + "aws_ap_northeast_2": 9, + "aws_ap_northeast_1": 10, + "aws_ap_southeast_2": 11, + "aws_ap_southeast_1": 12, + "aws_ca_central_1": 13, + "aws_eu_central_1": 14, + "aws_eu_west_1": 15, + "aws_eu_west_2": 16, + "aws_eu_south_1": 17, + "aws_eu_west_3": 18, + "aws_eu_north_1": 19, + "aws_me_south_1": 20, + "aws_sa_east_1": 21, + } +) + +func (x AwsRegionId) Enum() *AwsRegionId { + p := new(AwsRegionId) + *p = x + return p +} + +func (x AwsRegionId) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (AwsRegionId) Descriptor() protoreflect.EnumDescriptor { + return file_idl_pbtenant_tenant_proto_enumTypes[5].Descriptor() +} + +func (AwsRegionId) Type() protoreflect.EnumType { + return &file_idl_pbtenant_tenant_proto_enumTypes[5] +} + +func (x AwsRegionId) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use AwsRegionId.Descriptor instead. +func (AwsRegionId) EnumDescriptor() ([]byte, []int) { + return file_idl_pbtenant_tenant_proto_rawDescGZIP(), []int{5} +} + +// 云配置信息 +type CloudConfigs struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // 云配置 + Configs []*CloudConfig `protobuf:"bytes,1,rep,name=configs,proto3" json:"configs,omitempty"` +} + +func (x *CloudConfigs) Reset() { + *x = CloudConfigs{} + if protoimpl.UnsafeEnabled { + mi := &file_idl_pbtenant_tenant_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CloudConfigs) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CloudConfigs) ProtoMessage() {} + +func (x *CloudConfigs) ProtoReflect() protoreflect.Message { + mi := &file_idl_pbtenant_tenant_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 CloudConfigs.ProtoReflect.Descriptor instead. +func (*CloudConfigs) Descriptor() ([]byte, []int) { + return file_idl_pbtenant_tenant_proto_rawDescGZIP(), []int{0} +} + +func (x *CloudConfigs) GetConfigs() []*CloudConfig { + if x != nil { + return x.Configs + } + return nil +} + +type CloudConfig struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // 云服务提供商,具体参考 CloudProvider 的定义 + Provider CloudProvider `protobuf:"varint,1,opt,name=provider,proto3,enum=pbtenant.CloudProvider" json:"provider,omitempty"` + // 账户名称,由用户自定义,必须全局唯一,方便多个系统之间的维护 + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + // 认证方式1:与 access_secret 结合使用,两者均非空时生效 + AccessId string `protobuf:"bytes,3,opt,name=access_id,json=accessId,proto3" json:"access_id,omitempty"` + // 认证方式1:与 access_id 结合使用,两者均非空时生效 + AccessSecret string `protobuf:"bytes,4,opt,name=access_secret,json=accessSecret,proto3" json:"access_secret,omitempty"` +} + +func (x *CloudConfig) Reset() { + *x = CloudConfig{} + if protoimpl.UnsafeEnabled { + mi := &file_idl_pbtenant_tenant_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CloudConfig) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CloudConfig) ProtoMessage() {} + +func (x *CloudConfig) ProtoReflect() protoreflect.Message { + mi := &file_idl_pbtenant_tenant_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 CloudConfig.ProtoReflect.Descriptor instead. +func (*CloudConfig) Descriptor() ([]byte, []int) { + return file_idl_pbtenant_tenant_proto_rawDescGZIP(), []int{1} +} + +func (x *CloudConfig) GetProvider() CloudProvider { + if x != nil { + return x.Provider + } + return CloudProvider_ali +} + +func (x *CloudConfig) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *CloudConfig) GetAccessId() string { + if x != nil { + return x.AccessId + } + return "" +} + +func (x *CloudConfig) GetAccessSecret() string { + if x != nil { + return x.AccessSecret + } + return "" +} + +var File_idl_pbtenant_tenant_proto protoreflect.FileDescriptor + +var file_idl_pbtenant_tenant_proto_rawDesc = []byte{ + 0x0a, 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, 0x12, 0x08, 0x70, 0x62, 0x74, + 0x65, 0x6e, 0x61, 0x6e, 0x74, 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, 0x1a, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x2d, 0x67, 0x65, 0x6e, 0x2d, + 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, + 0x73, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x22, 0x3f, 0x0a, 0x0c, 0x43, 0x6c, 0x6f, 0x75, 0x64, 0x43, 0x6f, 0x6e, 0x66, + 0x69, 0x67, 0x73, 0x12, 0x2f, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x18, 0x01, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x70, 0x62, 0x74, 0x65, 0x6e, 0x61, 0x6e, 0x74, 0x2e, + 0x43, 0x6c, 0x6f, 0x75, 0x64, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x07, 0x63, 0x6f, 0x6e, + 0x66, 0x69, 0x67, 0x73, 0x22, 0x98, 0x01, 0x0a, 0x0b, 0x43, 0x6c, 0x6f, 0x75, 0x64, 0x43, 0x6f, + 0x6e, 0x66, 0x69, 0x67, 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, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, + 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1b, 0x0a, + 0x09, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x08, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x49, 0x64, 0x12, 0x23, 0x0a, 0x0d, 0x61, 0x63, + 0x63, 0x65, 0x73, 0x73, 0x5f, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0c, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x53, 0x65, 0x63, 0x72, 0x65, 0x74, 0x2a, + 0x3a, 0x0a, 0x0d, 0x43, 0x6c, 0x6f, 0x75, 0x64, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, + 0x12, 0x07, 0x0a, 0x03, 0x61, 0x6c, 0x69, 0x10, 0x00, 0x12, 0x0b, 0x0a, 0x07, 0x74, 0x65, 0x6e, + 0x63, 0x65, 0x6e, 0x74, 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, 0x68, 0x75, 0x61, 0x77, 0x65, 0x69, + 0x10, 0x02, 0x12, 0x07, 0x0a, 0x03, 0x61, 0x77, 0x73, 0x10, 0x03, 0x2a, 0x66, 0x0a, 0x0c, 0x43, + 0x6c, 0x6f, 0x75, 0x64, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x12, 0x0f, 0x0a, 0x0b, 0x70, + 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x5f, 0x61, 0x6c, 0x6c, 0x10, 0x00, 0x12, 0x0f, 0x0a, 0x0b, + 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x5f, 0x65, 0x63, 0x73, 0x10, 0x01, 0x12, 0x0f, 0x0a, + 0x0b, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x5f, 0x72, 0x64, 0x73, 0x10, 0x02, 0x12, 0x12, + 0x0a, 0x0e, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x5f, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, + 0x10, 0x03, 0x12, 0x0f, 0x0a, 0x0b, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x5f, 0x6f, 0x73, + 0x73, 0x10, 0x04, 0x2a, 0x86, 0x04, 0x0a, 0x0b, 0x41, 0x6c, 0x69, 0x52, 0x65, 0x67, 0x69, 0x6f, + 0x6e, 0x49, 0x64, 0x12, 0x0b, 0x0a, 0x07, 0x61, 0x6c, 0x69, 0x5f, 0x61, 0x6c, 0x6c, 0x10, 0x00, + 0x12, 0x12, 0x0a, 0x0e, 0x61, 0x6c, 0x69, 0x5f, 0x63, 0x6e, 0x5f, 0x71, 0x69, 0x6e, 0x67, 0x64, + 0x61, 0x6f, 0x10, 0x01, 0x12, 0x12, 0x0a, 0x0e, 0x61, 0x6c, 0x69, 0x5f, 0x63, 0x6e, 0x5f, 0x62, + 0x65, 0x69, 0x6a, 0x69, 0x6e, 0x67, 0x10, 0x02, 0x12, 0x16, 0x0a, 0x12, 0x61, 0x6c, 0x69, 0x5f, + 0x63, 0x6e, 0x5f, 0x7a, 0x68, 0x61, 0x6e, 0x67, 0x6a, 0x69, 0x61, 0x6b, 0x6f, 0x75, 0x10, 0x03, + 0x12, 0x14, 0x0a, 0x10, 0x61, 0x6c, 0x69, 0x5f, 0x63, 0x6e, 0x5f, 0x68, 0x75, 0x68, 0x65, 0x68, + 0x61, 0x6f, 0x74, 0x65, 0x10, 0x04, 0x12, 0x15, 0x0a, 0x11, 0x61, 0x6c, 0x69, 0x5f, 0x63, 0x6e, + 0x5f, 0x77, 0x75, 0x6c, 0x61, 0x6e, 0x63, 0x68, 0x61, 0x62, 0x75, 0x10, 0x05, 0x12, 0x13, 0x0a, + 0x0f, 0x61, 0x6c, 0x69, 0x5f, 0x63, 0x6e, 0x5f, 0x68, 0x61, 0x6e, 0x67, 0x7a, 0x68, 0x6f, 0x75, + 0x10, 0x06, 0x12, 0x13, 0x0a, 0x0f, 0x61, 0x6c, 0x69, 0x5f, 0x63, 0x6e, 0x5f, 0x73, 0x68, 0x61, + 0x6e, 0x67, 0x68, 0x61, 0x69, 0x10, 0x07, 0x12, 0x13, 0x0a, 0x0f, 0x61, 0x6c, 0x69, 0x5f, 0x63, + 0x6e, 0x5f, 0x73, 0x68, 0x65, 0x6e, 0x7a, 0x68, 0x65, 0x6e, 0x10, 0x08, 0x12, 0x11, 0x0a, 0x0d, + 0x61, 0x6c, 0x69, 0x5f, 0x63, 0x6e, 0x5f, 0x68, 0x65, 0x79, 0x75, 0x61, 0x6e, 0x10, 0x09, 0x12, + 0x14, 0x0a, 0x10, 0x61, 0x6c, 0x69, 0x5f, 0x63, 0x6e, 0x5f, 0x67, 0x75, 0x61, 0x6e, 0x67, 0x7a, + 0x68, 0x6f, 0x75, 0x10, 0x0a, 0x12, 0x12, 0x0a, 0x0e, 0x61, 0x6c, 0x69, 0x5f, 0x63, 0x6e, 0x5f, + 0x63, 0x68, 0x65, 0x6e, 0x67, 0x64, 0x75, 0x10, 0x0b, 0x12, 0x13, 0x0a, 0x0f, 0x61, 0x6c, 0x69, + 0x5f, 0x63, 0x6e, 0x5f, 0x68, 0x6f, 0x6e, 0x67, 0x6b, 0x6f, 0x6e, 0x67, 0x10, 0x0c, 0x12, 0x16, + 0x0a, 0x12, 0x61, 0x6c, 0x69, 0x5f, 0x61, 0x70, 0x5f, 0x73, 0x6f, 0x75, 0x74, 0x68, 0x65, 0x61, + 0x73, 0x74, 0x5f, 0x31, 0x10, 0x0d, 0x12, 0x16, 0x0a, 0x12, 0x61, 0x6c, 0x69, 0x5f, 0x61, 0x70, + 0x5f, 0x73, 0x6f, 0x75, 0x74, 0x68, 0x65, 0x61, 0x73, 0x74, 0x5f, 0x32, 0x10, 0x0e, 0x12, 0x16, + 0x0a, 0x12, 0x61, 0x6c, 0x69, 0x5f, 0x61, 0x70, 0x5f, 0x73, 0x6f, 0x75, 0x74, 0x68, 0x65, 0x61, + 0x73, 0x74, 0x5f, 0x33, 0x10, 0x0f, 0x12, 0x16, 0x0a, 0x12, 0x61, 0x6c, 0x69, 0x5f, 0x61, 0x70, + 0x5f, 0x73, 0x6f, 0x75, 0x74, 0x68, 0x65, 0x61, 0x73, 0x74, 0x5f, 0x35, 0x10, 0x10, 0x12, 0x12, + 0x0a, 0x0e, 0x61, 0x6c, 0x69, 0x5f, 0x61, 0x70, 0x5f, 0x73, 0x6f, 0x75, 0x74, 0x68, 0x5f, 0x31, + 0x10, 0x11, 0x12, 0x16, 0x0a, 0x12, 0x61, 0x6c, 0x69, 0x5f, 0x61, 0x70, 0x5f, 0x6e, 0x6f, 0x72, + 0x74, 0x68, 0x65, 0x61, 0x73, 0x74, 0x5f, 0x31, 0x10, 0x12, 0x12, 0x11, 0x0a, 0x0d, 0x61, 0x6c, + 0x69, 0x5f, 0x75, 0x73, 0x5f, 0x77, 0x65, 0x73, 0x74, 0x5f, 0x31, 0x10, 0x13, 0x12, 0x11, 0x0a, + 0x0d, 0x61, 0x6c, 0x69, 0x5f, 0x75, 0x73, 0x5f, 0x65, 0x61, 0x73, 0x74, 0x5f, 0x31, 0x10, 0x14, + 0x12, 0x14, 0x0a, 0x10, 0x61, 0x6c, 0x69, 0x5f, 0x65, 0x75, 0x5f, 0x63, 0x65, 0x6e, 0x74, 0x72, + 0x61, 0x6c, 0x5f, 0x31, 0x10, 0x15, 0x12, 0x11, 0x0a, 0x0d, 0x61, 0x6c, 0x69, 0x5f, 0x65, 0x75, + 0x5f, 0x77, 0x65, 0x73, 0x74, 0x5f, 0x31, 0x10, 0x16, 0x12, 0x11, 0x0a, 0x0d, 0x61, 0x6c, 0x69, + 0x5f, 0x6d, 0x65, 0x5f, 0x65, 0x61, 0x73, 0x74, 0x5f, 0x31, 0x10, 0x17, 0x2a, 0xa1, 0x03, 0x0a, + 0x0f, 0x54, 0x65, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x67, 0x69, 0x6f, 0x6e, 0x49, 0x64, + 0x12, 0x0a, 0x0a, 0x06, 0x74, 0x63, 0x5f, 0x61, 0x6c, 0x6c, 0x10, 0x00, 0x12, 0x11, 0x0a, 0x0d, + 0x74, 0x63, 0x5f, 0x61, 0x70, 0x5f, 0x62, 0x61, 0x6e, 0x67, 0x6b, 0x6f, 0x6b, 0x10, 0x01, 0x12, + 0x11, 0x0a, 0x0d, 0x74, 0x63, 0x5f, 0x61, 0x70, 0x5f, 0x62, 0x65, 0x69, 0x6a, 0x69, 0x6e, 0x67, + 0x10, 0x02, 0x12, 0x11, 0x0a, 0x0d, 0x74, 0x63, 0x5f, 0x61, 0x70, 0x5f, 0x63, 0x68, 0x65, 0x6e, + 0x67, 0x64, 0x75, 0x10, 0x03, 0x12, 0x13, 0x0a, 0x0f, 0x74, 0x63, 0x5f, 0x61, 0x70, 0x5f, 0x63, + 0x68, 0x6f, 0x6e, 0x67, 0x71, 0x69, 0x6e, 0x67, 0x10, 0x04, 0x12, 0x13, 0x0a, 0x0f, 0x74, 0x63, + 0x5f, 0x61, 0x70, 0x5f, 0x67, 0x75, 0x61, 0x6e, 0x67, 0x7a, 0x68, 0x6f, 0x75, 0x10, 0x05, 0x12, + 0x18, 0x0a, 0x14, 0x74, 0x63, 0x5f, 0x61, 0x70, 0x5f, 0x67, 0x75, 0x61, 0x6e, 0x67, 0x7a, 0x68, + 0x6f, 0x75, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x10, 0x06, 0x12, 0x12, 0x0a, 0x0e, 0x74, 0x63, 0x5f, + 0x61, 0x70, 0x5f, 0x68, 0x6f, 0x6e, 0x67, 0x6b, 0x6f, 0x6e, 0x67, 0x10, 0x07, 0x12, 0x10, 0x0a, + 0x0c, 0x74, 0x63, 0x5f, 0x61, 0x70, 0x5f, 0x6d, 0x75, 0x6d, 0x62, 0x61, 0x69, 0x10, 0x08, 0x12, + 0x0f, 0x0a, 0x0b, 0x74, 0x63, 0x5f, 0x61, 0x70, 0x5f, 0x73, 0x65, 0x6f, 0x75, 0x6c, 0x10, 0x09, + 0x12, 0x12, 0x0a, 0x0e, 0x74, 0x63, 0x5f, 0x61, 0x70, 0x5f, 0x73, 0x68, 0x61, 0x6e, 0x67, 0x68, + 0x61, 0x69, 0x10, 0x0a, 0x12, 0x16, 0x0a, 0x12, 0x74, 0x63, 0x5f, 0x61, 0x70, 0x5f, 0x73, 0x68, + 0x61, 0x6e, 0x67, 0x68, 0x61, 0x69, 0x5f, 0x66, 0x73, 0x69, 0x10, 0x0b, 0x12, 0x16, 0x0a, 0x12, + 0x74, 0x63, 0x5f, 0x61, 0x70, 0x5f, 0x73, 0x68, 0x65, 0x6e, 0x7a, 0x68, 0x65, 0x6e, 0x5f, 0x66, + 0x73, 0x69, 0x10, 0x0c, 0x12, 0x13, 0x0a, 0x0f, 0x74, 0x63, 0x5f, 0x61, 0x70, 0x5f, 0x73, 0x69, + 0x6e, 0x67, 0x61, 0x70, 0x6f, 0x72, 0x65, 0x10, 0x0d, 0x12, 0x0f, 0x0a, 0x0b, 0x74, 0x63, 0x5f, + 0x61, 0x70, 0x5f, 0x74, 0x6f, 0x6b, 0x79, 0x6f, 0x10, 0x0e, 0x12, 0x13, 0x0a, 0x0f, 0x74, 0x63, + 0x5f, 0x65, 0x75, 0x5f, 0x66, 0x72, 0x61, 0x6e, 0x6b, 0x66, 0x75, 0x72, 0x74, 0x10, 0x0f, 0x12, + 0x10, 0x0a, 0x0c, 0x74, 0x63, 0x5f, 0x65, 0x75, 0x5f, 0x6d, 0x6f, 0x73, 0x63, 0x6f, 0x77, 0x10, + 0x10, 0x12, 0x11, 0x0a, 0x0d, 0x74, 0x63, 0x5f, 0x6e, 0x61, 0x5f, 0x61, 0x73, 0x68, 0x62, 0x75, + 0x72, 0x6e, 0x10, 0x11, 0x12, 0x17, 0x0a, 0x13, 0x74, 0x63, 0x5f, 0x6e, 0x61, 0x5f, 0x73, 0x69, + 0x6c, 0x69, 0x63, 0x6f, 0x6e, 0x76, 0x61, 0x6c, 0x6c, 0x65, 0x79, 0x10, 0x12, 0x12, 0x11, 0x0a, + 0x0d, 0x74, 0x63, 0x5f, 0x6e, 0x61, 0x5f, 0x74, 0x6f, 0x72, 0x6f, 0x6e, 0x74, 0x6f, 0x10, 0x13, + 0x2a, 0xe8, 0x01, 0x0a, 0x0e, 0x48, 0x75, 0x61, 0x77, 0x65, 0x69, 0x52, 0x65, 0x67, 0x69, 0x6f, + 0x6e, 0x49, 0x64, 0x12, 0x0a, 0x0a, 0x06, 0x68, 0x77, 0x5f, 0x61, 0x6c, 0x6c, 0x10, 0x00, 0x12, + 0x11, 0x0a, 0x0d, 0x68, 0x77, 0x5f, 0x63, 0x6e, 0x5f, 0x6e, 0x6f, 0x72, 0x74, 0x68, 0x5f, 0x31, + 0x10, 0x01, 0x12, 0x11, 0x0a, 0x0d, 0x68, 0x77, 0x5f, 0x63, 0x6e, 0x5f, 0x6e, 0x6f, 0x72, 0x74, + 0x68, 0x5f, 0x34, 0x10, 0x02, 0x12, 0x11, 0x0a, 0x0d, 0x68, 0x77, 0x5f, 0x63, 0x6e, 0x5f, 0x73, + 0x6f, 0x75, 0x74, 0x68, 0x5f, 0x31, 0x10, 0x03, 0x12, 0x10, 0x0a, 0x0c, 0x68, 0x77, 0x5f, 0x63, + 0x6e, 0x5f, 0x65, 0x61, 0x73, 0x74, 0x5f, 0x32, 0x10, 0x04, 0x12, 0x10, 0x0a, 0x0c, 0x68, 0x77, + 0x5f, 0x63, 0x6e, 0x5f, 0x65, 0x61, 0x73, 0x74, 0x5f, 0x33, 0x10, 0x05, 0x12, 0x15, 0x0a, 0x11, + 0x68, 0x77, 0x5f, 0x63, 0x6e, 0x5f, 0x73, 0x6f, 0x75, 0x74, 0x68, 0x77, 0x65, 0x73, 0x74, 0x5f, + 0x32, 0x10, 0x06, 0x12, 0x15, 0x0a, 0x11, 0x68, 0x77, 0x5f, 0x61, 0x70, 0x5f, 0x73, 0x6f, 0x75, + 0x74, 0x68, 0x65, 0x61, 0x73, 0x74, 0x5f, 0x31, 0x10, 0x07, 0x12, 0x15, 0x0a, 0x11, 0x68, 0x77, + 0x5f, 0x61, 0x70, 0x5f, 0x73, 0x6f, 0x75, 0x74, 0x68, 0x65, 0x61, 0x73, 0x74, 0x5f, 0x32, 0x10, + 0x08, 0x12, 0x15, 0x0a, 0x11, 0x68, 0x77, 0x5f, 0x61, 0x70, 0x5f, 0x73, 0x6f, 0x75, 0x74, 0x68, + 0x65, 0x61, 0x73, 0x74, 0x5f, 0x33, 0x10, 0x09, 0x12, 0x11, 0x0a, 0x0d, 0x68, 0x77, 0x5f, 0x61, + 0x66, 0x5f, 0x73, 0x6f, 0x75, 0x74, 0x68, 0x5f, 0x31, 0x10, 0x0a, 0x2a, 0xcd, 0x03, 0x0a, 0x0b, + 0x41, 0x77, 0x73, 0x52, 0x65, 0x67, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x0b, 0x0a, 0x07, 0x61, + 0x77, 0x73, 0x5f, 0x61, 0x6c, 0x6c, 0x10, 0x00, 0x12, 0x11, 0x0a, 0x0d, 0x61, 0x77, 0x73, 0x5f, + 0x75, 0x73, 0x5f, 0x65, 0x61, 0x73, 0x74, 0x5f, 0x32, 0x10, 0x01, 0x12, 0x11, 0x0a, 0x0d, 0x61, + 0x77, 0x73, 0x5f, 0x75, 0x73, 0x5f, 0x65, 0x61, 0x73, 0x74, 0x5f, 0x31, 0x10, 0x02, 0x12, 0x11, + 0x0a, 0x0d, 0x61, 0x77, 0x73, 0x5f, 0x75, 0x73, 0x5f, 0x77, 0x65, 0x73, 0x74, 0x5f, 0x31, 0x10, + 0x03, 0x12, 0x11, 0x0a, 0x0d, 0x61, 0x77, 0x73, 0x5f, 0x75, 0x73, 0x5f, 0x77, 0x65, 0x73, 0x74, + 0x5f, 0x32, 0x10, 0x04, 0x12, 0x12, 0x0a, 0x0e, 0x61, 0x77, 0x73, 0x5f, 0x61, 0x66, 0x5f, 0x73, + 0x6f, 0x75, 0x74, 0x68, 0x5f, 0x31, 0x10, 0x05, 0x12, 0x11, 0x0a, 0x0d, 0x61, 0x77, 0x73, 0x5f, + 0x61, 0x70, 0x5f, 0x65, 0x61, 0x73, 0x74, 0x5f, 0x31, 0x10, 0x06, 0x12, 0x12, 0x0a, 0x0e, 0x61, + 0x77, 0x73, 0x5f, 0x61, 0x70, 0x5f, 0x73, 0x6f, 0x75, 0x74, 0x68, 0x5f, 0x31, 0x10, 0x07, 0x12, + 0x16, 0x0a, 0x12, 0x61, 0x77, 0x73, 0x5f, 0x61, 0x70, 0x5f, 0x6e, 0x6f, 0x72, 0x74, 0x68, 0x65, + 0x61, 0x73, 0x74, 0x5f, 0x33, 0x10, 0x08, 0x12, 0x16, 0x0a, 0x12, 0x61, 0x77, 0x73, 0x5f, 0x61, + 0x70, 0x5f, 0x6e, 0x6f, 0x72, 0x74, 0x68, 0x65, 0x61, 0x73, 0x74, 0x5f, 0x32, 0x10, 0x09, 0x12, + 0x16, 0x0a, 0x12, 0x61, 0x77, 0x73, 0x5f, 0x61, 0x70, 0x5f, 0x6e, 0x6f, 0x72, 0x74, 0x68, 0x65, + 0x61, 0x73, 0x74, 0x5f, 0x31, 0x10, 0x0a, 0x12, 0x16, 0x0a, 0x12, 0x61, 0x77, 0x73, 0x5f, 0x61, + 0x70, 0x5f, 0x73, 0x6f, 0x75, 0x74, 0x68, 0x65, 0x61, 0x73, 0x74, 0x5f, 0x32, 0x10, 0x0b, 0x12, + 0x16, 0x0a, 0x12, 0x61, 0x77, 0x73, 0x5f, 0x61, 0x70, 0x5f, 0x73, 0x6f, 0x75, 0x74, 0x68, 0x65, + 0x61, 0x73, 0x74, 0x5f, 0x31, 0x10, 0x0c, 0x12, 0x14, 0x0a, 0x10, 0x61, 0x77, 0x73, 0x5f, 0x63, + 0x61, 0x5f, 0x63, 0x65, 0x6e, 0x74, 0x72, 0x61, 0x6c, 0x5f, 0x31, 0x10, 0x0d, 0x12, 0x14, 0x0a, + 0x10, 0x61, 0x77, 0x73, 0x5f, 0x65, 0x75, 0x5f, 0x63, 0x65, 0x6e, 0x74, 0x72, 0x61, 0x6c, 0x5f, + 0x31, 0x10, 0x0e, 0x12, 0x11, 0x0a, 0x0d, 0x61, 0x77, 0x73, 0x5f, 0x65, 0x75, 0x5f, 0x77, 0x65, + 0x73, 0x74, 0x5f, 0x31, 0x10, 0x0f, 0x12, 0x11, 0x0a, 0x0d, 0x61, 0x77, 0x73, 0x5f, 0x65, 0x75, + 0x5f, 0x77, 0x65, 0x73, 0x74, 0x5f, 0x32, 0x10, 0x10, 0x12, 0x12, 0x0a, 0x0e, 0x61, 0x77, 0x73, + 0x5f, 0x65, 0x75, 0x5f, 0x73, 0x6f, 0x75, 0x74, 0x68, 0x5f, 0x31, 0x10, 0x11, 0x12, 0x11, 0x0a, + 0x0d, 0x61, 0x77, 0x73, 0x5f, 0x65, 0x75, 0x5f, 0x77, 0x65, 0x73, 0x74, 0x5f, 0x33, 0x10, 0x12, + 0x12, 0x12, 0x0a, 0x0e, 0x61, 0x77, 0x73, 0x5f, 0x65, 0x75, 0x5f, 0x6e, 0x6f, 0x72, 0x74, 0x68, + 0x5f, 0x31, 0x10, 0x13, 0x12, 0x12, 0x0a, 0x0e, 0x61, 0x77, 0x73, 0x5f, 0x6d, 0x65, 0x5f, 0x73, + 0x6f, 0x75, 0x74, 0x68, 0x5f, 0x31, 0x10, 0x14, 0x12, 0x11, 0x0a, 0x0d, 0x61, 0x77, 0x73, 0x5f, + 0x73, 0x61, 0x5f, 0x65, 0x61, 0x73, 0x74, 0x5f, 0x31, 0x10, 0x15, 0x32, 0x78, 0x0a, 0x0d, 0x54, + 0x65, 0x6e, 0x61, 0x6e, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x1a, 0x67, 0x92, 0x41, + 0x64, 0x12, 0x1e, 0xe6, 0x89, 0x80, 0xe6, 0x9c, 0x89, 0xe4, 0xba, 0x91, 0xe7, 0xa7, 0x9f, 0xe6, + 0x88, 0xb7, 0xe7, 0x9a, 0x84, 0xe8, 0xae, 0xa4, 0xe8, 0xaf, 0x81, 0xe6, 0x9c, 0x8d, 0xe5, 0x8a, + 0xa1, 0x1a, 0x42, 0x0a, 0x1f, 0x46, 0x69, 0x6e, 0x64, 0x20, 0x6f, 0x75, 0x74, 0x20, 0x6d, 0x6f, + 0x72, 0x65, 0x20, 0x61, 0x62, 0x6f, 0x75, 0x74, 0x20, 0x43, 0x6c, 0x6f, 0x75, 0x64, 0x46, 0x69, + 0x74, 0x74, 0x65, 0x72, 0x12, 0x1f, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x67, 0x69, + 0x74, 0x6c, 0x69, 0x6e, 0x6b, 0x2e, 0x6f, 0x72, 0x67, 0x2e, 0x63, 0x6e, 0x2f, 0x4a, 0x43, 0x43, + 0x45, 0x2f, 0x50, 0x43, 0x4d, 0x42, 0x30, 0x5a, 0x2e, 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, 0x74, 0x65, 0x6e, 0x61, 0x6e, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_idl_pbtenant_tenant_proto_rawDescOnce sync.Once + file_idl_pbtenant_tenant_proto_rawDescData = file_idl_pbtenant_tenant_proto_rawDesc +) + +func file_idl_pbtenant_tenant_proto_rawDescGZIP() []byte { + file_idl_pbtenant_tenant_proto_rawDescOnce.Do(func() { + file_idl_pbtenant_tenant_proto_rawDescData = protoimpl.X.CompressGZIP(file_idl_pbtenant_tenant_proto_rawDescData) + }) + return file_idl_pbtenant_tenant_proto_rawDescData +} + +var file_idl_pbtenant_tenant_proto_enumTypes = make([]protoimpl.EnumInfo, 6) +var file_idl_pbtenant_tenant_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_idl_pbtenant_tenant_proto_goTypes = []interface{}{ + (CloudProvider)(0), // 0: pbtenant.CloudProvider + (CloudProduct)(0), // 1: pbtenant.CloudProduct + (AliRegionId)(0), // 2: pbtenant.AliRegionId + (TencentRegionId)(0), // 3: pbtenant.TencentRegionId + (HuaweiRegionId)(0), // 4: pbtenant.HuaweiRegionId + (AwsRegionId)(0), // 5: pbtenant.AwsRegionId + (*CloudConfigs)(nil), // 6: pbtenant.CloudConfigs + (*CloudConfig)(nil), // 7: pbtenant.CloudConfig +} +var file_idl_pbtenant_tenant_proto_depIdxs = []int32{ + 7, // 0: pbtenant.CloudConfigs.configs:type_name -> pbtenant.CloudConfig + 0, // 1: pbtenant.CloudConfig.provider:type_name -> pbtenant.CloudProvider + 2, // [2:2] is the sub-list for method output_type + 2, // [2:2] is the sub-list for method input_type + 2, // [2:2] is the sub-list for extension type_name + 2, // [2:2] is the sub-list for extension extendee + 0, // [0:2] is the sub-list for field type_name +} + +func init() { file_idl_pbtenant_tenant_proto_init() } +func file_idl_pbtenant_tenant_proto_init() { + if File_idl_pbtenant_tenant_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_idl_pbtenant_tenant_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CloudConfigs); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_idl_pbtenant_tenant_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CloudConfig); 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_pbtenant_tenant_proto_rawDesc, + NumEnums: 6, + NumMessages: 2, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_idl_pbtenant_tenant_proto_goTypes, + DependencyIndexes: file_idl_pbtenant_tenant_proto_depIdxs, + EnumInfos: file_idl_pbtenant_tenant_proto_enumTypes, + MessageInfos: file_idl_pbtenant_tenant_proto_msgTypes, + }.Build() + File_idl_pbtenant_tenant_proto = out.File + file_idl_pbtenant_tenant_proto_rawDesc = nil + file_idl_pbtenant_tenant_proto_goTypes = nil + file_idl_pbtenant_tenant_proto_depIdxs = nil +} diff --git a/lan_trans/idl/pbtenant/tenant_grpc.pb.go b/lan_trans/idl/pbtenant/tenant_grpc.pb.go new file mode 100644 index 0000000..1fd0710 --- /dev/null +++ b/lan_trans/idl/pbtenant/tenant_grpc.pb.go @@ -0,0 +1,65 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.2.0 +// - protoc (unknown) +// source: idl/pbtenant/tenant.proto + +package pbtenant + +import ( + grpc "google.golang.org/grpc" +) + +// 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 + +// TenantServiceClient is the client API for TenantService 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 TenantServiceClient interface { +} + +type tenantServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewTenantServiceClient(cc grpc.ClientConnInterface) TenantServiceClient { + return &tenantServiceClient{cc} +} + +// TenantServiceServer is the server API for TenantService service. +// All implementations must embed UnimplementedTenantServiceServer +// for forward compatibility +type TenantServiceServer interface { + mustEmbedUnimplementedTenantServiceServer() +} + +// UnimplementedTenantServiceServer must be embedded to have forward compatible implementations. +type UnimplementedTenantServiceServer struct { +} + +func (UnimplementedTenantServiceServer) mustEmbedUnimplementedTenantServiceServer() {} + +// UnsafeTenantServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to TenantServiceServer will +// result in compilation errors. +type UnsafeTenantServiceServer interface { + mustEmbedUnimplementedTenantServiceServer() +} + +func RegisterTenantServiceServer(s grpc.ServiceRegistrar, srv TenantServiceServer) { + s.RegisterService(&TenantService_ServiceDesc, srv) +} + +// TenantService_ServiceDesc is the grpc.ServiceDesc for TenantService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var TenantService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "pbtenant.TenantService", + HandlerType: (*TenantServiceServer)(nil), + Methods: []grpc.MethodDesc{}, + Streams: []grpc.StreamDesc{}, + Metadata: "idl/pbtenant/tenant.proto", +} diff --git a/lan_trans/swagger.json b/lan_trans/swagger.json new file mode 100644 index 0000000..8d6af87 --- /dev/null +++ b/lan_trans/swagger.json @@ -0,0 +1,384 @@ +{ + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "swagger": "2.0", + "info": { + "title": "idl/demo/demo.proto", + "version": "version not set" + }, + "paths": { + "/apis/demo": { + "post": { + "security": [], + "tags": [ + "DemoService" + ], + "summary": "Echo 样例接口", + "externalDocs": { + "description": "Find out more about the interface", + "url": "https://github.com/grpc-ecosystem/grpc-gateway" + }, + "operationId": "DemoService_Echo", + "deprecated": true, + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/demoStringMessage" + } + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/demoStringMessage" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + } + } + }, + "/apis/ecs": { + "post": { + "tags": [ + "EcsService" + ], + "summary": "查询ECS全量 - 根据云类型", + "operationId": "EcsService_ListEcs", + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/pbecsListReq" + } + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/pbecsListResp" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + } + } + }, + "/apis/ecs/all": { + "post": { + "tags": [ + "EcsService" + ], + "summary": "查询所有云的ECS", + "operationId": "EcsService_ListEcsAll", + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/pbecsListAllReq" + } + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/pbecsListResp" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + } + } + }, + "/apis/ecs/detail": { + "post": { + "tags": [ + "EcsService" + ], + "summary": "查询ECS明细 - 支持云类型、区域、账户、分页等过滤条件", + "operationId": "EcsService_ListEcsDetail", + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/pbecsListDetailReq" + } + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/pbecsListDetailResp" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + } + } + } + }, + "definitions": { + "demoStringMessage": { + "type": "object", + "properties": { + "value": { + "type": "string" + } + } + }, + "pbecsEcsInstance": { + "type": "object", + "properties": { + "accountName": { + "type": "string", + "title": "账号名称" + }, + "chargeType": { + "type": "string", + "title": "收费类型" + }, + "cpu": { + "type": "integer", + "format": "int32", + "title": "vcpu数" + }, + "creationTime": { + "type": "string", + "title": "创建时间,ISO8601" + }, + "description": { + "type": "string", + "title": "实例描述" + }, + "expireTime": { + "type": "string", + "title": "过期时间" + }, + "innerIps": { + "type": "array", + "title": "内网ip", + "items": { + "type": "string" + } + }, + "instanceId": { + "type": "string", + "title": "实例id" + }, + "instanceName": { + "type": "string", + "title": "实例名称" + }, + "instanceType": { + "type": "string", + "title": "实例类型" + }, + "memory": { + "type": "integer", + "format": "int32", + "title": "内存MB" + }, + "provider": { + "title": "云类型", + "$ref": "#/definitions/pbtenantCloudProvider" + }, + "publicIps": { + "type": "array", + "title": "公网ip", + "items": { + "type": "string" + } + }, + "regionName": { + "type": "string", + "title": "地域,数据中心" + }, + "resourceGroupId": { + "type": "string", + "title": "资源组id" + }, + "status": { + "type": "string", + "title": "状态" + }, + "vpcId": { + "type": "string", + "title": "vcp id" + } + } + }, + "pbecsListAllReq": { + "type": "object" + }, + "pbecsListDetailReq": { + "type": "object", + "properties": { + "accountName": { + "type": "string", + "title": "账户名称,根据config.yaml中的配置,默认为第一个配置的账户" + }, + "nextToken": { + "type": "string", + "title": "分页相关参数,下一页的token" + }, + "pageNumber": { + "type": "integer", + "format": "int32", + "title": "分页相关参数,页码" + }, + "pageSize": { + "type": "integer", + "format": "int32", + "title": "分页相关参数,每页数量" + }, + "provider": { + "title": "云名称", + "$ref": "#/definitions/pbtenantCloudProvider" + }, + "regionId": { + "type": "integer", + "format": "int32", + "title": "区域Id,参考 tenant.proto 中的各个云的区域" + } + } + }, + "pbecsListDetailResp": { + "type": "object", + "properties": { + "ecses": { + "type": "array", + "title": "Ecs 机器集合", + "items": { + "$ref": "#/definitions/pbecsEcsInstance" + } + }, + "finished": { + "type": "boolean", + "title": "查询是否完成,如果为否-false,则可以将下面三个分页参数填入到请求中,继续查询" + }, + "nextToken": { + "type": "string", + "title": "分页相关参数,下一页的token" + }, + "pageNumber": { + "type": "integer", + "format": "int32", + "title": "分页相关参数,页码" + }, + "pageSize": { + "type": "integer", + "format": "int32", + "title": "分页相关参数,每页数量" + }, + "requestId": { + "type": "string", + "title": "请求id,出现问题后提供给云厂商,排查问题" + } + } + }, + "pbecsListReq": { + "type": "object", + "properties": { + "provider": { + "title": "云名称", + "$ref": "#/definitions/pbtenantCloudProvider" + } + } + }, + "pbecsListResp": { + "type": "object", + "properties": { + "ecses": { + "type": "array", + "title": "Ecs 机器集合", + "items": { + "$ref": "#/definitions/pbecsEcsInstance" + } + } + } + }, + "pbtenantCloudProvider": { + "description": "- ali: 0 - 阿里云\n - tencent: 1 - 腾讯云\n - huawei: 2 - 华为云\n - aws: 3 - 亚马逊云", + "type": "string", + "title": "云提供商", + "default": "ali", + "enum": [ + "ali", + "tencent", + "huawei", + "aws" + ] + }, + "protobufAny": { + "type": "object", + "properties": { + "typeUrl": { + "type": "string" + }, + "value": { + "type": "string", + "format": "byte" + } + } + }, + "rpcStatus": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "details": { + "type": "array", + "items": { + "$ref": "#/definitions/protobufAny" + } + }, + "message": { + "type": "string" + } + } + } + }, + "tags": [ + { + "name": "DemoService" + }, + { + "name": "EcsService" + } + ] +} \ No newline at end of file diff --git a/main.go b/main.go index 9903fbe..54b92d4 100644 --- a/main.go +++ b/main.go @@ -3,14 +3,17 @@ package main import ( "context" "flag" + "gitlink.org.cn/JCCE/PCM/common/server" + "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" + "net" + "net/http" + "github.com/golang/glog" "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" "github.com/pkg/errors" - "gitlink.org.cn/JCCE/PCM/internal/server" - "gitlink.org.cn/JCCE/PCM/lan_trans/gen/idl/demo" "google.golang.org/grpc" - "net" - "net/http" ) var ( @@ -30,6 +33,8 @@ func run() error { if err := demo.RegisterDemoServiceHandlerFromEndpoint(ctx, mux, *grpcServerEndpoint, opts); err != nil { return errors.Wrap(err, "RegisterDemoServiceHandlerFromEndpoint error") + } else if err = pbecs.RegisterEcsServiceHandlerFromEndpoint(ctx, mux, *grpcServerEndpoint, opts); err != nil { + return errors.Wrap(err, "RegisterEcsServiceHandlerFromEndpoint error") } // Start HTTP server (and proxy calls to gRPC server endpoint) @@ -42,6 +47,13 @@ func main() { flag.Parse() defer glog.Flush() + if err := tenanter.LoadCloudConfigsFromFile(configFile); err != nil { + if !errors.Is(err, tenanter.ErrLoadTenanterFileEmpty) { + glog.Fatalf("LoadCloudConfigsFromFile error %+v", err) + } + glog.Warningf("LoadCloudConfigsFromFile empty file path %s", configFile) + } + glog.Infof("load tenant from file finished") go func() { @@ -52,6 +64,7 @@ func main() { s := grpc.NewServer() demo.RegisterDemoServiceServer(s, &server.Server{}) + pbecs.RegisterEcsServiceServer(s, &server.Server{}) if err = s.Serve(lis); err != nil { glog.Fatalf("failed to serve: %v", err) diff --git a/swagger.sh b/swagger.sh index 6212fa9..2a1b44c 100755 --- a/swagger.sh +++ b/swagger.sh @@ -2,9 +2,9 @@ # 请先保证swagger的安装,可参考 https://goswagger.io/install.html -swagger mixin lan_trans/gen/openapiv2/idl/*/*.json -o lan_trans/gen/swagger.json +swagger mixin lan_trans/openapiv2/idl/*/*.json -o lan_trans/swagger.json -rm -rf lan_trans/gen/openapiv2 +rm -rf lan_trans/openapiv2 # 将机器的sshkey保存到公有云机器121.41.88.120上 #scp -P 22 gen/swagger.json root@121.41.88.120:/root/doc diff --git a/unittest.sh b/unittest.sh new file mode 100755 index 0000000..d6d05fa --- /dev/null +++ b/unittest.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +set -e +echo "" > coverage.txt + +for d in $(go list ./internal/...); do + echo $d +# 部分sdk内部有并发问题,无法通过检查 + go test -race -coverprofile=profile.out -covermode=atomic $d + if [ -f profile.out ]; then + cat profile.out >> coverage.txt + rm profile.out + fi +done \ No newline at end of file From 42e11cd2d6e5ee4d0a10020378c928034146a3cb Mon Sep 17 00:00:00 2001 From: zhouqunjie <450705171@qq.com> Date: Sat, 2 Apr 2022 16:35:43 +0800 Subject: [PATCH 5/8] refactor --- CHANGELOG | 0 Makefile | 0 configs/config.yaml | 14 ++++++++++++++ examples/main.go | 1 + go.mod | 12 ------------ main.go | 2 +- 6 files changed, 16 insertions(+), 13 deletions(-) create mode 100644 CHANGELOG create mode 100644 Makefile create mode 100644 configs/config.yaml create mode 100644 examples/main.go diff --git a/CHANGELOG b/CHANGELOG new file mode 100644 index 0000000..e69de29 diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..e69de29 diff --git a/configs/config.yaml b/configs/config.yaml new file mode 100644 index 0000000..27b43ac --- /dev/null +++ b/configs/config.yaml @@ -0,0 +1,14 @@ +configs: + # provider 0:阿里云 1:腾讯云 2:华为云 + - provider: 0 + name: "ali-PCM" + accessid: "" + accesssecret: "" + - provider: 1 + name: "tencent-PCM" + accessid: "" + accesssecret: "" + - provider: 2 + name: "huawei-PCM" + accessid: "" + accesssecret: "" diff --git a/examples/main.go b/examples/main.go new file mode 100644 index 0000000..c7842af --- /dev/null +++ b/examples/main.go @@ -0,0 +1 @@ +package examples diff --git a/go.mod b/go.mod index fd57a01..f1e37ae 100644 --- a/go.mod +++ b/go.mod @@ -5,9 +5,6 @@ go 1.17 require ( github.com/Unknwon/goconfig v1.0.0 github.com/aliyun/alibaba-cloud-sdk-go v1.61.1530 - github.com/aws/aws-sdk-go-v2/config v1.15.3 - github.com/aws/aws-sdk-go-v2/credentials v1.11.2 - github.com/aws/aws-sdk-go-v2/service/ec2 v1.34.0 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 @@ -25,15 +22,6 @@ require ( ) require ( - github.com/aws/aws-sdk-go-v2 v1.16.2 // indirect - github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.3 // indirect - github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.9 // indirect - github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.3 // indirect - github.com/aws/aws-sdk-go-v2/internal/ini v1.3.10 // indirect - github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.3 // indirect - github.com/aws/aws-sdk-go-v2/service/sso v1.11.3 // indirect - github.com/aws/aws-sdk-go-v2/service/sts v1.16.3 // indirect - github.com/aws/smithy-go v1.11.2 // indirect 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 diff --git a/main.go b/main.go index 54b92d4..1a4bef8 100644 --- a/main.go +++ b/main.go @@ -43,7 +43,7 @@ func run() error { func main() { var configFile string - flag.StringVar(&configFile, "conf", "config.yaml", "config.yaml") + flag.StringVar(&configFile, "conf", "config.yaml", "configs/config.yaml") flag.Parse() defer glog.Flush() 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 6/8] 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 7/8] 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 8/8] 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": {