@@ -11,13 +11,13 @@ func (d *HyperV) CreateVM(name string, cpus int, memory int, efiPath string) (st
11
11
cfDevVHD = filepath .Join (d .Config .StateDir , "disk.vhdx" )
12
12
)
13
13
14
- command := fmt .Sprintf ("New-VM -Name %s -Generation 2 -NoVHD" , name )
14
+ command := fmt .Sprintf ("Hyper-V \\ New-VM -Name %s -Generation 2 -NoVHD" , name )
15
15
_ , err := d .Powershell .Output (command )
16
16
if err != nil {
17
17
return "" , fmt .Errorf ("creating new vm: %s" , err )
18
18
}
19
19
20
- command = fmt .Sprintf ("Set-VM -Name %s " +
20
+ command = fmt .Sprintf ("Hyper-V \\ Set-VM -Name %s " +
21
21
"-AutomaticStartAction Nothing " +
22
22
"-AutomaticStopAction ShutDown " +
23
23
"-CheckpointType Disabled " +
@@ -30,26 +30,26 @@ func (d *HyperV) CreateVM(name string, cpus int, memory int, efiPath string) (st
30
30
return "" , fmt .Errorf ("setting vm properites (memoryMB:%d, cpus:%d): %s" , memory , cpus , err )
31
31
}
32
32
33
- command = fmt .Sprintf (`Add-VMDvdDrive -VMName %s -Path "%s"` , name , efiPath )
33
+ command = fmt .Sprintf (`Hyper-V\ Add-VMDvdDrive -VMName %s -Path "%s"` , name , efiPath )
34
34
_ , err = d .Powershell .Output (command )
35
35
if err != nil {
36
36
return "" , fmt .Errorf ("adding dvd drive %s: %s" , efiPath , err )
37
37
}
38
38
39
- command = fmt .Sprintf ("Remove-VMNetworkAdapter -VMName %s" , name )
39
+ command = fmt .Sprintf ("Hyper-V \\ Remove-VMNetworkAdapter -VMName %s" , name )
40
40
_ , err = d .Powershell .Output (command )
41
41
if err != nil {
42
42
fmt .Printf ("failed to remove network adapter: %s" , err )
43
43
}
44
44
45
- command = fmt .Sprintf ("Add-VMHardDiskDrive -VMName %s " +
45
+ command = fmt .Sprintf ("Hyper-V \\ Add-VMHardDiskDrive -VMName %s " +
46
46
`-Path "%s"` , name , cfDevVHD )
47
47
_ , err = d .Powershell .Output (command )
48
48
if err != nil {
49
49
return "" , fmt .Errorf ("adding vhd %s : %s" , cfDevVHD , err )
50
50
}
51
51
52
- command = fmt .Sprintf ("Set-VMFirmware " +
52
+ command = fmt .Sprintf ("Hyper-V \\ Set-VMFirmware " +
53
53
"-VMName %s " +
54
54
"-EnableSecureBoot Off " +
55
55
"-FirstBootDevice $cdrom" ,
@@ -59,7 +59,7 @@ func (d *HyperV) CreateVM(name string, cpus int, memory int, efiPath string) (st
59
59
return "" , fmt .Errorf ("setting firmware: %s" , err )
60
60
}
61
61
62
- command = fmt .Sprintf ("Set-VMComPort " +
62
+ command = fmt .Sprintf ("Hyper-V \\ Set-VMComPort " +
63
63
"-VMName %s " +
64
64
"-number 1 " +
65
65
"-Path \\ \\ .\\ pipe\\ cfdev-com" ,
@@ -69,7 +69,7 @@ func (d *HyperV) CreateVM(name string, cpus int, memory int, efiPath string) (st
69
69
return "" , fmt .Errorf ("setting com port: %s" , err )
70
70
}
71
71
72
- output , err := d .Powershell .Output ("((Get-VM -Name cfdev).Id).Guid" )
72
+ output , err := d .Powershell .Output ("((Hyper-V \\ Get-VM -Name cfdev).Id).Guid" )
73
73
if err != nil {
74
74
return "" , fmt .Errorf ("fetching VM Guid: %s" , err )
75
75
}
@@ -85,7 +85,7 @@ func (d *HyperV) StartVM(vmName string) error {
85
85
return fmt .Errorf ("hyperv vm with name %s does not exist" , vmName )
86
86
}
87
87
88
- command := fmt .Sprintf ("Start-VM -Name %s" , vmName )
88
+ command := fmt .Sprintf ("Hyper-V \\ Start-VM -Name %s" , vmName )
89
89
if _ , err := d .Powershell .Output (command ); err != nil {
90
90
return fmt .Errorf ("start-vm: %s" , err )
91
91
}
@@ -100,7 +100,7 @@ func (d *HyperV) StopVM(vmName string) error {
100
100
return nil
101
101
}
102
102
103
- command := fmt .Sprintf ("Stop-VM -Name %s -Turnoff" , vmName )
103
+ command := fmt .Sprintf ("Hyper-V \\ Stop-VM -Name %s -Turnoff" , vmName )
104
104
if _ , err := d .Powershell .Output (command ); err != nil {
105
105
return fmt .Errorf ("stopping vm: %s" , err )
106
106
}
@@ -115,7 +115,7 @@ func (d *HyperV) DestroyVM(vmName string) error {
115
115
return nil
116
116
}
117
117
118
- command := fmt .Sprintf ("Remove-VM -Name %s -Force" , vmName )
118
+ command := fmt .Sprintf ("Hyper-V \\ Remove-VM -Name %s -Force" , vmName )
119
119
if _ , err := d .Powershell .Output (command ); err != nil {
120
120
return fmt .Errorf ("removing vm: %s" , err )
121
121
}
@@ -128,7 +128,7 @@ func (d *HyperV) IsVMRunning(vmName string) (bool, error) {
128
128
return false , err
129
129
}
130
130
131
- command := fmt .Sprintf ("Get-VM -Name %s | format-list -Property State" , vmName )
131
+ command := fmt .Sprintf ("Hyper-V \\ Get-VM -Name %s | format-list -Property State" , vmName )
132
132
output , err := d .Powershell .Output (command )
133
133
if err != nil {
134
134
return false , err
@@ -142,7 +142,7 @@ func (d *HyperV) IsVMRunning(vmName string) (bool, error) {
142
142
}
143
143
144
144
func (d * HyperV ) exists (vmName string ) (bool , error ) {
145
- command := fmt .Sprintf ("Get-VM -Name %s*" , vmName )
145
+ command := fmt .Sprintf ("Hyper-V \\ Get-VM -Name %s*" , vmName )
146
146
output , err := d .Powershell .Output (command )
147
147
if err != nil {
148
148
return false , fmt .Errorf ("getting vms: %s" , err )
0 commit comments