feat(misc): use cloudmux package (#15254)

This commit is contained in:
Zexi Li
2022-10-28 19:53:03 +08:00
committed by GitHub
parent 72c7fe038c
commit 0e2c520ecd
3181 changed files with 220135 additions and 251244 deletions

View File

@@ -1,152 +0,0 @@
// 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 main
import (
"fmt"
"net/http"
"net/url"
"os"
"golang.org/x/net/http/httpproxy"
"yunion.io/x/structarg"
"yunion.io/x/onecloud/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/multicloud/aliyun"
_ "yunion.io/x/onecloud/pkg/multicloud/aliyun/shell"
"yunion.io/x/onecloud/pkg/util/shellutils"
)
type BaseOptions struct {
Debug bool `help:"debug mode"`
CloudEnv string `help:"Cloud environment" default:"$ALIYUN_CLOUD_ENV" choices:"InternationalCloud|FinanceCloud" metavar:"ALIYUN_CLOUD_ENV"`
AccessKey string `help:"Access key" default:"$ALIYUN_ACCESS_KEY" metavar:"ALIYUN_ACCESS_KEY"`
Secret string `help:"Secret" default:"$ALIYUN_SECRET" metavar:"ALIYUN_SECRET"`
RegionId string `help:"RegionId" default:"$ALIYUN_REGION" metavar:"ALIYUN_REGION"`
SUBCOMMAND string `help:"aliyuncli subcommand" subcommand:"true"`
}
func getSubcommandParser() (*structarg.ArgumentParser, error) {
parse, e := structarg.NewArgumentParserWithHelp(&BaseOptions{},
"aliyuncli",
"Command-line interface to aliyun API.",
`See "aliyuncli COMMAND --help" for help on a specific command.`)
if e != nil {
return nil, e
}
subcmd := parse.GetSubcommand()
if subcmd == nil {
return nil, fmt.Errorf("No subcommand argument.")
}
for _, v := range shellutils.CommandTable {
_, e := subcmd.AddSubParserWithHelp(v.Options, v.Command, v.Desc, v.Callback)
if e != nil {
return nil, e
}
}
return parse, nil
}
func showErrorAndExit(e error) {
fmt.Fprintf(os.Stderr, "%s", e)
fmt.Fprintln(os.Stderr)
os.Exit(1)
}
func newClient(options *BaseOptions) (*aliyun.SRegion, error) {
if len(options.AccessKey) == 0 {
return nil, fmt.Errorf("Missing accessKey")
}
if len(options.Secret) == 0 {
return nil, fmt.Errorf("Missing secret")
}
cfg := &httpproxy.Config{
HTTPProxy: os.Getenv("HTTP_PROXY"),
HTTPSProxy: os.Getenv("HTTPS_PROXY"),
NoProxy: os.Getenv("NO_PROXY"),
}
cfgProxyFunc := cfg.ProxyFunc()
proxyFunc := func(req *http.Request) (*url.URL, error) {
return cfgProxyFunc(req.URL)
}
cli, err := aliyun.NewAliyunClient(
aliyun.NewAliyunClientConfig(
options.CloudEnv,
options.AccessKey,
options.Secret,
).Debug(options.Debug).
CloudproviderConfig(
cloudprovider.ProviderConfig{
ProxyFunc: proxyFunc,
},
),
)
if err != nil {
return nil, err
}
region := cli.GetRegion(options.RegionId)
if region == nil {
return nil, fmt.Errorf("No such region %s", options.RegionId)
}
return region, nil
}
func main() {
parser, e := getSubcommandParser()
if e != nil {
showErrorAndExit(e)
}
e = parser.ParseArgs(os.Args[1:], false)
options := parser.Options().(*BaseOptions)
if parser.IsHelpSet() {
fmt.Print(parser.HelpString())
return
}
subcmd := parser.GetSubcommand()
subparser := subcmd.GetSubParser()
if e != nil || subparser == nil {
if subparser != nil {
fmt.Print(subparser.Usage())
} else {
fmt.Print(parser.Usage())
}
showErrorAndExit(e)
return
}
suboptions := subparser.Options()
if subparser.IsHelpSet() {
fmt.Print(subparser.HelpString())
return
}
var region *aliyun.SRegion
region, e = newClient(options)
if e != nil {
showErrorAndExit(e)
}
e = subcmd.Invoke(region, suboptions)
if e != nil {
showErrorAndExit(e)
}
}

View File

@@ -1,154 +0,0 @@
// 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 main
import (
"fmt"
"net/http"
"net/url"
"os"
"golang.org/x/net/http/httpproxy"
"yunion.io/x/structarg"
"yunion.io/x/onecloud/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/multicloud/apsara"
_ "yunion.io/x/onecloud/pkg/multicloud/apsara/shell"
"yunion.io/x/onecloud/pkg/util/shellutils"
)
type BaseOptions struct {
Debug bool `help:"debug mode"`
AccessKey string `help:"Access key" default:"$APSARA_ACCESS_KEY" metavar:"APSARA_ACCESS_KEY"`
Secret string `help:"Secret" default:"$APSARA_SECRET" metavar:"APSARA_SECRET"`
Endpoint string `help:"Apsara endpoint" default:"$APSARA_ENDPOINT" metavar:"APSARA_ENDPOINT"`
RegionId string `help:"RegionId" default:"$APSARA_REGION" metavar:"APSARA_REGION"`
DEFAULT_REGION string `help:"Default region" default:"$APSARA_DEFAULT_REGION"`
SUBCOMMAND string `help:"apsaracli subcommand" subcommand:"true"`
}
func getSubcommandParser() (*structarg.ArgumentParser, error) {
parse, e := structarg.NewArgumentParserWithHelp(&BaseOptions{},
"apsaracli",
"Command-line interface to apsara API.",
`See "apsaracli COMMAND --help" for help on a specific command.`)
if e != nil {
return nil, e
}
subcmd := parse.GetSubcommand()
if subcmd == nil {
return nil, fmt.Errorf("No subcommand argument.")
}
for _, v := range shellutils.CommandTable {
_, e := subcmd.AddSubParserWithHelp(v.Options, v.Command, v.Desc, v.Callback)
if e != nil {
return nil, e
}
}
return parse, nil
}
func showErrorAndExit(e error) {
fmt.Fprintf(os.Stderr, "%s", e)
fmt.Fprintln(os.Stderr)
os.Exit(1)
}
func newClient(options *BaseOptions) (*apsara.SRegion, error) {
if len(options.AccessKey) == 0 {
return nil, fmt.Errorf("Missing accessKey")
}
if len(options.Secret) == 0 {
return nil, fmt.Errorf("Missing secret")
}
cfg := &httpproxy.Config{
HTTPProxy: os.Getenv("HTTP_PROXY"),
HTTPSProxy: os.Getenv("HTTPS_PROXY"),
NoProxy: os.Getenv("NO_PROXY"),
}
cfgProxyFunc := cfg.ProxyFunc()
proxyFunc := func(req *http.Request) (*url.URL, error) {
return cfgProxyFunc(req.URL)
}
cli, err := apsara.NewApsaraClient(
apsara.NewApsaraClientConfig(
options.AccessKey,
options.Secret,
options.Endpoint,
).Debug(options.Debug).
CloudproviderConfig(
cloudprovider.ProviderConfig{
ProxyFunc: proxyFunc,
URL: options.Endpoint,
DefaultRegion: options.DEFAULT_REGION,
},
),
)
if err != nil {
return nil, err
}
region := cli.GetRegion(options.RegionId)
if region == nil {
return nil, fmt.Errorf("No such region %s", options.RegionId)
}
return region, nil
}
func main() {
parser, e := getSubcommandParser()
if e != nil {
showErrorAndExit(e)
}
e = parser.ParseArgs(os.Args[1:], false)
options := parser.Options().(*BaseOptions)
if parser.IsHelpSet() {
fmt.Print(parser.HelpString())
return
}
subcmd := parser.GetSubcommand()
subparser := subcmd.GetSubParser()
if e != nil || subparser == nil {
if subparser != nil {
fmt.Print(subparser.Usage())
} else {
fmt.Print(parser.Usage())
}
showErrorAndExit(e)
return
}
suboptions := subparser.Options()
if subparser.IsHelpSet() {
fmt.Print(subparser.HelpString())
return
}
var region *apsara.SRegion
region, e = newClient(options)
if e != nil {
showErrorAndExit(e)
}
e = subcmd.Invoke(region, suboptions)
if e != nil {
showErrorAndExit(e)
}
}

View File

@@ -1,154 +0,0 @@
// 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 main
import (
"fmt"
"net/http"
"net/url"
"os"
"golang.org/x/net/http/httpproxy"
"yunion.io/x/pkg/errors"
"yunion.io/x/structarg"
"yunion.io/x/onecloud/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/multicloud/aws"
_ "yunion.io/x/onecloud/pkg/multicloud/aws/shell"
"yunion.io/x/onecloud/pkg/util/shellutils"
)
type BaseOptions struct {
Debug bool `help:"debug mode"`
AccessUrl string `help:"Access key" default:"$AWS_ACCESS_URL" choices:"ChinaCloud|InternationalCloud" metavar:"AWS_ACCESS_URL"`
AccessKey string `help:"Access key" default:"$AWS_ACCESS_KEY" metavar:"AWS_ACCESS_KEY"`
Secret string `help:"Secret" default:"$AWS_SECRET" metavar:"AWS_SECRET"`
RegionId string `help:"RegionId" default:"$AWS_REGION" metavar:"AWS_REGION"`
AccountId string `help:"Subaccount ID" default:"$AWS_ACCOUNT_ID" metavar:"AWS_ACCOUNT_ID"`
SUBCOMMAND string `help:"awscli subcommand" subcommand:"true"`
}
func getSubcommandParser() (*structarg.ArgumentParser, error) {
parse, e := structarg.NewArgumentParserWithHelp(&BaseOptions{},
"awscli",
"Command-line interface to aws API.",
`See "awscli COMMAND --help" for help on a specific command.`)
if e != nil {
return nil, e
}
subcmd := parse.GetSubcommand()
if subcmd == nil {
return nil, fmt.Errorf("No subcommand argument.")
}
for _, v := range shellutils.CommandTable {
_, e := subcmd.AddSubParserWithHelp(v.Options, v.Command, v.Desc, v.Callback)
if e != nil {
return nil, e
}
}
return parse, nil
}
func showErrorAndExit(e error) {
fmt.Fprintf(os.Stderr, "%s", e)
fmt.Fprintln(os.Stderr)
os.Exit(1)
}
func newClient(options *BaseOptions) (*aws.SRegion, error) {
if len(options.AccessKey) == 0 {
return nil, fmt.Errorf("Missing accessKey")
}
if len(options.Secret) == 0 {
return nil, fmt.Errorf("Missing secret")
}
cfg := &httpproxy.Config{
HTTPProxy: os.Getenv("HTTP_PROXY"),
HTTPSProxy: os.Getenv("HTTPS_PROXY"),
NoProxy: os.Getenv("NO_PROXY"),
}
cfgProxyFunc := cfg.ProxyFunc()
proxyFunc := func(req *http.Request) (*url.URL, error) {
return cfgProxyFunc(req.URL)
}
cli, err := aws.NewAwsClient(
aws.NewAwsClientConfig(
options.AccessUrl,
options.AccessKey,
options.Secret,
options.AccountId,
).Debug(options.Debug).
CloudproviderConfig(
cloudprovider.ProviderConfig{
ProxyFunc: proxyFunc,
},
),
)
if err != nil {
return nil, err
}
region, err := cli.GetRegion(options.RegionId)
if err != nil {
return nil, errors.Wrapf(err, "GetRegion(%s)", options.RegionId)
}
return region, nil
}
func main() {
parser, e := getSubcommandParser()
if e != nil {
showErrorAndExit(e)
}
e = parser.ParseArgs(os.Args[1:], false)
options := parser.Options().(*BaseOptions)
if parser.IsHelpSet() {
fmt.Print(parser.HelpString())
return
}
subcmd := parser.GetSubcommand()
subparser := subcmd.GetSubParser()
if e != nil || subparser == nil {
if subparser != nil {
fmt.Print(subparser.Usage())
} else {
fmt.Print(parser.Usage())
}
showErrorAndExit(e)
return
}
suboptions := subparser.Options()
if subparser.IsHelpSet() {
fmt.Print(subparser.HelpString())
return
}
var region *aws.SRegion
region, e = newClient(options)
if e != nil {
showErrorAndExit(e)
}
e = subcmd.Invoke(region, suboptions)
if e != nil {
showErrorAndExit(e)
}
}

View File

@@ -1,171 +0,0 @@
// 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 main
import (
"fmt"
"net/http"
"net/url"
"os"
"golang.org/x/net/http/httpproxy"
"yunion.io/x/structarg"
"yunion.io/x/onecloud/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/multicloud/azure"
_ "yunion.io/x/onecloud/pkg/multicloud/azure/shell"
"yunion.io/x/onecloud/pkg/util/printutils"
"yunion.io/x/onecloud/pkg/util/shellutils"
)
type BaseOptions struct {
Debug bool `help:"debug mode"`
DirectoryID string `help:"Azure account Directory ID/Tenant ID" default:"$AZURE_DIRECTORY_ID" metavar:"AZURE_DIRECTORY_ID"`
SubscriptionID string `help:"Azure account subscription ID" default:"$AZURE_SUBSCRIPTION_ID" metavar:"AZURE_SUBSCRIPTION_ID"`
ApplicationID string `help:"Azure application ID" default:"$AZURE_APPLICATION_ID" metavar:"AZURE_APPLICATION_ID"`
ApplicationKey string `help:"Azure application key" default:"$AZURE_APPLICATION_KEY" metavar:"AZURE_APPLICATION_KEY"`
RegionId string `help:"RegionId" default:"$AZURE_REGION_ID" metavar:"AZURE_REGION_ID"`
CloudEnv string `help:"Cloud Environment" default:"$AZURE_CLOUD_ENV" choices:"AzureGermanCloud|AzureChinaCloud|AzureUSGovernmentCloud|AzurePublicCloud" metavar:"AZURE_CLOUD_ENV"`
SUBCOMMAND string `help:"azurecli subcommand" subcommand:"true"`
}
func getSubcommandParser() (*structarg.ArgumentParser, error) {
parse, e := structarg.NewArgumentParserWithHelp(&BaseOptions{},
"azurecli",
"Command-line interface to azure API.",
`See "azurecli COMMAND --help" for help on a specific command.`)
if e != nil {
return nil, e
}
subcmd := parse.GetSubcommand()
if subcmd == nil {
return nil, fmt.Errorf("No subcommand argument.")
}
for _, v := range shellutils.CommandTable {
_, e := subcmd.AddSubParserWithHelp(v.Options, v.Command, v.Desc, v.Callback)
if e != nil {
return nil, e
}
}
return parse, nil
}
func showErrorAndExit(e error) {
fmt.Fprintf(os.Stderr, "%s", e)
fmt.Fprintln(os.Stderr)
os.Exit(1)
}
func newClient(options *BaseOptions) (*azure.SRegion, error) {
if len(options.DirectoryID) == 0 {
return nil, fmt.Errorf("Missing Directory ID")
}
if len(options.SubscriptionID) == 0 {
return nil, fmt.Errorf("Missing subscription ID")
}
if len(options.ApplicationID) == 0 {
return nil, fmt.Errorf("Missing Application ID")
}
if len(options.ApplicationKey) == 0 {
return nil, fmt.Errorf("Missing Application Key")
}
if len(options.CloudEnv) == 0 {
return nil, fmt.Errorf("Missing Cloud Environment")
}
cfg := &httpproxy.Config{
HTTPProxy: os.Getenv("HTTP_PROXY"),
HTTPSProxy: os.Getenv("HTTPS_PROXY"),
NoProxy: os.Getenv("NO_PROXY"),
}
cfgProxyFunc := cfg.ProxyFunc()
proxyFunc := func(req *http.Request) (*url.URL, error) {
return cfgProxyFunc(req.URL)
}
cli, err := azure.NewAzureClient(
azure.NewAzureClientConfig(
options.CloudEnv,
options.DirectoryID,
options.ApplicationID,
options.ApplicationKey,
).
SubscriptionId(options.SubscriptionID).
Debug(options.Debug).
CloudproviderConfig(
cloudprovider.ProviderConfig{
ProxyFunc: proxyFunc,
},
),
)
if err != nil {
return nil, err
}
region := cli.GetRegion(options.RegionId)
if region == nil {
fmt.Println("Please chooce which region you are going to use:")
regions := cli.GetRegions()
printutils.PrintInterfaceList(regions, 0, 0, 0, nil)
return nil, fmt.Errorf("No such region %s", options.RegionId)
}
return region, nil
}
func main() {
parser, e := getSubcommandParser()
if e != nil {
showErrorAndExit(e)
}
e = parser.ParseArgs(os.Args[1:], false)
options := parser.Options().(*BaseOptions)
if parser.IsHelpSet() {
fmt.Print(parser.HelpString())
return
}
subcmd := parser.GetSubcommand()
subparser := subcmd.GetSubParser()
if e != nil || subparser == nil {
if subparser != nil {
fmt.Print(subparser.Usage())
} else {
fmt.Print(parser.Usage())
}
showErrorAndExit(e)
}
suboptions := subparser.Options()
if subparser.IsHelpSet() {
fmt.Print(subparser.HelpString())
return
}
var region *azure.SRegion
region, e = newClient(options)
if e != nil {
showErrorAndExit(e)
}
e = subcmd.Invoke(region, suboptions)
if e != nil {
showErrorAndExit(e)
}
}

View File

@@ -1,150 +0,0 @@
// 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 main
import (
"fmt"
"net/http"
"net/url"
"os"
"golang.org/x/net/http/httpproxy"
"yunion.io/x/structarg"
"yunion.io/x/onecloud/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/multicloud/bingocloud"
_ "yunion.io/x/onecloud/pkg/multicloud/bingocloud/shell"
"yunion.io/x/onecloud/pkg/util/shellutils"
)
type BaseOptions struct {
Debug bool `help:"debug mode"`
RegionId string
Endpoint string `help:"Endpoint" default:"$BINGO_CLOUD_ENDPOINT" metavar:"BINGO_CLOUD_ENDPOINT"`
AccessKey string `help:"Access Key" default:"$BINGO_CLOUD_ACCESS_KEY" metavar:"BINGO_CLOUD_ACCESS_KEY"`
SecretKey string `help:"Secret Key" default:"$BINGO_CLOUD_SECRET_KEY" metavar:"BINGO_CLOUD_SECRET_KEY"`
SUBCOMMAND string `help:"bingocli subcommand" subcommand:"true"`
}
func getSubcommandParser() (*structarg.ArgumentParser, error) {
parse, e := structarg.NewArgumentParserWithHelp(&BaseOptions{},
"bingocli",
"Command-line interface to bingo cloud API.",
`See "bingocli COMMAND --help" for help on a specific command.`)
if e != nil {
return nil, e
}
subcmd := parse.GetSubcommand()
if subcmd == nil {
return nil, fmt.Errorf("No subcommand argument.")
}
for _, v := range shellutils.CommandTable {
_, e := subcmd.AddSubParserWithHelp(v.Options, v.Command, v.Desc, v.Callback)
if e != nil {
return nil, e
}
}
return parse, nil
}
func showErrorAndExit(e error) {
fmt.Fprintf(os.Stderr, "%s", e)
fmt.Fprintln(os.Stderr)
os.Exit(1)
}
func newClient(options *BaseOptions) (*bingocloud.SRegion, error) {
if len(options.Endpoint) == 0 {
return nil, fmt.Errorf("Missing endpoint")
}
if len(options.AccessKey) == 0 {
return nil, fmt.Errorf("Missing access key")
}
if len(options.SecretKey) == 0 {
return nil, fmt.Errorf("Missing secret key")
}
cfg := &httpproxy.Config{
HTTPProxy: os.Getenv("HTTP_PROXY"),
HTTPSProxy: os.Getenv("HTTPS_PROXY"),
NoProxy: os.Getenv("NO_PROXY"),
}
cfgProxyFunc := cfg.ProxyFunc()
proxyFunc := func(req *http.Request) (*url.URL, error) {
return cfgProxyFunc(req.URL)
}
cli, err := bingocloud.NewBingoCloudClient(
bingocloud.NewBingoCloudClientConfig(
options.Endpoint,
options.AccessKey,
options.SecretKey,
).Debug(options.Debug).
CloudproviderConfig(
cloudprovider.ProviderConfig{
ProxyFunc: proxyFunc,
},
),
)
if err != nil {
return nil, err
}
return cli.GetRegion(options.RegionId)
}
func main() {
parser, e := getSubcommandParser()
if e != nil {
showErrorAndExit(e)
}
e = parser.ParseArgs(os.Args[1:], false)
options := parser.Options().(*BaseOptions)
if parser.IsHelpSet() {
fmt.Print(parser.HelpString())
return
}
subcmd := parser.GetSubcommand()
subparser := subcmd.GetSubParser()
if e != nil || subparser == nil {
if subparser != nil {
fmt.Print(subparser.Usage())
} else {
fmt.Print(parser.Usage())
}
showErrorAndExit(e)
return
}
suboptions := subparser.Options()
if subparser.IsHelpSet() {
fmt.Print(subparser.HelpString())
return
}
var region *bingocloud.SRegion
region, e = newClient(options)
if e != nil {
showErrorAndExit(e)
}
e = subcmd.Invoke(region, suboptions)
if e != nil {
showErrorAndExit(e)
}
}

View File

@@ -19,6 +19,7 @@ import (
"io"
"os"
"yunion.io/x/cloudmux/pkg/multicloud/objectstore"
"yunion.io/x/jsonutils"
api "yunion.io/x/onecloud/pkg/apis/compute"
@@ -26,7 +27,6 @@ import (
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
modules "yunion.io/x/onecloud/pkg/mcclient/modules/compute"
"yunion.io/x/onecloud/pkg/mcclient/options"
"yunion.io/x/onecloud/pkg/multicloud/objectstore"
)
func init() {

View File

@@ -17,11 +17,11 @@ package misc
import (
"fmt"
"yunion.io/x/cloudmux/pkg/cloudprovider"
"yunion.io/x/jsonutils"
"yunion.io/x/pkg/errors"
"yunion.io/x/pkg/utils"
"yunion.io/x/onecloud/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
modules "yunion.io/x/onecloud/pkg/mcclient/modules"

View File

@@ -1,153 +0,0 @@
// 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 main
import (
"fmt"
"net/http"
"net/url"
"os"
"golang.org/x/net/http/httpproxy"
"yunion.io/x/structarg"
"yunion.io/x/onecloud/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/multicloud/cloudpods"
_ "yunion.io/x/onecloud/pkg/multicloud/cloudpods/shell"
"yunion.io/x/onecloud/pkg/util/shellutils"
)
type BaseOptions struct {
Debug bool `help:"debug mode"`
AuthURL string `help:"Auth URL" default:"$CLOUDPODS_AUTH_URL" metavar:"CLOUDPODS_AUTH_URL"`
AccessKey string `help:"AccessKey" default:"$CLOUDPODS_ACCESS_KEY" metavar:"CLOUDPODS_ACCESS_KEY"`
AccessSecret string `help:"AccessSecret" default:"$CLOUDPODS_ACCESS_SECRET" metavar:"CLOUDPODS_ACCESS_SECRET"`
RegionId string `help:"RegionId" default:"$CLOUDPODS_REGION_ID|default" metavar:"CLOUDPODS_REGION_ID"`
SUBCOMMAND string `help:"cloudpodscli subcommand" subcommand:"true"`
}
func getSubcommandParser() (*structarg.ArgumentParser, error) {
parse, err := structarg.NewArgumentParserWithHelp(&BaseOptions{},
"cloudpodscli",
"Command-line interface to cloudpods API.",
`See "cloudpodscli COMMAND --help" for help on a specific command.`)
if err != nil {
return nil, err
}
subcmd := parse.GetSubcommand()
if subcmd == nil {
return nil, fmt.Errorf("No subcommand argument.")
}
for _, v := range shellutils.CommandTable {
_, err = subcmd.AddSubParserWithHelp(v.Options, v.Command, v.Desc, v.Callback)
if err != nil {
return nil, err
}
}
return parse, nil
}
func showErrorAndExit(e error) {
fmt.Fprintf(os.Stderr, "%s", e)
fmt.Fprintln(os.Stderr)
os.Exit(1)
}
func newClient(options *BaseOptions) (*cloudpods.SRegion, error) {
if len(options.AuthURL) == 0 {
return nil, fmt.Errorf("Missing AuthURL")
}
if len(options.AccessKey) == 0 {
return nil, fmt.Errorf("Missing access key")
}
if len(options.AccessSecret) == 0 {
return nil, fmt.Errorf("Missing access secret")
}
cfg := &httpproxy.Config{
HTTPProxy: os.Getenv("HTTP_PROXY"),
HTTPSProxy: os.Getenv("HTTPS_PROXY"),
NoProxy: os.Getenv("NO_PROXY"),
}
cfgProxyFunc := cfg.ProxyFunc()
proxyFunc := func(req *http.Request) (*url.URL, error) {
return cfgProxyFunc(req.URL)
}
cli, err := cloudpods.NewCloudpodsClient(
cloudpods.NewCloudpodsClientConfig(
options.AuthURL,
options.AccessKey,
options.AccessSecret,
).Debug(options.Debug).
CloudproviderConfig(
cloudprovider.ProviderConfig{
ProxyFunc: proxyFunc,
},
),
)
if err != nil {
return nil, err
}
region, err := cli.GetRegion(options.RegionId)
if err != nil {
return nil, err
}
return region, nil
}
func main() {
parser, err := getSubcommandParser()
if err != nil {
showErrorAndExit(err)
}
err = parser.ParseArgs(os.Args[1:], false)
options := parser.Options().(*BaseOptions)
if parser.IsHelpSet() {
fmt.Print(parser.HelpString())
return
}
subcmd := parser.GetSubcommand()
subparser := subcmd.GetSubParser()
if err != nil || subparser == nil {
if subparser != nil {
fmt.Print(subparser.Usage())
} else {
fmt.Print(parser.Usage())
}
showErrorAndExit(err)
return
}
suboptions := subparser.Options()
if subparser.IsHelpSet() {
fmt.Print(subparser.HelpString())
return
}
var region *cloudpods.SRegion
region, err = newClient(options)
if err != nil {
showErrorAndExit(err)
}
err = subcmd.Invoke(region, suboptions)
if err != nil {
showErrorAndExit(err)
}
}

View File

@@ -1,149 +0,0 @@
// 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 main
import (
"fmt"
"net/http"
"net/url"
"os"
"golang.org/x/net/http/httpproxy"
"yunion.io/x/structarg"
"yunion.io/x/onecloud/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/multicloud/ctyun"
_ "yunion.io/x/onecloud/pkg/multicloud/ctyun/shell"
"yunion.io/x/onecloud/pkg/util/shellutils"
)
type BaseOptions struct {
cloudprovider.SCtyunExtraOptions
Debug bool `help:"Show debug" default:"false"`
AccessKey string `help:"Access key" default:"$CTYUN_ACCESS_KEY"`
Secret string `help:"Secret" default:"$CTYUN_SECRET"`
RegionId string `help:"RegionId" default:"$CTYUN_REGION"`
SUBCOMMAND string `help:"ctyuncli subcommand" subcommand:"true"`
}
func getSubcommandParser() (*structarg.ArgumentParser, error) {
parse, e := structarg.NewArgumentParserWithHelp(&BaseOptions{},
"ctyuncli",
"Command-line interface to ctyun API.",
`See "ctyuncli COMMAND --help" for help on a specific command.`)
if e != nil {
return nil, e
}
subcmd := parse.GetSubcommand()
if subcmd == nil {
return nil, fmt.Errorf("No subcommand argument.")
}
for _, v := range shellutils.CommandTable {
_, e := subcmd.AddSubParserWithHelp(v.Options, v.Command, v.Desc, v.Callback)
if e != nil {
return nil, e
}
}
return parse, nil
}
func showErrorAndExit(e error) {
fmt.Fprintf(os.Stderr, "%s", e)
fmt.Fprintln(os.Stderr)
os.Exit(1)
}
func newClient(options *BaseOptions) (*ctyun.SRegion, error) {
if len(options.AccessKey) == 0 {
return nil, fmt.Errorf("Missing accessKey")
}
if len(options.Secret) == 0 {
return nil, fmt.Errorf("Missing secret")
}
cfg := &httpproxy.Config{
HTTPProxy: os.Getenv("HTTP_PROXY"),
HTTPSProxy: os.Getenv("HTTPS_PROXY"),
NoProxy: os.Getenv("NO_PROXY"),
}
cfgProxyFunc := cfg.ProxyFunc()
proxyFunc := func(req *http.Request) (*url.URL, error) {
return cfgProxyFunc(req.URL)
}
cli, err := ctyun.NewSCtyunClient(
ctyun.NewSCtyunClientConfig(
options.AccessKey, options.Secret, &options.SCtyunExtraOptions,
).Debug(options.Debug).
CloudproviderConfig(
cloudprovider.ProviderConfig{
ProxyFunc: proxyFunc,
},
),
)
if err != nil {
return nil, err
}
region := cli.GetRegion(options.RegionId)
if region == nil {
return nil, fmt.Errorf("No such region %s", options.RegionId)
}
return region, nil
}
func main() {
parser, e := getSubcommandParser()
if e != nil {
showErrorAndExit(e)
}
e = parser.ParseArgs(os.Args[1:], false)
options := parser.Options().(*BaseOptions)
if parser.IsHelpSet() {
fmt.Print(parser.HelpString())
return
}
subcmd := parser.GetSubcommand()
subparser := subcmd.GetSubParser()
if e != nil || subparser == nil {
if subparser != nil {
fmt.Print(subparser.Usage())
} else {
fmt.Print(parser.Usage())
}
showErrorAndExit(e)
}
suboptions := subparser.Options()
if subparser.IsHelpSet() {
fmt.Print(subparser.HelpString())
return
}
var region *ctyun.SRegion
region, e = newClient(options)
if e != nil {
showErrorAndExit(e)
}
e = subcmd.Invoke(region, suboptions)
if e != nil {
showErrorAndExit(e)
}
}

View File

@@ -1,147 +0,0 @@
// 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 main
import (
"fmt"
"net/http"
"net/url"
"os"
"golang.org/x/net/http/httpproxy"
"yunion.io/x/structarg"
"yunion.io/x/onecloud/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/multicloud/ecloud"
_ "yunion.io/x/onecloud/pkg/multicloud/ecloud/shell"
"yunion.io/x/onecloud/pkg/util/shellutils"
)
type Options struct {
Debug bool `help:"Show debug" default:"false"`
AccessKey string `help:"Access key" default:"$ECLOUD_ACCESS_KEY"`
AccessSecret string `help:"Secret" default:"$ECLOUD_ACCESS_SECRET"`
RegionId string `help:"RegionId" default:"$ECLOUD_REGION"`
SUBCOMMAND string `help:"ecloudcli subcommand" subcommand:"true"`
}
func getSubcommandParser() (*structarg.ArgumentParser, error) {
parse, e := structarg.NewArgumentParserWithHelp(&Options{},
"ecloudcli",
"Command-line interface to ecloud API.",
`See "ecloudcli COMMAND --help" for help on a specific command.`)
if e != nil {
return nil, e
}
subcmd := parse.GetSubcommand()
if subcmd == nil {
return nil, fmt.Errorf("No subcommand argument.")
}
for _, v := range shellutils.CommandTable {
_, e := subcmd.AddSubParserWithHelp(v.Options, v.Command, v.Desc, v.Callback)
if e != nil {
return nil, e
}
}
return parse, nil
}
func showErrorAndExit(e error) {
fmt.Fprintf(os.Stderr, "%s", e)
fmt.Fprintln(os.Stderr)
os.Exit(1)
}
func newClient(options *Options) (*ecloud.SRegion, error) {
if len(options.AccessKey) == 0 {
return nil, fmt.Errorf("Missing access key")
}
if len(options.AccessSecret) == 0 {
return nil, fmt.Errorf("Missing access secret")
}
cfg := &httpproxy.Config{
HTTPProxy: os.Getenv("HTTP_PROXY"),
HTTPSProxy: os.Getenv("HTTPS_PROXY"),
NoProxy: os.Getenv("NO_PROXY"),
}
cfgProxyFunc := cfg.ProxyFunc()
proxyFunc := func(req *http.Request) (*url.URL, error) {
return cfgProxyFunc(req.URL)
}
cli, err := ecloud.NewEcloudClient(
ecloud.NewEcloudClientConfig(
ecloud.NewRamRoleSigner(options.AccessKey, options.AccessSecret),
).SetDebug(options.Debug).
SetCloudproviderConfig(
cloudprovider.ProviderConfig{
ProxyFunc: proxyFunc,
},
),
)
if err != nil {
return nil, err
}
region, err := cli.GetRegionById(options.RegionId)
if err != nil {
return nil, err
}
return region, nil
}
func main() {
parser, e := getSubcommandParser()
if e != nil {
showErrorAndExit(e)
}
e = parser.ParseArgs(os.Args[1:], false)
options := parser.Options().(*Options)
if parser.IsHelpSet() {
fmt.Print(parser.HelpString())
return
}
subcmd := parser.GetSubcommand()
subparser := subcmd.GetSubParser()
if e != nil || subparser == nil {
if subparser != nil {
fmt.Print(subparser.Usage())
} else {
fmt.Print(parser.Usage())
}
showErrorAndExit(e)
}
suboptions := subparser.Options()
if subparser.IsHelpSet() {
fmt.Print(subparser.HelpString())
return
}
var region *ecloud.SRegion
region, e = newClient(options)
if e != nil {
showErrorAndExit(e)
}
e = subcmd.Invoke(region, suboptions)
if e != nil {
showErrorAndExit(e)
}
}

View File

@@ -1,146 +0,0 @@
// 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 main
import (
"fmt"
"net/http"
"net/url"
"os"
"golang.org/x/net/http/httpproxy"
"yunion.io/x/structarg"
"yunion.io/x/onecloud/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/multicloud/esxi"
_ "yunion.io/x/onecloud/pkg/multicloud/esxi/shell"
"yunion.io/x/onecloud/pkg/util/shellutils"
)
type BaseOptions struct {
Host string `help:"Host IP or NAME" default:"$VMWARE_HOST" metavar:"VMWARE_HOST"`
Port int `help:"Service port" default:"$VMWARE_PORT" metavar:"VMWARE_PORT"`
Account string `help:"VCenter or ESXi Account" default:"$VMWARE_ACCOUNT" metavar:"VMWARE_ACCOUNT"`
Password string `help:"Password" default:"$VMWARE_PASSWORD" metavar:"VMWARE_PASSWORD"`
Debug bool
Format string `choices:"xml|json" default:"json"`
SUBCOMMAND string `help:"aliyuncli subcommand" subcommand:"true"`
}
func getSubcommandParser() (*structarg.ArgumentParser, error) {
parse, e := structarg.NewArgumentParserWithHelp(&BaseOptions{},
"esxicli",
"Command-line interface to VMware VSphere Webservice API.",
`See "esxicli COMMAND --help" for help on a specific command.`)
if e != nil {
return nil, e
}
subcmd := parse.GetSubcommand()
if subcmd == nil {
return nil, fmt.Errorf("No subcommand argument.")
}
for _, v := range shellutils.CommandTable {
_, e := subcmd.AddSubParserWithHelp(v.Options, v.Command, v.Desc, v.Callback)
if e != nil {
return nil, e
}
}
return parse, nil
}
func showErrorAndExit(e error) {
fmt.Fprintf(os.Stderr, "%s", e)
fmt.Fprintln(os.Stderr)
os.Exit(1)
}
func newClient(options *BaseOptions) (*esxi.SESXiClient, error) {
if len(options.Host) == 0 {
return nil, fmt.Errorf("Missing host")
}
if len(options.Account) == 0 {
return nil, fmt.Errorf("Missing account")
}
if len(options.Password) == 0 {
return nil, fmt.Errorf("Missing password")
}
cfg := &httpproxy.Config{
HTTPProxy: os.Getenv("HTTP_PROXY"),
HTTPSProxy: os.Getenv("HTTPS_PROXY"),
NoProxy: os.Getenv("NO_PROXY"),
}
cfgProxyFunc := cfg.ProxyFunc()
proxyFunc := func(req *http.Request) (*url.URL, error) {
return cfgProxyFunc(req.URL)
}
return esxi.NewESXiClient2(
esxi.NewESXiClientConfig(
options.Host,
options.Port,
options.Account,
options.Password,
).
CloudproviderConfig(
cloudprovider.ProviderConfig{
ProxyFunc: proxyFunc,
},
).Debug(options.Debug).Format(options.Format),
)
}
func main() {
parser, e := getSubcommandParser()
if e != nil {
showErrorAndExit(e)
}
e = parser.ParseArgs(os.Args[1:], false)
options := parser.Options().(*BaseOptions)
if parser.IsHelpSet() {
fmt.Print(parser.HelpString())
return
}
subcmd := parser.GetSubcommand()
subparser := subcmd.GetSubParser()
if e != nil || subparser == nil {
if subparser != nil {
fmt.Print(subparser.Usage())
} else {
fmt.Print(parser.Usage())
}
showErrorAndExit(e)
}
suboptions := subparser.Options()
if subparser.IsHelpSet() {
fmt.Print(subparser.HelpString())
return
}
var esxicli *esxi.SESXiClient
esxicli, e = newClient(options)
if e != nil {
showErrorAndExit(e)
}
e = subcmd.Invoke(esxicli, suboptions)
if e != nil {
showErrorAndExit(e)
}
}

View File

@@ -1,179 +0,0 @@
// 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 main
import (
"fmt"
"net/http"
"net/url"
"os"
"golang.org/x/net/http/httpproxy"
"yunion.io/x/jsonutils"
"yunion.io/x/log"
"yunion.io/x/pkg/errors"
"yunion.io/x/structarg"
"yunion.io/x/onecloud/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/multicloud/google"
_ "yunion.io/x/onecloud/pkg/multicloud/google/shell"
"yunion.io/x/onecloud/pkg/util/fileutils2"
"yunion.io/x/onecloud/pkg/util/shellutils"
)
type BaseOptions struct {
Debug bool `help:"debug mode"`
AuthFile string `help:"google cloud auth json file path" default:"$GOOGLE_AUTH_FILE" metavar:"GOOGLE_AUTH_FILE"`
ClientEmail string `help:"Client email" default:"$GOOGLE_CLIENT_EMAIL" metavar:"GOOGLE_CLIENT_EMAIL"`
ProjectID string `help:"Project ID" default:"$GOOGLE_PROJECT_ID" metavar:"GOOGLE_PROJECT_ID"`
PrivateKeyID string `help:"Private Key ID" default:"$GOOGLE_PRIVATE_KEY_ID" metavar:"GOOGLE_PRIVATE_KEY_ID"`
PrivateKey string `help:"Private Key" default:"$GOOGLE_PRIVATE_KEY" metavar:"GOOGLE_PRIVATE_KEY"`
RegionID string `help:"RegionID" default:"$GOOGLE_REGION" metavar:"GOOGLE_REGION"`
SUBCOMMAND string `help:"googlecli subcommand" subcommand:"true"`
}
func getSubcommandParser() (*structarg.ArgumentParser, error) {
parse, e := structarg.NewArgumentParserWithHelp(&BaseOptions{},
"googlecli",
"Command-line interface to google API.",
`See "googlecli COMMAND --help" for help on a specific command.`)
if e != nil {
return nil, e
}
subcmd := parse.GetSubcommand()
if subcmd == nil {
return nil, fmt.Errorf("No subcommand argument.")
}
for _, v := range shellutils.CommandTable {
_, e := subcmd.AddSubParserWithHelp(v.Options, v.Command, v.Desc, v.Callback)
if e != nil {
return nil, e
}
}
return parse, nil
}
func showErrorAndExit(e error) {
log.Errorf("%s", e)
os.Exit(1)
}
func newClient(options *BaseOptions) (*google.SRegion, error) {
if len(options.AuthFile) > 0 {
jsonStr, err := fileutils2.FileGetContents(options.AuthFile)
if err != nil {
return nil, errors.Wrap(err, "FileGetContents")
}
jsonCfg, err := jsonutils.ParseString(jsonStr)
if err != nil {
return nil, errors.Wrap(err, "jsonutils.ParseString")
}
options.ClientEmail, _ = jsonCfg.GetString("client_email")
options.PrivateKeyID, _ = jsonCfg.GetString("private_key_id")
options.PrivateKey, _ = jsonCfg.GetString("private_key")
options.ProjectID, _ = jsonCfg.GetString("project_id")
}
if len(options.ClientEmail) == 0 {
return nil, fmt.Errorf("Missing ClientEmail")
}
if len(options.PrivateKeyID) == 0 {
return nil, fmt.Errorf("Missing PrivateKeyID")
}
if len(options.PrivateKey) == 0 {
return nil, fmt.Errorf("Missing PrivateKey")
}
if len(options.ProjectID) == 0 {
return nil, fmt.Errorf("Missing ProjectID")
}
cfg := &httpproxy.Config{
HTTPProxy: os.Getenv("HTTP_PROXY"),
HTTPSProxy: os.Getenv("HTTPS_PROXY"),
NoProxy: os.Getenv("NO_PROXY"),
}
cfgProxyFunc := cfg.ProxyFunc()
proxyFunc := func(req *http.Request) (*url.URL, error) {
return cfgProxyFunc(req.URL)
}
cli, err := google.NewGoogleClient(
google.NewGoogleClientConfig(
options.ProjectID,
options.ClientEmail,
options.PrivateKeyID,
options.PrivateKey,
).Debug(options.Debug).
CloudproviderConfig(
cloudprovider.ProviderConfig{
ProxyFunc: proxyFunc,
},
),
)
if err != nil {
return nil, err
}
region := cli.GetRegion(options.RegionID)
if region == nil {
return nil, fmt.Errorf("No such region %s", options.RegionID)
}
return region, nil
}
func main() {
parser, e := getSubcommandParser()
if e != nil {
showErrorAndExit(e)
}
e = parser.ParseArgs(os.Args[1:], false)
options := parser.Options().(*BaseOptions)
if parser.IsHelpSet() {
fmt.Print(parser.HelpString())
return
}
subcmd := parser.GetSubcommand()
subparser := subcmd.GetSubParser()
if e != nil || subparser == nil {
if subparser != nil {
fmt.Print(subparser.Usage())
} else {
fmt.Print(parser.Usage())
}
showErrorAndExit(e)
return
}
suboptions := subparser.Options()
if subparser.IsHelpSet() {
fmt.Print(subparser.HelpString())
return
}
var region *google.SRegion
region, e = newClient(options)
if e != nil {
showErrorAndExit(e)
}
e = subcmd.Invoke(region, suboptions)
if e != nil {
showErrorAndExit(e)
}
}

View File

@@ -1,157 +0,0 @@
// 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 main
import (
"fmt"
"net/http"
"net/url"
"os"
"golang.org/x/net/http/httpproxy"
"yunion.io/x/structarg"
"yunion.io/x/onecloud/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/multicloud/hcs"
_ "yunion.io/x/onecloud/pkg/multicloud/hcs/shell"
"yunion.io/x/onecloud/pkg/util/shellutils"
)
type BaseOptions struct {
Debug bool `help:"debug mode"`
AuthUrl string `help:"Auth url" default:"$HCS_AUTH_URL"`
AccessKey string `help:"Access key" default:"$HCS_ACCESS_KEY" metavar:"HCS_ACCESS_KEY"`
Secret string `help:"Secret" default:"$HCS_SECRET" metavar:"HCS_SECRET"`
RegionId string `help:"RegionId" default:"$HCS_REGION" metavar:"HCS_REGION"`
ProjectId string `help:"RegionId" default:"$HCS_PROJECT_ID" metavar:"HCS_PROJECT_ID"`
SUBCOMMAND string `help:"hcscli subcommand" subcommand:"true"`
}
func getSubcommandParser() (*structarg.ArgumentParser, error) {
parse, e := structarg.NewArgumentParserWithHelp(&BaseOptions{},
"hcscli",
"Command-line interface to hcs API.",
`See "hcscli COMMAND --help" for help on a specific command.`)
if e != nil {
return nil, e
}
subcmd := parse.GetSubcommand()
if subcmd == nil {
return nil, fmt.Errorf("No subcommand argument.")
}
for _, v := range shellutils.CommandTable {
_, e := subcmd.AddSubParserWithHelp(v.Options, v.Command, v.Desc, v.Callback)
if e != nil {
return nil, e
}
}
return parse, nil
}
func showErrorAndExit(e error) {
fmt.Fprintf(os.Stderr, "%s", e)
fmt.Fprintln(os.Stderr)
os.Exit(1)
}
func newClient(options *BaseOptions) (*hcs.SRegion, error) {
if len(options.AccessKey) == 0 {
return nil, fmt.Errorf("Missing accessKey")
}
if len(options.Secret) == 0 {
return nil, fmt.Errorf("Missing secret")
}
if len(options.AuthUrl) == 0 {
return nil, fmt.Errorf("Missing authUrl")
}
if len(options.RegionId) == 0 {
return nil, fmt.Errorf("Missing regionId")
}
cfg := &httpproxy.Config{
HTTPProxy: os.Getenv("HTTP_PROXY"),
HTTPSProxy: os.Getenv("HTTPS_PROXY"),
NoProxy: os.Getenv("NO_PROXY"),
}
cfgProxyFunc := cfg.ProxyFunc()
proxyFunc := func(req *http.Request) (*url.URL, error) {
return cfgProxyFunc(req.URL)
}
cli, err := hcs.NewHcsClient(
hcs.NewHcsConfig(
options.AccessKey,
options.Secret,
options.ProjectId,
options.AuthUrl,
).Debug(options.Debug).
CloudproviderConfig(
cloudprovider.ProviderConfig{
ProxyFunc: proxyFunc,
},
),
)
if err != nil {
return nil, err
}
return cli.GetRegion(options.RegionId)
}
func main() {
parser, e := getSubcommandParser()
if e != nil {
showErrorAndExit(e)
}
e = parser.ParseArgs(os.Args[1:], false)
options := parser.Options().(*BaseOptions)
if parser.IsHelpSet() {
fmt.Print(parser.HelpString())
return
}
subcmd := parser.GetSubcommand()
subparser := subcmd.GetSubParser()
if e != nil || subparser == nil {
if subparser != nil {
fmt.Print(subparser.Usage())
} else {
fmt.Print(parser.Usage())
}
showErrorAndExit(e)
return
}
suboptions := subparser.Options()
if subparser.IsHelpSet() {
fmt.Print(subparser.HelpString())
return
}
var region *hcs.SRegion
region, e = newClient(options)
if e != nil {
showErrorAndExit(e)
}
e = subcmd.Invoke(region, suboptions)
if e != nil {
showErrorAndExit(e)
}
}

View File

@@ -1,154 +0,0 @@
// 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 main
import (
"fmt"
"net/http"
"net/url"
"os"
"golang.org/x/net/http/httpproxy"
"yunion.io/x/structarg"
"yunion.io/x/onecloud/pkg/cloudprovider"
huawei "yunion.io/x/onecloud/pkg/multicloud/hcso"
_ "yunion.io/x/onecloud/pkg/multicloud/hcso/shell"
"yunion.io/x/onecloud/pkg/util/shellutils"
)
type BaseOptions struct {
cloudprovider.SHCSOEndpoints
Debug bool `help:"Show debug" default:"false"`
AccessKey string `help:"Access key" default:"$HUAWEI_ACCESS_KEY" metavar:"HUAWEI_ACCESS_KEY"`
Secret string `help:"Secret" default:"$HUAWEI_SECRET" metavar:"HUAWEI_SECRET"`
RegionId string `help:"RegionId" default:"$HUAWEI_REGION" metavar:"HUAWEI_REGION"`
DEFAULT_REGION string `help:"Default Region" default:"$HUAWEI_DEFAULT_REGION" metavar:"HUAWEI_DEFAULT_REGION"`
ProjectId string `help:"ProjectId" default:"$HUAWEI_PROJECT" metavar:"HUAWEI_PROJECT"`
SUBCOMMAND string `help:"huaweicli subcommand" subcommand:"true"`
}
func getSubcommandParser() (*structarg.ArgumentParser, error) {
parse, e := structarg.NewArgumentParserWithHelp(&BaseOptions{},
"hcsocli",
"Command-line interface to huawei API.",
`See "hcsocli COMMAND --help" for help on a specific command.`)
if e != nil {
return nil, e
}
subcmd := parse.GetSubcommand()
if subcmd == nil {
return nil, fmt.Errorf("No subcommand argument.")
}
for _, v := range shellutils.CommandTable {
_, e := subcmd.AddSubParserWithHelp(v.Options, v.Command, v.Desc, v.Callback)
if e != nil {
return nil, e
}
}
return parse, nil
}
func showErrorAndExit(e error) {
fmt.Fprintf(os.Stderr, "%s", e)
fmt.Fprintln(os.Stderr)
os.Exit(1)
}
func newClient(options *BaseOptions) (*huawei.SRegion, error) {
if len(options.AccessKey) == 0 {
return nil, fmt.Errorf("Missing accessKey")
}
if len(options.Secret) == 0 {
return nil, fmt.Errorf("Missing secret")
}
cfg := &httpproxy.Config{
HTTPProxy: os.Getenv("HTTP_PROXY"),
HTTPSProxy: os.Getenv("HTTPS_PROXY"),
NoProxy: os.Getenv("NO_PROXY"),
}
cfgProxyFunc := cfg.ProxyFunc()
proxyFunc := func(req *http.Request) (*url.URL, error) {
return cfgProxyFunc(req.URL)
}
cli, err := huawei.NewHuaweiClient(
huawei.NewHuaweiClientConfig(
options.AccessKey,
options.Secret,
options.ProjectId,
&options.SHCSOEndpoints,
).Debug(options.Debug).
CloudproviderConfig(
cloudprovider.ProviderConfig{
ProxyFunc: proxyFunc,
DefaultRegion: options.DEFAULT_REGION,
},
),
)
if err != nil {
return nil, err
}
region := cli.GetRegion(options.RegionId)
if region == nil {
return nil, fmt.Errorf("No such region %s", options.RegionId)
}
return region, nil
}
func main() {
parser, e := getSubcommandParser()
if e != nil {
showErrorAndExit(e)
}
e = parser.ParseArgs(os.Args[1:], false)
options := parser.Options().(*BaseOptions)
if parser.IsHelpSet() {
fmt.Print(parser.HelpString())
return
}
subcmd := parser.GetSubcommand()
subparser := subcmd.GetSubParser()
if e != nil || subparser == nil {
if subparser != nil {
fmt.Print(subparser.Usage())
} else {
fmt.Print(parser.Usage())
}
showErrorAndExit(e)
}
suboptions := subparser.Options()
if subparser.IsHelpSet() {
fmt.Print(subparser.HelpString())
return
}
var region *huawei.SRegion
region, e = newClient(options)
if e != nil {
showErrorAndExit(e)
}
e = subcmd.Invoke(region, suboptions)
if e != nil {
showErrorAndExit(e)
}
}

View File

@@ -1,152 +0,0 @@
// 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 main
import (
"fmt"
"net/http"
"net/url"
"os"
"golang.org/x/net/http/httpproxy"
"yunion.io/x/structarg"
"yunion.io/x/onecloud/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/multicloud/huawei"
_ "yunion.io/x/onecloud/pkg/multicloud/huawei/shell"
"yunion.io/x/onecloud/pkg/util/shellutils"
)
type BaseOptions struct {
Debug bool `help:"Show debug" default:"false"`
CloudEnv string `help:"Cloud environment" default:"$HUAWEI_CLOUD_ENV" choices:"ChinaCloud|InternationalCloud" metavar:"HUAWEI_CLOUD_ENV"`
AccessKey string `help:"Access key" default:"$HUAWEI_ACCESS_KEY" metavar:"HUAWEI_ACCESS_KEY"`
Secret string `help:"Secret" default:"$HUAWEI_SECRET" metavar:"HUAWEI_SECRET"`
RegionId string `help:"RegionId" default:"$HUAWEI_REGION" metavar:"HUAWEI_REGION"`
ProjectId string `help:"RegionId" default:"$HUAWEI_PROJECT" metavar:"HUAWEI_PROJECT"`
SUBCOMMAND string `help:"huaweicli subcommand" subcommand:"true"`
}
func getSubcommandParser() (*structarg.ArgumentParser, error) {
parse, e := structarg.NewArgumentParserWithHelp(&BaseOptions{},
"huaweicli",
"Command-line interface to huawei API.",
`See "huaweicli COMMAND --help" for help on a specific command.`)
if e != nil {
return nil, e
}
subcmd := parse.GetSubcommand()
if subcmd == nil {
return nil, fmt.Errorf("No subcommand argument.")
}
for _, v := range shellutils.CommandTable {
_, e := subcmd.AddSubParserWithHelp(v.Options, v.Command, v.Desc, v.Callback)
if e != nil {
return nil, e
}
}
return parse, nil
}
func showErrorAndExit(e error) {
fmt.Fprintf(os.Stderr, "%s", e)
fmt.Fprintln(os.Stderr)
os.Exit(1)
}
func newClient(options *BaseOptions) (*huawei.SRegion, error) {
if len(options.AccessKey) == 0 {
return nil, fmt.Errorf("Missing accessKey")
}
if len(options.Secret) == 0 {
return nil, fmt.Errorf("Missing secret")
}
cfg := &httpproxy.Config{
HTTPProxy: os.Getenv("HTTP_PROXY"),
HTTPSProxy: os.Getenv("HTTPS_PROXY"),
NoProxy: os.Getenv("NO_PROXY"),
}
cfgProxyFunc := cfg.ProxyFunc()
proxyFunc := func(req *http.Request) (*url.URL, error) {
return cfgProxyFunc(req.URL)
}
cli, err := huawei.NewHuaweiClient(
huawei.NewHuaweiClientConfig(
options.CloudEnv,
options.AccessKey,
options.Secret,
options.ProjectId,
).Debug(options.Debug).
CloudproviderConfig(
cloudprovider.ProviderConfig{
ProxyFunc: proxyFunc,
},
),
)
if err != nil {
return nil, err
}
region := cli.GetRegion(options.RegionId)
if region == nil {
return nil, fmt.Errorf("No such region %s", options.RegionId)
}
return region, nil
}
func main() {
parser, e := getSubcommandParser()
if e != nil {
showErrorAndExit(e)
}
e = parser.ParseArgs(os.Args[1:], false)
options := parser.Options().(*BaseOptions)
if parser.IsHelpSet() {
fmt.Print(parser.HelpString())
return
}
subcmd := parser.GetSubcommand()
subparser := subcmd.GetSubParser()
if e != nil || subparser == nil {
if subparser != nil {
fmt.Print(subparser.Usage())
} else {
fmt.Print(parser.Usage())
}
showErrorAndExit(e)
}
suboptions := subparser.Options()
if subparser.IsHelpSet() {
fmt.Print(subparser.HelpString())
return
}
var region *huawei.SRegion
region, e = newClient(options)
if e != nil {
showErrorAndExit(e)
}
e = subcmd.Invoke(region, suboptions)
if e != nil {
showErrorAndExit(e)
}
}

View File

@@ -1,149 +0,0 @@
// 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 main
import (
"fmt"
"net/http"
"net/url"
"os"
"golang.org/x/net/http/httpproxy"
"yunion.io/x/structarg"
"yunion.io/x/onecloud/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/multicloud/incloudsphere"
_ "yunion.io/x/onecloud/pkg/multicloud/incloudsphere/shell"
"yunion.io/x/onecloud/pkg/util/shellutils"
)
type BaseOptions struct {
Debug bool `help:"debug mode"`
Host string `help:"Host" default:"$INCLOUD_SPHERE_HOST" metavar:"INCLOUD_SPHERE_HOST"`
AccessKeyId string `help:"AccessKey" default:"$INCLOUD_SPHERE_ACCESS_KEY_ID" metavar:"INCLOUD_SPHERE_ACCESS_KEY_ID"`
AccessSecret string `help:"AccessSecret" default:"$INCLOUD_SPHERE_ACCESS_KEY_SECRET" metavar:"INCLOUD_SPHERE_ACCESS_SECRET"`
SUBCOMMAND string `help:"incloudspherecli subcommand" subcommand:"true"`
}
func getSubcommandParser() (*structarg.ArgumentParser, error) {
parse, e := structarg.NewArgumentParserWithHelp(&BaseOptions{},
"incloudspherecli",
"Command-line interface to InCloud Sphere API.",
`See "incloudspherecli COMMAND --help" for help on a specific command.`)
if e != nil {
return nil, e
}
subcmd := parse.GetSubcommand()
if subcmd == nil {
return nil, fmt.Errorf("No subcommand argument.")
}
for _, v := range shellutils.CommandTable {
_, e := subcmd.AddSubParserWithHelp(v.Options, v.Command, v.Desc, v.Callback)
if e != nil {
return nil, e
}
}
return parse, nil
}
func showErrorAndExit(e error) {
fmt.Fprintf(os.Stderr, "%s", e)
fmt.Fprintln(os.Stderr)
os.Exit(1)
}
func newClient(options *BaseOptions) (*incloudsphere.SRegion, error) {
if len(options.Host) == 0 {
return nil, fmt.Errorf("Missing host")
}
if len(options.AccessKeyId) == 0 {
return nil, fmt.Errorf("Missing access key id")
}
if len(options.AccessSecret) == 0 {
return nil, fmt.Errorf("Missing access secret")
}
cfg := &httpproxy.Config{
HTTPProxy: os.Getenv("HTTP_PROXY"),
HTTPSProxy: os.Getenv("HTTPS_PROXY"),
NoProxy: os.Getenv("NO_PROXY"),
}
cfgProxyFunc := cfg.ProxyFunc()
proxyFunc := func(req *http.Request) (*url.URL, error) {
return cfgProxyFunc(req.URL)
}
cli, err := incloudsphere.NewSphereClient(
incloudsphere.NewSphereClientConfig(
options.Host,
options.AccessKeyId,
options.AccessSecret,
).Debug(options.Debug).
CloudproviderConfig(
cloudprovider.ProviderConfig{
ProxyFunc: proxyFunc,
},
),
)
if err != nil {
return nil, err
}
return cli.GetRegion()
}
func main() {
parser, e := getSubcommandParser()
if e != nil {
showErrorAndExit(e)
}
e = parser.ParseArgs(os.Args[1:], false)
options := parser.Options().(*BaseOptions)
if parser.IsHelpSet() {
fmt.Print(parser.HelpString())
return
}
subcmd := parser.GetSubcommand()
subparser := subcmd.GetSubParser()
if e != nil || subparser == nil {
if subparser != nil {
fmt.Print(subparser.Usage())
} else {
fmt.Print(parser.Usage())
}
showErrorAndExit(e)
return
}
suboptions := subparser.Options()
if subparser.IsHelpSet() {
fmt.Print(subparser.HelpString())
return
}
var region *incloudsphere.SRegion
region, e = newClient(options)
if e != nil {
showErrorAndExit(e)
}
e = subcmd.Invoke(region, suboptions)
if e != nil {
showErrorAndExit(e)
}
}

View File

@@ -1,151 +0,0 @@
// 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 main
import (
"fmt"
"net/http"
"net/url"
"os"
"github.com/sirupsen/logrus"
"golang.org/x/net/http/httpproxy"
"yunion.io/x/log"
"yunion.io/x/structarg"
"yunion.io/x/onecloud/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/multicloud/jdcloud"
_ "yunion.io/x/onecloud/pkg/multicloud/jdcloud/shell"
"yunion.io/x/onecloud/pkg/util/shellutils"
)
type Options struct {
Debug bool `help:"Show debug" default:"false"`
AccessKey string `help:"Access key" default:"$JDCLOUD_ACCESS_KEY"`
AccessSecret string `help:"Secret" default:"$JDCLOUD_SECRET"`
RegionId string `help:"RegionId" default:"$JDCLOUD_REGION"`
SUBCOMMAND string `help:"jdcloudcli subcommand" subcommand:"true"`
}
func getSubcommandParser() (*structarg.ArgumentParser, error) {
parse, err := structarg.NewArgumentParserWithHelp(&Options{},
"jdcloudcli",
"Command-line interface to ecloud API.",
`See "jdcloudcli COMMAND --help" for help on a specific command.`,
)
if err != nil {
return nil, err
}
subcmd := parse.GetSubcommand()
if subcmd == nil {
return nil, fmt.Errorf("No subcommand argument")
}
for _, v := range shellutils.CommandTable {
_, e := subcmd.AddSubParserWithHelp(v.Options, v.Command, v.Desc, v.Callback)
if e != nil {
return nil, e
}
}
return parse, nil
}
func showErrorAndExit(e error) {
fmt.Fprintf(os.Stderr, "%s", e)
fmt.Fprintln(os.Stderr)
os.Exit(1)
}
func newClient(options *Options) (*jdcloud.SJDCloudClient, error) {
if len(options.AccessKey) == 0 {
return nil, fmt.Errorf("Missing access key")
}
if len(options.AccessSecret) == 0 {
return nil, fmt.Errorf("Missing access secret")
}
regionId := options.RegionId
if regionId == "" {
regionId = jdcloud.JDCLOUD_DEFAULT_REGION
}
cfg := &httpproxy.Config{
HTTPProxy: os.Getenv("HTTP_PROXY"),
HTTPSProxy: os.Getenv("HTTPS_PROXY"),
NoProxy: os.Getenv("NO_PROXY"),
}
cfgProxyFunc := cfg.ProxyFunc()
proxyFunc := func(req *http.Request) (*url.URL, error) {
return cfgProxyFunc(req.URL)
}
cfcg := cloudprovider.ProviderConfig{
ProxyFunc: proxyFunc,
}
return jdcloud.NewJDCloudClient(
jdcloud.NewJDCloudClientConfig(
options.AccessKey,
options.AccessSecret,
).CloudproviderConfig(cfcg).Debug(options.Debug),
)
}
func main() {
parser, err := getSubcommandParser()
if err != nil {
showErrorAndExit(err)
}
err = parser.ParseArgs(os.Args[1:], false)
options := parser.Options().(*Options)
if parser.IsHelpSet() {
fmt.Print(parser.HelpString())
return
}
if options.Debug {
log.SetLogLevel(log.Logger(), logrus.DebugLevel)
} else {
log.SetLogLevel(log.Logger(), logrus.InfoLevel)
}
subcmd := parser.GetSubcommand()
subparser := subcmd.GetSubParser()
if err != nil || subparser == nil {
if subparser != nil {
fmt.Print(subparser.Usage())
} else {
fmt.Print(parser.Usage())
}
showErrorAndExit(err)
}
suboptions := subparser.Options()
if subparser.IsHelpSet() {
fmt.Print(subparser.HelpString())
return
}
client, err := newClient(options)
if err != nil {
showErrorAndExit(err)
}
region := client.GetRegion(options.RegionId)
if region == nil {
fmt.Printf("not found region: %s", options.RegionId)
return
}
err = subcmd.Invoke(region, suboptions)
if err != nil {
showErrorAndExit(err)
}
}

View File

@@ -1,151 +0,0 @@
// 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 main
import (
"fmt"
"net/http"
"net/url"
"os"
"golang.org/x/net/http/httpproxy"
"yunion.io/x/structarg"
"yunion.io/x/onecloud/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/multicloud/nutanix"
_ "yunion.io/x/onecloud/pkg/multicloud/nutanix/shell"
"yunion.io/x/onecloud/pkg/util/shellutils"
)
type BaseOptions struct {
Debug bool `help:"debug mode"`
Host string `help:"Host" default:"$NUTANIX_HOST" metavar:"NUTANIX_HOST"`
Username string `help:"Username" default:"$NUTANIX_USERNAME" metavar:"NUTANIX_USERNAME"`
Password string `help:"Password" default:"$NUTANIX_PASSWORD" metavar:"NUTANIX_PASSWORD"`
Port int `help:"Port" default:"$NUTANIX_PORT|9440" metavar:"NUTANIX_PORT"`
SUBCOMMAND string `help:"ncli subcommand" subcommand:"true"`
}
func getSubcommandParser() (*structarg.ArgumentParser, error) {
parse, e := structarg.NewArgumentParserWithHelp(&BaseOptions{},
"ncli",
"Command-line interface to nutanix API.",
`See "ncli COMMAND --help" for help on a specific command.`)
if e != nil {
return nil, e
}
subcmd := parse.GetSubcommand()
if subcmd == nil {
return nil, fmt.Errorf("No subcommand argument.")
}
for _, v := range shellutils.CommandTable {
_, e := subcmd.AddSubParserWithHelp(v.Options, v.Command, v.Desc, v.Callback)
if e != nil {
return nil, e
}
}
return parse, nil
}
func showErrorAndExit(e error) {
fmt.Fprintf(os.Stderr, "%s", e)
fmt.Fprintln(os.Stderr)
os.Exit(1)
}
func newClient(options *BaseOptions) (*nutanix.SRegion, error) {
if len(options.Host) == 0 {
return nil, fmt.Errorf("Missing host")
}
if len(options.Username) == 0 {
return nil, fmt.Errorf("Missing username")
}
if len(options.Password) == 0 {
return nil, fmt.Errorf("Missing password")
}
cfg := &httpproxy.Config{
HTTPProxy: os.Getenv("HTTP_PROXY"),
HTTPSProxy: os.Getenv("HTTPS_PROXY"),
NoProxy: os.Getenv("NO_PROXY"),
}
cfgProxyFunc := cfg.ProxyFunc()
proxyFunc := func(req *http.Request) (*url.URL, error) {
return cfgProxyFunc(req.URL)
}
cli, err := nutanix.NewNutanixClient(
nutanix.NewNutanixClientConfig(
options.Host,
options.Username,
options.Password,
options.Port,
).Debug(options.Debug).
CloudproviderConfig(
cloudprovider.ProviderConfig{
ProxyFunc: proxyFunc,
},
),
)
if err != nil {
return nil, err
}
return cli.GetRegion()
}
func main() {
parser, e := getSubcommandParser()
if e != nil {
showErrorAndExit(e)
}
e = parser.ParseArgs(os.Args[1:], false)
options := parser.Options().(*BaseOptions)
if parser.IsHelpSet() {
fmt.Print(parser.HelpString())
return
}
subcmd := parser.GetSubcommand()
subparser := subcmd.GetSubParser()
if e != nil || subparser == nil {
if subparser != nil {
fmt.Print(subparser.Usage())
} else {
fmt.Print(parser.Usage())
}
showErrorAndExit(e)
return
}
suboptions := subparser.Options()
if subparser.IsHelpSet() {
fmt.Print(subparser.HelpString())
return
}
var region *nutanix.SRegion
region, e = newClient(options)
if e != nil {
showErrorAndExit(e)
}
e = subcmd.Invoke(region, suboptions)
if e != nil {
showErrorAndExit(e)
}
}

View File

@@ -1,164 +0,0 @@
// 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 main
import (
"fmt"
"net/http"
"net/url"
"os"
"golang.org/x/net/http/httpproxy"
"yunion.io/x/structarg"
"yunion.io/x/onecloud/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/multicloud/openstack"
_ "yunion.io/x/onecloud/pkg/multicloud/openstack/shell"
"yunion.io/x/onecloud/pkg/util/shellutils"
)
type BaseOptions struct {
Debug bool `help:"debug mode"`
AuthURL string `help:"Auth URL" default:"$OPENSTACK_AUTH_URL" metavar:"OPENSTACK_AUTH_URL"`
Username string `help:"Username" default:"$OPENSTACK_USERNAME" metavar:"OPENSTACK_USERNAME"`
Password string `help:"Password" default:"$OPENSTACK_PASSWORD" metavar:"OPENSTACK_PASSWORD"`
Project string `help:"Project" default:"$OPENSTACK_PROJECT" metavar:"OPENSTACK_PROJECT"`
EndpointType string `help:"Project" default:"$OPENSTACK_ENDPOINT_TYPE|internal" metavar:"OPENSTACK_ENDPOINT_TYPE"`
DomainName string `help:"Domain of user" default:"$OPENSTACK_DOMAIN_NAME|Default" metavar:"OPENSTACK_DOMAIN_NAME"`
ProjectDomain string `help:"Domain of project" default:"$OPENSTACK_PROJECT_DOMAIN|Default" metavar:"OPENSTACK_PROJECT_DOMAIN"`
RegionID string `help:"RegionId" default:"$OPENSTACK_REGION_ID" metavar:"OPENSTACK_REGION_ID"`
SUBCOMMAND string `help:"openstackcli subcommand" subcommand:"true"`
}
func getSubcommandParser() (*structarg.ArgumentParser, error) {
parse, e := structarg.NewArgumentParserWithHelp(&BaseOptions{},
"openstackcli",
"Command-line interface to openstack API.",
`See "openstackcli COMMAND --help" for help on a specific command.`)
if e != nil {
return nil, e
}
subcmd := parse.GetSubcommand()
if subcmd == nil {
return nil, fmt.Errorf("No subcommand argument.")
}
for _, v := range shellutils.CommandTable {
_, e := subcmd.AddSubParserWithHelp(v.Options, v.Command, v.Desc, v.Callback)
if e != nil {
return nil, e
}
}
return parse, nil
}
func showErrorAndExit(e error) {
fmt.Fprintf(os.Stderr, "%s", e)
fmt.Fprintln(os.Stderr)
os.Exit(1)
}
func newClient(options *BaseOptions) (*openstack.SRegion, error) {
if len(options.AuthURL) == 0 {
return nil, fmt.Errorf("Missing AuthURL")
}
if len(options.Username) == 0 {
return nil, fmt.Errorf("Missing Username")
}
if len(options.Password) == 0 {
return nil, fmt.Errorf("Missing Password")
}
cfg := &httpproxy.Config{
HTTPProxy: os.Getenv("HTTP_PROXY"),
HTTPSProxy: os.Getenv("HTTPS_PROXY"),
NoProxy: os.Getenv("NO_PROXY"),
}
cfgProxyFunc := cfg.ProxyFunc()
proxyFunc := func(req *http.Request) (*url.URL, error) {
return cfgProxyFunc(req.URL)
}
cli, err := openstack.NewOpenStackClient(
openstack.NewOpenstackClientConfig(
options.AuthURL,
options.Username,
options.Password,
options.Project,
options.ProjectDomain,
).
EndpointType(options.EndpointType).
DomainName(options.DomainName).
Debug(options.Debug).
CloudproviderConfig(
cloudprovider.ProviderConfig{
ProxyFunc: proxyFunc,
},
),
)
if err != nil {
return nil, err
}
region := cli.GetRegion(options.RegionID)
if region == nil {
return nil, fmt.Errorf("No such region %s", options.RegionID)
}
return region, nil
}
func main() {
parser, e := getSubcommandParser()
if e != nil {
showErrorAndExit(e)
}
e = parser.ParseArgs(os.Args[1:], false)
options := parser.Options().(*BaseOptions)
if parser.IsHelpSet() {
fmt.Print(parser.HelpString())
return
}
subcmd := parser.GetSubcommand()
subparser := subcmd.GetSubParser()
if e != nil || subparser == nil {
if subparser != nil {
fmt.Print(subparser.Usage())
} else {
fmt.Print(parser.Usage())
}
showErrorAndExit(e)
}
suboptions := subparser.Options()
if subparser.IsHelpSet() {
fmt.Print(subparser.HelpString())
return
}
var region *openstack.SRegion
if len(options.RegionID) == 0 {
options.RegionID = openstack.OPENSTACK_DEFAULT_REGION
}
region, e = newClient(options)
if e != nil {
showErrorAndExit(e)
}
e = subcmd.Invoke(region, suboptions)
if e != nil {
showErrorAndExit(e)
}
}

View File

@@ -1,152 +0,0 @@
// 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 main
import (
"fmt"
"net/http"
"net/url"
"os"
"golang.org/x/net/http/httpproxy"
"yunion.io/x/structarg"
"yunion.io/x/onecloud/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/multicloud/proxmox"
_ "yunion.io/x/onecloud/pkg/multicloud/proxmox/shell"
"yunion.io/x/onecloud/pkg/util/shellutils"
)
type BaseOptions struct {
Debug bool `help:"debug mode"`
Username string `help:"Username" default:"$PROXMOX_USERNAME" metavar:"PROXMOX_USERNAME"`
Password string `help:"Password" default:"$PROXMOX_PASSWORD" metavar:"PROXMOX_PASSWORD"`
Host string `help:"Host" default:"$PROXMOX_HOST" metavar:"PROXMOX_HOST"`
Port int `help:"Port" default:"$PROXMOX_PORT|8006" metavar:"PROXMOX_PORT"`
SUBCOMMAND string `help:"proxmoxcli subcommand" subcommand:"true"`
}
func getSubcommandParser() (*structarg.ArgumentParser, error) {
parse, e := structarg.NewArgumentParserWithHelp(&BaseOptions{},
"proxmoxcli",
"Command-line interface to proxmoxc API.",
`See "proxmoxcli COMMAND --help" for help on a specific command.`)
if e != nil {
return nil, e
}
subcmd := parse.GetSubcommand()
if subcmd == nil {
return nil, fmt.Errorf("No subcommand argument.")
}
for _, v := range shellutils.CommandTable {
_, e := subcmd.AddSubParserWithHelp(v.Options, v.Command, v.Desc, v.Callback)
if e != nil {
return nil, e
}
}
return parse, nil
}
func showErrorAndExit(e error) {
fmt.Fprintf(os.Stderr, "%s", e)
fmt.Fprintln(os.Stderr)
os.Exit(1)
}
func newClient(options *BaseOptions) (*proxmox.SRegion, error) {
if len(options.Host) == 0 {
return nil, fmt.Errorf("Missing host")
}
if len(options.Username) == 0 {
return nil, fmt.Errorf("Missing username")
}
if len(options.Password) == 0 {
return nil, fmt.Errorf("Missing password")
}
cfg := &httpproxy.Config{
HTTPProxy: os.Getenv("HTTP_PROXY"),
HTTPSProxy: os.Getenv("HTTPS_PROXY"),
NoProxy: os.Getenv("NO_PROXY"),
}
cfgProxyFunc := cfg.ProxyFunc()
proxyFunc := func(req *http.Request) (*url.URL, error) {
return cfgProxyFunc(req.URL)
}
cli, err := proxmox.NewProxmoxClient(
proxmox.NewProxmoxClientConfig(
options.Username,
options.Password,
options.Host,
options.Port,
).Debug(options.Debug).
CloudproviderConfig(
cloudprovider.ProviderConfig{
ProxyFunc: proxyFunc,
},
),
)
if err != nil {
return nil, err
}
return cli.GetRegion(), nil
}
func main() {
parser, e := getSubcommandParser()
if e != nil {
showErrorAndExit(e)
}
e = parser.ParseArgs(os.Args[1:], false)
options := parser.Options().(*BaseOptions)
if parser.IsHelpSet() {
fmt.Print(parser.HelpString())
return
}
subcmd := parser.GetSubcommand()
subparser := subcmd.GetSubParser()
if e != nil || subparser == nil {
if subparser != nil {
fmt.Print(subparser.Usage())
} else {
fmt.Print(parser.Usage())
}
showErrorAndExit(e)
return
}
suboptions := subparser.Options()
if subparser.IsHelpSet() {
fmt.Print(subparser.HelpString())
return
}
var region *proxmox.SRegion
region, e = newClient(options)
if e != nil {
showErrorAndExit(e)
}
e = subcmd.Invoke(region, suboptions)
if e != nil {
showErrorAndExit(e)
}
}

View File

@@ -1,149 +0,0 @@
// 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 main
import (
"fmt"
"net/http"
"net/url"
"os"
"golang.org/x/net/http/httpproxy"
"yunion.io/x/structarg"
"yunion.io/x/onecloud/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/multicloud/qcloud"
_ "yunion.io/x/onecloud/pkg/multicloud/qcloud/shell"
"yunion.io/x/onecloud/pkg/util/shellutils"
)
type BaseOptions struct {
Debug bool `help:"debug mode"`
AppID string `help:"AppID" default:"$QCLOUD_APPID" metavar:"QCLOUD_APPID"`
SecretID string `help:"Secret" default:"$QCLOUD_SECRET_ID" metavar:"QCLOUD_SECRET_ID"`
SecretKey string `help:"Access key" default:"$QCLOUD_SECRET_KEY" metavar:"QCLOUD_SECRET_KEY"`
RegionId string `help:"RegionId" default:"$QCLOUD_REGION" metavar:"QCLOUD_REGION"`
SUBCOMMAND string `help:"azurecli subcommand" subcommand:"true"`
}
func getSubcommandParser() (*structarg.ArgumentParser, error) {
parse, e := structarg.NewArgumentParserWithHelp(&BaseOptions{},
"qcloudcli",
"Command-line interface to tencentcloud API.",
`See "qcloudcli COMMAND --help" for help on a specific command.`)
if e != nil {
return nil, e
}
subcmd := parse.GetSubcommand()
if subcmd == nil {
return nil, fmt.Errorf("No subcommand argument.")
}
for _, v := range shellutils.CommandTable {
_, e := subcmd.AddSubParserWithHelp(v.Options, v.Command, v.Desc, v.Callback)
if e != nil {
return nil, e
}
}
return parse, nil
}
func showErrorAndExit(e error) {
fmt.Fprintf(os.Stderr, "%s", e)
fmt.Fprintln(os.Stderr)
os.Exit(1)
}
func newClient(options *BaseOptions) (*qcloud.SRegion, error) {
if len(options.SecretKey) == 0 {
return nil, fmt.Errorf("Missing SecretKey")
}
if len(options.SecretID) == 0 {
return nil, fmt.Errorf("Missing SecretID")
}
cfg := &httpproxy.Config{
HTTPProxy: os.Getenv("HTTP_PROXY"),
HTTPSProxy: os.Getenv("HTTPS_PROXY"),
NoProxy: os.Getenv("NO_PROXY"),
}
cfgProxyFunc := cfg.ProxyFunc()
proxyFunc := func(req *http.Request) (*url.URL, error) {
return cfgProxyFunc(req.URL)
}
if cli, err := qcloud.NewQcloudClient(
qcloud.NewQcloudClientConfig(
options.SecretID,
options.SecretKey,
).AppId(options.AppID).
Debug(options.Debug).
CloudproviderConfig(
cloudprovider.ProviderConfig{
ProxyFunc: proxyFunc,
},
),
); err != nil {
return nil, err
} else if region := cli.GetRegion(options.RegionId); region == nil {
return nil, fmt.Errorf("No such region %s", options.RegionId)
} else {
return region, nil
}
}
func main() {
parser, e := getSubcommandParser()
if e != nil {
showErrorAndExit(e)
}
e = parser.ParseArgs(os.Args[1:], false)
options := parser.Options().(*BaseOptions)
if parser.IsHelpSet() {
fmt.Print(parser.HelpString())
return
}
subcmd := parser.GetSubcommand()
subparser := subcmd.GetSubParser()
if e != nil || subparser == nil {
if subparser != nil {
fmt.Print(subparser.Usage())
} else {
fmt.Print(parser.Usage())
}
showErrorAndExit(e)
}
suboptions := subparser.Options()
if subparser.IsHelpSet() {
fmt.Print(subparser.HelpString())
return
}
var region *qcloud.SRegion
if len(options.RegionId) == 0 {
options.RegionId = qcloud.QCLOUD_DEFAULT_REGION
}
region, e = newClient(options)
if e != nil {
showErrorAndExit(e)
}
e = subcmd.Invoke(region, suboptions)
if e != nil {
showErrorAndExit(e)
}
}

View File

@@ -1,139 +0,0 @@
// 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 main
import (
"fmt"
"os"
"yunion.io/x/structarg"
api "yunion.io/x/onecloud/pkg/apis/compute"
"yunion.io/x/onecloud/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/multicloud/objectstore"
"yunion.io/x/onecloud/pkg/multicloud/objectstore/ceph"
_ "yunion.io/x/onecloud/pkg/multicloud/objectstore/shell"
"yunion.io/x/onecloud/pkg/multicloud/objectstore/xsky"
"yunion.io/x/onecloud/pkg/util/shellutils"
)
type BaseOptions struct {
Debug bool `help:"debug mode"`
AccessUrl string `help:"Access url" default:"$S3_ACCESS_URL" metavar:"S3_ACCESS_URL"`
AccessKey string `help:"Access key" default:"$S3_ACCESS_KEY" metavar:"S3_ACCESS_KEY"`
Secret string `help:"Secret" default:"$S3_SECRET" metavar:"S3_SECRET"`
Backend string `help:"Backend driver" default:"$S3_BACKEND" metavar:"S3_BACKEND"`
SUBCOMMAND string `help:"s3cli subcommand" subcommand:"true"`
}
func getSubcommandParser() (*structarg.ArgumentParser, error) {
parse, e := structarg.NewArgumentParserWithHelp(&BaseOptions{},
"s3cli",
"Command-line interface to standard S3 API.",
`See "s3cli COMMAND --help" for help on a specific command.`)
if e != nil {
return nil, e
}
subcmd := parse.GetSubcommand()
if subcmd == nil {
return nil, fmt.Errorf("No subcommand argument.")
}
for _, v := range shellutils.CommandTable {
_, e := subcmd.AddSubParserWithHelp(v.Options, v.Command, v.Desc, v.Callback)
if e != nil {
return nil, e
}
}
return parse, nil
}
func showErrorAndExit(e error) {
fmt.Fprintf(os.Stderr, "%s", e)
fmt.Fprintln(os.Stderr)
os.Exit(1)
}
func newClient(options *BaseOptions) (cloudprovider.ICloudRegion, error) {
if len(options.AccessUrl) == 0 {
return nil, fmt.Errorf("Missing accessUrl")
}
if len(options.AccessKey) == 0 {
return nil, fmt.Errorf("Missing accessKey")
}
if len(options.Secret) == 0 {
return nil, fmt.Errorf("Missing secret")
}
if options.Backend == api.CLOUD_PROVIDER_CEPH {
return ceph.NewCephRados(
objectstore.NewObjectStoreClientConfig(
options.AccessUrl, options.AccessKey, options.Secret,
).Debug(options.Debug),
)
} else if options.Backend == api.CLOUD_PROVIDER_XSKY {
return xsky.NewXskyClient(
objectstore.NewObjectStoreClientConfig(
options.AccessUrl, options.AccessKey, options.Secret,
).Debug(options.Debug),
)
}
return objectstore.NewObjectStoreClient(
objectstore.NewObjectStoreClientConfig(
options.AccessUrl, options.AccessKey, options.Secret,
).Debug(options.Debug),
)
}
func main() {
parser, e := getSubcommandParser()
if e != nil {
showErrorAndExit(e)
}
e = parser.ParseArgs(os.Args[1:], false)
options := parser.Options().(*BaseOptions)
if parser.IsHelpSet() {
fmt.Print(parser.HelpString())
return
}
subcmd := parser.GetSubcommand()
subparser := subcmd.GetSubParser()
if e != nil || subparser == nil {
if subparser != nil {
fmt.Print(subparser.Usage())
} else {
fmt.Print(parser.Usage())
}
showErrorAndExit(e)
}
suboptions := subparser.Options()
if subparser.IsHelpSet() {
fmt.Print(subparser.HelpString())
return
}
var client cloudprovider.ICloudRegion
client, e = newClient(options)
if e != nil {
showErrorAndExit(e)
}
e = subcmd.Invoke(client, suboptions)
if e != nil {
showErrorAndExit(e)
}
}

View File

@@ -1,150 +0,0 @@
// 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 main
import (
"fmt"
"net/http"
"net/url"
"os"
"golang.org/x/net/http/httpproxy"
"yunion.io/x/structarg"
"yunion.io/x/onecloud/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/multicloud/ucloud"
_ "yunion.io/x/onecloud/pkg/multicloud/ucloud/shell"
"yunion.io/x/onecloud/pkg/util/shellutils"
)
type BaseOptions struct {
Debug bool `help:"Show debug" default:"false"`
AccessKey string `help:"Access key" default:"$UCLOUD_ACCESS_KEY" metavar:"UCLOUD_ACCESS_KEY"`
Secret string `help:"Secret" default:"$UCLOUD_SECRET" metavar:"UCLOUD_SECRET"`
RegionId string `help:"RegionId" default:"$UCLOUD_REGION" metavar:"UCLOUD_REGION"`
ProjectId string `help:"ProjectId" default:"$UCLOUD_PROJECT" metavar:"UCLOUD_PROJECT"`
SUBCOMMAND string `help:"ucloudcli subcommand" subcommand:"true"`
}
func getSubcommandParser() (*structarg.ArgumentParser, error) {
parse, e := structarg.NewArgumentParserWithHelp(&BaseOptions{},
"ucloudcli",
"Command-line interface to ucloud API.",
`See "ucloudcli COMMAND --help" for help on a specific command.`)
if e != nil {
return nil, e
}
subcmd := parse.GetSubcommand()
if subcmd == nil {
return nil, fmt.Errorf("No subcommand argument.")
}
for _, v := range shellutils.CommandTable {
_, e := subcmd.AddSubParserWithHelp(v.Options, v.Command, v.Desc, v.Callback)
if e != nil {
return nil, e
}
}
return parse, nil
}
func showErrorAndExit(e error) {
fmt.Fprintf(os.Stderr, "%s", e)
fmt.Fprintln(os.Stderr)
os.Exit(1)
}
func newClient(options *BaseOptions) (*ucloud.SRegion, error) {
if len(options.AccessKey) == 0 {
return nil, fmt.Errorf("Missing accessKey")
}
if len(options.Secret) == 0 {
return nil, fmt.Errorf("Missing secret")
}
cfg := &httpproxy.Config{
HTTPProxy: os.Getenv("HTTP_PROXY"),
HTTPSProxy: os.Getenv("HTTPS_PROXY"),
NoProxy: os.Getenv("NO_PROXY"),
}
cfgProxyFunc := cfg.ProxyFunc()
proxyFunc := func(req *http.Request) (*url.URL, error) {
return cfgProxyFunc(req.URL)
}
cli, err := ucloud.NewUcloudClient(
ucloud.NewUcloudClientConfig(
options.AccessKey,
options.Secret,
).ProjectId(options.ProjectId).Debug(options.Debug).
CloudproviderConfig(
cloudprovider.ProviderConfig{
ProxyFunc: proxyFunc,
},
),
)
if err != nil {
return nil, err
}
region := cli.GetRegion(options.RegionId)
if region == nil {
return nil, fmt.Errorf("No such region %s", options.RegionId)
}
return region, nil
}
func main() {
parser, e := getSubcommandParser()
if e != nil {
showErrorAndExit(e)
}
e = parser.ParseArgs(os.Args[1:], false)
options := parser.Options().(*BaseOptions)
if parser.IsHelpSet() {
fmt.Print(parser.HelpString())
return
}
subcmd := parser.GetSubcommand()
subparser := subcmd.GetSubParser()
if e != nil || subparser == nil {
if subparser != nil {
fmt.Print(subparser.Usage())
} else {
fmt.Print(parser.Usage())
}
showErrorAndExit(e)
}
suboptions := subparser.Options()
if subparser.IsHelpSet() {
fmt.Print(subparser.HelpString())
return
}
var region *ucloud.SRegion
region, e = newClient(options)
if e != nil {
showErrorAndExit(e)
}
e = subcmd.Invoke(region, suboptions)
if e != nil {
showErrorAndExit(e)
}
}

View File

@@ -1,155 +0,0 @@
// 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 main
import (
"fmt"
"net/http"
"net/url"
"os"
"golang.org/x/net/http/httpproxy"
"yunion.io/x/structarg"
"yunion.io/x/onecloud/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/multicloud/zstack"
_ "yunion.io/x/onecloud/pkg/multicloud/zstack/shell"
"yunion.io/x/onecloud/pkg/util/shellutils"
)
type BaseOptions struct {
Debug bool `help:"debug mode"`
AuthURL string `help:"Auth URL" default:"$ZSTACK_AUTH_URL" metavar:"ZSTACK_AUTH_URL"`
Username string `help:"Username" default:"$ZSTACK_USERNAME" metavar:"ZSTACK_USERNAME"`
Password string `help:"Password" default:"$ZSTACK_PASSWORD" metavar:"ZSTACK_PASSWORD"`
RegionID string `help:"RegionId" default:"$ZSTACK_REGION_ID" metavar:"ZSTACK_REGION_ID"`
SUBCOMMAND string `help:"zstackcli subcommand" subcommand:"true"`
}
func getSubcommandParser() (*structarg.ArgumentParser, error) {
parse, e := structarg.NewArgumentParserWithHelp(&BaseOptions{},
"zstackcli",
"Command-line interface to zstack API.",
`See "zstackcli COMMAND --help" for help on a specific command.`)
if e != nil {
return nil, e
}
subcmd := parse.GetSubcommand()
if subcmd == nil {
return nil, fmt.Errorf("No subcommand argument.")
}
for _, v := range shellutils.CommandTable {
_, e := subcmd.AddSubParserWithHelp(v.Options, v.Command, v.Desc, v.Callback)
if e != nil {
return nil, e
}
}
return parse, nil
}
func showErrorAndExit(e error) {
fmt.Fprintf(os.Stderr, "%s", e)
fmt.Fprintln(os.Stderr)
os.Exit(1)
}
func newClient(options *BaseOptions) (*zstack.SRegion, error) {
if len(options.AuthURL) == 0 {
return nil, fmt.Errorf("Missing AuthURL")
}
if len(options.Username) == 0 {
return nil, fmt.Errorf("Missing Username")
}
if len(options.Password) == 0 {
return nil, fmt.Errorf("Missing Password")
}
cfg := &httpproxy.Config{
HTTPProxy: os.Getenv("HTTP_PROXY"),
HTTPSProxy: os.Getenv("HTTPS_PROXY"),
NoProxy: os.Getenv("NO_PROXY"),
}
cfgProxyFunc := cfg.ProxyFunc()
proxyFunc := func(req *http.Request) (*url.URL, error) {
return cfgProxyFunc(req.URL)
}
cli, err := zstack.NewZStackClient(
zstack.NewZstackClientConfig(
options.AuthURL,
options.Username,
options.Password,
).Debug(options.Debug).
CloudproviderConfig(
cloudprovider.ProviderConfig{
ProxyFunc: proxyFunc,
},
),
)
if err != nil {
return nil, err
}
region := cli.GetRegion(options.RegionID)
if region == nil {
return nil, fmt.Errorf("No such region %s", options.RegionID)
}
return region, nil
}
func main() {
parser, e := getSubcommandParser()
if e != nil {
showErrorAndExit(e)
}
e = parser.ParseArgs(os.Args[1:], false)
options := parser.Options().(*BaseOptions)
if parser.IsHelpSet() {
fmt.Print(parser.HelpString())
return
}
subcmd := parser.GetSubcommand()
subparser := subcmd.GetSubParser()
if e != nil || subparser == nil {
if subparser != nil {
fmt.Print(subparser.Usage())
} else {
fmt.Print(parser.Usage())
}
showErrorAndExit(e)
}
suboptions := subparser.Options()
if subparser.IsHelpSet() {
fmt.Print(subparser.HelpString())
return
}
var region *zstack.SRegion
if len(options.RegionID) == 0 {
options.RegionID = zstack.ZSTACK_DEFAULT_REGION
}
region, e = newClient(options)
if e != nil {
showErrorAndExit(e)
}
e = subcmd.Invoke(region, suboptions)
if e != nil {
showErrorAndExit(e)
}
}

49
go.mod
View File

@@ -4,20 +4,10 @@ go 1.18
require (
bazil.org/fuse v0.0.0-20180421153158-65cc252bf669
cloud.google.com/go/storage v1.10.0
github.com/360EntSecGroup-Skylar/excelize v1.4.0
github.com/Azure/azure-sdk-for-go v36.1.0+incompatible
github.com/Azure/go-autorest/autorest v0.9.6
github.com/Azure/go-autorest/autorest/azure/auth v0.4.2
github.com/LeeEirc/terminalparser v0.0.0-20220328021224-de16b7643ea4
github.com/Masterminds/sprig v2.22.0+incompatible
github.com/Microsoft/azure-vhd-utils v0.0.0-20181115010904-44cbada2ece3
github.com/aliyun/alibaba-cloud-sdk-go v1.61.684
github.com/aliyun/aliyun-oss-go-sdk v2.0.4+incompatible
github.com/anacrolix/torrent v0.0.0-20181129073333-cc531b8c4a80
github.com/aokoli/goutils v1.0.1
github.com/aws/aws-sdk-go v1.39.0
github.com/basgys/goxml2json v1.1.1-0.20181031222924-996d9fc8d313
github.com/benbjohnson/clock v1.0.0
github.com/bitly/go-simplejson v0.5.0
github.com/c-bata/go-prompt v0.2.4
@@ -25,7 +15,7 @@ require (
github.com/coredns/coredns v1.3.0
github.com/coreos/go-iptables v0.6.0
github.com/creack/pty v1.1.11
github.com/fatih/color v1.10.0
github.com/fatih/color v1.13.0
github.com/fernet/fernet-go v0.0.0-20180830025343-9eac43b88a5e
github.com/fsnotify/fsnotify v1.4.9
github.com/ghodss/yaml v1.0.0
@@ -42,15 +32,12 @@ require (
github.com/gorilla/websocket v1.4.1
github.com/gosuri/uitable v0.0.0-20160404203958-36ee7e946282
github.com/hako/durafmt v0.0.0-20180520121703-7b7ae1e72ead
github.com/huaweicloud/huaweicloud-sdk-go v1.0.26
github.com/huaweicloud/huaweicloud-sdk-go-obs v3.21.12+incompatible
github.com/jaypipes/ghw v0.9.1
github.com/jdcloud-api/jdcloud-sdk-go v1.55.0
github.com/koding/websocketproxy v0.0.0-20181220232114-7ed82d81a28c
github.com/lestrrat-go/jwx v1.0.2
github.com/lestrrat/go-jwx v0.0.0-20180221005942-b7d4802280ae
github.com/libvirt/libvirt-go-xml v5.2.0+incompatible
github.com/ma314smith/signedxml v0.0.0-20200410192636-c342a2d0ae60
github.com/ma314smith/signedxml v0.0.0-20210628192057-abc5b481ae1c
github.com/mattn/go-sqlite3 v1.14.12
github.com/mdlayher/arp v0.0.0-20190313224443-98a83c8a2717
github.com/mdlayher/ethernet v0.0.0-20190606142754-0394541c37b7
@@ -66,28 +53,23 @@ require (
github.com/serialx/hashring v0.0.0-20180504054112-49a4782e9908
github.com/sevlyar/go-daemon v0.1.5
github.com/shirou/gopsutil v3.21.11+incompatible
github.com/sirupsen/logrus v1.9.0
github.com/skip2/go-qrcode v0.0.0-20190110000554-dc11ecdae0a9
github.com/smartystreets/goconvey v1.6.4
github.com/stretchr/testify v1.7.2
github.com/tatsushid/go-fastping v0.0.0-20160109021039-d7bb493dee3e
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.413
github.com/tencentyun/cos-go-sdk-v5 v0.7.24
github.com/tjfoc/gmsm v1.4.1
github.com/tredoe/osutil v0.0.0-20161130133508-7d3ee1afa71c
github.com/vishvananda/netlink v1.0.0
github.com/tredoe/osutil v1.0.6
github.com/vishvananda/netlink v1.1.0
github.com/vishvananda/netns v0.0.0-20211101163701-50045581ed74
github.com/vmihailenco/msgpack v4.0.4+incompatible
github.com/vmware/govmomi v0.20.1
go.etcd.io/etcd/api/v3 v3.5.0
go.etcd.io/etcd/client/v3 v3.5.0
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4
golang.org/x/net v0.0.0-20220418201149-a630d4f3e7a2
golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
golang.org/x/sys v0.0.0-20220829200755-d48e67d00261
golang.org/x/text v0.3.7
golang.org/x/time v0.0.0-20191024005414-555d28b269f0
golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1
golang.zx2c4.com/wireguard/wgctrl v0.0.0-20191008142428-8d021180e987
google.golang.org/grpc v1.38.0
@@ -101,6 +83,7 @@ require (
k8s.io/client-go v0.19.3
k8s.io/cluster-bootstrap v0.19.3
moul.io/http2curl/v2 v2.3.0
yunion.io/x/cloudmux v0.3.10-0-alpha.0
yunion.io/x/executor v0.0.0-20211018100936-39a2cd966656
yunion.io/x/jsonutils v1.0.1-0.20220819091305-3bab322ab4fd
yunion.io/x/log v1.0.0
@@ -113,7 +96,11 @@ require (
require (
cloud.google.com/go v0.65.0 // indirect
cloud.google.com/go/storage v1.10.0 // indirect
github.com/Azure/azure-sdk-for-go v36.1.0+incompatible // indirect
github.com/Azure/go-autorest/autorest v0.9.6 // indirect
github.com/Azure/go-autorest/autorest/adal v0.8.2 // indirect
github.com/Azure/go-autorest/autorest/azure/auth v0.4.2 // indirect
github.com/Azure/go-autorest/autorest/azure/cli v0.3.1 // indirect
github.com/Azure/go-autorest/autorest/date v0.2.0 // indirect
github.com/Azure/go-autorest/autorest/to v0.4.0 // indirect
@@ -124,11 +111,14 @@ require (
github.com/DataDog/zstd v1.3.4 // indirect
github.com/Masterminds/goutils v1.1.0 // indirect
github.com/Masterminds/semver v1.5.0 // indirect
github.com/Microsoft/azure-vhd-utils v0.0.0-20181115010904-44cbada2ece3 // indirect
github.com/RoaringBitmap/roaring v0.4.16 // indirect
github.com/Shopify/sarama v1.20.0 // indirect
github.com/Shopify/toxiproxy v2.1.4+incompatible // indirect
github.com/StackExchange/wmi v1.2.1 // indirect
github.com/VividCortex/ewma v1.1.1 // indirect
github.com/aliyun/alibaba-cloud-sdk-go v1.61.684 // indirect
github.com/aliyun/aliyun-oss-go-sdk v2.0.4+incompatible // indirect
github.com/anacrolix/dht v0.0.0-20181129074040-b09db78595aa // indirect
github.com/anacrolix/go-libutp v0.0.0-20180808010927-aebbeb60ea05 // indirect
github.com/anacrolix/log v0.0.0-20180808012509-286fcf906b48 // indirect
@@ -136,8 +126,11 @@ require (
github.com/anacrolix/mmsg v0.0.0-20180808012353-5adb2c1127c0 // indirect
github.com/anacrolix/sync v0.0.0-20180808010631-44578de4e778 // indirect
github.com/anacrolix/utp v0.0.0-20180219060659-9e0e1d1d0572 // indirect
github.com/aokoli/goutils v1.0.1 // indirect
github.com/apache/thrift v0.12.0 // indirect
github.com/aws/aws-sdk-go v1.39.0 // indirect
github.com/baiyubin/aliyun-sts-go-sdk v0.0.0-20180326062324-cfa1a18b161f // indirect
github.com/basgys/goxml2json v1.1.1-0.20181031222924-996d9fc8d313 // indirect
github.com/beevik/etree v1.1.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 // indirect
@@ -185,7 +178,10 @@ require (
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 // indirect
github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645 // indirect
github.com/huandu/xstrings v1.2.0 // indirect
github.com/huaweicloud/huaweicloud-sdk-go v1.0.26 // indirect
github.com/huaweicloud/huaweicloud-sdk-go-obs v3.21.12+incompatible // indirect
github.com/imdario/mergo v0.3.6 // indirect
github.com/jdcloud-api/jdcloud-sdk-go v1.55.0 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/jstemmer/go-junit-report v0.9.1 // indirect
@@ -195,7 +191,7 @@ require (
github.com/lestrrat-go/iter v0.0.0-20200422075355-fc1769541911 // indirect
github.com/lestrrat-go/pdebug v0.0.0-20200204225717-4d6bd78da58d // indirect
github.com/lestrrat/go-pdebug v0.0.0-20180220043741-569c97477ae8 // indirect
github.com/mattn/go-colorable v0.1.8 // indirect
github.com/mattn/go-colorable v0.1.9 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/mattn/go-runewidth v0.0.13 // indirect
github.com/mattn/go-tty v0.0.0-20181127064339-e4f871175a2f // indirect
@@ -226,15 +222,19 @@ require (
github.com/rivo/uniseg v0.2.0 // indirect
github.com/ryszard/goskiplist v0.0.0-20150312221310-2dfbae5fcf46 // indirect
github.com/satori/go.uuid v1.2.0 // indirect
github.com/sirupsen/logrus v1.9.0 // indirect
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d // indirect
github.com/spaolacci/murmur3 v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stretchr/objx v0.1.1 // indirect
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.413 // indirect
github.com/tencentyun/cos-go-sdk-v5 v0.7.24 // indirect
github.com/texttheater/golang-levenshtein v0.0.0-20180516184445-d188e65d659e // indirect
github.com/tinylib/msgp v1.1.0 // indirect
github.com/tklauser/go-sysconf v0.3.10 // indirect
github.com/tklauser/numcpus v0.4.0 // indirect
github.com/ugorji/go/codec v1.1.7 // indirect
github.com/vmware/govmomi v0.20.1 // indirect
github.com/willf/bitset v1.1.9 // indirect
github.com/willf/bloom v2.0.3+incompatible // indirect
github.com/yusufpapurcu/wmi v1.2.2 // indirect
@@ -245,6 +245,7 @@ require (
go.uber.org/zap v1.17.0 // indirect
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 // indirect
golang.org/x/mod v0.4.2 // indirect
golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c // indirect
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
golang.org/x/tools v0.1.2 // indirect
google.golang.org/api v0.30.0 // indirect

28
go.sum
View File

@@ -3,7 +3,6 @@ bazil.org/fuse v0.0.0-20180421153158-65cc252bf669/go.mod h1:Xbm+BRKSBEpa4q4hTSxo
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU=
cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU=
cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU=
cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY=
cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc=
@@ -242,8 +241,9 @@ github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7
github.com/evanphx/json-patch v4.9.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk=
github.com/farsightsec/golang-framestream v0.0.0-20181102145529-8a0cb8ba8710 h1:QdyRyGZWLEvJG5Kw3VcVJvhXJ5tZ1MkRgqpJOEZSySM=
github.com/farsightsec/golang-framestream v0.0.0-20181102145529-8a0cb8ba8710/go.mod h1:eNde4IQyEiA5br02AouhEHCu3p3UzrCdFR4LuQHklMI=
github.com/fatih/color v1.10.0 h1:s36xzo75JdqLaaWoiEHk767eHiwo0598uUxyfiPkDsg=
github.com/fatih/color v1.10.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM=
github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w=
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
github.com/fernet/fernet-go v0.0.0-20180830025343-9eac43b88a5e h1:P10tZmVD2XclAaT9l7OduMH1OLFzTa1wUuUqHZnEdI0=
github.com/fernet/fernet-go v0.0.0-20180830025343-9eac43b88a5e/go.mod h1:2H9hjfbpSMHwY503FclkV/lZTBh2YlOmLLSda12uL8c=
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568 h1:BHsljHzVlRcyQhjrss6TZTdY2VfCqZPbv5k3iBFa2ZQ=
@@ -486,13 +486,14 @@ github.com/lestrrat/go-pdebug v0.0.0-20180220043741-569c97477ae8/go.mod h1:VXFH1
github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/libvirt/libvirt-go-xml v5.2.0+incompatible h1:ALyVpa0/lFfFaUpb5l0fNBohufmQG6jsOGRCl/nKEi8=
github.com/libvirt/libvirt-go-xml v5.2.0+incompatible/go.mod h1:oBlgD3xOA01ihiK5stbhFzvieyW+jVS6kbbsMVF623A=
github.com/ma314smith/signedxml v0.0.0-20200410192636-c342a2d0ae60 h1:q5rqPuvxdOzg1NC6sls3XSpRokQ5KAmLIYdLW1/kyOo=
github.com/ma314smith/signedxml v0.0.0-20200410192636-c342a2d0ae60/go.mod h1:KEgVcb43+f5KFUH/x6Vd3NROG0AIL2CuKMrIqYsmx6E=
github.com/ma314smith/signedxml v0.0.0-20210628192057-abc5b481ae1c h1:UPJygtyk491bJJ/DnRJFuzcq9Dl9NSeFrJ7VdiRzMxc=
github.com/ma314smith/signedxml v0.0.0-20210628192057-abc5b481ae1c/go.mod h1:KEgVcb43+f5KFUH/x6Vd3NROG0AIL2CuKMrIqYsmx6E=
github.com/mailru/easyjson v0.0.0-20160728113105-d5b7844b561a/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
github.com/mattn/go-colorable v0.1.8 h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8=
github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-colorable v0.1.9 h1:sqDoxXbdeALODt0DAeJCVp38ps9ZogZEAXjus69YV3U=
github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
@@ -694,13 +695,16 @@ github.com/tklauser/go-sysconf v0.3.10 h1:IJ1AZGZRWbY8T5Vfk04D9WOA5WSejdflXxP03O
github.com/tklauser/go-sysconf v0.3.10/go.mod h1:C8XykCvCb+Gn0oNCWPIlcb0RuglQTYaQ2hGm7jmxEFk=
github.com/tklauser/numcpus v0.4.0 h1:E53Dm1HjH1/R2/aoCtXtPgzmElmn51aOkhCFSuZq//o=
github.com/tklauser/numcpus v0.4.0/go.mod h1:1+UI3pD8NW14VMwdgJNJ1ESk2UnwhAnz5hMwiKKqXCQ=
github.com/tredoe/osutil v0.0.0-20161130133508-7d3ee1afa71c h1:5q7IHeqvAA4hWR1CfpTOS7RFsTDC36TaSZ8Dvc00bPk=
github.com/tredoe/osutil v0.0.0-20161130133508-7d3ee1afa71c/go.mod h1:M/I710pXKQToMdqt/D+mJ4QsnW6WDaajyB6DWFmDXBs=
github.com/tredoe/fileutil v1.0.5/go.mod h1:HFzzpvg+3Q8LgmZgo1mVF5epHc/CVkWKEb3hja+/1Zo=
github.com/tredoe/goutil v1.0.0/go.mod h1:Qhf75QLcNEChimbl4wb8nROzw9PCFCPYTEUmTnoszXY=
github.com/tredoe/osutil v1.0.6 h1:KJvG9AFmUPLe3hsNKyPMIjNx77CkAJtMKVS4ugAT7vM=
github.com/tredoe/osutil v1.0.6/go.mod h1:zNq93p2DLHJWkHi2/+zi3xOjZl8xxiv3tiI2A6zcB3w=
github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw=
github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs=
github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY=
github.com/vishvananda/netlink v1.0.0 h1:bqNY2lgheFIu1meHUFSH3d7vG93AFyqg3oGbJCOJgSM=
github.com/vishvananda/netlink v1.0.0/go.mod h1:+SR5DhBJrl6ZM7CoCKvpw5BKroDKQ+PJqOg65H/2ktk=
github.com/vishvananda/netlink v1.1.0 h1:1iyaYNBLmP6L0220aDnYQpo1QEV4t4hJ+xEEhhJH8j0=
github.com/vishvananda/netlink v1.1.0/go.mod h1:cTgwzPIzzgDAYoQrMm0EdrjRUBkTqKYppBueQtXaqoE=
github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df/go.mod h1:JP3t17pCcGlemwknint6hfoeCVQrEMVwxRLRjXpq+BU=
github.com/vishvananda/netns v0.0.0-20211101163701-50045581ed74 h1:gga7acRE695APm9hlsSMoOoE65U4/TcqNj90mc69Rlg=
github.com/vishvananda/netns v0.0.0-20211101163701-50045581ed74/go.mod h1:DD4vA1DwXk04H54A1oHXtwZmA0grkVMdPxx/VGLCah0=
github.com/vmihailenco/msgpack v4.0.4+incompatible h1:dSLoQfGFAo3F6OoNhwUmLwVgaUXK79GlxNBwueZn0xI=
@@ -872,6 +876,7 @@ golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190606122018-79a91cf218c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190606203320-7fc4e5ec1444/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@@ -936,8 +941,9 @@ golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20191024005414-555d28b269f0 h1:/5xXl8Y5W96D+TtHSlonuFqGHIWVuyCkGJLwGh9JJFs=
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba h1:O8mE0/t419eoIwhTFpKVkHiTs/Igowgfkj25AcZrtiE=
golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20181011042414-1f849cf54d09/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
@@ -1156,6 +1162,8 @@ sigs.k8s.io/structured-merge-diff/v4 v4.0.1/go.mod h1:bJZC9H9iH24zzfZ/41RGcq60oK
sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
sigs.k8s.io/yaml v1.2.0 h1:kr/MCeFWJWTwyaHoR9c8EjH9OumOmoF9YGiZd7lFm/Q=
sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc=
yunion.io/x/cloudmux v0.3.10-0-alpha.0 h1:lHjIqTm/VYxKZ3XHcIIfQ+/qOdDG3aP+8IypXoR2uqw=
yunion.io/x/cloudmux v0.3.10-0-alpha.0/go.mod h1:V2DwCkdaS+IZ/qrNlO1bSZY0mccB3tw/xqZ75GuAXyU=
yunion.io/x/executor v0.0.0-20211018100936-39a2cd966656 h1:0zlZD5uhZoIHgLVAWCz2aHaYk2ZrNsACCYD7R6EIBII=
yunion.io/x/executor v0.0.0-20211018100936-39a2cd966656/go.mod h1:Uxuou9WQIeJXNpy7t2fPLL0BYLvLiMvGQwY7Qc6aSws=
yunion.io/x/jsonutils v0.0.0-20190625054549-a964e1e8a051/go.mod h1:4N0/RVzsYL3kH3WE/H1BjUQdFiWu50JGCFQuuy+Z634=

View File

@@ -226,8 +226,8 @@ type ModelSetUpdateResult struct {
// ModelSetApplyUpdates applies bSet to aSet.
//
// - PendingDeleted in bSet are removed from aSet
// - Newer models in bSet are updated in aSet
// - PendingDeleted in bSet are removed from aSet
// - Newer models in bSet are updated in aSet
func ModelSetApplyUpdates(aSet, bSet IModelSet) *ModelSetUpdateResult {
r := &ModelSetUpdateResult{
Changed: false,

View File

@@ -14,9 +14,9 @@
package cloudprovider
import "yunion.io/x/onecloud/pkg/cloudprovider"
import "yunion.io/x/cloudmux/pkg/cloudprovider"
// DefaultAction is an autogenerated struct via yunion.io/x/onecloud/pkg/cloudprovider.DefaultAction.
// DefaultAction is an autogenerated struct via yunion.io/x/cloudmux/pkg/cloudprovider.DefaultAction.
type DefaultAction struct {
// Allow, Block, Log, Count, Alert, Detection, Prevention
Action string `json:"action"`
@@ -30,7 +30,7 @@ type DefaultAction struct {
ResponseHeaders map[string]string `json:"response_headers"`
}
// SCdnDomain is an autogenerated struct via yunion.io/x/onecloud/pkg/cloudprovider.SCdnDomain.
// SCdnDomain is an autogenerated struct via yunion.io/x/cloudmux/pkg/cloudprovider.SCdnDomain.
type SCdnDomain struct {
// cdn加速域名
Domain string `json:"domain"`
@@ -46,7 +46,7 @@ type SCdnDomain struct {
OriginType string `json:"origin_type"`
}
// SCdnOrigin is an autogenerated struct via yunion.io/x/onecloud/pkg/cloudprovider.SCdnOrigin.
// SCdnOrigin is an autogenerated struct via yunion.io/x/cloudmux/pkg/cloudprovider.SCdnOrigin.
type SCdnOrigin struct {
Type string `json:"type"`
Origin string `json:"origin"`
@@ -58,18 +58,18 @@ type SCdnOrigin struct {
Priority int `json:"priority"`
}
// SCdnOrigins is an autogenerated struct via yunion.io/x/onecloud/pkg/cloudprovider.SCdnOrigins.
// SCdnOrigins is an autogenerated struct via yunion.io/x/cloudmux/pkg/cloudprovider.SCdnOrigins.
type SCdnOrigins []SCdnOrigin
// SExcludeRule is an autogenerated struct via yunion.io/x/onecloud/pkg/cloudprovider.SExcludeRule.
// SExcludeRule is an autogenerated struct via yunion.io/x/cloudmux/pkg/cloudprovider.SExcludeRule.
type SExcludeRule struct {
Name string `json:"name"`
}
// SExcludeRules is an autogenerated struct via yunion.io/x/onecloud/pkg/cloudprovider.SExcludeRules.
// SExcludeRules is an autogenerated struct via yunion.io/x/cloudmux/pkg/cloudprovider.SExcludeRules.
type SExcludeRules []SExcludeRule
// SGeographicInfo is an autogenerated struct via yunion.io/x/onecloud/pkg/cloudprovider.SGeographicInfo.
// SGeographicInfo is an autogenerated struct via yunion.io/x/cloudmux/pkg/cloudprovider.SGeographicInfo.
type SGeographicInfo struct {
// 纬度
// example: 26.647003
@@ -85,7 +85,7 @@ type SGeographicInfo struct {
CountryCode string `json:"country_code"`
}
// SSubAccount is an autogenerated struct via yunion.io/x/onecloud/pkg/cloudprovider.SSubAccount.
// SSubAccount is an autogenerated struct via yunion.io/x/cloudmux/pkg/cloudprovider.SSubAccount.
type SSubAccount struct {
// 若Account不为空可不传
Name string `json:"name"`
@@ -96,7 +96,7 @@ type SSubAccount struct {
DefaultProjectId string `json:"default_project_id"`
}
// SWafStatement is an autogenerated struct via yunion.io/x/onecloud/pkg/cloudprovider.SWafStatement.
// SWafStatement is an autogenerated struct via yunion.io/x/cloudmux/pkg/cloudprovider.SWafStatement.
type SWafStatement struct {
// 管理规则组名称
ManagedRuleGroupName string `json:"managed_rule_group_name"`
@@ -130,14 +130,14 @@ type SWafStatement struct {
RuleGroupId string `json:"rule_group_id"`
}
// ServerVncInput is an autogenerated struct via yunion.io/x/onecloud/pkg/cloudprovider.ServerVncInput.
// ServerVncInput is an autogenerated struct via yunion.io/x/cloudmux/pkg/cloudprovider.ServerVncInput.
type ServerVncInput struct {
// 是否使用原生vnc控制台此选项仅对openstack有效
// default: false
Origin bool `json:"origin"`
}
// ServerVncOutput is an autogenerated struct via yunion.io/x/onecloud/pkg/cloudprovider.ServerVncOutput.
// ServerVncOutput is an autogenerated struct via yunion.io/x/cloudmux/pkg/cloudprovider.ServerVncOutput.
type ServerVncOutput struct {
Id string `json:"id"`
// baremetal
@@ -160,7 +160,7 @@ type ServerVncOutput struct {
Hypervisor string `json:"hypervisor"`
}
// SubAccounts is an autogenerated struct via yunion.io/x/onecloud/pkg/cloudprovider.SubAccounts.
// SubAccounts is an autogenerated struct via yunion.io/x/cloudmux/pkg/cloudprovider.SubAccounts.
type SubAccounts struct {
// 若输出则是全量子账号列表,若输入,代表允许同步的子账号
Accounts []cloudprovider.SSubAccount `json:"accounts"`
@@ -172,29 +172,29 @@ type SubAccounts struct {
} `json:"cloudregions"`
}
// TWafAction is an autogenerated struct via yunion.io/x/onecloud/pkg/cloudprovider.TWafAction.
// TWafAction is an autogenerated struct via yunion.io/x/cloudmux/pkg/cloudprovider.TWafAction.
type TWafAction string
// TWafMatchField is an autogenerated struct via yunion.io/x/onecloud/pkg/cloudprovider.TWafMatchField.
// TWafMatchField is an autogenerated struct via yunion.io/x/cloudmux/pkg/cloudprovider.TWafMatchField.
type TWafMatchField string
// TWafMatchFieldValues is an autogenerated struct via yunion.io/x/onecloud/pkg/cloudprovider.TWafMatchFieldValues.
// TWafMatchFieldValues is an autogenerated struct via yunion.io/x/cloudmux/pkg/cloudprovider.TWafMatchFieldValues.
type TWafMatchFieldValues []string
// TWafOperator is an autogenerated struct via yunion.io/x/onecloud/pkg/cloudprovider.TWafOperator.
// TWafOperator is an autogenerated struct via yunion.io/x/cloudmux/pkg/cloudprovider.TWafOperator.
type TWafOperator string
// TWafStatementType is an autogenerated struct via yunion.io/x/onecloud/pkg/cloudprovider.TWafStatementType.
// TWafStatementType is an autogenerated struct via yunion.io/x/cloudmux/pkg/cloudprovider.TWafStatementType.
type TWafStatementType string
// TWafTextTransformation is an autogenerated struct via yunion.io/x/onecloud/pkg/cloudprovider.TWafTextTransformation.
// TWafTextTransformation is an autogenerated struct via yunion.io/x/cloudmux/pkg/cloudprovider.TWafTextTransformation.
type TWafTextTransformation string
// TextTransformations is an autogenerated struct via yunion.io/x/onecloud/pkg/cloudprovider.TextTransformations.
// TextTransformations is an autogenerated struct via yunion.io/x/cloudmux/pkg/cloudprovider.TextTransformations.
type TextTransformations []TWafTextTransformation
// WafAddresses is an autogenerated struct via yunion.io/x/onecloud/pkg/cloudprovider.WafAddresses.
// WafAddresses is an autogenerated struct via yunion.io/x/cloudmux/pkg/cloudprovider.WafAddresses.
type WafAddresses []string
// WafRegexPatterns is an autogenerated struct via yunion.io/x/onecloud/pkg/cloudprovider.WafRegexPatterns.
// WafRegexPatterns is an autogenerated struct via yunion.io/x/cloudmux/pkg/cloudprovider.WafRegexPatterns.
type WafRegexPatterns []string

View File

@@ -17,12 +17,12 @@ package compute
import (
"net/http"
"yunion.io/x/cloudmux/pkg/cloudprovider"
"yunion.io/x/pkg/errors"
"yunion.io/x/pkg/util/regutils"
"yunion.io/x/pkg/utils"
"yunion.io/x/onecloud/pkg/apis"
"yunion.io/x/onecloud/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/httperrors"
)

View File

@@ -15,8 +15,9 @@
package compute
import (
"yunion.io/x/cloudmux/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/apis"
"yunion.io/x/onecloud/pkg/cloudprovider"
)
const (

View File

@@ -18,13 +18,13 @@ import (
"fmt"
"reflect"
"yunion.io/x/cloudmux/pkg/cloudprovider"
"yunion.io/x/jsonutils"
"yunion.io/x/pkg/gotypes"
"yunion.io/x/pkg/utils"
"yunion.io/x/onecloud/pkg/apis"
proxyapi "yunion.io/x/onecloud/pkg/apis/cloudcommon/proxy"
"yunion.io/x/onecloud/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/httperrors"
)

View File

@@ -15,8 +15,9 @@
package compute
import (
"yunion.io/x/cloudmux/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/apis"
"yunion.io/x/onecloud/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/util/choices"
)

View File

@@ -15,11 +15,11 @@
package compute
import (
"yunion.io/x/cloudmux/pkg/cloudprovider"
"yunion.io/x/pkg/utils"
"yunion.io/x/onecloud/pkg/apis"
proxyapi "yunion.io/x/onecloud/pkg/apis/cloudcommon/proxy"
"yunion.io/x/onecloud/pkg/cloudprovider"
)
type ManagedResourceInfo struct {

View File

@@ -17,13 +17,13 @@ package compute
import (
"time"
"yunion.io/x/cloudmux/pkg/multicloud/esxi/vcenter"
"yunion.io/x/jsonutils"
"yunion.io/x/pkg/util/fileutils"
"yunion.io/x/onecloud/pkg/apis"
"yunion.io/x/onecloud/pkg/apis/billing"
"yunion.io/x/onecloud/pkg/httperrors"
"yunion.io/x/onecloud/pkg/multicloud/esxi/vcenter"
)
type DiskCreateInput struct {

View File

@@ -17,11 +17,11 @@ package compute
import (
"regexp"
"yunion.io/x/cloudmux/pkg/cloudprovider"
"yunion.io/x/jsonutils"
"yunion.io/x/pkg/util/regutils"
"yunion.io/x/onecloud/pkg/apis"
"yunion.io/x/onecloud/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/httperrors"
)

View File

@@ -20,10 +20,10 @@ import (
// Load balancer status transition (for spec status)
//
// create start stop delete
// init running - - -
// running - - stopped stopped
// stopped - running - -
// create start stop delete
// init running - - -
// running - - stopped stopped
// stopped - running - -
//
// Each entity will have spec and runtime version. Spec version will increment
// on entity attribute update. Runtime version will be filled by the scheduler
@@ -35,7 +35,6 @@ import (
// In the case of instance has PendingDeleted marked, it is also the
// scheduler's duty to make the runtime status to stopped and finally the
// entity in question
//
const (
LB_STATUS_ENABLED = "enabled"
LB_STATUS_DISABLED = "disabled"
@@ -321,7 +320,7 @@ var LB_BOOL_VALUES = choices.NewChoices(
LB_BOOL_OFF,
)
//TODO
// TODO
//
// - qch, quic connection id
// - mh, maglev consistent hash

View File

@@ -15,7 +15,7 @@
package compute
import (
"yunion.io/x/onecloud/pkg/cloudprovider"
"yunion.io/x/cloudmux/pkg/cloudprovider"
)
var (

View File

@@ -15,8 +15,9 @@
package compute
import (
"yunion.io/x/cloudmux/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/apis"
"yunion.io/x/onecloud/pkg/cloudprovider"
)
const (

View File

@@ -15,8 +15,9 @@
package compute
import (
"yunion.io/x/cloudmux/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/apis"
"yunion.io/x/onecloud/pkg/cloudprovider"
)
const (

View File

@@ -306,12 +306,13 @@ func (ada *AdaptecRaidAdaptor) getCreateCmd(args ...string) string {
}
// setControllerMode change adapter controller's mode
// Controller Modes : 0 - RAID: Expose RAW
// : 1 - Auto Volume Mode
// : 2 - HBA Mode
// : 3 - RAID: Hide RAW
// : 4 - Simple Volume Mode
// : 5 - Mixed
//
// Controller Modes : 0 - RAID: Expose RAW
// : 1 - Auto Volume Mode
// : 2 - HBA Mode
// : 3 - RAID: Hide RAW
// : 4 - Simple Volume Mode
// : 5 - Mixed
func (ada *AdaptecRaidAdaptor) setControllerMode(mode int) error {
cmd := GetCommand("SETCONTROLLERMODE", fmt.Sprintf("%d", ada.GetIndex()), fmt.Sprintf("%d", mode), "noprompt")
if _, err := ada.remoteRun(fmt.Sprintf("set controller mode to %d", mode), cmd); err != nil {

View File

@@ -4,7 +4,7 @@
// 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
// 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,

View File

@@ -4,7 +4,7 @@
// 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
// 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,

View File

@@ -390,10 +390,8 @@ func (manager *SPolicyManager) allowWithoutCache(policies rbacutils.TPolicySet,
return result
}
//
// result: allow/deny for the named policy
// userResult: allow/deny for the matched policies of userCred
//
func explainPolicy(userCred mcclient.TokenCredential, policyReq jsonutils.JSONObject, policyData *sPolicyData) ([]string, rbacutils.SPolicyResult, rbacutils.SPolicyResult, error) {
_, request, result, userResult, err := explainPolicyInternal(userCred, policyReq, policyData)
return request, result, userResult, err

View File

@@ -18,6 +18,7 @@ import (
"context"
"time"
"yunion.io/x/cloudmux/pkg/cloudprovider"
"yunion.io/x/jsonutils"
"yunion.io/x/log"
"yunion.io/x/pkg/errors"
@@ -28,7 +29,6 @@ import (
api "yunion.io/x/onecloud/pkg/apis/cloudevent"
"yunion.io/x/onecloud/pkg/cloudcommon/consts"
"yunion.io/x/onecloud/pkg/cloudcommon/db"
"yunion.io/x/onecloud/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/util/rbacutils"
"yunion.io/x/onecloud/pkg/util/stringutils2"

View File

@@ -22,6 +22,7 @@ import (
"golang.org/x/net/http/httpproxy"
"yunion.io/x/cloudmux/pkg/cloudprovider"
"yunion.io/x/jsonutils"
"yunion.io/x/log"
"yunion.io/x/pkg/errors"
@@ -35,7 +36,6 @@ import (
"yunion.io/x/onecloud/pkg/cloudcommon/db"
"yunion.io/x/onecloud/pkg/cloudcommon/db/taskman"
"yunion.io/x/onecloud/pkg/cloudevent/options"
"yunion.io/x/onecloud/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/httperrors"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/mcclient/auth"

View File

@@ -18,6 +18,7 @@ import (
"os"
"time"
_ "yunion.io/x/cloudmux/pkg/multicloud/loader"
"yunion.io/x/log"
_ "yunion.io/x/sqlchemy/backends"
@@ -32,7 +33,6 @@ import (
_ "yunion.io/x/onecloud/pkg/cloudevent/policy"
_ "yunion.io/x/onecloud/pkg/cloudevent/tasks"
_ "yunion.io/x/onecloud/pkg/mcclient/modules"
_ "yunion.io/x/onecloud/pkg/multicloud/loader"
)
func StartService() {

View File

@@ -20,6 +20,7 @@ import (
"github.com/pkg/errors"
"yunion.io/x/cloudmux/pkg/cloudprovider"
"yunion.io/x/jsonutils"
"yunion.io/x/log"
@@ -27,7 +28,6 @@ import (
"yunion.io/x/onecloud/pkg/cloudcommon/db/taskman"
"yunion.io/x/onecloud/pkg/cloudevent/models"
"yunion.io/x/onecloud/pkg/cloudevent/options"
"yunion.io/x/onecloud/pkg/cloudprovider"
)
type CloudeventSyncTask struct {

View File

@@ -24,6 +24,7 @@ import (
"golang.org/x/net/http/httpproxy"
"yunion.io/x/cloudmux/pkg/cloudprovider"
"yunion.io/x/jsonutils"
"yunion.io/x/log"
"yunion.io/x/pkg/errors"
@@ -39,7 +40,6 @@ import (
"yunion.io/x/onecloud/pkg/cloudcommon/db/lockman"
"yunion.io/x/onecloud/pkg/cloudcommon/db/taskman"
"yunion.io/x/onecloud/pkg/cloudid/options"
"yunion.io/x/onecloud/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/mcclient/auth"
modules "yunion.io/x/onecloud/pkg/mcclient/modules/compute"

View File

@@ -20,6 +20,7 @@ import (
"gopkg.in/fatih/set.v0"
"yunion.io/x/cloudmux/pkg/cloudprovider"
"yunion.io/x/jsonutils"
"yunion.io/x/pkg/errors"
"yunion.io/x/pkg/util/compare"
@@ -29,7 +30,6 @@ import (
"yunion.io/x/onecloud/pkg/cloudcommon/db"
"yunion.io/x/onecloud/pkg/cloudcommon/db/lockman"
"yunion.io/x/onecloud/pkg/cloudcommon/db/taskman"
"yunion.io/x/onecloud/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/httperrors"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/util/logclient"

View File

@@ -19,6 +19,7 @@ import (
"database/sql"
"fmt"
"yunion.io/x/cloudmux/pkg/cloudprovider"
"yunion.io/x/jsonutils"
"yunion.io/x/log"
"yunion.io/x/pkg/errors"
@@ -29,7 +30,6 @@ import (
"yunion.io/x/onecloud/pkg/cloudcommon/db"
"yunion.io/x/onecloud/pkg/cloudcommon/db/lockman"
"yunion.io/x/onecloud/pkg/cloudcommon/db/taskman"
"yunion.io/x/onecloud/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/httperrors"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/util/logclient"

View File

@@ -18,6 +18,7 @@ import (
"context"
"database/sql"
"yunion.io/x/cloudmux/pkg/cloudprovider"
"yunion.io/x/jsonutils"
"yunion.io/x/log"
"yunion.io/x/pkg/errors"
@@ -28,7 +29,6 @@ import (
"yunion.io/x/onecloud/pkg/cloudcommon/db"
"yunion.io/x/onecloud/pkg/cloudcommon/db/lockman"
"yunion.io/x/onecloud/pkg/cloudcommon/db/taskman"
"yunion.io/x/onecloud/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/httperrors"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/util/stringutils2"

View File

@@ -19,13 +19,13 @@ import (
"database/sql"
"fmt"
"yunion.io/x/cloudmux/pkg/cloudprovider"
"yunion.io/x/jsonutils"
"yunion.io/x/pkg/errors"
"yunion.io/x/sqlchemy"
api "yunion.io/x/onecloud/pkg/apis/cloudid"
"yunion.io/x/onecloud/pkg/cloudcommon/db"
"yunion.io/x/onecloud/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/httperrors"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/util/stringutils2"

View File

@@ -18,6 +18,7 @@ import (
"context"
"database/sql"
"yunion.io/x/cloudmux/pkg/cloudprovider"
"yunion.io/x/log"
"yunion.io/x/pkg/errors"
"yunion.io/x/pkg/util/compare"
@@ -25,7 +26,6 @@ import (
"yunion.io/x/onecloud/pkg/cloudcommon/db"
"yunion.io/x/onecloud/pkg/cloudcommon/db/lockman"
"yunion.io/x/onecloud/pkg/cloudid/options"
"yunion.io/x/onecloud/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/mcclient/auth"
modules "yunion.io/x/onecloud/pkg/mcclient/modules/compute"

View File

@@ -22,6 +22,7 @@ import (
"gopkg.in/fatih/set.v0"
"yunion.io/x/cloudmux/pkg/cloudprovider"
"yunion.io/x/jsonutils"
"yunion.io/x/pkg/errors"
"yunion.io/x/pkg/utils"
@@ -31,7 +32,6 @@ import (
computeapi "yunion.io/x/onecloud/pkg/apis/compute"
"yunion.io/x/onecloud/pkg/cloudcommon/db"
"yunion.io/x/onecloud/pkg/cloudcommon/db/taskman"
"yunion.io/x/onecloud/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/util/stringutils2"
)

View File

@@ -21,6 +21,7 @@ import (
"gopkg.in/fatih/set.v0"
"yunion.io/x/cloudmux/pkg/cloudprovider"
"yunion.io/x/jsonutils"
"yunion.io/x/log"
"yunion.io/x/pkg/errors"
@@ -36,7 +37,6 @@ import (
"yunion.io/x/onecloud/pkg/cloudcommon/db/lockman"
"yunion.io/x/onecloud/pkg/cloudcommon/db/taskman"
"yunion.io/x/onecloud/pkg/cloudcommon/notifyclient"
"yunion.io/x/onecloud/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/httperrors"
"yunion.io/x/onecloud/pkg/mcclient"
npk "yunion.io/x/onecloud/pkg/mcclient/modules/notify"

View File

@@ -17,13 +17,13 @@ package models
import (
"context"
"yunion.io/x/cloudmux/pkg/cloudprovider"
"yunion.io/x/jsonutils"
"yunion.io/x/pkg/errors"
"yunion.io/x/sqlchemy"
api "yunion.io/x/onecloud/pkg/apis/cloudid"
"yunion.io/x/onecloud/pkg/cloudcommon/db"
"yunion.io/x/onecloud/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/httperrors"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/util/stringutils2"

View File

@@ -19,6 +19,7 @@ import (
"fmt"
"strings"
"yunion.io/x/cloudmux/pkg/cloudprovider"
"yunion.io/x/jsonutils"
"yunion.io/x/log"
"yunion.io/x/pkg/errors"
@@ -29,7 +30,6 @@ import (
"yunion.io/x/onecloud/pkg/cloudcommon/db/taskman"
"yunion.io/x/onecloud/pkg/cloudcommon/validators"
"yunion.io/x/onecloud/pkg/cloudid/options"
"yunion.io/x/onecloud/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/httperrors"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/util/samlutils"

View File

@@ -15,8 +15,9 @@
package aliyun
import (
"yunion.io/x/cloudmux/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/cloudid/models"
"yunion.io/x/onecloud/pkg/cloudprovider"
)
type SAliyunSAMLDriver struct{}

View File

@@ -15,8 +15,9 @@
package aws
import (
"yunion.io/x/cloudmux/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/cloudid/models"
"yunion.io/x/onecloud/pkg/cloudprovider"
)
type SAWSSAMLDriver struct{}

View File

@@ -15,8 +15,9 @@
package awscn
import (
"yunion.io/x/cloudmux/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/cloudid/models"
"yunion.io/x/onecloud/pkg/cloudprovider"
)
type SAWSCNSAMLDriver struct{}

View File

@@ -15,8 +15,9 @@
package azure
import (
"yunion.io/x/cloudmux/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/cloudid/models"
"yunion.io/x/onecloud/pkg/cloudprovider"
)
type SAzureSAMLDriver struct{}

View File

@@ -15,8 +15,9 @@
package google
import (
"yunion.io/x/cloudmux/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/cloudid/models"
"yunion.io/x/onecloud/pkg/cloudprovider"
)
type SGoogleSAMLDriver struct{}

View File

@@ -15,8 +15,9 @@
package huawei
import (
"yunion.io/x/cloudmux/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/cloudid/models"
"yunion.io/x/onecloud/pkg/cloudprovider"
)
func init() {

View File

@@ -15,8 +15,9 @@
package qcloud
import (
"yunion.io/x/cloudmux/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/cloudid/models"
"yunion.io/x/onecloud/pkg/cloudprovider"
)
type SQcloudSAMLDriver struct{}

View File

@@ -18,6 +18,7 @@ import (
"os"
"time"
_ "yunion.io/x/cloudmux/pkg/multicloud/loader"
"yunion.io/x/log"
_ "yunion.io/x/sqlchemy/backends"
@@ -32,7 +33,6 @@ import (
_ "yunion.io/x/onecloud/pkg/cloudid/policy"
"yunion.io/x/onecloud/pkg/cloudid/saml"
_ "yunion.io/x/onecloud/pkg/cloudid/tasks"
_ "yunion.io/x/onecloud/pkg/multicloud/loader"
)
func StartService() {

View File

@@ -17,6 +17,7 @@ package tasks
import (
"context"
"yunion.io/x/cloudmux/pkg/cloudprovider"
"yunion.io/x/jsonutils"
"yunion.io/x/pkg/errors"
@@ -24,7 +25,6 @@ import (
"yunion.io/x/onecloud/pkg/cloudcommon/db"
"yunion.io/x/onecloud/pkg/cloudcommon/db/taskman"
"yunion.io/x/onecloud/pkg/cloudid/models"
"yunion.io/x/onecloud/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/util/logclient"
)

View File

@@ -17,6 +17,7 @@ package tasks
import (
"context"
"yunion.io/x/cloudmux/pkg/cloudprovider"
"yunion.io/x/jsonutils"
"yunion.io/x/pkg/errors"
@@ -24,7 +25,6 @@ import (
"yunion.io/x/onecloud/pkg/cloudcommon/db"
"yunion.io/x/onecloud/pkg/cloudcommon/db/taskman"
"yunion.io/x/onecloud/pkg/cloudid/models"
"yunion.io/x/onecloud/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/util/logclient"
)

View File

@@ -17,6 +17,7 @@ package tasks
import (
"context"
"yunion.io/x/cloudmux/pkg/cloudprovider"
"yunion.io/x/jsonutils"
"yunion.io/x/pkg/errors"
@@ -24,7 +25,6 @@ import (
"yunion.io/x/onecloud/pkg/cloudcommon/db"
"yunion.io/x/onecloud/pkg/cloudcommon/db/taskman"
"yunion.io/x/onecloud/pkg/cloudid/models"
"yunion.io/x/onecloud/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/util/logclient"
)

View File

@@ -17,6 +17,7 @@ package tasks
import (
"context"
"yunion.io/x/cloudmux/pkg/cloudprovider"
"yunion.io/x/jsonutils"
"yunion.io/x/pkg/errors"
@@ -24,7 +25,6 @@ import (
"yunion.io/x/onecloud/pkg/cloudcommon/db"
"yunion.io/x/onecloud/pkg/cloudcommon/db/taskman"
"yunion.io/x/onecloud/pkg/cloudid/models"
"yunion.io/x/onecloud/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/util/logclient"
)

View File

@@ -17,6 +17,7 @@ package tasks
import (
"context"
"yunion.io/x/cloudmux/pkg/cloudprovider"
"yunion.io/x/jsonutils"
"yunion.io/x/pkg/errors"
@@ -25,7 +26,6 @@ import (
"yunion.io/x/onecloud/pkg/cloudcommon/db/lockman"
"yunion.io/x/onecloud/pkg/cloudcommon/db/taskman"
"yunion.io/x/onecloud/pkg/cloudid/models"
"yunion.io/x/onecloud/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/util/logclient"
)

View File

@@ -17,6 +17,7 @@ package tasks
import (
"context"
"yunion.io/x/cloudmux/pkg/cloudprovider"
"yunion.io/x/jsonutils"
"yunion.io/x/pkg/errors"
@@ -24,7 +25,6 @@ import (
"yunion.io/x/onecloud/pkg/cloudcommon/db"
"yunion.io/x/onecloud/pkg/cloudcommon/db/taskman"
"yunion.io/x/onecloud/pkg/cloudid/models"
"yunion.io/x/onecloud/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/util/logclient"
)

View File

@@ -18,6 +18,7 @@ import (
"context"
"fmt"
"yunion.io/x/cloudmux/pkg/cloudprovider"
"yunion.io/x/jsonutils"
"yunion.io/x/pkg/errors"
@@ -25,7 +26,6 @@ import (
"yunion.io/x/onecloud/pkg/cloudcommon/db"
"yunion.io/x/onecloud/pkg/cloudcommon/db/taskman"
"yunion.io/x/onecloud/pkg/cloudid/models"
"yunion.io/x/onecloud/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/util/logclient"
)

View File

@@ -17,13 +17,13 @@ package tasks
import (
"context"
"yunion.io/x/cloudmux/pkg/cloudprovider"
"yunion.io/x/jsonutils"
"yunion.io/x/pkg/errors"
"yunion.io/x/onecloud/pkg/cloudcommon/db"
"yunion.io/x/onecloud/pkg/cloudcommon/db/taskman"
"yunion.io/x/onecloud/pkg/cloudid/models"
"yunion.io/x/onecloud/pkg/cloudprovider"
)
type SyncCloudIdResourcesTask struct {

View File

@@ -18,6 +18,7 @@ import (
"context"
"fmt"
"yunion.io/x/cloudmux/pkg/cloudprovider"
"yunion.io/x/jsonutils"
"yunion.io/x/log"
"yunion.io/x/pkg/errors"
@@ -26,7 +27,6 @@ import (
"yunion.io/x/onecloud/pkg/cloudcommon/db/lockman"
"yunion.io/x/onecloud/pkg/cloudcommon/db/taskman"
"yunion.io/x/onecloud/pkg/cloudid/models"
"yunion.io/x/onecloud/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/mcclient"
)

View File

@@ -101,7 +101,7 @@ func UsegReport(ctx context.Context, userCred mcclient.TokenCredential, isStart
}
}
//根据capabilities中的hypevisors和brands中的对应属性组装Metric
// 根据capabilities中的hypevisors和brands中的对应属性组装Metric
func packMetricList(session *mcclient.ClientSession, dataList []influxdb.SMetricData,
imageUsageFieldsDict *jsonutils.JSONDict, paramKey string,
paramValue string, nowTime time.Time) (rtnList []influxdb.SMetricData, err error) {
@@ -141,7 +141,7 @@ func packMetricList(session *mcclient.ClientSession, dataList []influxdb.SMetric
return dataList, nil
}
//获得镜像使用量
// 获得镜像使用量
func getImageUsageFields(session *mcclient.ClientSession) (jsonutils.JSONObject, error) {
respObj, e := (&image.ImageUsages).GetUsage(session, nil)
if e != nil {
@@ -154,7 +154,7 @@ func getImageUsageFields(session *mcclient.ClientSession) (jsonutils.JSONObject,
return respDict, nil
}
//将JSONDict的信息放置到SMetricData中
// 将JSONDict的信息放置到SMetricData中
func jsonTometricData(obj *jsonutils.JSONDict, metric *influxdb.SMetricData,
metricDataType string) (*influxdb.SMetricData, error) {

View File

@@ -20,13 +20,13 @@ import (
"sync"
"time"
"yunion.io/x/cloudmux/pkg/cloudprovider"
"yunion.io/x/log"
"yunion.io/x/pkg/errors"
"yunion.io/x/onecloud/pkg/apis"
api "yunion.io/x/onecloud/pkg/apis/compute"
"yunion.io/x/onecloud/pkg/cloudmon/options"
"yunion.io/x/onecloud/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/mcclient/auth"
"yunion.io/x/onecloud/pkg/util/influxdb"
)

View File

@@ -19,8 +19,9 @@ import (
"fmt"
"time"
"yunion.io/x/cloudmux/pkg/cloudprovider"
api "yunion.io/x/onecloud/pkg/apis/compute"
"yunion.io/x/onecloud/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/util/influxdb"
)

View File

@@ -20,13 +20,13 @@ import (
"sync"
"time"
"yunion.io/x/cloudmux/pkg/cloudprovider"
"yunion.io/x/log"
"yunion.io/x/pkg/errors"
"yunion.io/x/onecloud/pkg/apis"
api "yunion.io/x/onecloud/pkg/apis/compute"
"yunion.io/x/onecloud/pkg/cloudmon/options"
"yunion.io/x/onecloud/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/mcclient/auth"
"yunion.io/x/onecloud/pkg/util/influxdb"
)

View File

@@ -20,13 +20,13 @@ import (
"sync"
"time"
"yunion.io/x/cloudmux/pkg/cloudprovider"
"yunion.io/x/log"
"yunion.io/x/pkg/errors"
"yunion.io/x/onecloud/pkg/apis"
api "yunion.io/x/onecloud/pkg/apis/compute"
"yunion.io/x/onecloud/pkg/cloudmon/options"
"yunion.io/x/onecloud/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/mcclient/auth"
"yunion.io/x/onecloud/pkg/util/influxdb"
)

View File

@@ -21,13 +21,13 @@ import (
"sync"
"time"
"yunion.io/x/cloudmux/pkg/cloudprovider"
"yunion.io/x/log"
"yunion.io/x/pkg/errors"
"yunion.io/x/onecloud/pkg/apis"
api "yunion.io/x/onecloud/pkg/apis/compute"
"yunion.io/x/onecloud/pkg/cloudmon/options"
"yunion.io/x/onecloud/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/mcclient/auth"
"yunion.io/x/onecloud/pkg/util/influxdb"
)

View File

@@ -21,6 +21,7 @@ import (
"sync"
"time"
"yunion.io/x/cloudmux/pkg/cloudprovider"
"yunion.io/x/jsonutils"
"yunion.io/x/log"
"yunion.io/x/pkg/errors"
@@ -29,7 +30,6 @@ import (
api "yunion.io/x/onecloud/pkg/apis/compute"
"yunion.io/x/onecloud/pkg/cloudmon/options"
"yunion.io/x/onecloud/pkg/cloudmon/providerdriver"
"yunion.io/x/onecloud/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/mcclient/auth"
"yunion.io/x/onecloud/pkg/mcclient/modulebase"

View File

@@ -18,6 +18,7 @@ import (
"os"
"time"
_ "yunion.io/x/cloudmux/pkg/multicloud/loader"
"yunion.io/x/log"
"yunion.io/x/onecloud/pkg/apis"
@@ -27,7 +28,6 @@ import (
"yunion.io/x/onecloud/pkg/cloudmon/misc"
"yunion.io/x/onecloud/pkg/cloudmon/options"
"yunion.io/x/onecloud/pkg/cloudmon/resources"
_ "yunion.io/x/onecloud/pkg/multicloud/loader"
)
func StartService() {

View File

@@ -1,179 +0,0 @@
// 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 cloudprovider
import (
"testing"
"yunion.io/x/jsonutils"
)
func TestDiff(t *testing.T) {
cases := []struct {
Name string
Remote []DnsRecordSet
Local []DnsRecordSet
CommonCount int
AddCount int
DelCount int
UpdateCount int
}{
{
Name: "Test delete",
CommonCount: 4,
AddCount: 0,
DelCount: 1,
UpdateCount: 0,
Remote: []DnsRecordSet{
DnsRecordSet{ExternalId: "650124294", Enabled: true, DnsName: "@", DnsType: DnsTypeNS, DnsValue: "f1g1ns1.dnspod.net.", Ttl: 86400, PolicyType: DnsPolicyTypeSimple},
DnsRecordSet{ExternalId: "650124301", Enabled: true, DnsName: "@", DnsType: DnsTypeNS, DnsValue: "f1g1ns2.dnspod.net.", Ttl: 86400, PolicyType: DnsPolicyTypeSimple},
DnsRecordSet{ExternalId: "650124650", Enabled: true, DnsName: "@", DnsType: DnsTypeMX, DnsValue: "qiye163mx01.mxmail.netease.com.", Ttl: 600, PolicyType: DnsPolicyTypeSimple},
DnsRecordSet{ExternalId: "650124659", Enabled: true, DnsName: "@", DnsType: DnsTypeMX, DnsValue: "qiye163mx02.mxmail.netease.com.", Ttl: 600, PolicyType: DnsPolicyTypeSimple},
DnsRecordSet{ExternalId: "650124661", Enabled: true, DnsName: "mail", DnsType: DnsTypeCNAME, DnsValue: "qiye.163.com.", Ttl: 600, PolicyType: DnsPolicyTypeSimple},
},
Local: []DnsRecordSet{
DnsRecordSet{Id: "d599c0e0-0653-40ed-85e1-86502a8d23d4", Enabled: true, DnsName: "mail", DnsType: DnsTypeCNAME, DnsValue: "qiye.163.com.", Ttl: 600, PolicyType: DnsPolicyTypeSimple},
DnsRecordSet{Id: "5728b06e-f8cb-41eb-86e9-0e5836195ad1", Enabled: true, DnsName: "@", DnsType: DnsTypeMX, DnsValue: "qiye163mx01.mxmail.netease.com.", Ttl: 600, PolicyType: DnsPolicyTypeSimple},
DnsRecordSet{Id: "427b38d2-77e2-4705-8880-0852da9cfb6b", Enabled: true, DnsName: "@", DnsType: DnsTypeNS, DnsValue: "f1g1ns1.dnspod.net.", Ttl: 86400, PolicyType: DnsPolicyTypeSimple},
DnsRecordSet{Id: "0390724d-cb49-43f8-8ccd-117fef3f5034", Enabled: true, DnsName: "@", DnsType: DnsTypeNS, DnsValue: "f1g1ns2.dnspod.net.", Ttl: 86400, PolicyType: DnsPolicyTypeSimple},
},
},
{
Name: "Test update",
CommonCount: 14,
AddCount: 0,
DelCount: 0,
UpdateCount: 1,
Remote: []DnsRecordSet{
DnsRecordSet{ExternalId: "647776715", Enabled: true, DnsName: "@", Ttl: 86400, DnsType: DnsTypeNS, DnsValue: "f1g1ns1.dnspod.net.", PolicyType: DnsPolicyTypeSimple},
DnsRecordSet{ExternalId: "647776716", Enabled: true, DnsName: "@", Ttl: 86400, DnsType: DnsTypeNS, DnsValue: "f1g1ns2.dnspod.net.", PolicyType: DnsPolicyTypeSimple},
DnsRecordSet{ExternalId: "647850198", Enabled: true, DnsName: "abc", Ttl: 600, DnsType: DnsTypeA, DnsValue: "123.12.12.12", PolicyType: DnsPolicyTypeSimple},
DnsRecordSet{ExternalId: "647850256", Enabled: true, DnsName: "abc", Ttl: 600, DnsType: DnsTypeA, DnsValue: "123.21.21.21", PolicyType: DnsPolicyTypeSimple},
DnsRecordSet{ExternalId: "651667846", Enabled: false, DnsName: "ert", Ttl: 600, DnsType: DnsTypeA, DnsValue: "123.23.23.23", PolicyType: DnsPolicyTypeSimple},
DnsRecordSet{ExternalId: "651667854", Enabled: false, DnsName: "ert2", Ttl: 600, DnsType: DnsTypeA, DnsValue: "123.23.23.23", PolicyType: DnsPolicyTypeSimple},
DnsRecordSet{ExternalId: "651690475", Enabled: false, DnsName: "ert7", Ttl: 600, DnsType: DnsTypeA, DnsValue: "123.23.23.23", PolicyType: DnsPolicyTypeSimple},
DnsRecordSet{ExternalId: "651667834", Enabled: true, DnsName: "example3.com", Ttl: 600, DnsType: DnsTypeA, DnsValue: "12.12.12.12", PolicyType: DnsPolicyTypeSimple},
DnsRecordSet{ExternalId: "651694910", Enabled: true, DnsName: "example3.com", Ttl: 600, DnsType: DnsTypeA, DnsValue: "12.12.21.122", PolicyType: DnsPolicyTypeSimple},
DnsRecordSet{ExternalId: "651694952", Enabled: true, DnsName: "sd.sd", Ttl: 600, DnsType: DnsTypeA, DnsValue: "13.34.34.34", PolicyType: DnsPolicyTypeSimple},
DnsRecordSet{ExternalId: "651694923", Enabled: true, DnsName: "stest", Ttl: 600, DnsType: DnsTypeA, DnsValue: "234.90.8.8", PolicyType: DnsPolicyTypeSimple},
DnsRecordSet{ExternalId: "651694918", Enabled: true, DnsName: "teset34", Ttl: 600, DnsType: DnsTypeA, DnsValue: "123.56.56.56", PolicyType: DnsPolicyTypeSimple},
DnsRecordSet{ExternalId: "651694931", Enabled: true, DnsName: "teset66", Ttl: 600, DnsType: DnsTypeA, DnsValue: "123.56.56.56", PolicyType: DnsPolicyTypeSimple},
DnsRecordSet{ExternalId: "651694942", Enabled: true, DnsName: "teset67", Ttl: 600, DnsType: DnsTypeA, DnsValue: "123.56.56.56", PolicyType: DnsPolicyTypeSimple},
DnsRecordSet{ExternalId: "651694960", Enabled: true, DnsName: "test", Ttl: 600, DnsType: DnsTypeA, DnsValue: "123.34.34.34", PolicyType: DnsPolicyTypeSimple},
},
Local: []DnsRecordSet{
DnsRecordSet{DnsType: DnsTypeA, DnsValue: "123.23.23.23", Enabled: false, Id: "1a38903e-dac8-4f75-877e-05f88f515a1f", DnsName: "ert7", Ttl: 600, PolicyType: DnsPolicyTypeSimple},
DnsRecordSet{DnsType: DnsTypeA, DnsValue: "123.23.23.23", Enabled: false, Id: "6e7d2c83-770c-4ecd-8c6b-4caf87fe8c23", DnsName: "ert2", Ttl: 600, PolicyType: DnsPolicyTypeSimple},
DnsRecordSet{DnsType: DnsTypeA, DnsValue: "123.23.23.23", Enabled: false, Id: "7fd3796a-fada-4af5-88c4-afbf36c697cd", DnsName: "ert", Ttl: 600, PolicyType: DnsPolicyTypeSimple},
DnsRecordSet{DnsType: DnsTypeNS, DnsValue: "f1g1ns2.dnspod.net.", Enabled: true, Id: "3de80b12-851d-4418-8ffc-bd6ef90fb1f0", DnsName: "@", Ttl: 86400, PolicyType: DnsPolicyTypeSimple},
DnsRecordSet{DnsType: DnsTypeNS, DnsValue: "f1g1ns1.dnspod.net.", Enabled: true, Id: "fc7dde12-1c96-479f-82dd-e97200b8737f", DnsName: "@", Ttl: 86400, PolicyType: DnsPolicyTypeSimple},
DnsRecordSet{DnsType: DnsTypeA, DnsValue: "123.56.56.56", Enabled: true, Id: "6d6ede14-01e8-49e4-8316-13b77d481b6c", DnsName: "teset34", Ttl: 600, PolicyType: DnsPolicyTypeSimple},
DnsRecordSet{DnsType: DnsTypeA, DnsValue: "13.34.34.34", Enabled: true, Id: "0e001e25-4567-4d76-8e45-ddb0012dcedf", DnsName: "sd.sd", Ttl: 600, PolicyType: DnsPolicyTypeSimple},
DnsRecordSet{DnsType: DnsTypeA, DnsValue: "123.56.56.56", Enabled: true, Id: "6479e99f-8031-43c7-855a-8abc1f82028c", DnsName: "teset67", Ttl: 600, PolicyType: DnsPolicyTypeSimple},
DnsRecordSet{DnsType: DnsTypeA, DnsValue: "123.56.56.56", Enabled: false, Id: "3b0e373f-ba22-4137-8900-d93fb2e55f12", DnsName: "teset66", Ttl: 600, PolicyType: DnsPolicyTypeSimple},
DnsRecordSet{DnsType: DnsTypeA, DnsValue: "123.34.34.34", Enabled: true, Id: "c9b607e5-e5ac-485f-8189-966f74914203", DnsName: "test", Ttl: 600, PolicyType: DnsPolicyTypeSimple},
DnsRecordSet{DnsType: DnsTypeA, DnsValue: "123.21.21.21", Enabled: true, Id: "a08cd8a6-fc7c-4de7-89b1-f962f2d9d5e5", DnsName: "abc", Ttl: 600, PolicyType: DnsPolicyTypeSimple},
DnsRecordSet{DnsType: DnsTypeA, DnsValue: "12.12.21.122", Enabled: true, Id: "251224a5-c6a1-447c-87f3-b64be34f4dd6", DnsName: "example3.com", Ttl: 600, PolicyType: DnsPolicyTypeSimple},
DnsRecordSet{DnsType: DnsTypeA, DnsValue: "12.12.12.12", Enabled: true, Id: "0ad65043-a4ca-4866-8032-56a51b018b46", DnsName: "example3.com", Ttl: 600, PolicyType: DnsPolicyTypeSimple},
DnsRecordSet{DnsType: DnsTypeA, DnsValue: "234.90.8.8", Enabled: true, Id: "f0ee44c9-12d4-40a3-84c4-ce9df25d0831", DnsName: "stest", Ttl: 600, PolicyType: DnsPolicyTypeSimple},
DnsRecordSet{DnsType: DnsTypeA, DnsValue: "123.12.12.12", Enabled: true, Id: "f82d1a9b-f3db-4617-8e59-4c264cecc1b6", DnsName: "abc", Ttl: 600, PolicyType: DnsPolicyTypeSimple},
},
},
{
Name: "Test update",
CommonCount: 13,
AddCount: 2,
DelCount: 0,
UpdateCount: 3,
Remote: []DnsRecordSet{
DnsRecordSet{Enabled: true, ExternalId: "647776715", DnsName: "@", Ttl: 86400, DnsType: DnsTypeNS, DnsValue: "f1g1ns1.dnspod.net.", PolicyType: DnsPolicyTypeSimple},
DnsRecordSet{Enabled: true, ExternalId: "647776716", DnsName: "@", Ttl: 86400, DnsType: DnsTypeNS, DnsValue: "f1g1ns2.dnspod.net.", PolicyType: DnsPolicyTypeSimple},
DnsRecordSet{Enabled: true, ExternalId: "647850198", DnsName: "abc", Ttl: 600, DnsType: DnsTypeA, DnsValue: "123.12.12.12", PolicyType: DnsPolicyTypeSimple},
DnsRecordSet{Enabled: true, ExternalId: "647850256", DnsName: "abc", Ttl: 600, DnsType: DnsTypeA, DnsValue: "123.21.21.21", PolicyType: DnsPolicyTypeSimple},
DnsRecordSet{Enabled: false, ExternalId: "651667846", DnsName: "ert", Ttl: 600, DnsType: DnsTypeA, DnsValue: "123.23.23.23", PolicyType: DnsPolicyTypeSimple},
DnsRecordSet{Enabled: false, ExternalId: "651667854", DnsName: "ert2", Ttl: 600, DnsType: DnsTypeA, DnsValue: "123.23.23.23", PolicyType: DnsPolicyTypeSimple},
DnsRecordSet{Enabled: false, ExternalId: "651690475", DnsName: "ert7", Ttl: 600, DnsType: DnsTypeA, DnsValue: "123.23.23.23", PolicyType: DnsPolicyTypeSimple},
DnsRecordSet{Enabled: true, ExternalId: "652048718", DnsName: "ert8", Ttl: 600, DnsType: DnsTypeA, DnsValue: "123.23.23.23", PolicyType: DnsPolicyTypeSimple},
DnsRecordSet{Enabled: true, ExternalId: "652048736", DnsName: "example3.com", Ttl: 600, DnsType: DnsTypeA, DnsValue: "12.12.12.12", PolicyType: DnsPolicyTypeSimple},
DnsRecordSet{Enabled: true, ExternalId: "652048745", DnsName: "example3.com", Ttl: 600, DnsType: DnsTypeA, DnsValue: "12.12.21.122", PolicyType: DnsPolicyTypeSimple},
DnsRecordSet{Enabled: true, ExternalId: "652048753", DnsName: "sd.sd", Ttl: 600, DnsType: DnsTypeA, DnsValue: "13.34.34.34", PolicyType: DnsPolicyTypeSimple},
DnsRecordSet{Enabled: true, ExternalId: "652048760", DnsName: "stest", Ttl: 600, DnsType: DnsTypeA, DnsValue: "234.90.8.8", PolicyType: DnsPolicyTypeSimple},
DnsRecordSet{Enabled: true, ExternalId: "652048770", DnsName: "teset34", Ttl: 600, DnsType: DnsTypeA, DnsValue: "123.56.56.56", PolicyType: DnsPolicyTypeSimple},
DnsRecordSet{Enabled: true, ExternalId: "652048778", DnsName: "teset66", Ttl: 600, DnsType: DnsTypeA, DnsValue: "123.56.56.56", PolicyType: DnsPolicyTypeSimple},
DnsRecordSet{Enabled: true, ExternalId: "652048785", DnsName: "teset67", Ttl: 600, DnsType: DnsTypeA, DnsValue: "123.56.56.56", PolicyType: DnsPolicyTypeSimple},
DnsRecordSet{Enabled: true, ExternalId: "652048789", DnsName: "test", Ttl: 600, DnsType: DnsTypeA, DnsValue: "123.34.34.34", PolicyType: DnsPolicyTypeSimple},
},
Local: []DnsRecordSet{
DnsRecordSet{DnsType: DnsTypeA, DnsValue: "123.23.23.23", Enabled: false, Id: "9402de3c-43e4-499d-8257-3b546abff684", DnsName: "ert10", Status: "available", Ttl: 600, PolicyType: DnsPolicyTypeSimple},
DnsRecordSet{DnsType: DnsTypeA, DnsValue: "123.23.23.23", Enabled: false, Id: "89a3d7f9-7d68-4f2f-834f-2caf787d7ff1", DnsName: "ert9", Status: "available", Ttl: 600, PolicyType: DnsPolicyTypeSimple},
DnsRecordSet{DnsType: DnsTypeA, DnsValue: "123.23.23.23", Enabled: false, Id: "5edb132b-7c67-4cc7-8b85-f32f6e22d88a", DnsName: "ert8", Status: "available", Ttl: 600, PolicyType: DnsPolicyTypeSimple},
DnsRecordSet{DnsType: DnsTypeA, DnsValue: "123.23.23.23", Enabled: false, Id: "1a38903e-dac8-4f75-877e-05f88f515a1f", DnsName: "ert7", Status: "init", Ttl: 600, PolicyType: DnsPolicyTypeSimple},
DnsRecordSet{DnsType: DnsTypeA, DnsValue: "123.23.23.23", Enabled: false, Id: "6e7d2c83-770c-4ecd-8c6b-4caf87fe8c23", DnsName: "ert2", Status: "init", Ttl: 600, PolicyType: DnsPolicyTypeSimple},
DnsRecordSet{DnsType: DnsTypeA, DnsValue: "123.23.23.23", Enabled: false, Id: "7fd3796a-fada-4af5-88c4-afbf36c697cd", DnsName: "ert", Status: "init", Ttl: 600, PolicyType: DnsPolicyTypeSimple},
DnsRecordSet{DnsType: DnsTypeNS, DnsValue: "f1g1ns2.dnspod.net.", Enabled: true, Id: "3de80b12-851d-4418-8ffc-bd6ef90fb1f0", DnsName: "@", Status: "available", Ttl: 86400, PolicyType: DnsPolicyTypeSimple},
DnsRecordSet{DnsType: DnsTypeNS, DnsValue: "f1g1ns1.dnspod.net.", Enabled: true, Id: "fc7dde12-1c96-479f-82dd-e97200b8737f", DnsName: "@", Status: "available", Ttl: 86400, PolicyType: DnsPolicyTypeSimple},
DnsRecordSet{DnsType: DnsTypeA, DnsValue: "123.56.56.56", Enabled: false, Id: "6d6ede14-01e8-49e4-8316-13b77d481b6c", DnsName: "teset34", Status: "available", Ttl: 600, PolicyType: DnsPolicyTypeSimple},
DnsRecordSet{DnsType: DnsTypeA, DnsValue: "13.34.34.34", Enabled: true, Id: "0e001e25-4567-4d76-8e45-ddb0012dcedf", DnsName: "sd.sd", Status: "available", Ttl: 600, PolicyType: DnsPolicyTypeSimple},
DnsRecordSet{DnsType: DnsTypeA, DnsValue: "123.56.56.56", Enabled: true, Id: "6479e99f-8031-43c7-855a-8abc1f82028c", DnsName: "teset67", Status: "available", Ttl: 600, PolicyType: DnsPolicyTypeSimple},
DnsRecordSet{DnsType: DnsTypeA, DnsValue: "123.56.56.56", Enabled: false, Id: "3b0e373f-ba22-4137-8900-d93fb2e55f12", DnsName: "teset66", Status: "available", Ttl: 600, PolicyType: DnsPolicyTypeSimple},
DnsRecordSet{DnsType: DnsTypeA, DnsValue: "123.34.34.34", Enabled: true, Id: "c9b607e5-e5ac-485f-8189-966f74914203", DnsName: "test", Status: "available", Ttl: 600, PolicyType: DnsPolicyTypeSimple},
DnsRecordSet{DnsType: DnsTypeA, DnsValue: "123.21.21.21", Enabled: true, Id: "a08cd8a6-fc7c-4de7-89b1-f962f2d9d5e5", DnsName: "abc", Status: "available", Ttl: 600, PolicyType: DnsPolicyTypeSimple},
DnsRecordSet{DnsType: DnsTypeA, DnsValue: "12.12.21.122", Enabled: true, Id: "251224a5-c6a1-447c-87f3-b64be34f4dd6", DnsName: "example3.com", Status: "available", Ttl: 600, PolicyType: DnsPolicyTypeSimple},
DnsRecordSet{DnsType: DnsTypeA, DnsValue: "12.12.12.12", Enabled: true, Id: "0ad65043-a4ca-4866-8032-56a51b018b46", DnsName: "example3.com", Status: "available", Ttl: 600, PolicyType: DnsPolicyTypeSimple},
DnsRecordSet{DnsType: DnsTypeA, DnsValue: "234.90.8.8", Enabled: true, Id: "f0ee44c9-12d4-40a3-84c4-ce9df25d0831", DnsName: "stest", Status: "available", Ttl: 600, PolicyType: DnsPolicyTypeSimple},
DnsRecordSet{DnsType: DnsTypeA, DnsValue: "123.12.12.12", Enabled: true, Id: "f82d1a9b-f3db-4617-8e59-4c264cecc1b6", DnsName: "abc", Status: "available", Ttl: 600, PolicyType: DnsPolicyTypeSimple},
},
},
}
for _, c := range cases {
iRecords := []ICloudDnsRecordSet{}
for i := range c.Remote {
iRecords = append(iRecords, &c.Remote[i])
}
common, added, removed, updated := CompareDnsRecordSet(iRecords, c.Local, true)
if len(common) != c.CommonCount {
t.Fatalf("[%s] common should be %d current is %d", c.Name, c.CommonCount, len(common))
}
if len(added) != c.AddCount {
t.Fatalf("[%s] added should be %d current is %d", c.Name, c.AddCount, len(added))
}
if len(removed) != c.DelCount {
t.Fatalf("[%s] removed should be %d current is %d", c.Name, c.DelCount, len(removed))
}
if len(updated) != c.UpdateCount {
t.Fatalf("[%s] updated should be %d current is %d", c.Name, c.UpdateCount, len(updated))
}
t.Logf("%s update:", c.Name)
for i, update := range updated {
t.Logf("%d %s", i, jsonutils.Marshal(update))
}
}
}
func TestDiscreteTTlRange(t *testing.T) {
cases := []struct {
TtlInput int64
TtlOutPut int64
}{
{TtlInput: 0, TtlOutPut: 5},
{TtlInput: 86399, TtlOutPut: 86400},
{TtlInput: 86401, TtlOutPut: 86400},
}
for _, c := range cases {
if c.TtlOutPut != TtlRangeAliyunPvtz.GetSuppportedTTL(c.TtlInput) {
t.Fatalf("input %d GetSuppportedTTL should be %d", c.TtlInput, c.TtlOutPut)
}
}
}

View File

@@ -1,15 +0,0 @@
// 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 cloudprovider // import "yunion.io/x/onecloud/pkg/cloudprovider"

View File

@@ -1,52 +0,0 @@
// 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 cloudprovider
import "testing"
func TestParseRange(t *testing.T) {
cases := []struct {
in string
start int64
end int64
}{
{
in: "bytes=0-200",
start: 0,
end: 200,
},
{
in: "200-3232300",
start: 200,
end: 3232300,
},
{
in: "200-",
start: 200,
end: 0,
},
{
in: "-232323",
start: 0,
end: 232323,
},
}
for _, c := range cases {
got := ParseRange(c.in)
if got.Start != c.start || got.End != c.end {
t.Fatalf("got.start(%d) != want.start(%d) or got.end(%d) != want.end(%d)", got.Start, c.start, got.End, c.end)
}
}
}

View File

@@ -18,13 +18,13 @@ import (
"context"
"fmt"
"yunion.io/x/cloudmux/pkg/cloudprovider"
"yunion.io/x/log"
"yunion.io/x/pkg/errors"
"yunion.io/x/pkg/utils"
api "yunion.io/x/onecloud/pkg/apis/compute"
"yunion.io/x/onecloud/pkg/cloudcommon/db/quotas"
"yunion.io/x/onecloud/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/compute/models"
"yunion.io/x/onecloud/pkg/httperrors"
"yunion.io/x/onecloud/pkg/mcclient"

View File

@@ -19,6 +19,7 @@ import (
"fmt"
"strings"
"yunion.io/x/cloudmux/pkg/cloudprovider"
"yunion.io/x/pkg/errors"
"yunion.io/x/pkg/util/osprofile"
"yunion.io/x/pkg/utils"
@@ -26,7 +27,6 @@ import (
api "yunion.io/x/onecloud/pkg/apis/compute"
"yunion.io/x/onecloud/pkg/cloudcommon/db"
"yunion.io/x/onecloud/pkg/cloudcommon/db/quotas"
"yunion.io/x/onecloud/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/compute/models"
"yunion.io/x/onecloud/pkg/httperrors"
"yunion.io/x/onecloud/pkg/mcclient"

View File

@@ -19,12 +19,12 @@ import (
"fmt"
"strings"
"yunion.io/x/cloudmux/pkg/cloudprovider"
"yunion.io/x/pkg/errors"
"yunion.io/x/pkg/utils"
api "yunion.io/x/onecloud/pkg/apis/compute"
"yunion.io/x/onecloud/pkg/cloudcommon/db/quotas"
"yunion.io/x/onecloud/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/compute/models"
"yunion.io/x/onecloud/pkg/compute/options"
"yunion.io/x/onecloud/pkg/httperrors"

View File

@@ -21,6 +21,7 @@ import (
"regexp"
"strings"
"yunion.io/x/cloudmux/pkg/cloudprovider"
"yunion.io/x/jsonutils"
"yunion.io/x/log"
"yunion.io/x/pkg/errors"
@@ -30,7 +31,6 @@ import (
"yunion.io/x/onecloud/pkg/cloudcommon/db"
"yunion.io/x/onecloud/pkg/cloudcommon/db/quotas"
"yunion.io/x/onecloud/pkg/cloudcommon/db/taskman"
"yunion.io/x/onecloud/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/compute/baremetal"
"yunion.io/x/onecloud/pkg/compute/models"
"yunion.io/x/onecloud/pkg/compute/options"

View File

@@ -21,6 +21,7 @@ import (
"strings"
"time"
"yunion.io/x/cloudmux/pkg/cloudprovider"
"yunion.io/x/jsonutils"
"yunion.io/x/pkg/errors"
"yunion.io/x/pkg/util/osprofile"
@@ -28,7 +29,6 @@ import (
api "yunion.io/x/onecloud/pkg/apis/compute"
"yunion.io/x/onecloud/pkg/cloudcommon/db/quotas"
"yunion.io/x/onecloud/pkg/cloudcommon/db/taskman"
"yunion.io/x/onecloud/pkg/cloudprovider"
guestdriver_types "yunion.io/x/onecloud/pkg/compute/guestdrivers/types"
"yunion.io/x/onecloud/pkg/compute/models"
"yunion.io/x/onecloud/pkg/httperrors"

View File

@@ -15,9 +15,10 @@
package guestdrivers
import (
"yunion.io/x/cloudmux/pkg/cloudprovider"
api "yunion.io/x/onecloud/pkg/apis/compute"
"yunion.io/x/onecloud/pkg/cloudcommon/db/quotas"
"yunion.io/x/onecloud/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/compute/models"
"yunion.io/x/onecloud/pkg/compute/options"
"yunion.io/x/onecloud/pkg/mcclient"

View File

@@ -15,11 +15,11 @@
package guestdrivers
import (
"yunion.io/x/cloudmux/pkg/cloudprovider"
"yunion.io/x/pkg/utils"
api "yunion.io/x/onecloud/pkg/apis/compute"
"yunion.io/x/onecloud/pkg/cloudcommon/db/quotas"
"yunion.io/x/onecloud/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/compute/models"
"yunion.io/x/onecloud/pkg/compute/options"
"yunion.io/x/onecloud/pkg/httperrors"

View File

@@ -18,13 +18,13 @@ import (
"context"
"fmt"
"yunion.io/x/cloudmux/pkg/cloudprovider"
"yunion.io/x/jsonutils"
"yunion.io/x/log"
api "yunion.io/x/onecloud/pkg/apis/compute"
"yunion.io/x/onecloud/pkg/cloudcommon/db/quotas"
"yunion.io/x/onecloud/pkg/cloudcommon/db/taskman"
"yunion.io/x/onecloud/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/compute/models"
"yunion.io/x/onecloud/pkg/compute/options"
"yunion.io/x/onecloud/pkg/httperrors"

View File

@@ -17,11 +17,11 @@ package guestdrivers
import (
"fmt"
"yunion.io/x/cloudmux/pkg/cloudprovider"
"yunion.io/x/pkg/utils"
api "yunion.io/x/onecloud/pkg/apis/compute"
"yunion.io/x/onecloud/pkg/cloudcommon/db/quotas"
"yunion.io/x/onecloud/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/compute/models"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/util/rbacutils"

View File

@@ -15,11 +15,11 @@
package guestdrivers
import (
"yunion.io/x/cloudmux/pkg/cloudprovider"
"yunion.io/x/pkg/errors"
api "yunion.io/x/onecloud/pkg/apis/compute"
"yunion.io/x/onecloud/pkg/cloudcommon/db/quotas"
"yunion.io/x/onecloud/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/compute/models"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/util/rbacutils"

View File

@@ -20,6 +20,8 @@ import (
"sort"
"time"
"yunion.io/x/cloudmux/pkg/cloudprovider"
"yunion.io/x/cloudmux/pkg/multicloud/esxi"
"yunion.io/x/jsonutils"
"yunion.io/x/log"
"yunion.io/x/pkg/errors"
@@ -30,12 +32,10 @@ import (
"yunion.io/x/onecloud/pkg/cloudcommon/db"
"yunion.io/x/onecloud/pkg/cloudcommon/db/quotas"
"yunion.io/x/onecloud/pkg/cloudcommon/db/taskman"
"yunion.io/x/onecloud/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/compute/models"
"yunion.io/x/onecloud/pkg/compute/options"
"yunion.io/x/onecloud/pkg/httperrors"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/multicloud/esxi"
"yunion.io/x/onecloud/pkg/util/billing"
"yunion.io/x/onecloud/pkg/util/httputils"
"yunion.io/x/onecloud/pkg/util/rbacutils"

View File

@@ -20,6 +20,8 @@ import (
"strings"
"time"
"yunion.io/x/cloudmux/pkg/cloudprovider"
"yunion.io/x/cloudmux/pkg/multicloud/google"
"yunion.io/x/jsonutils"
"yunion.io/x/log"
"yunion.io/x/pkg/errors"
@@ -29,11 +31,9 @@ import (
api "yunion.io/x/onecloud/pkg/apis/compute"
"yunion.io/x/onecloud/pkg/cloudcommon/db/quotas"
"yunion.io/x/onecloud/pkg/cloudcommon/db/taskman"
"yunion.io/x/onecloud/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/compute/models"
"yunion.io/x/onecloud/pkg/httperrors"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/multicloud/google"
"yunion.io/x/onecloud/pkg/util/billing"
"yunion.io/x/onecloud/pkg/util/rbacutils"
)

View File

@@ -19,6 +19,7 @@ import (
"database/sql"
"fmt"
"yunion.io/x/cloudmux/pkg/cloudprovider"
"yunion.io/x/log"
"yunion.io/x/pkg/errors"
"yunion.io/x/pkg/utils"
@@ -27,7 +28,6 @@ import (
api "yunion.io/x/onecloud/pkg/apis/compute"
"yunion.io/x/onecloud/pkg/cloudcommon/db"
"yunion.io/x/onecloud/pkg/cloudcommon/db/quotas"
"yunion.io/x/onecloud/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/compute/models"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/util/billing"

View File

@@ -17,11 +17,11 @@ package guestdrivers
import (
"fmt"
"yunion.io/x/cloudmux/pkg/cloudprovider"
"yunion.io/x/pkg/utils"
api "yunion.io/x/onecloud/pkg/apis/compute"
"yunion.io/x/onecloud/pkg/cloudcommon/db/quotas"
"yunion.io/x/onecloud/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/compute/models"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/util/billing"

View File

@@ -19,6 +19,7 @@ import (
"database/sql"
"fmt"
"yunion.io/x/cloudmux/pkg/cloudprovider"
"yunion.io/x/log"
"yunion.io/x/pkg/errors"
"yunion.io/x/pkg/utils"
@@ -27,7 +28,6 @@ import (
api "yunion.io/x/onecloud/pkg/apis/compute"
"yunion.io/x/onecloud/pkg/cloudcommon/db"
"yunion.io/x/onecloud/pkg/cloudcommon/db/quotas"
"yunion.io/x/onecloud/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/compute/models"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/util/billing"

Some files were not shown because too many files have changed in this diff Show More