Unable to select Default Switch by name in case of localized Windows
When trying to select the switch using a localized string, eg. "Przełącznik domyślny" (meaning 'Default Switch') for Polish, the selection will fail with:
Error starting the VM: Error creating the VM. Error with pre-create check: "vswitch "Prze\u0088¥cznik domy\u0098lny" not found"
The problem lies with:
https://github.com/docker/machine/blob/51ed7e7b5f6474fac5c0011ea3f7445cd8dfe05c/drivers/hyperv/hyperv.go#L283
Besides a string, is should desirably also check for the switch by ID, as this value is static:
PS> Get-VMSwitch -Id c08cb7b8-9b3c-408e-8e30-5e16a3aeb444
Related to https://github.com/minishift/minishift/issues/2096
Similar issue happens, during machine creation:
(swarm1) DBG | [executing ==>] : C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile -NonInteractive New-VM swarm1 -Path 'C:\Users\xx\.docker\machine\machines\swarm1' -SwitchName 'Alap�rtelmezett kapcsol�' -MemorySta
rtupBytes 1024MB
(swarm1) DBG | [stdout =====>] :
(swarm1) DBG | [stderr =====>] : New-VM : Hyper-V was unable to find a virtual switch with name "Alap?rtelmezett kapcsol
?".
Correct name of switch is Alapértelmezett kapcsoló
@ssaldi this is the actual test I refer to... I will have a look, as within minikube and minishift it is impossible to select the right switch this way. It would fail for any localized name...
While the chooseVirtualSwitch logic is currently not sufficient, I at least added a fix to handle localized names as #4509.
For those looking for a temporary workaround, I was able to install with a "Commutateur par défaut" default switch in french locale by changing the console code page for the current session to utf-8:
chcp 65001
This should work until the #4509 PR is merged.