Really solve #40 , use read_guest_ip to handle Hyper-V with dynamic IP.
Original @machine.config.vm.provider :hyperv do ... end's block is never executed since provider configuration blocks are only possible to be executed in a very early stage(far before VM boot, while goodhosts is triggered after VM up, and read_guest_ip need a booted VM), and its read_guest_ip usage is incorrect(Hyper-V driver's read_guest_ip accept 0 argument).
Also:
Remove useless networks.empty? check, since there is always the default forwarded_port network for ssh.
Note this removal does NOT make the code vulnerable, since networks.each do |network| .... end do nothing if networks is empty.
Correct action hooks timing: "add" after "up" should correspond to "remove" before "halt".
Without this, we cannot RemoveHosts when halting or destroying Hyper-V VM, since read_guest_ip can only work with running or suspended VMs.
Really solve #40 , use
read_guest_ip
to handle Hyper-V with dynamic IP. Original@machine.config.vm.provider :hyperv do ... end
's block is never executed since provider configuration blocks are only possible to be executed in a very early stage(far before VM boot, whilegoodhosts
is triggered after VM up, andread_guest_ip
need a booted VM), and itsread_guest_ip
usage is incorrect(Hyper-V driver'sread_guest_ip
accept 0 argument).Also:
networks.empty?
check, since there is always the default forwarded_port network for ssh.networks.each do |network| .... end
do nothing ifnetworks
is empty.read_guest_ip
can only work with running or suspended VMs.