diff --git a/plugins/providers/hyperv/driver.rb b/plugins/providers/hyperv/driver.rb index e200a8224..4f95db8c7 100644 --- a/plugins/providers/hyperv/driver.rb +++ b/plugins/providers/hyperv/driver.rb @@ -10,15 +10,16 @@ module VagrantPlugins ERROR_REGEXP = /===Begin-Error===(.+?)===End-Error===/m OUTPUT_REGEXP = /===Begin-Output===(.+?)===End-Output===/m - # Name mapping for integration services for nicer keys + # Name mapping for integration services for id + # https://social.technet.microsoft.com/Forums/de-DE/154917de-f3ca-4b1e-b3f8-23dd4b4f0f06/getvmintegrationservice-sprachabhngig?forum=powershell_de INTEGRATION_SERVICES_MAP = { - guest_service_interface: "Guest Service Interface", - heartbeat: "Heartbeat", - key_value_pair_exchange: "Key-Value Pair Exchange", - shutdown: "Shutdown", - time_synchronization: "Time Synchronization", - vss: "VSS", - } + guest_service_interface: "6C09BB55-D683-4DA0-8931-C9BF705F6480".freeze, + heartbeat: "84EAAE65-2F2E-45F5-9BB5-0E857DC8EB47".freeze, + key_value_pair_exchange: "2A34B1C2-FD73-4043-8A5B-DD2159BC743F".freeze, + shutdown: "9F8233AC-BE49-4C79-8EE3-E7E1985B2077".freeze, + time_synchronization: "2497F4DE-E9FA-4204-80E4-4B75C46419C0".freeze, + vss: "5CED1297-4598-4915-A5FC-AD21BB4D02A4".freeze, + }.freeze # @return [String] VM ID attr_reader :vm_id @@ -203,7 +204,7 @@ module VagrantPlugins # to configurable even if Vagrant is not aware of them. def set_vm_integration_services(config) config.each_pair do |srv_name, srv_enable| - args = {VMID: vm_id, Name: INTEGRATION_SERVICES_MAP.fetch(srv_name.to_sym, srv_name).to_s} + args = {VMID: vm_id, Id: INTEGRATION_SERVICES_MAP.fetch(srv_name.to_sym, srv_name).to_s} args[:Enable] = true if srv_enable execute(:set_vm_integration_services, args) end diff --git a/plugins/providers/hyperv/scripts/set_vm_integration_services.ps1 b/plugins/providers/hyperv/scripts/set_vm_integration_services.ps1 index 9e8092b55..f53c97bc5 100644 --- a/plugins/providers/hyperv/scripts/set_vm_integration_services.ps1 +++ b/plugins/providers/hyperv/scripts/set_vm_integration_services.ps1 @@ -4,7 +4,7 @@ param ( [parameter (Mandatory=$true)] [string] $VMID, [parameter (Mandatory=$true)] - [string] $Name, + [string] $Id, [parameter (Mandatory=$false)] [switch] $Enable ) @@ -19,9 +19,9 @@ try { } try { - Set-VagrantVMService -VM $VM -Name $Name -Enable $Enable + Set-VagrantVMService -VM $VM -Id $Id -Enable $Enable } catch { if($Enable){ $action = "enable" } else { $action = "disable" } - Write-ErrorMessage "Failed to ${action} VM integration service ${Name}: ${PSItem}" + Write-ErrorMessage "Failed to ${action} VM integration service id ${Id}: ${PSItem}" exit 1 } diff --git a/plugins/providers/hyperv/scripts/utils/VagrantVM/VagrantVM.psm1 b/plugins/providers/hyperv/scripts/utils/VagrantVM/VagrantVM.psm1 index 3e53ae47e..c2703f8b5 100644 --- a/plugins/providers/hyperv/scripts/utils/VagrantVM/VagrantVM.psm1 +++ b/plugins/providers/hyperv/scripts/utils/VagrantVM/VagrantVM.psm1 @@ -614,15 +614,15 @@ function Set-VagrantVMService { [parameter (Mandatory=$true)] [Microsoft.HyperV.PowerShell.VirtualMachine] $VM, [parameter (Mandatory=$true)] - [string] $Name, + [string] $Id, [parameter (Mandatory=$true)] [bool] $Enable ) if($Enable) { - Hyper-V\Enable-VMIntegrationService -VM $VM -Name $Name + Hyper-V\Get-VMIntegrationService -VM $VM | ?{$_.Id -match $Id} | Hyper-V\Enable-VMIntegrationService } else { - Hyper-V\Disable-VMIntegrationService -VM $VM -Name $Name + Hyper-V\Get-VMIntegrationService -VM $VM | ?{$_.Id -match $Id} | Hyper-V\Disable-VMIntegrationService } return $VM <# @@ -634,9 +634,9 @@ Enable or disable Hyper-V VM integration services. Hyper-V VM for modification. -.PARAMETER Name +.PARAMETER Id -Name of the integration service. +Id of the integration service. .PARAMETER Enable diff --git a/test/unit/plugins/providers/hyperv/driver_test.rb b/test/unit/plugins/providers/hyperv/driver_test.rb index 585337600..47562b742 100644 --- a/test/unit/plugins/providers/hyperv/driver_test.rb +++ b/test/unit/plugins/providers/hyperv/driver_test.rb @@ -91,7 +91,7 @@ describe VagrantPlugins::HyperV::Driver do describe "#set_vm_integration_services" do it "should map known integration services names automatically" do expect(subject).to receive(:execute) do |name, args| - expect(args[:Name]).to eq("Shutdown") + expect(args[:Id]).to eq(VagrantPlugins::HyperV::Driver::INTEGRATION_SERVICES_MAP[:shutdown]) end subject.set_vm_integration_services(shutdown: true) end @@ -112,7 +112,7 @@ describe VagrantPlugins::HyperV::Driver do it "should pass unknown key names directly through" do expect(subject).to receive(:execute) do |name, args| - expect(args[:Name]).to eq("CustomKey") + expect(args[:Id]).to eq("CustomKey") end subject.set_vm_integration_services(CustomKey: true) end