mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-19 10:46:58 +08:00
fix list guests on host
This commit is contained in:
@@ -69,8 +69,8 @@ type ServerListInput struct {
|
||||
// 按主机资源类型进行排序
|
||||
// enum: shared,prepaid,dedicated
|
||||
ResourceType string `json:"resource_type"`
|
||||
// 返回开启主备机功能的主机
|
||||
GetBackupGuestsOnHost *bool `json:"get_backup_guests_on_host"`
|
||||
// 返回该宿主机上的所有虚拟机,包括备份机
|
||||
GetAllGuestsOnHost string `json:"get_all_guests_on_host"`
|
||||
|
||||
// 根据宿主机 SN 过滤
|
||||
// HostSn string `json:"host_sn"`
|
||||
|
||||
@@ -245,18 +245,14 @@ func (manager *SGuestManager) ListItemFilter(
|
||||
q = q.In("host_id", subq.SubQuery())
|
||||
}
|
||||
|
||||
hostFilter := query.Host
|
||||
hostFilter := query.GetAllGuestsOnHost
|
||||
if len(hostFilter) > 0 {
|
||||
host, _ := HostManager.FetchByIdOrName(nil, hostFilter)
|
||||
if host == nil {
|
||||
return nil, httperrors.NewResourceNotFoundError("host %s not found", hostFilter)
|
||||
}
|
||||
if query.GetBackupGuestsOnHost != nil && *query.GetBackupGuestsOnHost {
|
||||
q.Filter(sqlchemy.OR(sqlchemy.Equals(q.Field("host_id"), host.GetId()),
|
||||
sqlchemy.Equals(q.Field("backup_host_id"), host.GetId())))
|
||||
} else {
|
||||
q = q.Equals("host_id", host.GetId())
|
||||
}
|
||||
q.Filter(sqlchemy.OR(sqlchemy.Equals(q.Field("host_id"), host.GetId()),
|
||||
sqlchemy.Equals(q.Field("backup_host_id"), host.GetId())))
|
||||
}
|
||||
|
||||
secgrpFilter := query.Secgroup
|
||||
@@ -1021,8 +1017,12 @@ func (manager *SGuestManager) validateCreateData(
|
||||
return nil, err
|
||||
}
|
||||
// keep input cpu mem flavor
|
||||
input.VmemSize = inputMem
|
||||
input.VcpuCount = inputCpu
|
||||
if inputMem > 0 {
|
||||
input.VmemSize = inputMem
|
||||
}
|
||||
if inputMem > 0 {
|
||||
input.VcpuCount = inputCpu
|
||||
}
|
||||
input.InstanceType = inputInstaceType
|
||||
}
|
||||
|
||||
|
||||
@@ -130,9 +130,8 @@ func (m *SGuestManager) VerifyExistingGuests(pendingDelete bool) {
|
||||
params.Set("limit", jsonutils.NewInt(0))
|
||||
params.Set("scope", jsonutils.NewString("system"))
|
||||
params.Set("system", jsonutils.JSONTrue)
|
||||
params.Set("host", jsonutils.NewString(m.host.GetHostId()))
|
||||
params.Set("pending_delete", jsonutils.NewBool(pendingDelete))
|
||||
params.Set("get_backup_guests_on_host", jsonutils.JSONTrue)
|
||||
params.Set("get_all_guests_on_host", jsonutils.NewString(m.host.GetHostId()))
|
||||
if len(m.CandidateServers) > 0 {
|
||||
keys := make([]string, len(m.CandidateServers))
|
||||
var index = 0
|
||||
|
||||
Reference in New Issue
Block a user