Skip to content

Commit

Permalink
check in domain if dhcp var is nil
Browse files Browse the repository at this point in the history
  • Loading branch information
MalloZup authored and inercia committed Sep 3, 2018
1 parent 881d576 commit 3090722
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions libvirt/domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,10 @@ func getDomainInterfacesFromNetworks(domain libvirtxml.Domain,
networkDef, err := newDefNetworkfromLibvirt(network)
macAddresses := make(map[string][]string)
for _, ips := range networkDef.IPs {
for _, dhcpHost := range ips.DHCP.Hosts {
macAddresses[dhcpHost.MAC] = append(macAddresses[dhcpHost.MAC], dhcpHost.IP)
if ips.DHCP != nil {
for _, dhcpHost := range ips.DHCP.Hosts {
macAddresses[dhcpHost.MAC] = append(macAddresses[dhcpHost.MAC], dhcpHost.IP)
}
}
}
networkMacAddresses[networkName] = macAddresses
Expand Down

0 comments on commit 3090722

Please sign in to comment.