diff --git a/pkg/compute/tasks/cdn_domain_create_task.go b/pkg/compute/tasks/cdn_domain_create_task.go index f0cbf33bd7..b927ad926c 100644 --- a/pkg/compute/tasks/cdn_domain_create_task.go +++ b/pkg/compute/tasks/cdn_domain_create_task.go @@ -75,6 +75,12 @@ func (self *CDNDomainCreateTask) OnInit(ctx context.Context, obj db.IStandaloneM return } + err = db.SetExternalId(domain, self.UserCred, iCdn.GetGlobalId()) + if err != nil { + self.taskFailed(ctx, domain, errors.Wrapf(err, "unable to update externalId")) + return + } + cloudprovider.WaitMultiStatus(iCdn, []string{ api.CDN_DOMAIN_STATUS_ONLINE, api.CDN_DOMAIN_STATUS_OFFLINE, @@ -82,12 +88,27 @@ func (self *CDNDomainCreateTask) OnInit(ctx context.Context, obj db.IStandaloneM api.CDN_DOMAIN_STATUS_UNKNOWN, }, time.Second*5, time.Minute*3) - domain.SyncWithCloudCDNDomain(ctx, self.GetUserCred(), iCdn) + tags, _ := domain.GetAllUserMetadata() + if len(tags) > 0 { + err = iCdn.SetTags(tags, true) + if err != nil { + logclient.AddActionLogWithStartable(self, domain, logclient.ACT_UPDATE, errors.Wrapf(err, "SetTags"), self.UserCred, false) + } + } notifyclient.EventNotify(ctx, self.UserCred, notifyclient.SEventNotifyParam{ Obj: domain, Action: notifyclient.ActionCreate, }) + self.SetStage("OnSyncstatusComplete", nil) + domain.StartSyncstatus(ctx, self.GetUserCred(), self.GetTaskId()) +} + +func (self *CDNDomainCreateTask) OnSyncstatusComplete(ctx context.Context, domain *models.SCDNDomain, data jsonutils.JSONObject) { self.taskComplete(ctx, domain) } + +func (self *CDNDomainCreateTask) OnSyncstatusCompleteFailed(ctx context.Context, domain *models.SCDNDomain, data jsonutils.JSONObject) { + self.SetStageFailed(ctx, data) +} diff --git a/pkg/compute/tasks/filesystem_create_task.go b/pkg/compute/tasks/filesystem_create_task.go index 1120da8da4..f8e2eedd8a 100644 --- a/pkg/compute/tasks/filesystem_create_task.go +++ b/pkg/compute/tasks/filesystem_create_task.go @@ -113,16 +113,17 @@ func (self *FileSystemCreateTask) OnInit(ctx context.Context, obj db.IStandalone } } + notifyclient.EventNotify(ctx, self.UserCred, notifyclient.SEventNotifyParam{ + Obj: self, + Action: notifyclient.ActionCreate, + }) + self.SetStage("OnSyncstatusComplete", nil) fs.StartSyncstatus(ctx, self.GetUserCred(), self.GetTaskId()) } func (self *FileSystemCreateTask) OnSyncstatusComplete(ctx context.Context, fs *models.SFileSystem, data jsonutils.JSONObject) { self.SetStageComplete(ctx, nil) - notifyclient.EventNotify(ctx, self.UserCred, notifyclient.SEventNotifyParam{ - Obj: self, - Action: notifyclient.ActionCreate, - }) } func (self *FileSystemCreateTask) OnSyncstatusCompleteFailed(ctx context.Context, fs *models.SFileSystem, data jsonutils.JSONObject) {