From 677737215e02d647fcfeea32a7c05ea46c07257c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=97=AD?= Date: Wed, 11 Mar 2020 21:04:20 +0800 Subject: [PATCH 1/2] add bucket connection test --- cmd/climc/shell/bucket_options.go | 45 ++++++++++++++++++++++ pkg/mcclient/modules/mod_bucket_options.go | 15 ++++++++ 2 files changed, 60 insertions(+) create mode 100644 cmd/climc/shell/bucket_options.go create mode 100644 pkg/mcclient/modules/mod_bucket_options.go diff --git a/cmd/climc/shell/bucket_options.go b/cmd/climc/shell/bucket_options.go new file mode 100644 index 0000000000..38e04e82f8 --- /dev/null +++ b/cmd/climc/shell/bucket_options.go @@ -0,0 +1,45 @@ +// Copyright 2019 Yunion +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package shell + +import ( + "yunion.io/x/jsonutils" + "yunion.io/x/onecloud/pkg/mcclient" + "yunion.io/x/onecloud/pkg/mcclient/modules" + "yunion.io/x/onecloud/pkg/mcclient/options" +) + +func init() { + type BucketOptionsVerifyOptions struct { + options.BaseListOptions + CloudaccountId string `help:"cloudaccount Id" required:"true"` + BillingReportBucket string `help:"S3 bucket that stores account billing report"` + BillingFilePrefix string `help:"prefix of billing file name"` + BillingBucketAccount string `help:"Id of cloudaccount that can access billing bucket"` + UsageReportBucket string `help:"S3 bucket that stores account usage report"` + UsageFilePrefix string `help:"prefix of usage file name"` + UsageBucketAccount string `help:"Id of cloudaccount that can access usage bucket"` + } + R(&BucketOptionsVerifyOptions{}, "bucket-options-verify", "billing bucket connection test", + func(s *mcclient.ClientSession, args *BucketOptionsVerifyOptions) error { + params := jsonutils.Marshal(args) + result, err := modules.BucketOptions.PerformAction(s, args.CloudaccountId, "verify", params) + if err != nil { + return err + } + printObject(result) + return nil + }) +} diff --git a/pkg/mcclient/modules/mod_bucket_options.go b/pkg/mcclient/modules/mod_bucket_options.go new file mode 100644 index 0000000000..4746e90e10 --- /dev/null +++ b/pkg/mcclient/modules/mod_bucket_options.go @@ -0,0 +1,15 @@ +package modules + +import "yunion.io/x/onecloud/pkg/mcclient/modulebase" + +var ( + BucketOptions modulebase.ResourceManager +) + +func init() { + BucketOptions = NewMeterManager("bucket_option", "bucket_options", + []string{"status"}, + []string{}, + ) + register(&BucketOptions) +} From 8f69e245b29526236132c4f31b963a6920b66e57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=97=AD?= Date: Thu, 12 Mar 2020 10:44:23 +0800 Subject: [PATCH 2/2] change climc bucket options import --- cmd/climc/shell/bucket_options.go | 1 + 1 file changed, 1 insertion(+) diff --git a/cmd/climc/shell/bucket_options.go b/cmd/climc/shell/bucket_options.go index 38e04e82f8..f52f0b3581 100644 --- a/cmd/climc/shell/bucket_options.go +++ b/cmd/climc/shell/bucket_options.go @@ -16,6 +16,7 @@ package shell import ( "yunion.io/x/jsonutils" + "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/mcclient/modules" "yunion.io/x/onecloud/pkg/mcclient/options"