mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-10-16 06:57:44 +08:00
fix(region): not sync update netinterface wire_id when merge wires
This commit is contained in:
@@ -27,7 +27,7 @@ func init() {
|
||||
cmd.Show(&options.SCloudAccountIdOptions{})
|
||||
cmd.Delete(&options.SCloudAccountIdOptions{})
|
||||
cmd.Update(&options.SCloudAccountUpdateBaseOptions{})
|
||||
cmd.PerformClassWithKeyword("preparenets-vmware", "prepare-nets", &options.SVMwareCloudAccountPrepareNetsOptions{})
|
||||
// cmd.PerformClassWithKeyword("preparenets-vmware", "prepare-nets", &options.SVMwareCloudAccountPrepareNetsOptions{})
|
||||
|
||||
cmd.CreateWithKeyword("create-vmware", &options.SVMwareCloudAccountCreateOptions{})
|
||||
cmd.CreateWithKeyword("create-aliyun", &options.SAliyunCloudAccountCreateOptions{})
|
||||
|
||||
@@ -62,7 +62,7 @@ type CAPWire struct {
|
||||
|
||||
var ipMaskLen int8 = 24
|
||||
|
||||
func (account *SCloudaccount) PrepareEsxiHostNetwork(ctx context.Context, userCred mcclient.TokenCredential) error {
|
||||
func (account *SCloudaccount) PrepareEsxiHostNetwork(ctx context.Context, userCred mcclient.TokenCredential, zoneId string) error {
|
||||
cProvider, err := account.GetProvider(ctx)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "account.GetProvider")
|
||||
@@ -92,9 +92,11 @@ func (account *SCloudaccount) PrepareEsxiHostNetwork(ctx context.Context, userCr
|
||||
return errors.Wrap(err, "NetworkManager.fetchAllOnpremiseNetworks")
|
||||
}
|
||||
|
||||
zoneId, err := guessEsxiZoneId(vsList, onPremiseNets)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "fail to find zone of esxi")
|
||||
if zoneId == "" {
|
||||
zoneId, err = guessEsxiZoneId(vsList, onPremiseNets)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "fail to find zone of esxi")
|
||||
}
|
||||
}
|
||||
|
||||
desc := fmt.Sprintf("Auto create for cloudaccount %q", account.Name)
|
||||
|
||||
@@ -586,7 +586,7 @@ func (self *SCloudaccount) PostCreate(ctx context.Context, userCred mcclient.Tok
|
||||
self.savePassword(self.Secret)
|
||||
|
||||
if self.Enabled.IsTrue() && jsonutils.QueryBoolean(data, "start_sync", true) {
|
||||
self.StartSyncCloudAccountInfoTask(ctx, userCred, nil, "")
|
||||
self.StartSyncCloudAccountInfoTask(ctx, userCred, nil, "", data)
|
||||
} else {
|
||||
self.SubmitSyncAccountTask(ctx, userCred, nil)
|
||||
}
|
||||
@@ -623,7 +623,7 @@ func (self *SCloudaccount) PerformSync(ctx context.Context, userCred mcclient.To
|
||||
syncRange.DeepSync = true
|
||||
}
|
||||
if self.CanSync() || syncRange.Force {
|
||||
return nil, self.StartSyncCloudAccountInfoTask(ctx, userCred, &syncRange, "")
|
||||
return nil, self.StartSyncCloudAccountInfoTask(ctx, userCred, &syncRange, "", nil)
|
||||
}
|
||||
return nil, httperrors.NewInvalidStatusError("Unable to synchronize frequently")
|
||||
}
|
||||
@@ -786,14 +786,17 @@ func (self *SCloudaccount) PerformUpdateCredential(ctx context.Context, userCred
|
||||
logclient.AddActionLogWithContext(ctx, self, logclient.ACT_UPDATE_CREDENTIAL, account.Account, userCred, true)
|
||||
|
||||
self.SetStatus(userCred, api.CLOUD_PROVIDER_INIT, "Change credential")
|
||||
self.StartSyncCloudAccountInfoTask(ctx, userCred, nil, "")
|
||||
self.StartSyncCloudAccountInfoTask(ctx, userCred, nil, "", nil)
|
||||
}
|
||||
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (self *SCloudaccount) StartSyncCloudAccountInfoTask(ctx context.Context, userCred mcclient.TokenCredential, syncRange *SSyncRange, parentTaskId string) error {
|
||||
func (self *SCloudaccount) StartSyncCloudAccountInfoTask(ctx context.Context, userCred mcclient.TokenCredential, syncRange *SSyncRange, parentTaskId string, data jsonutils.JSONObject) error {
|
||||
params := jsonutils.NewDict()
|
||||
if data != nil {
|
||||
params.Update(data)
|
||||
}
|
||||
if syncRange != nil {
|
||||
params.Add(jsonutils.Marshal(syncRange), "sync_range")
|
||||
}
|
||||
@@ -2221,7 +2224,7 @@ func (account *SCloudaccount) PerformPublic(ctx context.Context, userCred mcclie
|
||||
FullSync: true,
|
||||
},
|
||||
}
|
||||
account.StartSyncCloudAccountInfoTask(ctx, userCred, syncRange, "")
|
||||
account.StartSyncCloudAccountInfoTask(ctx, userCred, syncRange, "", nil)
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
@@ -2255,7 +2258,7 @@ func (account *SCloudaccount) PerformPrivate(ctx context.Context, userCred mccli
|
||||
FullSync: true,
|
||||
},
|
||||
}
|
||||
account.StartSyncCloudAccountInfoTask(ctx, userCred, syncRange, "")
|
||||
account.StartSyncCloudAccountInfoTask(ctx, userCred, syncRange, "", nil)
|
||||
|
||||
return nil, nil
|
||||
}
|
||||
@@ -2704,7 +2707,7 @@ func (self *SCloudaccount) PerformCreateSubscription(ctx context.Context, userCr
|
||||
}
|
||||
|
||||
syncRange := SSyncRange{}
|
||||
return nil, self.StartSyncCloudAccountInfoTask(ctx, userCred, &syncRange, "")
|
||||
return nil, self.StartSyncCloudAccountInfoTask(ctx, userCred, &syncRange, "", nil)
|
||||
}
|
||||
|
||||
func (self *SCloudaccount) GetDnsZoneCaches() ([]SDnsZoneCache, error) {
|
||||
|
||||
@@ -88,3 +88,22 @@ func (manager *SNetworkManager) handleWireIdChange(ctx context.Context, args *wi
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (manager *SNetInterfaceManager) handleWireIdChange(ctx context.Context, args *wireIdChangeArgs) error {
|
||||
ns := make([]SNetInterface, 0, 8)
|
||||
err := db.FetchModelObjects(manager, manager.Query().Equals("wire_id", args.oldWire.Id), &ns)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for i := range ns {
|
||||
n := &ns[i]
|
||||
_, err := db.Update(n, func() error {
|
||||
n.WireId = args.newWire.Id
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "unable to update network %q", n.GetId())
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -1266,6 +1266,7 @@ func (wm *SWireManager) handleWireIdChange(ctx context.Context, args *wireIdChan
|
||||
HostwireManager,
|
||||
NetworkManager,
|
||||
LoadbalancerClusterManager,
|
||||
NetInterfaceManager,
|
||||
}
|
||||
|
||||
errs := []error{}
|
||||
|
||||
@@ -42,7 +42,8 @@ func (self *CloudAccountSyncInfoTask) OnInit(ctx context.Context, obj db.IStanda
|
||||
|
||||
if cloudaccount.Provider == api.CLOUD_PROVIDER_VMWARE {
|
||||
cloudaccount.SetStatus(self.UserCred, api.CLOUD_PROVIDER_SYNC_NETWORK, "StartSyncVMwareNetworkTask")
|
||||
err := cloudaccount.PrepareEsxiHostNetwork(ctx, self.UserCred)
|
||||
zone, _ := self.Params.GetString("zone")
|
||||
err := cloudaccount.PrepareEsxiHostNetwork(ctx, self.UserCred, zone)
|
||||
if err != nil {
|
||||
d := jsonutils.NewDict()
|
||||
d.Set("error", jsonutils.NewString(err.Error()))
|
||||
|
||||
@@ -46,6 +46,8 @@ type SVMwareCredentialWithEnvironment struct {
|
||||
|
||||
Host string `help:"VMware VCenter/ESXi host" positional:"true"`
|
||||
Port string `help:"VMware VCenter/ESXi host port" default:"443"`
|
||||
|
||||
Zone string `help:"zone for this account"`
|
||||
}
|
||||
|
||||
type SNutanixCredentialWithEnvironment struct {
|
||||
@@ -971,9 +973,10 @@ func (opts *SCloudpodsCloudAccountUpdateOptions) Params() (jsonutils.JSONObject,
|
||||
return jsonutils.Marshal(opts), nil
|
||||
}
|
||||
|
||||
type SVMwareCloudAccountPrepareNetsOptions struct {
|
||||
/*type SVMwareCloudAccountPrepareNetsOptions struct {
|
||||
SVMwareCredentialWithEnvironment
|
||||
|
||||
Zone string `help:"zone for this account"`
|
||||
Project string `help:"project for this account"`
|
||||
ProjectDomain string `help:"domain for this account"`
|
||||
WireLevel string `help:"wire level for this account" choices:"vcenter|datacenter|cluster" json:"wire_level_for_vmware"`
|
||||
@@ -985,7 +988,7 @@ func (opts *SVMwareCloudAccountPrepareNetsOptions) Params() (jsonutils.JSONObjec
|
||||
params := jsonutils.Marshal(opts)
|
||||
params.(*jsonutils.JSONDict).Add(jsonutils.NewString("VMware"), "provider")
|
||||
return params, nil
|
||||
}
|
||||
}*/
|
||||
|
||||
type SApsaraCloudAccountCreateOptions struct {
|
||||
SCloudAccountCreateBaseOptions
|
||||
|
||||
Reference in New Issue
Block a user