mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-21 14:19:49 +08:00
@@ -1002,9 +1002,6 @@ func (vpc *SVpc) Purge(ctx context.Context, userCred mcclient.TokenCredential) e
|
||||
}
|
||||
|
||||
func (dn *SNatDEntry) Purge(ctx context.Context, userCred mcclient.TokenCredential) error {
|
||||
lockman.LockObject(ctx, dn)
|
||||
defer lockman.ReleaseObject(ctx, dn)
|
||||
|
||||
err := dn.ValidateDeleteCondition(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -1013,9 +1010,6 @@ func (dn *SNatDEntry) Purge(ctx context.Context, userCred mcclient.TokenCredenti
|
||||
}
|
||||
|
||||
func (sn *SNatSEntry) Purge(ctx context.Context, userCred mcclient.TokenCredential) error {
|
||||
lockman.LockObject(ctx, sn)
|
||||
defer lockman.ReleaseObject(ctx, sn)
|
||||
|
||||
err := sn.ValidateDeleteCondition(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -865,7 +865,7 @@ func (self *SAliyunRegionDriver) RequestBindIPToNatgateway(ctx context.Context,
|
||||
return nil, errors.Wrap(err, "bind eip to natgateway")
|
||||
}
|
||||
|
||||
cloudprovider.WaitStatus(ieip, api.EIP_STATUS_READY, 10*time.Second, 300*time.Second)
|
||||
err = cloudprovider.WaitStatus(ieip, api.EIP_STATUS_ASSOCIATE, 10*time.Second, 300*time.Second)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ package tasks
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
@@ -51,6 +52,7 @@ func (self *SNatDEntryCreateTask) OnInit(ctx context.Context, obj db.IStandalone
|
||||
natgateway, err := dnatEntry.GetNatgateway()
|
||||
if err != nil {
|
||||
self.TaskFailed(ctx, dnatEntry, errors.Wrap(err, "fetch natgateway failed"))
|
||||
return
|
||||
}
|
||||
var needBind bool
|
||||
if self.Params.Contains("need_bind") {
|
||||
@@ -67,6 +69,12 @@ func (self *SNatDEntryCreateTask) OnInit(ctx context.Context, obj db.IStandalone
|
||||
|
||||
}
|
||||
|
||||
func (self *SNatDEntryCreateTask) OnBindIPCompleteFailed(ctx context.Context, dnatEntry *models.SNatDEntry,
|
||||
reason jsonutils.JSONObject) {
|
||||
|
||||
self.TaskFailed(ctx, dnatEntry, fmt.Errorf(reason.String()))
|
||||
}
|
||||
|
||||
func (self *SNatDEntryCreateTask) OnBindIPComplete(ctx context.Context, dnatEntry *models.SNatDEntry,
|
||||
body jsonutils.JSONObject) {
|
||||
|
||||
@@ -91,11 +99,6 @@ func (self *SNatDEntryCreateTask) OnBindIPComplete(ctx context.Context, dnatEntr
|
||||
self.TaskFailed(ctx, dnatEntry, errors.Wrapf(err, "Create DNat Entry '%s' failed", dnatEntry.ExternalId))
|
||||
return
|
||||
}
|
||||
err = db.SetExternalId(dnatEntry, self.UserCred, extDnat.GetGlobalId())
|
||||
if err != nil {
|
||||
self.TaskFailed(ctx, dnatEntry, errors.Wrap(err, "set external id failed"))
|
||||
return
|
||||
}
|
||||
|
||||
err = cloudprovider.WaitStatus(extDnat, api.NAT_STAUTS_AVAILABLE, 10*time.Second, 300*time.Second)
|
||||
if err != nil {
|
||||
@@ -103,6 +106,12 @@ func (self *SNatDEntryCreateTask) OnBindIPComplete(ctx context.Context, dnatEntr
|
||||
return
|
||||
}
|
||||
|
||||
err = db.SetExternalId(dnatEntry, self.UserCred, extDnat.GetGlobalId())
|
||||
if err != nil {
|
||||
self.TaskFailed(ctx, dnatEntry, errors.Wrap(err, "set external id failed"))
|
||||
return
|
||||
}
|
||||
|
||||
dnatEntry.SetStatus(self.UserCred, api.NAT_STAUTS_AVAILABLE, "")
|
||||
db.OpsLog.LogEvent(dnatEntry, db.ACT_ALLOCATE, dnatEntry.GetShortDesc(ctx), self.UserCred)
|
||||
logclient.AddActionLogWithStartable(self, dnatEntry, logclient.ACT_ALLOCATE, nil, self.UserCred, true)
|
||||
|
||||
@@ -16,6 +16,7 @@ package tasks
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
@@ -51,6 +52,7 @@ func (self *SNatSEntryCreateTask) OnInit(ctx context.Context, obj db.IStandalone
|
||||
natgateway, err := snatEntry.GetNatgateway()
|
||||
if err != nil {
|
||||
self.TaskFailed(ctx, snatEntry, errors.Wrap(err, "fetch natgateway failed"))
|
||||
return
|
||||
}
|
||||
var needBind bool
|
||||
if self.Params.Contains("need_bind") {
|
||||
@@ -67,6 +69,12 @@ func (self *SNatSEntryCreateTask) OnInit(ctx context.Context, obj db.IStandalone
|
||||
}
|
||||
}
|
||||
|
||||
func (self *SNatSEntryCreateTask) OnBindIPCompleteFailed(ctx context.Context, snatEntry *models.SNatSEntry,
|
||||
reason jsonutils.JSONObject) {
|
||||
|
||||
self.TaskFailed(ctx, snatEntry, fmt.Errorf(reason.String()))
|
||||
}
|
||||
|
||||
func (self *SNatSEntryCreateTask) OnBindIPComplete(ctx context.Context, snatEntry *models.SNatSEntry,
|
||||
body jsonutils.JSONObject) {
|
||||
|
||||
@@ -93,11 +101,6 @@ func (self *SNatSEntryCreateTask) OnBindIPComplete(ctx context.Context, snatEntr
|
||||
self.TaskFailed(ctx, snatEntry, errors.Wrapf(err, "Create SNat Entry '%s' failed", snatEntry.ExternalId))
|
||||
return
|
||||
}
|
||||
err = db.SetExternalId(snatEntry, self.UserCred, extSnat.GetGlobalId())
|
||||
if err != nil {
|
||||
self.TaskFailed(ctx, snatEntry, errors.Wrap(err, "set external id failed"))
|
||||
return
|
||||
}
|
||||
|
||||
err = cloudprovider.WaitStatus(extSnat, api.NAT_STAUTS_AVAILABLE, 10*time.Second, 300*time.Second)
|
||||
if err != nil {
|
||||
@@ -105,6 +108,12 @@ func (self *SNatSEntryCreateTask) OnBindIPComplete(ctx context.Context, snatEntr
|
||||
return
|
||||
}
|
||||
|
||||
err = db.SetExternalId(snatEntry, self.UserCred, extSnat.GetGlobalId())
|
||||
if err != nil {
|
||||
self.TaskFailed(ctx, snatEntry, errors.Wrap(err, "set external id failed"))
|
||||
return
|
||||
}
|
||||
|
||||
snatEntry.SetStatus(self.UserCred, api.NAT_STAUTS_AVAILABLE, "")
|
||||
db.OpsLog.LogEvent(snatEntry, db.ACT_ALLOCATE, snatEntry.GetShortDesc(ctx), self.UserCred)
|
||||
logclient.AddActionLogWithStartable(self, snatEntry, logclient.ACT_ALLOCATE, nil, self.UserCred, true)
|
||||
|
||||
@@ -144,6 +144,9 @@ func (region *SRegion) GetForwardTableEntry(tableID, forwardEntryID string) (SFo
|
||||
if err != nil {
|
||||
return SForwardTableEntry{}, err
|
||||
}
|
||||
if len(dtables) == 0 {
|
||||
return SForwardTableEntry{}, cloudprovider.ErrNotFound
|
||||
}
|
||||
return dtables[0], nil
|
||||
}
|
||||
|
||||
@@ -175,7 +178,7 @@ func (region *SRegion) CreateForwardTableEntry(rule cloudprovider.SNatDRule, tab
|
||||
}
|
||||
|
||||
func (dtable *SForwardTableEntry) Refresh() error {
|
||||
new, err := dtable.nat.vpc.region.GetForwardTableEntry(dtable.ForwardEntryId, dtable.ForwardTableId)
|
||||
new, err := dtable.nat.vpc.region.GetForwardTableEntry(dtable.ForwardTableId, dtable.ForwardEntryId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -130,6 +130,9 @@ func (self *SRegion) GetSNATEntry(tableID, SNATEntryID string) (SSNATTableEntry,
|
||||
log.Errorf("Unmarshal entries fail %s", err)
|
||||
return SSNATTableEntry{}, err
|
||||
}
|
||||
if len(entries) == 0 {
|
||||
return SSNATTableEntry{}, cloudprovider.ErrNotFound
|
||||
}
|
||||
return entries[0], nil
|
||||
|
||||
}
|
||||
@@ -209,7 +212,7 @@ func (nat *SNatGetway) dissociateWithVswitch(vswitchId string) error {
|
||||
}
|
||||
|
||||
func (stable *SSNATTableEntry) Refresh() error {
|
||||
new, err := stable.nat.vpc.region.GetForwardTableEntry(stable.SnatEntryId, stable.SnatTableId)
|
||||
new, err := stable.nat.vpc.region.GetSNATEntry(stable.SnatTableId, stable.SnatEntryId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user