mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
Merge pull request #13696 from ioito/hotfix/qx-cloudpods-err
fix(region): cloudpods error
This commit is contained in:
@@ -16,6 +16,7 @@ package cloudpods
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strings"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/pkg/errors"
|
||||
@@ -125,8 +126,15 @@ func (self *SCloudpodsClient) get(manager ModelManager, id string, params map[st
|
||||
if len(id) == 0 {
|
||||
return errors.Wrap(cloudprovider.ErrNotFound, "empty id")
|
||||
}
|
||||
resp, err := manager.Get(self.s, id, jsonutils.Marshal(params))
|
||||
body := jsonutils.NewDict()
|
||||
for k, v := range params {
|
||||
body.Set(k, jsonutils.NewString(v))
|
||||
}
|
||||
resp, err := manager.Get(self.s, id, body)
|
||||
if err != nil {
|
||||
if strings.Contains(err.Error(), "NotFoundError") {
|
||||
return errors.Wrapf(cloudprovider.ErrNotFound, err.Error())
|
||||
}
|
||||
return errors.Wrapf(err, "Get(%s)", id)
|
||||
}
|
||||
return resp.Unmarshal(retVal)
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
// 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/onecloud/pkg/multicloud/cloudpods"
|
||||
"yunion.io/x/onecloud/pkg/util/shellutils"
|
||||
)
|
||||
|
||||
func init() {
|
||||
type SecurityGroupListOptions struct {
|
||||
}
|
||||
shellutils.R(&SecurityGroupListOptions{}, "security-group-list", "List security-groups", func(cli *cloudpods.SRegion, args *SecurityGroupListOptions) error {
|
||||
groups, err := cli.GetSecurityGroups()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printList(groups, 0, 0, 0, nil)
|
||||
return nil
|
||||
})
|
||||
|
||||
type SecurityGroupIdOptions struct {
|
||||
ID string
|
||||
}
|
||||
shellutils.R(&SecurityGroupIdOptions{}, "security-group-show", "Show security group", func(cli *cloudpods.SRegion, args *SecurityGroupIdOptions) error {
|
||||
group, err := cli.GetSecurityGroup(args.ID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(group)
|
||||
return nil
|
||||
})
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user