mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-19 02:37:24 +08:00
elb sync fix
This commit is contained in:
@@ -20,12 +20,12 @@ import (
|
||||
"strings"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/log"
|
||||
"yunion.io/x/pkg/errors"
|
||||
"yunion.io/x/pkg/utils"
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db/taskman"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/compute/models"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
@@ -170,44 +170,46 @@ func (self *SAwsGuestDriver) IsSupportedBillingCycle(bc billing.SBillingCycle) b
|
||||
return false
|
||||
}
|
||||
|
||||
func (self *SAwsGuestDriver) RequestSyncstatusOnHost(ctx context.Context, guest *models.SGuest, host *models.SHost, userCred mcclient.TokenCredential) (jsonutils.JSONObject, error) {
|
||||
ihost, err := host.GetIHost()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ivm, err := ihost.GetIVMById(guest.ExternalId)
|
||||
if err != nil {
|
||||
log.Errorf("fail to find ivm by id %s", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = guest.SyncAllWithCloudVM(ctx, userCred, host, ivm)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ieip, err := ivm.GetIEIP()
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "AwsGuestDriver.GetIEIP")
|
||||
}
|
||||
|
||||
// 如果aws已经绑定了EIP,则要把多余的公有IP删除
|
||||
if ieip.GetMode() == api.EIP_MODE_STANDALONE_EIP {
|
||||
publicIP, err := guest.GetPublicIp()
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "AwsGuestDriver.GetPublicIp")
|
||||
func (self *SAwsGuestDriver) RequestAssociateEip(ctx context.Context, userCred mcclient.TokenCredential, server *models.SGuest, eip *models.SElasticip, task taskman.ITask) error {
|
||||
taskman.LocalTaskRun(task, func() (jsonutils.JSONObject, error) {
|
||||
if server.Status != api.VM_ASSOCIATE_EIP {
|
||||
server.SetStatus(userCred, api.VM_ASSOCIATE_EIP, "associate eip")
|
||||
}
|
||||
|
||||
if publicIP != nil {
|
||||
err = db.DeleteModel(ctx, userCred, publicIP)
|
||||
extEip, err := eip.GetIEip()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("SAwsGuestDriver.RequestAssociateEip fail to find iEIP for eip %s", err)
|
||||
}
|
||||
|
||||
err = extEip.Associate(server.ExternalId)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("SAwsGuestDriver.RequestAssociateEip fail to remote associate EIP %s", err)
|
||||
}
|
||||
|
||||
err = eip.AssociateVM(ctx, userCred, server)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("SAwsGuestDriver.RequestAssociateEip fail to local associate EIP %s", err)
|
||||
}
|
||||
|
||||
eip.SetStatus(userCred, api.EIP_STATUS_READY, "associate")
|
||||
|
||||
// 如果aws已经绑定了EIP,则要把多余的公有IP删除
|
||||
if extEip.GetMode() == api.EIP_MODE_STANDALONE_EIP {
|
||||
publicIP, err := server.GetPublicIp()
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "AwsGuestDriver.DeletePublicIp")
|
||||
return nil, errors.Wrap(err, "AwsGuestDriver.GetPublicIp")
|
||||
}
|
||||
|
||||
if publicIP != nil {
|
||||
err = db.DeleteModel(ctx, userCred, publicIP)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "AwsGuestDriver.DeletePublicIp")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
status := GetCloudVMStatus(ivm)
|
||||
body := jsonutils.NewDict()
|
||||
body.Add(jsonutils.NewString(status), "status")
|
||||
return body, nil
|
||||
return nil, nil
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -247,6 +247,10 @@ func (self *SBaseGuestDriver) IsSupportEip() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (self *SBaseGuestDriver) RequestAssociateEip(ctx context.Context, userCred mcclient.TokenCredential, guest *models.SGuest, eip *models.SElasticip, task taskman.ITask) error {
|
||||
return fmt.Errorf("SBaseGuestDriver: Not Implement RequestAssociateEip")
|
||||
}
|
||||
|
||||
func (self *SBaseGuestDriver) NeedStopForChangeSpec(guest *models.SGuest) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -226,6 +226,10 @@ func (self *SESXiGuestDriver) IsSupportEip() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (self *SESXiGuestDriver) RequestAssociateEip(ctx context.Context, userCred mcclient.TokenCredential, guest *models.SGuest, eip *models.SElasticip, task taskman.ITask) error {
|
||||
return fmt.Errorf("ESXiGuestDriver not support associate eip")
|
||||
}
|
||||
|
||||
func (self *SESXiGuestDriver) CancelExpireTime(
|
||||
ctx context.Context, userCred mcclient.TokenCredential, guest *models.SGuest) error {
|
||||
return guest.CancelExpireTime(ctx, userCred)
|
||||
|
||||
@@ -941,6 +941,34 @@ func (self *SManagedVirtualizedGuestDriver) IsSupportEip() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (self *SManagedVirtualizedGuestDriver) RequestAssociateEip(ctx context.Context, userCred mcclient.TokenCredential, server *models.SGuest, eip *models.SElasticip, task taskman.ITask) error {
|
||||
taskman.LocalTaskRun(task, func() (jsonutils.JSONObject, error) {
|
||||
if server.Status != api.VM_ASSOCIATE_EIP {
|
||||
server.SetStatus(userCred, api.VM_ASSOCIATE_EIP, "associate eip")
|
||||
}
|
||||
|
||||
extEip, err := eip.GetIEip()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("ManagedVirtualizedGuestDriver.RequestAssociateEip fail to find iEIP for eip %s", err)
|
||||
}
|
||||
|
||||
err = extEip.Associate(server.ExternalId)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("ManagedVirtualizedGuestDriver.RequestAssociateEip fail to remote associate EIP %s", err)
|
||||
}
|
||||
|
||||
err = eip.AssociateVM(ctx, userCred, server)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("ManagedVirtualizedGuestDriver.RequestAssociateEip fail to local associate EIP %s", err)
|
||||
}
|
||||
|
||||
eip.SetStatus(userCred, api.EIP_STATUS_READY, "associate")
|
||||
return nil, nil
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SManagedVirtualizedGuestDriver) chooseHostStorage(
|
||||
drv models.IGuestDriver,
|
||||
host *models.SHost,
|
||||
|
||||
@@ -20,7 +20,6 @@ import (
|
||||
|
||||
"yunion.io/x/log"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db/lockman"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
@@ -81,26 +80,22 @@ func syncRegionLoadbalancers(ctx context.Context, userCred mcclient.TokenCredent
|
||||
}
|
||||
db.OpsLog.LogEvent(provider, db.ACT_SYNC_LB_COMPLETE, msg, userCred)
|
||||
// 同步未关联负载均衡的后端服务器组
|
||||
if provider.Provider == compute.CLOUD_PROVIDER_AWS {
|
||||
syncAwsLoadbalancerBackendgroups(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange)
|
||||
regionDriver, err := localRegion.GetRegionDriver()
|
||||
if err != nil {
|
||||
msg := fmt.Sprintf("GetRegionDriver %s failed %s", localRegion.GetName(), err)
|
||||
log.Errorln(msg)
|
||||
return
|
||||
}
|
||||
|
||||
regionDriver.RequestPullRegionLoadbalancerBackendGroup(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange)
|
||||
|
||||
for i := 0; i < len(localLbs); i++ {
|
||||
func() {
|
||||
lockman.LockObject(ctx, &localLbs[i])
|
||||
defer lockman.ReleaseObject(ctx, &localLbs[i])
|
||||
|
||||
syncLoadbalancerEip(ctx, userCred, provider, &localLbs[i], remoteLbs[i])
|
||||
|
||||
switch provider.Provider {
|
||||
case compute.CLOUD_PROVIDER_AWS:
|
||||
break
|
||||
case compute.CLOUD_PROVIDER_HUAWEI:
|
||||
syncHuaweiLoadbalancerBackendgroups(ctx, userCred, syncResults, provider, &localLbs[i], remoteLbs[i], syncRange)
|
||||
default:
|
||||
syncLoadbalancerBackendgroups(ctx, userCred, syncResults, provider, &localLbs[i], remoteLbs[i], syncRange)
|
||||
}
|
||||
|
||||
regionDriver.RequestPullLoadbalancerBackendGroup(ctx, userCred, syncResults, provider, &localLbs[i], remoteLbs[i], syncRange)
|
||||
syncLoadbalancerListeners(ctx, userCred, syncResults, provider, &localLbs[i], remoteLbs[i], syncRange)
|
||||
}()
|
||||
}
|
||||
@@ -166,7 +161,7 @@ func syncLoadbalancerListenerRules(ctx context.Context, userCred mcclient.TokenC
|
||||
}
|
||||
}
|
||||
|
||||
func syncLoadbalancerBackendgroups(ctx context.Context, userCred mcclient.TokenCredential, syncResults SSyncResultSet, provider *SCloudprovider, localLoadbalancer *SLoadbalancer, remoteLoadbalancer cloudprovider.ICloudLoadbalancer, syncRange *SSyncRange) {
|
||||
func SyncLoadbalancerBackendgroups(ctx context.Context, userCred mcclient.TokenCredential, syncResults SSyncResultSet, provider *SCloudprovider, localLoadbalancer *SLoadbalancer, remoteLoadbalancer cloudprovider.ICloudLoadbalancer, syncRange *SSyncRange) {
|
||||
remoteBackendgroups, err := remoteLoadbalancer.GetILoadBalancerBackendGroups()
|
||||
if err != nil {
|
||||
msg := fmt.Sprintf("GetILoadBalancerBackendGroups for loadbalancer %s failed %s", localLoadbalancer.Name, err)
|
||||
@@ -211,7 +206,7 @@ func syncLoadbalancerBackends(ctx context.Context, userCred mcclient.TokenCreden
|
||||
}
|
||||
|
||||
/*huawei elb sync*/
|
||||
func syncHuaweiLoadbalancerBackendgroups(ctx context.Context, userCred mcclient.TokenCredential, syncResults SSyncResultSet, provider *SCloudprovider, localLoadbalancer *SLoadbalancer, remoteLoadbalancer cloudprovider.ICloudLoadbalancer, syncRange *SSyncRange) {
|
||||
func SyncHuaweiLoadbalancerBackendgroups(ctx context.Context, userCred mcclient.TokenCredential, syncResults SSyncResultSet, provider *SCloudprovider, localLoadbalancer *SLoadbalancer, remoteLoadbalancer cloudprovider.ICloudLoadbalancer, syncRange *SSyncRange) {
|
||||
remoteBackendgroups, err := remoteLoadbalancer.GetILoadBalancerBackendGroups()
|
||||
if err != nil {
|
||||
msg := fmt.Sprintf("GetILoadBalancerBackendGroups for loadbalancer %s failed %s", localLoadbalancer.Name, err)
|
||||
@@ -256,7 +251,7 @@ func syncHuaweiLoadbalancerBackends(ctx context.Context, userCred mcclient.Token
|
||||
}
|
||||
|
||||
/*aws elb sync*/
|
||||
func syncAwsLoadbalancerBackendgroups(ctx context.Context, userCred mcclient.TokenCredential, syncResults SSyncResultSet, provider *SCloudprovider, localRegion *SCloudregion, remoteRegion cloudprovider.ICloudRegion, syncRange *SSyncRange) {
|
||||
func SyncAwsLoadbalancerBackendgroups(ctx context.Context, userCred mcclient.TokenCredential, syncResults SSyncResultSet, provider *SCloudprovider, localRegion *SCloudregion, remoteRegion cloudprovider.ICloudRegion, syncRange *SSyncRange) {
|
||||
remoteBackendgroups, err := remoteRegion.GetILoadBalancerBackendGroups()
|
||||
if err != nil {
|
||||
msg := fmt.Sprintf("GetILoadBalancerBackendGroups for region %s failed %s", localRegion.Name, err)
|
||||
|
||||
@@ -434,35 +434,18 @@ func (manager *SElasticipManager) newFromCloudEip(ctx context.Context, userCred
|
||||
}
|
||||
|
||||
func (manager *SElasticipManager) getEipForInstance(instanceType string, instanceId string) (*SElasticip, error) {
|
||||
eip := SElasticip{}
|
||||
|
||||
q := manager.Query()
|
||||
q = q.Equals("associate_type", instanceType)
|
||||
q = q.Equals("associate_id", instanceId)
|
||||
|
||||
err := q.First(&eip)
|
||||
|
||||
if err != nil {
|
||||
if err != sql.ErrNoRows {
|
||||
log.Errorf("getEipForInstance query fail %s", err)
|
||||
return nil, err
|
||||
} else {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
|
||||
eip.SetModelManager(manager, &eip)
|
||||
|
||||
return &eip, nil
|
||||
return manager.getEip(instanceType, instanceId, "")
|
||||
}
|
||||
|
||||
func (manager *SElasticipManager) getPublicIpForInstance(instanceType string, instanceId string) (*SElasticip, error) {
|
||||
func (manager *SElasticipManager) getEip(instanceType string, instanceId string, eipMode string) (*SElasticip, error) {
|
||||
eip := SElasticip{}
|
||||
|
||||
q := manager.Query()
|
||||
q = q.Equals("associate_type", instanceType)
|
||||
q = q.Equals("associate_id", instanceId)
|
||||
q = q.Equals("mode", api.EIP_MODE_INSTANCE_PUBLICIP)
|
||||
if len(eipMode) > 0 {
|
||||
q = q.Equals("mode", eipMode)
|
||||
}
|
||||
|
||||
err := q.First(&eip)
|
||||
|
||||
|
||||
@@ -161,6 +161,7 @@ type IGuestDriver interface {
|
||||
|
||||
IsSupportEip() bool
|
||||
ValidateCreateEip(ctx context.Context, userCred mcclient.TokenCredential, data jsonutils.JSONObject) error
|
||||
RequestAssociateEip(ctx context.Context, userCred mcclient.TokenCredential, guest *SGuest, eip *SElasticip, task taskman.ITask) error
|
||||
|
||||
NeedStopForChangeSpec(guest *SGuest) bool
|
||||
|
||||
|
||||
@@ -4086,7 +4086,7 @@ func (self *SGuest) GetEip() (*SElasticip, error) {
|
||||
}
|
||||
|
||||
func (self *SGuest) GetPublicIp() (*SElasticip, error) {
|
||||
return ElasticipManager.getPublicIpForInstance("server", self.Id)
|
||||
return ElasticipManager.getEip("server", self.Id, api.EIP_MODE_INSTANCE_PUBLICIP)
|
||||
}
|
||||
|
||||
func (self *SGuest) SyncVMEip(ctx context.Context, userCred mcclient.TokenCredential, provider *SCloudprovider, extEip cloudprovider.ICloudEIP, syncOwnerId mcclient.IIdentityProvider) compare.SyncResult {
|
||||
|
||||
@@ -60,6 +60,8 @@ type IRegionDriver interface {
|
||||
RequestDeleteLoadbalancerBackendGroup(ctx context.Context, userCred mcclient.TokenCredential, lbbg *SLoadbalancerBackendGroup, task taskman.ITask) error
|
||||
ValidateDeleteLoadbalancerBackendGroupCondition(ctx context.Context, lbbb *SLoadbalancerBackendGroup) error
|
||||
RequestSyncLoadbalancerBackendGroup(ctx context.Context, userCred mcclient.TokenCredential, lblis *SLoadbalancerListener, lbbg *SLoadbalancerBackendGroup, task taskman.ITask) error
|
||||
RequestPullRegionLoadbalancerBackendGroup(ctx context.Context, userCred mcclient.TokenCredential, syncResults SSyncResultSet, provider *SCloudprovider, localRegion *SCloudregion, remoteRegion cloudprovider.ICloudRegion, syncRange *SSyncRange) error
|
||||
RequestPullLoadbalancerBackendGroup(ctx context.Context, userCred mcclient.TokenCredential, syncResults SSyncResultSet, provider *SCloudprovider, localLoadbalancer *SLoadbalancer, remoteLoadbalancer cloudprovider.ICloudLoadbalancer, syncRange *SSyncRange) error
|
||||
GetBackendStatusForAdd() []string
|
||||
|
||||
ValidateCreateLoadbalancerBackendData(ctx context.Context, userCred mcclient.TokenCredential, data *jsonutils.JSONDict, backendType string, lb *SLoadbalancer, backendGroup *SLoadbalancerBackendGroup, backend db.IModel) (*jsonutils.JSONDict, error)
|
||||
|
||||
@@ -1298,6 +1298,15 @@ func (self *SAwsRegionDriver) RequestSyncLoadbalancerBackendGroup(ctx context.Co
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SAwsRegionDriver) RequestPullRegionLoadbalancerBackendGroup(ctx context.Context, userCred mcclient.TokenCredential, syncResults models.SSyncResultSet, provider *models.SCloudprovider, localRegion *models.SCloudregion, remoteRegion cloudprovider.ICloudRegion, syncRange *models.SSyncRange) error {
|
||||
models.SyncAwsLoadbalancerBackendgroups(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SAwsRegionDriver) RequestPullLoadbalancerBackendGroup(ctx context.Context, userCred mcclient.TokenCredential, syncResults models.SSyncResultSet, provider *models.SCloudprovider, localLoadbalancer *models.SLoadbalancer, remoteLoadbalancer cloudprovider.ICloudLoadbalancer, syncRange *models.SSyncRange) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SAwsRegionDriver) IsSecurityGroupBelongVpc() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -85,6 +85,14 @@ func (self *SBaseRegionDriver) RequestSyncLoadbalancerBackendGroup(ctx context.C
|
||||
return fmt.Errorf("Not Implement RequestSyncLoadbalancerBackendGroup")
|
||||
}
|
||||
|
||||
func (self *SBaseRegionDriver) RequestPullRegionLoadbalancerBackendGroup(ctx context.Context, userCred mcclient.TokenCredential, syncResults models.SSyncResultSet, provider *models.SCloudprovider, localRegion *models.SCloudregion, remoteRegion cloudprovider.ICloudRegion, syncRange *models.SSyncRange) error {
|
||||
return fmt.Errorf("Not Implement RequestPullRegionLoadbalancerBackendGroup")
|
||||
}
|
||||
|
||||
func (self *SBaseRegionDriver) RequestPullLoadbalancerBackendGroup(ctx context.Context, userCred mcclient.TokenCredential, syncResults models.SSyncResultSet, provider *models.SCloudprovider, localLoadbalancer *models.SLoadbalancer, remoteLoadbalancer cloudprovider.ICloudLoadbalancer, syncRange *models.SSyncRange) error {
|
||||
return fmt.Errorf("Not Implement RequestPullLoadbalancerBackendGroup")
|
||||
}
|
||||
|
||||
func (self *SBaseRegionDriver) RequestCreateLoadbalancerBackend(ctx context.Context, userCred mcclient.TokenCredential, lbb *models.SLoadbalancerBackend, task taskman.ITask) error {
|
||||
return fmt.Errorf("Not Implement RequestCreateLoadbalancerBackend")
|
||||
}
|
||||
|
||||
@@ -1146,6 +1146,15 @@ func (self *SHuaWeiRegionDriver) RequestSyncLoadbalancerBackendGroup(ctx context
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SHuaWeiRegionDriver) RequestPullRegionLoadbalancerBackendGroup(ctx context.Context, userCred mcclient.TokenCredential, syncResults models.SSyncResultSet, provider *models.SCloudprovider, localRegion *models.SCloudregion, remoteRegion cloudprovider.ICloudRegion, syncRange *models.SSyncRange) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SHuaWeiRegionDriver) RequestPullLoadbalancerBackendGroup(ctx context.Context, userCred mcclient.TokenCredential, syncResults models.SSyncResultSet, provider *models.SCloudprovider, localLoadbalancer *models.SLoadbalancer, remoteLoadbalancer cloudprovider.ICloudLoadbalancer, syncRange *models.SSyncRange) error {
|
||||
models.SyncHuaweiLoadbalancerBackendgroups(ctx, userCred, syncResults, provider, localLoadbalancer, remoteLoadbalancer, syncRange)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SHuaWeiRegionDriver) RequestCreateLoadbalancerListener(ctx context.Context, userCred mcclient.TokenCredential, lblis *models.SLoadbalancerListener, task taskman.ITask) error {
|
||||
taskman.LocalTaskRun(task, func() (jsonutils.JSONObject, error) {
|
||||
{
|
||||
|
||||
@@ -596,6 +596,14 @@ func (self *SKVMRegionDriver) RequestSyncLoadbalancerBackendGroup(ctx context.Co
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SKVMRegionDriver) RequestPullRegionLoadbalancerBackendGroup(ctx context.Context, userCred mcclient.TokenCredential, syncResults models.SSyncResultSet, provider *models.SCloudprovider, localRegion *models.SCloudregion, remoteRegion cloudprovider.ICloudRegion, syncRange *models.SSyncRange) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SKVMRegionDriver) RequestPullLoadbalancerBackendGroup(ctx context.Context, userCred mcclient.TokenCredential, syncResults models.SSyncResultSet, provider *models.SCloudprovider, localLoadbalancer *models.SLoadbalancer, remoteLoadbalancer cloudprovider.ICloudLoadbalancer, syncRange *models.SSyncRange) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SKVMRegionDriver) RequestCreateLoadbalancerCertificate(ctx context.Context, userCred mcclient.TokenCredential, lbcert *models.SCachedLoadbalancerCertificate, task taskman.ITask) error {
|
||||
task.ScheduleRun(nil)
|
||||
return nil
|
||||
|
||||
@@ -551,6 +551,15 @@ func (self *SManagedVirtualizationRegionDriver) RequestSyncLoadbalancerBackendGr
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SManagedVirtualizationRegionDriver) RequestPullRegionLoadbalancerBackendGroup(ctx context.Context, userCred mcclient.TokenCredential, syncResults models.SSyncResultSet, provider *models.SCloudprovider, localRegion *models.SCloudregion, remoteRegion cloudprovider.ICloudRegion, syncRange *models.SSyncRange) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SManagedVirtualizationRegionDriver) RequestPullLoadbalancerBackendGroup(ctx context.Context, userCred mcclient.TokenCredential, syncResults models.SSyncResultSet, provider *models.SCloudprovider, localLoadbalancer *models.SLoadbalancer, remoteLoadbalancer cloudprovider.ICloudLoadbalancer, syncRange *models.SSyncRange) error {
|
||||
models.SyncLoadbalancerBackendgroups(ctx, userCred, syncResults, provider, localLoadbalancer, remoteLoadbalancer, syncRange)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SManagedVirtualizationRegionDriver) RequestCreateLoadbalancerBackend(ctx context.Context, userCred mcclient.TokenCredential, lbb *models.SLoadbalancerBackend, task taskman.ITask) error {
|
||||
taskman.LocalTaskRun(task, func() (jsonutils.JSONObject, error) {
|
||||
lbbg := lbb.GetLoadbalancerBackendGroup()
|
||||
|
||||
@@ -58,33 +58,17 @@ func (self *EipAssociateTask) OnInit(ctx context.Context, obj db.IStandaloneMode
|
||||
return
|
||||
}
|
||||
|
||||
if server.Status != api.VM_ASSOCIATE_EIP {
|
||||
server.SetStatus(self.UserCred, api.VM_ASSOCIATE_EIP, "associate eip")
|
||||
}
|
||||
|
||||
extEip, err := eip.GetIEip()
|
||||
if err != nil {
|
||||
msg := fmt.Sprintf("fail to find iEIP for eip %s", err)
|
||||
self.TaskFail(ctx, eip, msg, server)
|
||||
driver := server.GetDriver()
|
||||
if driver == nil {
|
||||
msg := fmt.Sprintf("fail to find guest driver for instanceId %s", instanceId)
|
||||
self.TaskFail(ctx, eip, msg, nil)
|
||||
return
|
||||
}
|
||||
|
||||
err = extEip.Associate(server.ExternalId)
|
||||
if err != nil {
|
||||
msg := fmt.Sprintf("fail to remote associate EIP %s", err)
|
||||
self.TaskFail(ctx, eip, msg, server)
|
||||
return
|
||||
if err := driver.RequestAssociateEip(ctx, self.UserCred, server, eip, self); err != nil {
|
||||
self.TaskFail(ctx, eip, err.Error(), server)
|
||||
}
|
||||
|
||||
err = eip.AssociateVM(ctx, self.UserCred, server)
|
||||
if err != nil {
|
||||
msg := fmt.Sprintf("fail to local associate EIP %s", err)
|
||||
self.TaskFail(ctx, eip, msg, server)
|
||||
return
|
||||
}
|
||||
|
||||
eip.SetStatus(self.UserCred, api.EIP_STATUS_READY, "associate")
|
||||
|
||||
server.StartSyncstatus(ctx, self.UserCred, "")
|
||||
logclient.AddActionLogWithStartable(self, server, logclient.ACT_EIP_ASSOCIATE, nil, self.UserCred, true)
|
||||
logclient.AddActionLogWithStartable(self, eip, logclient.ACT_VM_ASSOCIATE, nil, self.UserCred, true)
|
||||
|
||||
@@ -217,6 +217,11 @@ func (client *SAwsClient) fetchBuckets() error {
|
||||
|
||||
ret := make([]cloudprovider.ICloudBucket, 0)
|
||||
for _, bInfo := range output.Buckets {
|
||||
if err := FillZero(bInfo); err != nil {
|
||||
log.Errorf("s3cli.Binfo.FillZero error %s", err)
|
||||
continue
|
||||
}
|
||||
|
||||
input := &s3.GetBucketLocationInput{}
|
||||
input.Bucket = bInfo.Name
|
||||
output, err := s3cli.GetBucketLocation(input)
|
||||
@@ -225,8 +230,8 @@ func (client *SAwsClient) fetchBuckets() error {
|
||||
continue
|
||||
}
|
||||
|
||||
if output == nil {
|
||||
log.Errorf("s3cli.GetBucketLocation nil output")
|
||||
if err := FillZero(output); err != nil {
|
||||
log.Errorf("s3cli.GetBucketLocation.FillZero error %s", err)
|
||||
continue
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user