Merge pull request #6950 from wanyaoqi/bugfix/wyq/region-misc0628

bugfix: region list misc fix
This commit is contained in:
Zexi Li
2020-06-29 19:35:59 +08:00
committed by GitHub
4 changed files with 36 additions and 3 deletions
+2
View File
@@ -21,6 +21,8 @@ type GuestnetworkDetails struct {
// IP子网名称
Network string `json:"network"`
// 所属Wire
WireId string `json:"wire_id"`
}
type GuestnetworkShortDesc struct {
+6 -3
View File
@@ -108,6 +108,8 @@ type HostListInput struct {
Uuid []string `json:"uuid"`
// 主机启动模式, 可能值位PXE和ISO
BootMode []string `json:"boot_mode"`
// 虚拟机所在的二层网络
ServerIdForNetwork string `json:"server_id_for_network"`
}
type HostDetails struct {
@@ -119,9 +121,10 @@ type HostDetails struct {
Schedtags []SchedtagShortDescDetails `json:"schedtags"`
ServerId string `json:"server_id"`
Server string `json:"server"`
ServerIps string `json:"server_ips"`
ServerId string `json:"server_id"`
Server string `json:"server"`
ServerIps string `json:"server_ips"`
ServerPendingDeleted bool `json:"server_pending_deleted"`
// 网卡数量
NicCount int `json:"nic_count"`
// 网卡详情
+3
View File
@@ -142,6 +142,9 @@ func (manager *SGuestnetworkManager) FetchCustomizeColumns(
GuestJointResourceDetails: guestRows[i],
}
netIds[i] = objs[i].(*SGuestnetwork).NetworkId
iNet, _ := NetworkManager.FetchById(netIds[i])
net := iNet.(*SNetwork)
rows[i].WireId = net.WireId
}
netIdMaps, err := db.FetchIdNameMap2(NetworkManager, netIds)
+25
View File
@@ -432,6 +432,30 @@ func (manager *SHostManager) ListItemFilter(
q = q.In("boot_mode", query.BootMode)
}
// for provider onecloud
if len(query.ServerIdForNetwork) > 0 {
guest := GuestManager.FetchGuestById(query.ServerIdForNetwork)
if guest != nil && guest.GetHypervisor() == api.HYPERVISOR_KVM {
nets, _ := guest.GetNetworks("")
if len(nets) > 0 {
wires := []string{}
for i := 0; i < len(nets); i++ {
net := nets[i].GetNetwork()
if net.GetVpc().Id != api.DEFAULT_VPC_ID {
q = q.IsNotEmpty("ovn_version")
} else {
if !utils.IsInStringArray(net.WireId, wires) {
wires = append(wires, net.WireId)
hostwires := HostwireManager.Query().SubQuery()
scopeQuery := hostwires.Query(hostwires.Field("host_id")).Equals("wire_id", net.WireId).SubQuery()
q = q.In("id", scopeQuery)
}
}
}
}
}
}
return q, nil
}
@@ -2521,6 +2545,7 @@ func (self *SHost) getMoreDetails(ctx context.Context, out api.HostDetails, show
if server != nil {
out.ServerId = server.Id
out.Server = server.Name
out.ServerPendingDeleted = server.PendingDeleted
if self.HostType == api.HOST_TYPE_BAREMETAL {
out.ServerIps = strings.Join(server.GetRealIPs(), ",")
}