Automatic merge from release/2.1.0 -> release/2.2.0

* commit '41a806cc8c71b5cd9a947a930647c6b78a5e3f2e':
  增加:guests支持with_eip=true和without_eip=true两个过滤条件
This commit is contained in:
邱剑
2018-09-12 14:53:52 +08:00
2 changed files with 16 additions and 0 deletions
+14
View File
@@ -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()
+2
View File
@@ -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
}