From 963af1311a76769be89007dec45f5965c805903e Mon Sep 17 00:00:00 2001 From: Qiu Jian Date: Sat, 10 Aug 2019 16:46:56 +0800 Subject: [PATCH] fix: bucket GetShortDesc includes cloudproviderinfo --- cmd/climc/shell/events.go | 14 ++++++++++++-- pkg/compute/models/buckets.go | 5 +++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/cmd/climc/shell/events.go b/cmd/climc/shell/events.go index 452d5ce946..1696890862 100644 --- a/cmd/climc/shell/events.go +++ b/cmd/climc/shell/events.go @@ -151,8 +151,18 @@ func init() { return doComputeEventList(s, &nargs) }) - R(&TypeEventListOptions{}, "vcenter-event", "Show operation event logs of vcenter", func(s *mcclient.ClientSession, args *TypeEventListOptions) error { - nargs := EventListOptions{BaseEventListOptions: args.BaseEventListOptions, Id: args.ID, Type: []string{"vcenter"}} + R(&TypeEventListOptions{}, "cloud-provider-event", "Show operation event logs of cloudprovider", func(s *mcclient.ClientSession, args *TypeEventListOptions) error { + nargs := EventListOptions{BaseEventListOptions: args.BaseEventListOptions, Id: args.ID, Type: []string{"cloudprovider"}} + return doComputeEventList(s, &nargs) + }) + + R(&TypeEventListOptions{}, "cloud-account-event", "Show operation event logs of cloudaccount", func(s *mcclient.ClientSession, args *TypeEventListOptions) error { + nargs := EventListOptions{BaseEventListOptions: args.BaseEventListOptions, Id: args.ID, Type: []string{"cloudaccount"}} + return doComputeEventList(s, &nargs) + }) + + R(&TypeEventListOptions{}, "bucket-event", "Show operation event logs of bucket", func(s *mcclient.ClientSession, args *TypeEventListOptions) error { + nargs := EventListOptions{BaseEventListOptions: args.BaseEventListOptions, Id: args.ID, Type: []string{"bucket"}} return doComputeEventList(s, &nargs) }) diff --git a/pkg/compute/models/buckets.go b/pkg/compute/models/buckets.go index 085c09ae56..68a7da1dd7 100644 --- a/pkg/compute/models/buckets.go +++ b/pkg/compute/models/buckets.go @@ -213,10 +213,15 @@ func (bucket *SBucket) getStats() cloudprovider.SBucketStats { func (bucket *SBucket) GetShortDesc(ctx context.Context) *jsonutils.JSONDict { desc := bucket.SVirtualResourceBase.GetShortDesc(ctx) + desc.Add(jsonutils.NewInt(bucket.SizeBytes), "size_bytes") desc.Add(jsonutils.NewInt(int64(bucket.ObjectCnt)), "object_cnt") desc.Add(jsonutils.NewString(bucket.Acl), "acl") desc.Add(jsonutils.NewString(bucket.StorageClass), "storage_class") + + info := bucket.getCloudProviderInfo() + desc.Update(jsonutils.Marshal(&info)) + return desc }