Catch on empty Virtualbox network addr #43427

This commit is contained in:
Vasili Syrakis 2017-10-13 22:54:58 +11:00 committed by rallytime
parent 0cd493b691
commit 534faf0b7a
No known key found for this signature in database
GPG key ID: E8F1A4B90D0DEA19

View file

@ -278,7 +278,10 @@ def vb_get_network_addresses(machine_name=None, machine=None):
# We can't trust virtualbox to give us up to date guest properties if the machine isn't running
# For some reason it may give us outdated (cached?) values
if machine.state == _virtualboxManager.constants.MachineState_Running:
total_slots = int(machine.getGuestPropertyValue("/VirtualBox/GuestInfo/Net/Count"))
try:
total_slots = int(machine.getGuestPropertyValue('/VirtualBox/GuestInfo/Net/Count'))
except ValueError:
total_slots = 0
for i in range(total_slots):
try:
address = machine.getGuestPropertyValue("/VirtualBox/GuestInfo/Net/{0}/V4/IP".format(i))