mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
增加:guests支持with_eip=true和without_eip=true两个过滤条件
This commit is contained in:
@@ -316,6 +316,20 @@ func (manager *SGuestManager) ListItemFilter(ctx context.Context, q *sqlchemy.SQ
|
||||
q = q.In("host_id", sq)
|
||||
}
|
||||
|
||||
withEip, _ := queryDict.GetString("with_eip")
|
||||
withoutEip, _ := queryDict.GetString("without_eip")
|
||||
if len(withEip) > 0 || len(withoutEip) > 0 {
|
||||
eips := ElasticipManager.Query().SubQuery()
|
||||
sq := eips.Query(eips.Field("associate_id")).Equals("associate_type", EIP_ASSOCIATE_TYPE_SERVER)
|
||||
sq = sq.IsNotNull("associate_id").IsNotEmpty("associate_id")
|
||||
|
||||
if utils.ToBool(withEip) {
|
||||
q = q.In("id", sq)
|
||||
} else if utils.ToBool(withoutEip) {
|
||||
q = q.NotIn("id", sq)
|
||||
}
|
||||
}
|
||||
|
||||
gpu, _ := queryDict.GetString("gpu")
|
||||
if len(gpu) != 0 {
|
||||
isodev := IsolatedDeviceManager.Query().SubQuery()
|
||||
|
||||
@@ -21,6 +21,8 @@ type ServerListOptions struct {
|
||||
Hypervisor string `help:"Show server of hypervisor" choices:"kvm|esxi|container|baremetal|aliyun"`
|
||||
Manager string `help:"Show servers imported from manager"`
|
||||
Region string `help:"Show servers in cloudregion"`
|
||||
WithEip *bool `help:"Show Servers with EIP"`
|
||||
WithoutEip *bool `help:"Show Servers without EIP"`
|
||||
|
||||
BaseListOptions
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user