Skip to content

Commit

Permalink
hotfix: vpc change owners with wire
Browse files Browse the repository at this point in the history
  • Loading branch information
Qiu Jian committed Jul 9, 2020
1 parent 3f39164 commit c97e2ab
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
18 changes: 18 additions & 0 deletions pkg/compute/models/vpcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -1268,3 +1268,21 @@ func (vpc *SVpc) PerformPrivate(ctx context.Context, userCred mcclient.TokenCred
}
return vpc.SEnabledStatusInfrasResourceBase.PerformPrivate(ctx, userCred, query, input)
}

func (vpc *SVpc) PerformChangeOwner(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, input apis.PerformChangeDomainOwnerInput) (jsonutils.JSONObject, error) {
_, err := vpc.SEnabledStatusInfrasResourceBase.PerformChangeOwner(ctx, userCred, query, input)
if err != nil {
return nil, errors.Wrap(err, "SEnabledStatusInfrasResourceBase.PerformChangeOwner")
}
wires := vpc.GetWires()
for i := range wires {
if wires[i].IsEmulated {
_, err := wires[i].PerformChangeOwner(ctx, userCred, query, input)
if err != nil {
return nil, errors.Wrap(err, "wires[i].PerformChangeOwner")
}
}
}

return nil, nil
}
9 changes: 6 additions & 3 deletions pkg/compute/models/wires.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ func (self *SWire) syncWithCloudWire(ctx context.Context, userCred mcclient.Toke
log.Errorf("syncWithCloudWire error %s", err)
}

if provider != nil {
if provider != nil && !self.IsEmulated {
SyncCloudDomain(userCred, self, provider.GetOwnerId())
self.SyncShareState(ctx, userCred, provider.getAccountShareInfo())
}
Expand Down Expand Up @@ -408,17 +408,20 @@ func (manager *SWireManager) newFromCloudWire(ctx context.Context, userCred mccl
}

wire.IsEmulated = extWire.IsEmulated()
wire.DomainId = vpc.DomainId
wire.IsPublic = vpc.IsPublic
wire.PublicScope = vpc.PublicScope

err = manager.TableSpec().Insert(ctx, &wire)
if err != nil {
log.Errorf("newFromCloudWire fail %s", err)
return nil, err
}

if provider != nil {
/*if provider != nil {
SyncCloudDomain(userCred, &wire, provider.GetOwnerId())
wire.SyncShareState(ctx, userCred, provider.getAccountShareInfo())
}
}*/

db.OpsLog.LogEvent(&wire, db.ACT_CREATE, wire.GetShortDesc(ctx), userCred)
return &wire, nil
Expand Down

0 comments on commit c97e2ab

Please sign in to comment.