mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
fix(region): get cdrom details (#16908)
This commit is contained in:
@@ -1185,12 +1185,16 @@ func (self *SGuest) insertIso(imageId string, cdromOrdinal int64) bool {
|
||||
return cdrom.insertIso(imageId)
|
||||
}
|
||||
|
||||
func (self *SGuest) InsertIsoSucc(cdromOrdinal int64, imageId string, path string, size int64, name string, bootIndex *int8) bool {
|
||||
func (self *SGuest) InsertIsoSucc(cdromOrdinal int64, imageId string, path string, size int64, name string, bootIndex *int8) (*SGuestcdrom, bool) {
|
||||
cdrom := self.getCdrom(false, cdromOrdinal)
|
||||
return cdrom.insertIsoSucc(imageId, path, size, name, bootIndex)
|
||||
return cdrom, cdrom.insertIsoSucc(imageId, path, size, name, bootIndex)
|
||||
}
|
||||
|
||||
func (self *SGuest) GetDetailsIso(cdromOrdinal int64, userCred mcclient.TokenCredential) jsonutils.JSONObject {
|
||||
func (self *SGuest) GetDetailsIso(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject) (jsonutils.JSONObject, error) {
|
||||
var cdromOrdinal int64 = 0
|
||||
if query.Contains("ordinal") {
|
||||
cdromOrdinal, _ = query.Int("ordinal")
|
||||
}
|
||||
cdrom := self.getCdrom(false, cdromOrdinal)
|
||||
desc := jsonutils.NewDict()
|
||||
if len(cdrom.ImageId) > 0 {
|
||||
@@ -1202,7 +1206,7 @@ func (self *SGuest) GetDetailsIso(cdromOrdinal int64, userCred mcclient.TokenCre
|
||||
desc.Set("size", jsonutils.NewInt(int64(cdrom.Size)))
|
||||
desc.Set("status", jsonutils.NewString("ready"))
|
||||
}
|
||||
return desc
|
||||
return desc, nil
|
||||
}
|
||||
|
||||
func (self *SGuest) PerformInsertiso(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) (jsonutils.JSONObject, error) {
|
||||
|
||||
@@ -2434,6 +2434,10 @@ func (self *SGuest) GetCdrom() *SGuestcdrom {
|
||||
return self.getCdrom(false, 0)
|
||||
}
|
||||
|
||||
func (self *SGuest) GetCdromByOrdinal(ordinal int64) *SGuestcdrom {
|
||||
return self.getCdrom(false, ordinal)
|
||||
}
|
||||
|
||||
func (self *SGuest) getCdrom(create bool, ordinal int64) *SGuestcdrom {
|
||||
cdrom := SGuestcdrom{}
|
||||
cdrom.SetModelManager(GuestcdromManager, &cdrom)
|
||||
|
||||
@@ -91,8 +91,8 @@ func (self *GuestInsertIsoTask) OnIsoPrepareComplete(ctx context.Context, obj db
|
||||
}
|
||||
|
||||
guest := obj.(*models.SGuest)
|
||||
if guest.InsertIsoSucc(cdromOrdinal, imageId, path, size, name, bootIndex) {
|
||||
db.OpsLog.LogEvent(guest, db.ACT_ISO_ATTACH, guest.GetDetailsIso(cdromOrdinal, self.UserCred), self.UserCred)
|
||||
if cdrom, ok := guest.InsertIsoSucc(cdromOrdinal, imageId, path, size, name, bootIndex); ok {
|
||||
db.OpsLog.LogEvent(guest, db.ACT_ISO_ATTACH, cdrom.GetDetails(), self.UserCred)
|
||||
if guest.GetDriver().NeedRequestGuestHotAddIso(ctx, guest) {
|
||||
self.SetStage("OnConfigSyncComplete", nil)
|
||||
boot := jsonutils.QueryBoolean(self.Params, "boot", false)
|
||||
|
||||
@@ -1355,3 +1355,12 @@ type ServerVncOptions struct {
|
||||
func (o *ServerVncOptions) Params() (jsonutils.JSONObject, error) {
|
||||
return jsonutils.Marshal(o), nil
|
||||
}
|
||||
|
||||
type ServerIsoOptions struct {
|
||||
ServerIdOptions
|
||||
Ordinal int `help:"server iso ordinal, default 0"`
|
||||
}
|
||||
|
||||
func (o *ServerIsoOptions) Params() (jsonutils.JSONObject, error) {
|
||||
return jsonutils.Marshal(o), nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user