mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
climc: add commands for cloudproxy
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
// Copyright 2019 Yunion
|
||||
//
|
||||
// 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 cloudproxy
|
||||
|
||||
import (
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
)
|
||||
|
||||
func NewCloudProxyManager(keyword, keywordPlural string, columns, adminColumns []string) modulebase.ResourceManager {
|
||||
return modulebase.ResourceManager{
|
||||
BaseManager: *modulebase.NewBaseManager("cloudproxy", "", "", columns, adminColumns),
|
||||
Keyword: keyword, KeywordPlural: keywordPlural}
|
||||
}
|
||||
|
||||
var (
|
||||
registerV2 = func(mod modulebase.IBaseManager) {
|
||||
modulebase.Register("v2", mod)
|
||||
}
|
||||
)
|
||||
@@ -0,0 +1,15 @@
|
||||
// Copyright 2019 Yunion
|
||||
//
|
||||
// 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 cloudproxy // import "yunion.io/x/onecloud/pkg/mcclient/modules/cloudproxy"
|
||||
@@ -0,0 +1,45 @@
|
||||
// Copyright 2019 Yunion
|
||||
//
|
||||
// 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 cloudproxy
|
||||
|
||||
import (
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
)
|
||||
|
||||
type ProxyMatchManager struct {
|
||||
modulebase.ResourceManager
|
||||
}
|
||||
|
||||
var (
|
||||
ProxyMatches ProxyMatchManager
|
||||
)
|
||||
|
||||
func init() {
|
||||
ProxyMatches = ProxyMatchManager{
|
||||
NewCloudProxyManager(
|
||||
"proxy_match",
|
||||
"proxy_matches",
|
||||
[]string{
|
||||
"id",
|
||||
"name",
|
||||
"proxy_endpoint_id",
|
||||
"match_scope",
|
||||
"match_value",
|
||||
},
|
||||
[]string{"tenant"},
|
||||
),
|
||||
}
|
||||
registerV2(&ProxyMatches)
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
// Copyright 2019 Yunion
|
||||
//
|
||||
// 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 cloudproxy
|
||||
|
||||
import (
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
)
|
||||
|
||||
type ForwardManager struct {
|
||||
modulebase.ResourceManager
|
||||
}
|
||||
|
||||
var (
|
||||
Forwards ForwardManager
|
||||
)
|
||||
|
||||
func init() {
|
||||
Forwards = ForwardManager{
|
||||
NewCloudProxyManager(
|
||||
"forward",
|
||||
"forwards",
|
||||
[]string{
|
||||
"id",
|
||||
"name",
|
||||
"type",
|
||||
"remote_addr",
|
||||
"remote_port",
|
||||
"bind_port",
|
||||
"last_seen",
|
||||
},
|
||||
[]string{
|
||||
"proxy_endpoint_id",
|
||||
"proxy_agent_id",
|
||||
"bind_port_req",
|
||||
"tenant",
|
||||
},
|
||||
),
|
||||
}
|
||||
registerV2(&Forwards)
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
// Copyright 2019 Yunion
|
||||
//
|
||||
// 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 cloudproxy
|
||||
|
||||
import (
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
)
|
||||
|
||||
type ProxyAgentManager struct {
|
||||
modulebase.ResourceManager
|
||||
}
|
||||
|
||||
var (
|
||||
ProxyAgents ProxyAgentManager
|
||||
)
|
||||
|
||||
func init() {
|
||||
ProxyAgents = ProxyAgentManager{
|
||||
NewCloudProxyManager(
|
||||
"proxy_agent",
|
||||
"proxy_agents",
|
||||
[]string{
|
||||
"id",
|
||||
"name",
|
||||
"bind_addr",
|
||||
"advertise_addr",
|
||||
},
|
||||
[]string{},
|
||||
),
|
||||
}
|
||||
registerV2(&ProxyAgents)
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
// Copyright 2019 Yunion
|
||||
//
|
||||
// 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 cloudproxy
|
||||
|
||||
import (
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
)
|
||||
|
||||
type ProxyEndpointManager struct {
|
||||
modulebase.ResourceManager
|
||||
}
|
||||
|
||||
var (
|
||||
ProxyEndpoints ProxyEndpointManager
|
||||
)
|
||||
|
||||
func init() {
|
||||
ProxyEndpoints = ProxyEndpointManager{
|
||||
NewCloudProxyManager(
|
||||
"proxy_endpoint",
|
||||
"proxy_endpoints",
|
||||
[]string{
|
||||
"id",
|
||||
"name",
|
||||
"user",
|
||||
"host",
|
||||
"port",
|
||||
},
|
||||
[]string{"tenant"},
|
||||
),
|
||||
}
|
||||
registerV2(&ProxyEndpoints)
|
||||
}
|
||||
@@ -371,7 +371,7 @@ func (opts *BasePublicOptions) Params() (jsonutils.JSONObject, error) {
|
||||
}
|
||||
|
||||
type BaseCreateOptions struct {
|
||||
NAME string `help:"Resource Name"`
|
||||
NAME string `json:"name" help:"Resource Name"`
|
||||
Desc string `metavar:"<DESCRIPTION>" help:"Description" json:"description"`
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
// Copyright 2019 Yunion
|
||||
//
|
||||
// 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 cloudproxy // import "yunion.io/x/onecloud/pkg/mcclient/options/cloudproxy"
|
||||
@@ -0,0 +1,120 @@
|
||||
// Copyright 2019 Yunion
|
||||
//
|
||||
// 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 cloudproxy
|
||||
|
||||
import (
|
||||
"yunion.io/x/jsonutils"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
|
||||
type ForwardCreateOptions struct {
|
||||
NAME string
|
||||
|
||||
ProxyEndpointId string `required:"true"`
|
||||
ProxyAgentId string
|
||||
BindPortReq *int
|
||||
|
||||
Type string `choices:"local|remote" required:"true"`
|
||||
RemoteAddr string `required:"true"`
|
||||
RemotePort int `required:"true"`
|
||||
|
||||
LastSeenTimeout int `json:",omitzero"`
|
||||
|
||||
Opaque string
|
||||
}
|
||||
|
||||
func (o *ForwardCreateOptions) Params() (jsonutils.JSONObject, error) {
|
||||
return options.StructToParams(o)
|
||||
}
|
||||
|
||||
type ForwardCreateFromServerOptions struct {
|
||||
ServerId string `required:"true"`
|
||||
|
||||
Type string `choices:"local|remote" required:"true"`
|
||||
BindPortReq int `json:",omitzero"`
|
||||
RemotePort string `required:"true"`
|
||||
|
||||
LastSeenTimeout int `json:",omitzero"`
|
||||
|
||||
Opaque string
|
||||
}
|
||||
|
||||
func (opts *ForwardCreateFromServerOptions) Params() (jsonutils.JSONObject, error) {
|
||||
return options.StructToParams(opts)
|
||||
}
|
||||
|
||||
type ForwardHeartbeatOptions struct {
|
||||
ID string `json:"-"`
|
||||
}
|
||||
|
||||
func (o *ForwardHeartbeatOptions) GetId() string {
|
||||
return o.ID
|
||||
}
|
||||
|
||||
func (o *ForwardHeartbeatOptions) Params() (jsonutils.JSONObject, error) {
|
||||
return options.StructToParams(o)
|
||||
}
|
||||
|
||||
type ForwardShowOptions struct {
|
||||
options.BaseShowOptions
|
||||
}
|
||||
|
||||
type ForwardUpdateOptions struct {
|
||||
ID string `json:"-"`
|
||||
Name string
|
||||
|
||||
ProxyEndpointId string
|
||||
ProxyAgentId string
|
||||
|
||||
Type string `choices:"local|remote"`
|
||||
RemoteAddr string
|
||||
RemotePortReq *int
|
||||
BindPortReq *int
|
||||
|
||||
LastSeenTimeout int `json:",omitzero"`
|
||||
|
||||
Opaque string
|
||||
}
|
||||
|
||||
func (o *ForwardUpdateOptions) GetId() string {
|
||||
return o.ID
|
||||
}
|
||||
|
||||
func (o *ForwardUpdateOptions) Params() (jsonutils.JSONObject, error) {
|
||||
return options.StructToParams(o)
|
||||
}
|
||||
|
||||
type ForwardDeleteOptions struct {
|
||||
options.BaseIdOptions
|
||||
}
|
||||
|
||||
type ForwardListOptions struct {
|
||||
options.BaseListOptions
|
||||
|
||||
ProxyEndpointId string
|
||||
ProxyAgentId string
|
||||
|
||||
Type string `choices:"local|remote"`
|
||||
RemoteAddr string
|
||||
RemotePort *int
|
||||
BindPortReq *int
|
||||
|
||||
Opaque string
|
||||
}
|
||||
|
||||
func (o *ForwardListOptions) Params() (jsonutils.JSONObject, error) {
|
||||
return options.ListStructToParams(o)
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
// Copyright 2019 Yunion
|
||||
//
|
||||
// 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 cloudproxy
|
||||
|
||||
import (
|
||||
"yunion.io/x/jsonutils"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
|
||||
type ProxyAgentCreateOptions struct {
|
||||
NAME string
|
||||
|
||||
BindAddr string `json:"bind_addr"`
|
||||
AdvertiseAddr string `json:"advertise_addr"`
|
||||
}
|
||||
|
||||
func (o *ProxyAgentCreateOptions) Params() (jsonutils.JSONObject, error) {
|
||||
return options.StructToParams(o)
|
||||
}
|
||||
|
||||
type ProxyAgentShowOptions struct {
|
||||
options.BaseShowOptions
|
||||
}
|
||||
|
||||
type ProxyAgentUpdateOptions struct {
|
||||
ID string `help:"ID or Name of resource to update"`
|
||||
Name string `help:"Name of resource to update"`
|
||||
|
||||
BindAddr string `json:"bind_addr"`
|
||||
AdvertiseAddr string `json:"advertise_addr"`
|
||||
}
|
||||
|
||||
func (o *ProxyAgentUpdateOptions) GetId() string {
|
||||
return o.ID
|
||||
}
|
||||
|
||||
func (o *ProxyAgentUpdateOptions) Params() (jsonutils.JSONObject, error) {
|
||||
return options.StructToParams(o)
|
||||
}
|
||||
|
||||
type ProxyAgentDeleteOptions struct {
|
||||
options.BaseIdOptions
|
||||
}
|
||||
|
||||
type ProxyAgentListOptions struct {
|
||||
options.BaseListOptions
|
||||
|
||||
BindAddr string `json:"bind_addr"`
|
||||
AdvertiseAddr string `json:"advertise_addr"`
|
||||
}
|
||||
|
||||
func (o *ProxyAgentListOptions) Params() (jsonutils.JSONObject, error) {
|
||||
return options.ListStructToParams(o)
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
// Copyright 2019 Yunion
|
||||
//
|
||||
// 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 cloudproxy
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
|
||||
type ProxyEndpointCreateOptions struct {
|
||||
NAME string
|
||||
|
||||
User string
|
||||
Host string
|
||||
Port int `json:",omitzero"`
|
||||
PrivateKey string
|
||||
|
||||
IntranetIpAddr string `required:"true"`
|
||||
}
|
||||
|
||||
func (opts *ProxyEndpointCreateOptions) Params() (jsonutils.JSONObject, error) {
|
||||
params, err := options.StructToParams(opts)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if opts.PrivateKey != "" && opts.PrivateKey[0] == '@' {
|
||||
data, err := ioutil.ReadFile(opts.PrivateKey[1:])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
params.Set("private_key", jsonutils.NewString(string(data)))
|
||||
}
|
||||
return params, nil
|
||||
}
|
||||
|
||||
type ProxyEndpointCreateFromServerOptions struct {
|
||||
ServerId string `required:"true"`
|
||||
}
|
||||
|
||||
func (opts *ProxyEndpointCreateFromServerOptions) Params() (jsonutils.JSONObject, error) {
|
||||
return options.StructToParams(opts)
|
||||
}
|
||||
|
||||
type ProxyEndpointShowOptions struct {
|
||||
options.BaseShowOptions
|
||||
}
|
||||
|
||||
type ProxyEndpointUpdateOptions struct {
|
||||
ID string `json:"-"`
|
||||
Name string
|
||||
|
||||
User string
|
||||
Host string
|
||||
Port int `json:",omitzero"`
|
||||
PrivateKey string
|
||||
}
|
||||
|
||||
func (opts *ProxyEndpointUpdateOptions) GetId() string {
|
||||
return opts.ID
|
||||
}
|
||||
|
||||
func (opts *ProxyEndpointUpdateOptions) Params() (jsonutils.JSONObject, error) {
|
||||
params, err := options.StructToParams(opts)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if opts.PrivateKey != "" && opts.PrivateKey[0] == '@' {
|
||||
data, err := ioutil.ReadFile(opts.PrivateKey[1:])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
params.Set("private_key", jsonutils.NewString(string(data)))
|
||||
}
|
||||
return params, nil
|
||||
}
|
||||
|
||||
type ProxyEndpointDeleteOptions struct {
|
||||
options.BaseShowOptions
|
||||
}
|
||||
|
||||
type ProxyEndpointListOptions struct {
|
||||
options.BaseListOptions
|
||||
|
||||
//User string
|
||||
Host string
|
||||
Port int `json:",omitzero"`
|
||||
|
||||
VpcId string
|
||||
NetworkId string
|
||||
}
|
||||
|
||||
func (opts *ProxyEndpointListOptions) Params() (jsonutils.JSONObject, error) {
|
||||
return options.ListStructToParams(opts)
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
// Copyright 2019 Yunion
|
||||
//
|
||||
// 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 cloudproxy
|
||||
|
||||
import (
|
||||
"yunion.io/x/jsonutils"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
|
||||
type ProxyMatchCreateOptions struct {
|
||||
NAME string
|
||||
|
||||
ProxyEndpointId string `required:"true"`
|
||||
MatchScope string `required:"true" choices:"vpc|network"`
|
||||
MatchValue string `required:"true"`
|
||||
}
|
||||
|
||||
func (opts *ProxyMatchCreateOptions) Params() (jsonutils.JSONObject, error) {
|
||||
return options.StructToParams(opts)
|
||||
}
|
||||
|
||||
type ProxyMatchShowOptions struct {
|
||||
options.BaseShowOptions
|
||||
}
|
||||
|
||||
type ProxyMatchUpdateOptions struct {
|
||||
ID string `json:"-"`
|
||||
Name string
|
||||
|
||||
ProxyEndpointId string
|
||||
MatchScope string `choices:"vpc|network"`
|
||||
MatchValue string
|
||||
}
|
||||
|
||||
func (opts *ProxyMatchUpdateOptions) GetId() string {
|
||||
return opts.ID
|
||||
}
|
||||
|
||||
func (opts *ProxyMatchUpdateOptions) Params() (jsonutils.JSONObject, error) {
|
||||
return options.StructToParams(opts)
|
||||
}
|
||||
|
||||
type ProxyMatchDeleteOptions struct {
|
||||
options.BaseShowOptions
|
||||
}
|
||||
|
||||
type ProxyMatchListOptions struct {
|
||||
options.BaseListOptions
|
||||
|
||||
ProxyEndpointId string
|
||||
MatchScope string `choices:"vpc|network"`
|
||||
MatchValue string
|
||||
}
|
||||
|
||||
func (opts *ProxyMatchListOptions) Params() (jsonutils.JSONObject, error) {
|
||||
return options.ListStructToParams(opts)
|
||||
}
|
||||
Reference in New Issue
Block a user