From bce284a4c402028f5e98eb07f6f013e9859522c0 Mon Sep 17 00:00:00 2001 From: TangBin Date: Wed, 26 Feb 2020 17:12:41 +0800 Subject: [PATCH] ctyun vpc create fix --- pkg/multicloud/ctyun/region.go | 1 + pkg/multicloud/ctyun/vpc.go | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/pkg/multicloud/ctyun/region.go b/pkg/multicloud/ctyun/region.go index ffcdb1bb0e..a119051a8e 100644 --- a/pkg/multicloud/ctyun/region.go +++ b/pkg/multicloud/ctyun/region.go @@ -115,6 +115,7 @@ func (self *SRegion) CreateVpc(name, cidr string) (*SVpc, error) { return nil, err } + vpc.ResVpcID, _ = resp.GetString("returnObj", "id") vpc.region = self return vpc, nil } diff --git a/pkg/multicloud/ctyun/vpc.go b/pkg/multicloud/ctyun/vpc.go index c0aaab847e..743a51da97 100644 --- a/pkg/multicloud/ctyun/vpc.go +++ b/pkg/multicloud/ctyun/vpc.go @@ -204,6 +204,10 @@ func (self *SRegion) GetVpc(vpcId string) (*SVpc, error) { return nil, errors.Wrap(err, "SRegion.GetVpc.DoGet") } + if id, _ := resp.GetString("returnObj", "resVpcId"); len(id) == 0 { + return nil, errors.Wrap(cloudprovider.ErrNotFound, "SRegion.GetVpc.GetID") + } + err = resp.Unmarshal(vpc, "returnObj") if err != nil { return nil, errors.Wrap(err, "SRegion.GetVpc.Unmarshal")