mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
Merge pull request #3876 from wanyaoqi/bugfix/wyq/misc-fix-1125
bugfix: misc fix
This commit is contained in:
@@ -138,6 +138,7 @@ func init() {
|
||||
IsPublic string `help:"filter images public or not(True, False or None)" choices:"true|false"`
|
||||
IsStandard string `help:"filter images standard or non-standard" choices:"true|false"`
|
||||
Protected string `help:"filter images by protected" choices:"true|false"`
|
||||
IsUefi bool `help:"list uefi image"`
|
||||
Format []string `help:"Disk formats"`
|
||||
Name string `help:"Name filter"`
|
||||
}
|
||||
@@ -155,6 +156,9 @@ func init() {
|
||||
if len(args.Protected) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Protected), "protected")
|
||||
}
|
||||
if args.IsUefi {
|
||||
params.Add(jsonutils.JSONTrue, "uefi")
|
||||
}
|
||||
if len(args.Tenant) > 0 {
|
||||
tid, e := modules.Projects.GetId(s, args.Tenant, nil)
|
||||
if e != nil {
|
||||
|
||||
@@ -1577,7 +1577,7 @@ func (self *SGuest) moreExtraInfo(extra *jsonutils.JSONDict, fields stringutils2
|
||||
}
|
||||
}
|
||||
|
||||
if len(fields) == 0 || fields.Contains("host") || fields.ContainsAny(providerInfoFields...) {
|
||||
if len(fields) == 0 || fields.Contains("host") || fields.ContainsAny(providerInfoFields...) || fields.Contains("host_sn") {
|
||||
host := self.GetHost()
|
||||
if host != nil {
|
||||
if len(fields) == 0 || fields.Contains("host") {
|
||||
@@ -1591,6 +1591,9 @@ func (self *SGuest) moreExtraInfo(extra *jsonutils.JSONDict, fields stringutils2
|
||||
extra.Update(jsonutils.Marshal(&info).(*jsonutils.JSONDict).CopyIncludes([]string(fields)...))
|
||||
}
|
||||
}
|
||||
if len(fields) == 0 || fields.Contains("host_sn") {
|
||||
extra.Add(jsonutils.NewString(host.SN), "host_sn")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4097,7 +4100,8 @@ func (manager *SGuestManager) getExpiredPrepaidGuests() []SGuest {
|
||||
deadline := time.Now().Add(time.Duration(options.Options.PrepaidExpireCheckSeconds*-1) * time.Second)
|
||||
|
||||
q := manager.Query()
|
||||
q = q.Equals("billing_type", billing_api.BILLING_TYPE_PREPAID).LT("expired_at", deadline).Limit(options.Options.ExpiredPrepaidMaxCleanBatchSize)
|
||||
q = q.Equals("billing_type", billing_api.BILLING_TYPE_PREPAID).LT("expired_at", deadline).
|
||||
IsFalse("pending_deleted").Limit(options.Options.ExpiredPrepaidMaxCleanBatchSize)
|
||||
|
||||
guests := make([]SGuest, 0)
|
||||
err := db.FetchModelObjects(GuestManager, q, &guests)
|
||||
@@ -4111,7 +4115,7 @@ func (manager *SGuestManager) getExpiredPrepaidGuests() []SGuest {
|
||||
|
||||
func (manager *SGuestManager) getExpiredPostpaidGuests() []SGuest {
|
||||
deadline := time.Now()
|
||||
q := manager.Query().Equals("billing_type", billing_api.BILLING_TYPE_POSTPAID).
|
||||
q := manager.Query().Equals("billing_type", billing_api.BILLING_TYPE_POSTPAID).IsFalse("pending_deleted").
|
||||
LT("expired_at", deadline).Limit(options.Options.ExpiredPrepaidMaxCleanBatchSize)
|
||||
guests := make([]SGuest, 0)
|
||||
err := db.FetchModelObjects(GuestManager, q, &guests)
|
||||
|
||||
@@ -55,7 +55,6 @@ func (self *InstanceSnapshotDeleteTask) OnInit(
|
||||
ctx context.Context, obj db.IStandaloneModel, data jsonutils.JSONObject) {
|
||||
|
||||
isp := obj.(*models.SInstanceSnapshot)
|
||||
self.SetStage("OnSnapshotDelete", nil)
|
||||
self.StartSnapshotDelete(ctx, isp)
|
||||
}
|
||||
|
||||
@@ -72,10 +71,23 @@ func (self *InstanceSnapshotDeleteTask) StartSnapshotDelete(
|
||||
return
|
||||
}
|
||||
|
||||
params := jsonutils.NewDict()
|
||||
params.Set("del_snapshot_id", jsonutils.NewString(snapshots[0].Id))
|
||||
self.SetStage("OnSnapshotDelete", params)
|
||||
err = snapshots[0].StartSnapshotDeleteTask(ctx, self.UserCred, false, self.Id)
|
||||
if err != nil {
|
||||
self.taskFail(ctx, isp, err.Error())
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func (self *InstanceSnapshotDeleteTask) OnSnapshotDelete(
|
||||
ctx context.Context, isp *models.SInstanceSnapshot, data jsonutils.JSONObject) {
|
||||
snapshotId, _ := self.Params.GetString("del_snapshot_id")
|
||||
// detach snapshot and instance
|
||||
isjp := new(models.SInstanceSnapshotJoint)
|
||||
err = models.InstanceSnapshotJointManager.Query().
|
||||
Equals("instance_snapshot_id", isp.Id).Equals("snapshot_id", snapshots[0].Id).First(isjp)
|
||||
err := models.InstanceSnapshotJointManager.Query().
|
||||
Equals("instance_snapshot_id", isp.Id).Equals("snapshot_id", snapshotId).First(isjp)
|
||||
if err != nil {
|
||||
self.taskFail(ctx, isp, err.Error())
|
||||
return
|
||||
@@ -86,17 +98,6 @@ func (self *InstanceSnapshotDeleteTask) StartSnapshotDelete(
|
||||
self.taskFail(ctx, isp, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
err = snapshots[0].StartSnapshotDeleteTask(ctx, self.UserCred, false, self.Id)
|
||||
if err != nil {
|
||||
self.taskFail(ctx, isp, err.Error())
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func (self *InstanceSnapshotDeleteTask) OnSnapshotDelete(
|
||||
ctx context.Context, isp *models.SInstanceSnapshot, data jsonutils.JSONObject) {
|
||||
|
||||
self.StartSnapshotDelete(ctx, isp)
|
||||
}
|
||||
|
||||
|
||||
@@ -316,6 +316,10 @@ func NewNIC(desc string) (*SNIC, error) {
|
||||
time.Sleep(time.Second * 2)
|
||||
wait += 1
|
||||
}
|
||||
if wait >= max {
|
||||
// if ip not found in inter or bridge
|
||||
return nil, fmt.Errorf("Ip %s is not configure on %s/%s ?", nic.Ip, nic.Bridge, nic.Inter)
|
||||
}
|
||||
}
|
||||
|
||||
var err error
|
||||
|
||||
@@ -1087,6 +1087,11 @@ func (manager *SImageManager) ListItemFilter(ctx context.Context, q *sqlchemy.SQ
|
||||
fmtArray := jsonutils.JSONArray2StringArray(fmtJsonArray)
|
||||
q = q.In("disk_format", fmtArray)
|
||||
}
|
||||
if jsonutils.QueryBoolean(query, "uefi", false) {
|
||||
imagePropertyQ := ImagePropertyManager.Query().
|
||||
Equals("name", api.IMAGE_UEFI_SUPPORT).Equals("value", "true").SubQuery()
|
||||
q = q.Join(imagePropertyQ, sqlchemy.Equals(q.Field("id"), imagePropertyQ.Field("image_id")))
|
||||
}
|
||||
return q, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user