mirror of
https://hubproxy.babadafafafafa.cn/https://github.com/yunionio/cloudpods.git
synced 2026-09-20 16:13:56 +08:00
guest export keys add zone
This commit is contained in:
@@ -1445,6 +1445,16 @@ func (manager *SGuestManager) ListItemExportKeys(ctx context.Context, q *sqlchem
|
||||
q.AppendField(hostSubQuery.Field("name", "host"))
|
||||
}
|
||||
|
||||
if utils.IsInStringArray("zone", keys) {
|
||||
zoneQuery := ZoneManager.Query("id", "name").SubQuery()
|
||||
hostQuery := HostManager.Query("id", "zone_id").GroupBy("id")
|
||||
hostQuery.LeftJoin(zoneQuery, sqlchemy.Equals(hostQuery.Field("zone_id"), zoneQuery.Field("id")))
|
||||
hostQuery.AppendField(zoneQuery.Field("name", "zone"))
|
||||
hostSubQuery := hostQuery.SubQuery()
|
||||
q.LeftJoin(hostSubQuery, sqlchemy.Equals(q.Field("host_id"), hostSubQuery.Field("id")))
|
||||
q.AppendField(hostSubQuery.Field("zone"))
|
||||
}
|
||||
|
||||
// host_id as filter key
|
||||
if utils.IsInStringArray("region", keys) {
|
||||
zoneQuery := ZoneManager.Query("id", "cloudregion_id").SubQuery()
|
||||
@@ -1487,6 +1497,9 @@ func (manager *SGuestManager) GetExportExtraKeys(ctx context.Context, query json
|
||||
if host, ok := rowMap["host"]; ok && len(host) > 0 {
|
||||
res.Set("host", jsonutils.NewString(host))
|
||||
}
|
||||
if zone, ok := rowMap["zone"]; ok && len(zone) > 0 {
|
||||
res.Set("zone", jsonutils.NewString(zone))
|
||||
}
|
||||
if region, ok := rowMap["region"]; ok && len(region) > 0 {
|
||||
res.Set("region", jsonutils.NewString(region))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user