mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
fix(region): return storage info with topology
This commit is contained in:
@@ -137,6 +137,15 @@ type HostnetworkTopologyOutput struct {
|
||||
MacAddr string `json:"mac_addr"`
|
||||
}
|
||||
|
||||
type StorageShortDesc struct {
|
||||
Id string `json:"name"`
|
||||
Name string `json:"id"`
|
||||
Status string `json:"status"`
|
||||
Enabled bool `json:"enabled"`
|
||||
StorageType string `json:"storage_type"`
|
||||
CapacityMb int64 `json:"capacity_mb"`
|
||||
}
|
||||
|
||||
type HostTopologyOutput struct {
|
||||
Name string `json:"name"`
|
||||
Id string `json:"id"`
|
||||
@@ -145,6 +154,7 @@ type HostTopologyOutput struct {
|
||||
HostType string `json:"host_type"`
|
||||
Networks []HostnetworkTopologyOutput `json:"networks"`
|
||||
Schedtags []SchedtagShortDescDetails `json:"schedtags"`
|
||||
Storages []StorageShortDesc `json:"storages"`
|
||||
}
|
||||
|
||||
type WireTopologyOutput struct {
|
||||
|
||||
@@ -1757,6 +1757,7 @@ func (self *SVpc) GetDetailsTopology(ctx context.Context, userCred mcclient.Toke
|
||||
}
|
||||
for i := range hosts {
|
||||
hns := hosts[i].GetBaremetalnetworks()
|
||||
hss := hosts[i]._getAttachedStorages(tristate.None, tristate.None, nil)
|
||||
host := api.HostTopologyOutput{
|
||||
Name: hosts[i].Name,
|
||||
Id: hosts[i].Id,
|
||||
@@ -1764,6 +1765,7 @@ func (self *SVpc) GetDetailsTopology(ctx context.Context, userCred mcclient.Toke
|
||||
HostStatus: hosts[i].HostStatus,
|
||||
HostType: hosts[i].HostType,
|
||||
Networks: []api.HostnetworkTopologyOutput{},
|
||||
Storages: []api.StorageShortDesc{},
|
||||
Schedtags: GetSchedtagsDetailsToResourceV2(&hosts[i], ctx),
|
||||
}
|
||||
for j := range hns {
|
||||
@@ -1772,6 +1774,16 @@ func (self *SVpc) GetDetailsTopology(ctx context.Context, userCred mcclient.Toke
|
||||
MacAddr: hns[j].MacAddr,
|
||||
})
|
||||
}
|
||||
for j := range hss {
|
||||
host.Storages = append(host.Storages, api.StorageShortDesc{
|
||||
Name: hss[j].Name,
|
||||
Id: hss[j].Id,
|
||||
Status: hss[j].Status,
|
||||
Enabled: hss[j].Enabled.Bool(),
|
||||
StorageType: hss[j].StorageType,
|
||||
CapacityMb: hss[j].Capacity,
|
||||
})
|
||||
}
|
||||
wire.Hosts = append(wire.Hosts, host)
|
||||
}
|
||||
networks, err := wires[i].GetNetworks(nil, rbacutils.ScopeSystem)
|
||||
|
||||
@@ -1554,6 +1554,7 @@ func (self *SWire) GetDetailsTopology(ctx context.Context, userCred mcclient.Tok
|
||||
}
|
||||
for i := range hosts {
|
||||
hns := hosts[i].GetBaremetalnetworks()
|
||||
hss := hosts[i]._getAttachedStorages(tristate.None, tristate.None, nil)
|
||||
host := api.HostTopologyOutput{
|
||||
Name: hosts[i].Name,
|
||||
Id: hosts[i].Id,
|
||||
@@ -1569,6 +1570,16 @@ func (self *SWire) GetDetailsTopology(ctx context.Context, userCred mcclient.Tok
|
||||
MacAddr: hns[j].MacAddr,
|
||||
})
|
||||
}
|
||||
for j := range hss {
|
||||
host.Storages = append(host.Storages, api.StorageShortDesc{
|
||||
Name: hss[j].Name,
|
||||
Id: hss[j].Id,
|
||||
Status: hss[j].Status,
|
||||
Enabled: hss[j].Enabled.Bool(),
|
||||
StorageType: hss[j].StorageType,
|
||||
CapacityMb: hss[j].Capacity,
|
||||
})
|
||||
}
|
||||
ret.Hosts = append(ret.Hosts, host)
|
||||
}
|
||||
networks, err := self.GetNetworks(nil, rbacutils.ScopeSystem)
|
||||
|
||||
Reference in New Issue
Block a user