mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-10-29 17:58:36 +08:00
climc: add commands for cloudproxy
This commit is contained in:
@@ -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