fix(esxi): be compatible with disconnected host

This commit is contained in:
rainzm
2021-04-01 17:16:24 +08:00
parent c34d6984d5
commit 885a483e0f
+2 -2
View File
@@ -533,7 +533,7 @@ func (cli *SESXiClient) getVirtualSwitchs(hss []mo.HostSystem) (SVirtualSwitchMa
// vs
for i := range hss {
hs := hss[i]
if hs.Config.Network == nil {
if hs.Config == nil || hs.Config.Network == nil {
continue
}
for i := range hs.Config.Network.Vswitch {
@@ -570,7 +570,7 @@ func (cli *SESXiClient) getVirtualSwitchs(hss []mo.HostSystem) (SVirtualSwitchMa
func (cli *SESXiClient) getVPGMap(mohost *mo.HostSystem) sVPGMap {
sm := newVPGMap()
if mohost.Config.Network == nil {
if mohost.Config == nil || mohost.Config.Network == nil {
return sm
}
for i := range mohost.Config.Network.Portgroup {