Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes "Host IP for the HyperV machine: False" if more than one VMNetworkAdapter is found #7480

Conversation

BobSilent
Copy link
Contributor

When using a Network Switch from docker (nat) where already container are attached to the network the call to Get-VMNetworkAdapter -ManagementOS -SwitchName "nat"

results in more than one adapter found, e.g.

Name                                 IsManagementOs VMName SwitchName MacAddress   Status IPAddresses
----                                 -------------- ------ ---------- ----------   ------ -----------
Container NIC 7ddd4f35               True                  nat        00155DAE7F3D {Ok}
F010C062-134C-4B70-A306-DA49FB6F64B8 True                  nat        00155DAE7720 {Ok}

In order to handle the situation, the powershell code was improved to handle more than one result (lists)

my assumption is, this one fixes
Closes #5023

although #4947 is marked as duplicate, it shows a different error information
==> hyperv-iso: Error getting host adapter ip address: PowerShell error: Get-VMNetworkAdapter : No network adapter is found with the given input.
therefore I am not sure if this also would fix #4947

maybe also a fix for issue hashicorp#5023
at least I got same error like there, incl. VM response
==> hyperv-iso: Host IP for the HyperV machine: False

although hashicorp#4947 is marked as duplicate but shows different error output
==> hyperv-iso: Error getting host adapter ip address: PowerShell error: Get-VMNetworkAdapter : No network adapter is found with the given input.
@BobSilent BobSilent requested a review from a team as a code owner April 9, 2019 07:44
@hashicorp-cla
Copy link

hashicorp-cla commented Apr 9, 2019

CLA assistant check
All committers have signed the CLA.

@BobSilent
Copy link
Contributor Author

BobSilent commented Apr 9, 2019

@SwampDragons can you support me? Is the travis build issue from my change? where do i have to look for details.

@SwampDragons
Copy link
Contributor

Not you; we've been having some issues with Travis lately. I'll give this a quick test and then merge; it looks great!

@SwampDragons
Copy link
Contributor

I'm having some trouble with my windows VM; it'll probably be a day or two before I can get to testing this. Sorry for the delay!

@BobSilent
Copy link
Contributor Author

yeah, its always the infrastructure which makes trouble 😃
i was fighting the last days with my linux vms ;)

I am currently running my compiled version for this.
For testing i used the docker switch on my windows machine "nat" and just started a container (in my case a windows server core) which attached to the network, this gave me a simple way to have two managed network cards.

Another question, maybe a wrong place here, but i have some inputs for your description here https://github.com/hashicorp/packer/blob/master/.github/CONTRIBUTING.md#setting-up-go

As it was my first contact with GO and building on a windows machine.
When I followed the description (i manually downloaded make - http://gnuwin32.sourceforge.net/packages/make.htm)
I ran into this error:

C:\Projects\packer>make
...
# runtime/cgo
exec: "gcc": executable file not found in %PATH%

running this command,
go build -o bin/packer**.exe** .

I had to take care for a correct file ending in windows
and i am currently not sure if it really worked, because at the end
I installed mingw on windows

choco install mingw -y
Chocolatey v0.10.11
Installing the following packages:
mingw
By installing you accept licenses for the packages.
Progress: Downloading mingw 8.1.0... 100%

mingw v8.1.0 [Approved]

which made it possible to compile using make on windows without errors 🥇

@SwampDragons SwampDragons merged commit 78cf140 into hashicorp:master Apr 12, 2019
@SwampDragons
Copy link
Contributor

Do you think you could make a PR to the contributing.md with your suggestions? Those sound really valuable.

@ghost
Copy link

ghost commented Mar 28, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Mar 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
3 participants