mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
Merge pull request #1074 in YUNIONIO/onecloud from ~QIUJIAN/onecloud:hotfix/qj-resolve-conflict-2.6.0-20190218 to release/2.6.0
* commit '8e65f740cfb2df43f2909604ca7166c0157ac6e5': fix: build error because of notify and actionlog interface change
This commit is contained in:
@@ -22,7 +22,6 @@ func init() {
|
||||
MSG string `help:"The content of the notification"`
|
||||
Remark string `help:"Remark or description of the notification"`
|
||||
Group bool `help:"Send to group"`
|
||||
Channel string `help:"User's contacts type, cloud be email|mobile|dingtalk|webconsole" choices:"email|mobile|dingtalk|webconsole"`
|
||||
}
|
||||
R(&NotificationCreateOptions{}, "notify", "Send a notification to sb", func(s *mcclient.ClientSession, args *NotificationCreateOptions) error {
|
||||
msg := notify.SNotifyMessage{}
|
||||
@@ -32,10 +31,7 @@ func init() {
|
||||
msg.Uid = args.UID
|
||||
}
|
||||
|
||||
msg.ContactType = []notify.TNotifyChannel{notify.TNotifyChannel(args.CONTACTTYPE)}
|
||||
for _, c := range args.Channel {
|
||||
msg.ContactType = append(msg.ContactType, notify.TNotifyChannel(c))
|
||||
}
|
||||
msg.ContactType = notify.TNotifyChannel(args.CONTACTTYPE)
|
||||
msg.Topic = args.TOPIC
|
||||
msg.Priority = notify.TNotifyPriority(args.PRIORITY)
|
||||
msg.Msg = args.MSG
|
||||
|
||||
@@ -348,16 +348,34 @@ func (self *SImage) GetPath(format string) string {
|
||||
}
|
||||
|
||||
func (self *SImage) OnSaveFailed(ctx context.Context, userCred mcclient.TokenCredential, msg string) {
|
||||
log.Errorf(msg)
|
||||
self.SetStatus(userCred, IMAGE_STATUS_QUEUED, msg)
|
||||
db.OpsLog.LogEvent(self, db.ACT_SAVE_FAIL, msg, userCred)
|
||||
logclient.AddActionLog(self, logclient.ACT_IMAGE_SAVE, nil, userCred, false)
|
||||
self.saveFailed(userCred, msg)
|
||||
logclient.AddActionLogWithContext(ctx, self, logclient.ACT_IMAGE_SAVE, nil, userCred, false)
|
||||
}
|
||||
|
||||
func (self *SImage) OnSaveTaskFailed(task taskman.ITask, userCred mcclient.TokenCredential, msg string) {
|
||||
self.saveFailed(userCred, msg)
|
||||
logclient.AddActionLogWithStartable(task, self, logclient.ACT_IMAGE_SAVE, nil, userCred, false)
|
||||
}
|
||||
|
||||
func (self *SImage) OnSaveSuccess(ctx context.Context, userCred mcclient.TokenCredential, msg string) {
|
||||
self.saveSuccess(userCred, msg)
|
||||
logclient.AddActionLogWithContext(ctx, self, logclient.ACT_IMAGE_SAVE, nil, userCred, true)
|
||||
}
|
||||
|
||||
func (self *SImage) OnSaveTaskSuccess(task taskman.ITask, userCred mcclient.TokenCredential, msg string) {
|
||||
self.saveSuccess(userCred, msg)
|
||||
logclient.AddActionLogWithStartable(task, self, logclient.ACT_IMAGE_SAVE, nil, userCred, true)
|
||||
}
|
||||
|
||||
func (self *SImage) saveSuccess(userCred mcclient.TokenCredential, msg string) {
|
||||
self.SetStatus(userCred, IMAGE_STATUS_ACTIVE, msg)
|
||||
db.OpsLog.LogEvent(self, db.ACT_SAVE, msg, userCred)
|
||||
logclient.AddActionLog(self, logclient.ACT_IMAGE_SAVE, nil, userCred, true)
|
||||
}
|
||||
|
||||
func (self *SImage) saveFailed(userCred mcclient.TokenCredential, msg string) {
|
||||
log.Errorf(msg)
|
||||
self.SetStatus(userCred, IMAGE_STATUS_QUEUED, msg)
|
||||
db.OpsLog.LogEvent(self, db.ACT_SAVE_FAIL, msg, userCred)
|
||||
}
|
||||
|
||||
func (self *SImage) saveImageFromStream(localPath string, reader io.Reader) (*streamutils.SStreamProperty, error) {
|
||||
|
||||
@@ -46,6 +46,7 @@ func (self *ImageCopyFromUrlTask) OnInit(ctx context.Context, obj db.IStandalone
|
||||
|
||||
func (self *ImageCopyFromUrlTask) OnImageImportComplete(ctx context.Context, obj db.IStandaloneModel, data jsonutils.JSONObject) {
|
||||
image := obj.(*models.SImage)
|
||||
image.OnSaveTaskSuccess(self, self.UserCred, "create upload success")
|
||||
image.StartImageConvertTask(ctx, self.UserCred, "")
|
||||
self.SetStageComplete(ctx, nil)
|
||||
}
|
||||
@@ -54,6 +55,6 @@ func (self *ImageCopyFromUrlTask) OnImageImportCompleteFailed(ctx context.Contex
|
||||
image := obj.(*models.SImage)
|
||||
copyFrom, _ := self.Params.GetString("copy_from")
|
||||
msg := fmt.Sprintf("copy from url %s request fail %s", copyFrom, err)
|
||||
image.OnSaveFailed(ctx, self.UserCred, msg)
|
||||
image.OnSaveTaskFailed(self, self.UserCred, msg)
|
||||
self.SetStageFailed(ctx, msg)
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package shell
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/util/huawei"
|
||||
"yunion.io/x/onecloud/pkg/util/shellutils"
|
||||
@@ -108,11 +109,11 @@ func init() {
|
||||
|
||||
shellutils.R(&InstanceRebuildRootOptions{}, "instance-rebuild-root", "Reinstall virtual server system image", func(cli *huawei.SRegion, args *InstanceRebuildRootOptions) error {
|
||||
ctx := context.Background()
|
||||
err := cli.ChangeRoot(ctx, args.ID, args.Image, args.Password, args.PublicKey)
|
||||
jobId, err := cli.ChangeRoot(ctx, args.ID, args.Image, args.Password, args.PublicKey)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// fmt.Printf("New diskID is %s", diskID)
|
||||
fmt.Printf("ChangeRoot jobID is %s", jobId)
|
||||
return nil
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user