vagrant-parallels 1.2.2 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +1 -3
- data/LICENSE.txt +1 -0
- data/lib/vagrant-parallels/action.rb +25 -0
- data/lib/vagrant-parallels/action/export.rb +14 -23
- data/lib/vagrant-parallels/action/handle_forwarded_port_collisions.rb +2 -2
- data/lib/vagrant-parallels/action/import.rb +51 -31
- data/lib/vagrant-parallels/action/network.rb +14 -13
- data/lib/vagrant-parallels/action/prepare_nfs_settings.rb +19 -15
- data/lib/vagrant-parallels/driver/base.rb +8 -0
- data/lib/vagrant-parallels/driver/meta.rb +0 -1
- data/lib/vagrant-parallels/driver/pd_10.rb +1 -13
- data/lib/vagrant-parallels/driver/pd_8.rb +82 -41
- data/lib/vagrant-parallels/driver/pd_9.rb +0 -38
- data/lib/vagrant-parallels/errors.rb +8 -0
- data/lib/vagrant-parallels/guest_cap/linux/mount_parallels_shared_folder.rb +12 -0
- data/lib/vagrant-parallels/plugin.rb +1 -1
- data/lib/vagrant-parallels/provider.rb +4 -4
- data/lib/vagrant-parallels/version.rb +1 -1
- data/locales/en.yml +9 -0
- data/test/unit/driver/pd_10_test.rb +0 -191
- data/test/unit/driver/pd_8_test.rb +0 -191
- data/test/unit/driver/pd_9_test.rb +0 -192
- data/test/unit/support/shared/parallels_context.rb +204 -10
- data/vagrant-parallels.gemspec +2 -1
- metadata +37 -29
@@ -4,201 +4,10 @@ describe VagrantPlugins::Parallels::Driver::PD_8 do
|
|
4
4
|
include_context "parallels"
|
5
5
|
let(:parallels_version) { "8" }
|
6
6
|
|
7
|
-
let(:vm_name) {'VM_Name'}
|
8
|
-
|
9
|
-
let(:tpl_uuid) {'1234-some-template-uuid-5678'}
|
10
|
-
let(:tpl_name) {'Some_Template_Name'}
|
11
|
-
|
12
|
-
let(:tools_state) {'installed'}
|
13
|
-
let(:tools_version) {'8.0.18615.123456'}
|
14
|
-
|
15
|
-
let(:hostonly_iface) {'vnic10'}
|
16
|
-
|
17
|
-
let(:vnic_options) do {
|
18
|
-
name: 'vagrant_vnic6',
|
19
|
-
adapter_ip: '11.11.11.11',
|
20
|
-
netmask: '255.255.252.0',
|
21
|
-
dhcp: {
|
22
|
-
ip: '11.11.11.11',
|
23
|
-
lower: '11.11.8.1',
|
24
|
-
upper: '11.11.11.254'
|
25
|
-
}
|
26
|
-
} end
|
27
|
-
|
28
7
|
subject { VagrantPlugins::Parallels::Driver::Meta.new(uuid) }
|
29
8
|
|
30
9
|
it_behaves_like "parallels desktop driver"
|
31
10
|
|
32
|
-
before do
|
33
|
-
# Returns short info about all registered VMs
|
34
|
-
# `prlctl list --all --json`
|
35
|
-
subprocess.stub(:execute).
|
36
|
-
with("prlctl", "list", "--all", "--json", kind_of(Hash)) do
|
37
|
-
out = <<-eos
|
38
|
-
INFO[
|
39
|
-
{
|
40
|
-
"uuid": "#{uuid}",
|
41
|
-
"status": "stopped",
|
42
|
-
"name": "#{vm_name}"
|
43
|
-
}
|
44
|
-
]
|
45
|
-
eos
|
46
|
-
subprocess_result(stdout: out)
|
47
|
-
end
|
48
|
-
|
49
|
-
# Returns short info about all registered templates
|
50
|
-
# `prlctl list --all --json --template`
|
51
|
-
subprocess.stub(:execute).
|
52
|
-
with("prlctl", "list", "--all", "--json", "--template", kind_of(Hash)) do
|
53
|
-
out = <<-eos
|
54
|
-
INFO[
|
55
|
-
{
|
56
|
-
"uuid": "1234-some-template-uuid-5678",
|
57
|
-
"name": "Some_Template_Name"
|
58
|
-
}
|
59
|
-
]
|
60
|
-
eos
|
61
|
-
subprocess_result(stdout: out)
|
62
|
-
end
|
63
|
-
|
64
|
-
|
65
|
-
# Returns detailed info about specified VM or all registered VMs
|
66
|
-
# `prlctl list <vm_uuid> --info --json`
|
67
|
-
# `prlctl list --all --info --json`
|
68
|
-
subprocess.stub(:execute).
|
69
|
-
with("prlctl", "list", kind_of(String), "--info", "--json",
|
70
|
-
kind_of(Hash)) do
|
71
|
-
out = <<-eos
|
72
|
-
INFO[
|
73
|
-
{
|
74
|
-
"ID": "#{uuid}",
|
75
|
-
"Name": "#{vm_name}",
|
76
|
-
"State": "stopped",
|
77
|
-
"Home": "/path/to/#{vm_name}.pvm/",
|
78
|
-
"GuestTools": {
|
79
|
-
"state": "#{tools_state}",
|
80
|
-
"version": "#{tools_version}"
|
81
|
-
},
|
82
|
-
"Hardware": {
|
83
|
-
"cpu": {
|
84
|
-
"cpus": 1
|
85
|
-
},
|
86
|
-
"memory": {
|
87
|
-
"size": "512Mb"
|
88
|
-
},
|
89
|
-
"hdd0": {
|
90
|
-
"enabled": true,
|
91
|
-
"image": "/path/to/disk1.hdd"
|
92
|
-
},
|
93
|
-
"net0": {
|
94
|
-
"enabled": true,
|
95
|
-
"type": "shared",
|
96
|
-
"mac": "001C42B4B074",
|
97
|
-
"card": "e1000",
|
98
|
-
"dhcp": "yes"
|
99
|
-
},
|
100
|
-
"net1": {
|
101
|
-
"enabled": true,
|
102
|
-
"type": "bridged",
|
103
|
-
"iface": "vnic2",
|
104
|
-
"mac": "001C42EC0068",
|
105
|
-
"card": "e1000",
|
106
|
-
"ips": "33.33.33.5/255.255.255.0 "
|
107
|
-
}
|
108
|
-
},
|
109
|
-
"Host Shared Folders": {
|
110
|
-
"enabled": true,
|
111
|
-
"shared_folder_1": {
|
112
|
-
"enabled": true,
|
113
|
-
"path": "/path/to/shared/folder/1"
|
114
|
-
},
|
115
|
-
"shared_folder_2": {
|
116
|
-
"enabled": true,
|
117
|
-
"path": "/path/to/shared/folder/2"
|
118
|
-
}
|
119
|
-
}
|
120
|
-
}
|
121
|
-
]
|
122
|
-
eos
|
123
|
-
subprocess_result(stdout: out)
|
124
|
-
end
|
125
|
-
|
126
|
-
# Returns detailed info about specified template or all registered templates
|
127
|
-
# `prlctl list <tpl_uuid> --info --json --template`
|
128
|
-
# `prlctl list --all --info --json --template`
|
129
|
-
subprocess.stub(:execute).
|
130
|
-
with("prlctl", "list", kind_of(String), "--info", "--json", "--template",
|
131
|
-
kind_of(Hash)) do
|
132
|
-
out = <<-eos
|
133
|
-
INFO[
|
134
|
-
{
|
135
|
-
"ID": "#{tpl_uuid}",
|
136
|
-
"Name": "#{tpl_name}",
|
137
|
-
"State": "stopped",
|
138
|
-
"Home": "/path/to/#{tpl_name}.pvm/",
|
139
|
-
"GuestTools": {
|
140
|
-
"state": "#{tools_state}",
|
141
|
-
"version": "#{tools_version}"
|
142
|
-
},
|
143
|
-
"Hardware": {
|
144
|
-
"cpu": {
|
145
|
-
"cpus": 1
|
146
|
-
},
|
147
|
-
"memory": {
|
148
|
-
"size": "512Mb"
|
149
|
-
},
|
150
|
-
"hdd0": {
|
151
|
-
"enabled": true,
|
152
|
-
"image": "/path/to/harddisk.hdd"
|
153
|
-
},
|
154
|
-
"net0": {
|
155
|
-
"enabled": true,
|
156
|
-
"type": "shared",
|
157
|
-
"mac": "001C42F6E500",
|
158
|
-
"card": "e1000",
|
159
|
-
"dhcp": "yes"
|
160
|
-
},
|
161
|
-
"net1": {
|
162
|
-
"enabled": true,
|
163
|
-
"type": "bridged",
|
164
|
-
"iface": "vnic4",
|
165
|
-
"mac": "001C42AB0071",
|
166
|
-
"card": "e1000",
|
167
|
-
"ips": "33.33.33.10/255.255.255.0 "
|
168
|
-
}
|
169
|
-
}
|
170
|
-
}
|
171
|
-
]
|
172
|
-
eos
|
173
|
-
subprocess_result(stdout: out)
|
174
|
-
end
|
175
|
-
|
176
|
-
# Returns detailed info about virtual network interface
|
177
|
-
# `prlsrvctl net info <net_name>, '--json', retryable: true)
|
178
|
-
subprocess.stub(:execute).
|
179
|
-
with("prlsrvctl", "net", "info", kind_of(String), "--json",
|
180
|
-
kind_of(Hash)) do
|
181
|
-
out = <<-eos
|
182
|
-
{
|
183
|
-
"Network ID": "#{vnic_options[:name]}",
|
184
|
-
"Type": "host-only",
|
185
|
-
"Bound To": "#{hostonly_iface}",
|
186
|
-
"Parallels adapter": {
|
187
|
-
"IP address": "#{vnic_options[:adapter_ip]}",
|
188
|
-
"Subnet mask": "#{vnic_options[:netmask]}"
|
189
|
-
},
|
190
|
-
"DHCPv4 server": {
|
191
|
-
"Server address": "#{vnic_options[:dhcp][:ip] || "10.37.132.1"}",
|
192
|
-
"IP scope start address": "#{vnic_options[:dhcp][:lower] || "10.37.132.1"}",
|
193
|
-
"IP scope end address": "#{vnic_options[:dhcp][:upper] || "10.37.132.254"}"
|
194
|
-
}
|
195
|
-
}
|
196
|
-
eos
|
197
|
-
subprocess_result(stdout: out)
|
198
|
-
end
|
199
|
-
|
200
|
-
end
|
201
|
-
|
202
11
|
describe "ssh_ip" do
|
203
12
|
let(:content) {'10.200.0.99="1394547632,1800,001c420000ff,01001c420000ff"'}
|
204
13
|
|
@@ -2,203 +2,11 @@ require_relative "../base"
|
|
2
2
|
|
3
3
|
describe VagrantPlugins::Parallels::Driver::PD_9 do
|
4
4
|
include_context "parallels"
|
5
|
-
let(:parallels_version) { "9" }
|
6
|
-
|
7
|
-
let(:vm_name) {'VM_Name'}
|
8
|
-
|
9
|
-
let(:tpl_uuid) {'1234-some-template-uuid-5678'}
|
10
|
-
let(:tpl_name) {'Some_Template_Name'}
|
11
|
-
|
12
|
-
let(:tools_state) {'installed'}
|
13
|
-
let(:tools_version) {'9.0.23062.123456'}
|
14
|
-
|
15
|
-
let(:hostonly_iface) {'vnic10'}
|
16
|
-
|
17
|
-
let(:vnic_options) do {
|
18
|
-
name: 'vagrant_vnic6',
|
19
|
-
adapter_ip: '11.11.11.11',
|
20
|
-
netmask: '255.255.252.0',
|
21
|
-
dhcp: {
|
22
|
-
ip: '11.11.11.11',
|
23
|
-
lower: '11.11.8.1',
|
24
|
-
upper: '11.11.11.254'
|
25
|
-
}
|
26
|
-
} end
|
27
5
|
|
28
6
|
subject { VagrantPlugins::Parallels::Driver::Meta.new(uuid) }
|
29
7
|
|
30
8
|
it_behaves_like "parallels desktop driver"
|
31
9
|
|
32
|
-
before do
|
33
|
-
# Returns short info about all registered VMs
|
34
|
-
# `prlctl list --all --json`
|
35
|
-
subprocess.stub(:execute).
|
36
|
-
with("prlctl", "list", "--all", "--json", kind_of(Hash)) do
|
37
|
-
out = <<-eos
|
38
|
-
[
|
39
|
-
{
|
40
|
-
"uuid": "#{uuid}",
|
41
|
-
"status": "stopped",
|
42
|
-
"name": "#{vm_name}"
|
43
|
-
}
|
44
|
-
]
|
45
|
-
eos
|
46
|
-
subprocess_result(stdout: out)
|
47
|
-
end
|
48
|
-
|
49
|
-
# Returns short info about all registered templates
|
50
|
-
# `prlctl list --all --json --template`
|
51
|
-
subprocess.stub(:execute).
|
52
|
-
with("prlctl", "list", "--all", "--json", "--template", kind_of(Hash)) do
|
53
|
-
out = <<-eos
|
54
|
-
[
|
55
|
-
{
|
56
|
-
"uuid": "1234-some-template-uuid-5678",
|
57
|
-
"name": "Some_Template_Name"
|
58
|
-
}
|
59
|
-
]
|
60
|
-
eos
|
61
|
-
subprocess_result(stdout: out)
|
62
|
-
end
|
63
|
-
|
64
|
-
|
65
|
-
# Returns detailed info about specified VM or all registered VMs
|
66
|
-
# `prlctl list <vm_uuid> --info --json`
|
67
|
-
# `prlctl list --all --info --json`
|
68
|
-
subprocess.stub(:execute).
|
69
|
-
with("prlctl", "list", kind_of(String), "--info", "--json",
|
70
|
-
kind_of(Hash)) do
|
71
|
-
out = <<-eos
|
72
|
-
[
|
73
|
-
{
|
74
|
-
"ID": "#{uuid}",
|
75
|
-
"Name": "#{vm_name}",
|
76
|
-
"State": "stopped",
|
77
|
-
"Home": "/path/to/#{vm_name}.pvm/",
|
78
|
-
"GuestTools": {
|
79
|
-
"state": "#{tools_state}",
|
80
|
-
"version": "#{tools_version}"
|
81
|
-
},
|
82
|
-
"Hardware": {
|
83
|
-
"cpu": {
|
84
|
-
"cpus": 1
|
85
|
-
},
|
86
|
-
"memory": {
|
87
|
-
"size": "512Mb"
|
88
|
-
},
|
89
|
-
"hdd0": {
|
90
|
-
"enabled": true,
|
91
|
-
"image": "/path/to/disk1.hdd"
|
92
|
-
},
|
93
|
-
"net0": {
|
94
|
-
"enabled": true,
|
95
|
-
"type": "shared",
|
96
|
-
"mac": "001C42B4B074",
|
97
|
-
"card": "e1000",
|
98
|
-
"dhcp": "yes"
|
99
|
-
},
|
100
|
-
"net1": {
|
101
|
-
"enabled": true,
|
102
|
-
"type": "bridged",
|
103
|
-
"iface": "vnic2",
|
104
|
-
"mac": "001C42EC0068",
|
105
|
-
"card": "e1000",
|
106
|
-
"ips": "33.33.33.5/255.255.255.0 "
|
107
|
-
}
|
108
|
-
},
|
109
|
-
"Host Shared Folders": {
|
110
|
-
"enabled": true,
|
111
|
-
"shared_folder_1": {
|
112
|
-
"enabled": true,
|
113
|
-
"path": "/path/to/shared/folder/1"
|
114
|
-
},
|
115
|
-
"shared_folder_2": {
|
116
|
-
"enabled": true,
|
117
|
-
"path": "/path/to/shared/folder/2"
|
118
|
-
}
|
119
|
-
}
|
120
|
-
}
|
121
|
-
]
|
122
|
-
eos
|
123
|
-
subprocess_result(stdout: out)
|
124
|
-
end
|
125
|
-
|
126
|
-
# Returns detailed info about specified template or all registered templates
|
127
|
-
# `prlctl list <tpl_uuid> --info --json --template`
|
128
|
-
# `prlctl list --all --info --json --template`
|
129
|
-
subprocess.stub(:execute).
|
130
|
-
with("prlctl", "list", kind_of(String), "--info", "--json", "--template",
|
131
|
-
kind_of(Hash)) do
|
132
|
-
out = <<-eos
|
133
|
-
[
|
134
|
-
{
|
135
|
-
"ID": "#{tpl_uuid}",
|
136
|
-
"Name": "#{tpl_name}",
|
137
|
-
"State": "stopped",
|
138
|
-
"Home": "/path/to/#{tpl_name}.pvm/",
|
139
|
-
"GuestTools": {
|
140
|
-
"state": "#{tools_state}",
|
141
|
-
"version": "#{tools_version}"
|
142
|
-
},
|
143
|
-
"Hardware": {
|
144
|
-
"cpu": {
|
145
|
-
"cpus": 1
|
146
|
-
},
|
147
|
-
"memory": {
|
148
|
-
"size": "512Mb"
|
149
|
-
},
|
150
|
-
"hdd0": {
|
151
|
-
"enabled": true,
|
152
|
-
"image": "/path/to/harddisk.hdd"
|
153
|
-
},
|
154
|
-
"net0": {
|
155
|
-
"enabled": true,
|
156
|
-
"type": "shared",
|
157
|
-
"mac": "001C42F6E500",
|
158
|
-
"card": "e1000",
|
159
|
-
"dhcp": "yes"
|
160
|
-
},
|
161
|
-
"net1": {
|
162
|
-
"enabled": true,
|
163
|
-
"type": "bridged",
|
164
|
-
"iface": "vnic4",
|
165
|
-
"mac": "001C42AB0071",
|
166
|
-
"card": "e1000",
|
167
|
-
"ips": "33.33.33.10/255.255.255.0 "
|
168
|
-
}
|
169
|
-
}
|
170
|
-
}
|
171
|
-
]
|
172
|
-
eos
|
173
|
-
subprocess_result(stdout: out)
|
174
|
-
end
|
175
|
-
|
176
|
-
# Returns detailed info about virtual network interface
|
177
|
-
# `prlsrvctl net info <net_name>, '--json', retryable: true)
|
178
|
-
subprocess.stub(:execute).
|
179
|
-
with("prlsrvctl", "net", "info", kind_of(String), "--json",
|
180
|
-
kind_of(Hash)) do
|
181
|
-
out = <<-eos
|
182
|
-
{
|
183
|
-
"Network ID": "#{vnic_options[:name]}",
|
184
|
-
"Type": "host-only",
|
185
|
-
"Bound To": "#{hostonly_iface}",
|
186
|
-
"Parallels adapter": {
|
187
|
-
"IP address": "#{vnic_options[:adapter_ip]}",
|
188
|
-
"Subnet mask": "#{vnic_options[:netmask]}"
|
189
|
-
},
|
190
|
-
"DHCPv4 server": {
|
191
|
-
"Server address": "#{vnic_options[:dhcp][:ip] || "10.37.132.1"}",
|
192
|
-
"IP scope start address": "#{vnic_options[:dhcp][:lower] || "10.37.132.1"}",
|
193
|
-
"IP scope end address": "#{vnic_options[:dhcp][:upper] || "10.37.132.254"}"
|
194
|
-
}
|
195
|
-
}
|
196
|
-
eos
|
197
|
-
subprocess_result(stdout: out)
|
198
|
-
end
|
199
|
-
|
200
|
-
end
|
201
|
-
|
202
10
|
describe "set_power_consumption_mode" do
|
203
11
|
it "turns 'longer-battery-life' on" do
|
204
12
|
subprocess.should_receive(:execute).
|
@@ -1,31 +1,225 @@
|
|
1
|
-
shared_context
|
1
|
+
shared_context 'parallels' do
|
2
2
|
let(:parallels_context) { true }
|
3
|
-
let(:uuid) {
|
4
|
-
let(:parallels_version) {
|
5
|
-
let(:subprocess) { double(
|
6
|
-
let(:driver) { subject.instance_variable_get(
|
3
|
+
let(:uuid) { '1234-here-is-uuid-5678' }
|
4
|
+
let(:parallels_version) { '9' }
|
5
|
+
let(:subprocess) { double('Vagrant::Util::Subprocess') }
|
6
|
+
let(:driver) { subject.instance_variable_get('@driver') }
|
7
|
+
|
8
|
+
let(:vm_name) {'VM_Name'}
|
9
|
+
let(:tpl_uuid) {'1234-some-template-uuid-5678'}
|
10
|
+
let(:tpl_name) {'Some_Template_Name'}
|
11
|
+
let(:tools_state) {'installed'}
|
12
|
+
let(:tools_version) {'8.0.18615.123456'}
|
13
|
+
let(:hostonly_iface) {'vnic10'}
|
14
|
+
|
15
|
+
let(:vnic_options) do {
|
16
|
+
name: 'vagrant_vnic6',
|
17
|
+
adapter_ip: '11.11.11.11',
|
18
|
+
netmask: '255.255.252.0',
|
19
|
+
dhcp: {
|
20
|
+
ip: '11.11.11.11',
|
21
|
+
lower: '11.11.8.1',
|
22
|
+
upper: '11.11.11.254'
|
23
|
+
}
|
24
|
+
} end
|
7
25
|
|
8
26
|
# this is a helper that returns a duck type suitable from a system command
|
9
27
|
# execution; allows setting exit_code, stdout, and stderr in stubs.
|
10
28
|
def subprocess_result(options={})
|
11
|
-
defaults = {exit_code: 0, stdout:
|
12
|
-
double(
|
29
|
+
defaults = {exit_code: 0, stdout: '', stderr: ''}
|
30
|
+
double('subprocess_result', defaults.merge(options))
|
13
31
|
end
|
14
32
|
|
15
33
|
before do
|
16
34
|
# we don't want unit tests to ever run commands on the system; so we wire
|
17
35
|
# in a double to ensure any unexpected messages raise exceptions
|
18
|
-
stub_const(
|
36
|
+
stub_const('Vagrant::Util::Subprocess', subprocess)
|
19
37
|
|
20
38
|
# drivers will blow up on instantiation if they cannot determine the
|
21
39
|
# Parallels Desktop version, so wire this stub in automatically
|
22
40
|
subprocess.stub(:execute).
|
23
|
-
with(
|
41
|
+
with('prlctl', '--version', an_instance_of(Hash)).
|
24
42
|
and_return(subprocess_result(stdout: "prlctl version #{parallels_version}.0.98765"))
|
25
43
|
|
26
44
|
# drivers also call vm_exists? during init;
|
27
45
|
subprocess.stub(:execute).
|
28
|
-
with(
|
46
|
+
with('prlctl', 'list', uuid, kind_of(Hash)).
|
29
47
|
and_return(subprocess_result(exit_code: 0))
|
48
|
+
|
49
|
+
# Returns detailed info about specified VM or all registered VMs
|
50
|
+
# `prlctl list <vm_uuid> --info --no-header --json`
|
51
|
+
# `prlctl list --all --info --no-header --json`
|
52
|
+
subprocess.stub(:execute).
|
53
|
+
with('prlctl', 'list', kind_of(String), '--info', '--no-header', '--json',
|
54
|
+
kind_of(Hash)) do
|
55
|
+
out = <<-eos
|
56
|
+
[
|
57
|
+
{
|
58
|
+
"ID": "#{uuid}",
|
59
|
+
"Name": "#{vm_name}",
|
60
|
+
"State": "stopped",
|
61
|
+
"Home": "/path/to/#{vm_name}.pvm/",
|
62
|
+
"GuestTools": {
|
63
|
+
"state": "#{tools_state}",
|
64
|
+
"version": "#{tools_version}"
|
65
|
+
},
|
66
|
+
"Hardware": {
|
67
|
+
"cpu": {
|
68
|
+
"cpus": 1
|
69
|
+
},
|
70
|
+
"memory": {
|
71
|
+
"size": "512Mb"
|
72
|
+
},
|
73
|
+
"hdd0": {
|
74
|
+
"enabled": true,
|
75
|
+
"image": "/path/to/disk1.hdd"
|
76
|
+
},
|
77
|
+
"net0": {
|
78
|
+
"enabled": true,
|
79
|
+
"type": "shared",
|
80
|
+
"mac": "001C42B4B074",
|
81
|
+
"card": "e1000",
|
82
|
+
"dhcp": "yes"
|
83
|
+
},
|
84
|
+
"net1": {
|
85
|
+
"enabled": true,
|
86
|
+
"type": "bridged",
|
87
|
+
"iface": "vnic2",
|
88
|
+
"mac": "001C42EC0068",
|
89
|
+
"card": "e1000",
|
90
|
+
"ips": "33.33.33.5/255.255.255.0 "
|
91
|
+
}
|
92
|
+
},
|
93
|
+
"Host Shared Folders": {
|
94
|
+
"enabled": true,
|
95
|
+
"shared_folder_1": {
|
96
|
+
"enabled": true,
|
97
|
+
"path": "/path/to/shared/folder/1"
|
98
|
+
},
|
99
|
+
"shared_folder_2": {
|
100
|
+
"enabled": true,
|
101
|
+
"path": "/path/to/shared/folder/2"
|
102
|
+
}
|
103
|
+
}
|
104
|
+
}
|
105
|
+
]
|
106
|
+
eos
|
107
|
+
subprocess_result(stdout: out)
|
108
|
+
end
|
109
|
+
|
110
|
+
# Returns detailed info about specified template or all registered templates
|
111
|
+
# `prlctl list <tpl_uuid> --info --json --no-header --template`
|
112
|
+
# `prlctl list --all --info --no-header --json --template`
|
113
|
+
subprocess.stub(:execute).
|
114
|
+
with('prlctl', 'list', kind_of(String), '--info', '--no-header', '--json',
|
115
|
+
'--template', kind_of(Hash)) do
|
116
|
+
out = <<-eos
|
117
|
+
[
|
118
|
+
{
|
119
|
+
"ID": "#{tpl_uuid}",
|
120
|
+
"Name": "#{tpl_name}",
|
121
|
+
"State": "stopped",
|
122
|
+
"Home": "/path/to/#{tpl_name}.pvm/",
|
123
|
+
"GuestTools": {
|
124
|
+
"state": "#{tools_state}",
|
125
|
+
"version": "#{tools_version}"
|
126
|
+
},
|
127
|
+
"Hardware": {
|
128
|
+
"cpu": {
|
129
|
+
"cpus": 1
|
130
|
+
},
|
131
|
+
"memory": {
|
132
|
+
"size": "512Mb"
|
133
|
+
},
|
134
|
+
"hdd0": {
|
135
|
+
"enabled": true,
|
136
|
+
"image": "/path/to/harddisk.hdd"
|
137
|
+
},
|
138
|
+
"net0": {
|
139
|
+
"enabled": true,
|
140
|
+
"type": "shared",
|
141
|
+
"mac": "001C42F6E500",
|
142
|
+
"card": "e1000",
|
143
|
+
"dhcp": "yes"
|
144
|
+
},
|
145
|
+
"net1": {
|
146
|
+
"enabled": true,
|
147
|
+
"type": "bridged",
|
148
|
+
"iface": "vnic4",
|
149
|
+
"mac": "001C42AB0071",
|
150
|
+
"card": "e1000",
|
151
|
+
"ips": "33.33.33.10/255.255.255.0 "
|
152
|
+
}
|
153
|
+
}
|
154
|
+
}
|
155
|
+
]
|
156
|
+
eos
|
157
|
+
subprocess_result(stdout: out)
|
158
|
+
end
|
159
|
+
|
160
|
+
# Returns detailed info about virtual network interface
|
161
|
+
# `prlsrvctl net info <net_name>, '--json'`
|
162
|
+
subprocess.stub(:execute).
|
163
|
+
with('prlsrvctl', 'net', 'info', kind_of(String), '--json',
|
164
|
+
kind_of(Hash)) do
|
165
|
+
out = <<-eos
|
166
|
+
{
|
167
|
+
"Network ID": "#{vnic_options[:name]}",
|
168
|
+
"Type": "host-only",
|
169
|
+
"Bound To": "#{hostonly_iface}",
|
170
|
+
"Parallels adapter": {
|
171
|
+
"IP address": "#{vnic_options[:adapter_ip]}",
|
172
|
+
"Subnet mask": "#{vnic_options[:netmask]}"
|
173
|
+
},
|
174
|
+
"DHCPv4 server": {
|
175
|
+
"Server address": "#{vnic_options[:dhcp][:ip] || '10.37.132.1'}",
|
176
|
+
"IP scope start address": "#{vnic_options[:dhcp][:lower] || '10.37.132.1'}",
|
177
|
+
"IP scope end address": "#{vnic_options[:dhcp][:upper] || '10.37.132.254'}"
|
178
|
+
}
|
179
|
+
}
|
180
|
+
eos
|
181
|
+
subprocess_result(stdout: out)
|
182
|
+
end
|
183
|
+
|
184
|
+
# Returns values of 'name' and 'uuid' options for all registered VMs
|
185
|
+
# `prlctl list --all --no-header --json -o name,uuid`
|
186
|
+
subprocess.stub(:execute).
|
187
|
+
with('prlctl', 'list', '--all', '--no-header', '--json', '-o', 'name,uuid',
|
188
|
+
kind_of(Hash)) do
|
189
|
+
out = <<-eos
|
190
|
+
[
|
191
|
+
{
|
192
|
+
"name": "#{vm_name}",
|
193
|
+
"uuid": "#{uuid}"
|
194
|
+
}
|
195
|
+
]
|
196
|
+
eos
|
197
|
+
subprocess_result(stdout: out)
|
198
|
+
end
|
199
|
+
|
200
|
+
# Returns values of 'name' and 'uuid' options for all registered templates
|
201
|
+
# `prlctl list --all --no-header --json -o name,uuid --template`
|
202
|
+
subprocess.stub(:execute).
|
203
|
+
with('prlctl', 'list', '--all', '--no-header', '--json', '-o', 'name,uuid',
|
204
|
+
'--template', kind_of(Hash)) do
|
205
|
+
out = <<-eos
|
206
|
+
[
|
207
|
+
{
|
208
|
+
"name": "#{tpl_name}",
|
209
|
+
"uuid": "#{tpl_uuid}"
|
210
|
+
}
|
211
|
+
]
|
212
|
+
eos
|
213
|
+
subprocess_result(stdout: out)
|
214
|
+
end
|
215
|
+
|
216
|
+
# Returns value of 'mac' options for the specified VM
|
217
|
+
# `prlctl list --all --no-header -o mac`
|
218
|
+
subprocess.stub(:execute).
|
219
|
+
with('prlctl', 'list', kind_of(String), '--no-header', '-o', 'mac',
|
220
|
+
kind_of(Hash)) do
|
221
|
+
subprocess_result(stdout: "001C42B4B074\n")
|
222
|
+
end
|
223
|
+
|
30
224
|
end
|
31
225
|
end
|