vagrant-parallels 0.2.1 → 0.2.2.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +21 -13
- data/.travis.yml +1 -0
- data/README.md +43 -54
- data/config/i18n-tasks.yml.erb +1 -1
- data/debug.log +941 -0
- data/lib/vagrant-parallels/action.rb +0 -7
- data/lib/vagrant-parallels/action/check_accessible.rb +1 -1
- data/lib/vagrant-parallels/action/check_guest_tools.rb +10 -2
- data/lib/vagrant-parallels/action/clear_network_interfaces.rb +1 -1
- data/lib/vagrant-parallels/action/customize.rb +6 -4
- data/lib/vagrant-parallels/action/export.rb +56 -12
- data/lib/vagrant-parallels/action/import.rb +49 -30
- data/lib/vagrant-parallels/action/network.rb +137 -48
- data/lib/vagrant-parallels/action/package_config_files.rb +0 -12
- data/lib/vagrant-parallels/action/prepare_nfs_valid_ids.rb +1 -1
- data/lib/vagrant-parallels/action/set_name.rb +2 -2
- data/lib/vagrant-parallels/config.rb +11 -2
- data/lib/vagrant-parallels/driver/base.rb +281 -0
- data/lib/vagrant-parallels/driver/meta.rb +138 -0
- data/lib/vagrant-parallels/driver/{prl_ctl.rb → pd_8.rb} +116 -256
- data/lib/vagrant-parallels/driver/pd_9.rb +417 -0
- data/lib/vagrant-parallels/errors.rb +15 -7
- data/lib/vagrant-parallels/plugin.rb +7 -7
- data/lib/vagrant-parallels/provider.rb +33 -3
- data/lib/vagrant-parallels/version.rb +1 -1
- data/locales/en.yml +30 -16
- data/test/unit/base.rb +1 -5
- data/test/unit/config_test.rb +13 -2
- data/test/unit/driver/pd_8_test.rb +196 -0
- data/test/unit/driver/pd_9_test.rb +196 -0
- data/test/unit/locales/locales_test.rb +1 -1
- data/test/unit/support/shared/parallels_context.rb +2 -2
- data/test/unit/support/shared/pd_driver_examples.rb +243 -0
- data/test/unit/synced_folder_test.rb +37 -0
- data/vagrant-parallels.gemspec +5 -5
- metadata +39 -32
- data/lib/vagrant-parallels/action/match_mac_address.rb +0 -28
- data/lib/vagrant-parallels/action/register_template.rb +0 -24
- data/lib/vagrant-parallels/action/unregister_template.rb +0 -26
- data/test/support/isolated_environment.rb +0 -46
- data/test/support/tempdir.rb +0 -43
- data/test/unit/driver/prl_ctl_test.rb +0 -148
@@ -47,14 +47,14 @@ module VagrantPlugins
|
|
47
47
|
|
48
48
|
end
|
49
49
|
|
50
|
-
|
51
|
-
autoload :PrlCtl, File.expand_path("../driver/prl_ctl", __FILE__)
|
52
|
-
end
|
50
|
+
autoload :Action, File.expand_path("../action", __FILE__)
|
53
51
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
52
|
+
# Drop some autoloads in here to optimize the performance of loading
|
53
|
+
# our drivers only when they are needed.
|
54
|
+
module Driver
|
55
|
+
autoload :Meta, File.expand_path("../driver/meta", __FILE__)
|
56
|
+
autoload :PD_8, File.expand_path("../driver/pd_8", __FILE__)
|
57
|
+
autoload :PD_9, File.expand_path("../driver/pd_9", __FILE__)
|
58
58
|
end
|
59
59
|
end
|
60
60
|
end
|
@@ -9,7 +9,14 @@ module VagrantPlugins
|
|
9
9
|
def initialize(machine)
|
10
10
|
@logger = Log4r::Logger.new("vagrant::provider::parallels")
|
11
11
|
@machine = machine
|
12
|
-
|
12
|
+
|
13
|
+
if !Vagrant::Util::Platform.darwin?
|
14
|
+
raise Errors::MacOSXRequired
|
15
|
+
end
|
16
|
+
|
17
|
+
# This method will load in our driver, so we call it now to
|
18
|
+
# initialize it.
|
19
|
+
machine_id_changed
|
13
20
|
end
|
14
21
|
|
15
22
|
# @see Vagrant::Plugin::V2::Provider#action
|
@@ -22,15 +29,38 @@ module VagrantPlugins
|
|
22
29
|
nil
|
23
30
|
end
|
24
31
|
|
32
|
+
# If the machine ID changed, then we need to rebuild our underlying
|
33
|
+
# driver.
|
34
|
+
def machine_id_changed
|
35
|
+
id = @machine.id
|
36
|
+
|
37
|
+
begin
|
38
|
+
@logger.debug("Instantiating the driver for machine ID: #{@machine.id.inspect}")
|
39
|
+
@driver = VagrantPlugins::Parallels::Driver::Meta.new(id)
|
40
|
+
rescue VagrantPlugins::Parallels::Driver::Meta::VMNotFound
|
41
|
+
# The virtual machine doesn't exist, so we probably have a stale
|
42
|
+
# ID. Just clear the id out of the machine and reload it.
|
43
|
+
@logger.debug("VM not found! Clearing saved machine ID and reloading.")
|
44
|
+
id = nil
|
45
|
+
retry
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
25
49
|
# Returns the SSH info for accessing the Parallels VM.
|
26
50
|
def ssh_info
|
27
51
|
# If the VM is not created then we cannot possibly SSH into it, so
|
28
52
|
# we return nil.
|
29
53
|
return nil if state.id == :not_created
|
30
54
|
|
55
|
+
detected_ip = @machine.config.ssh.host || @driver.read_ip_dhcp
|
56
|
+
|
57
|
+
# If ip couldn't be detected then we cannot possibly SSH into it,
|
58
|
+
# and should return nil too.
|
59
|
+
return nil if detected_ip.nil?
|
60
|
+
|
31
61
|
# Return ip from running machine, use ip from config if available
|
32
62
|
return {
|
33
|
-
:host =>
|
63
|
+
:host => detected_ip,
|
34
64
|
:port => @driver.ssh_port(@machine.config.ssh.guest_port)
|
35
65
|
}
|
36
66
|
end
|
@@ -65,4 +95,4 @@ module VagrantPlugins
|
|
65
95
|
end
|
66
96
|
end
|
67
97
|
end
|
68
|
-
end
|
98
|
+
end
|
data/locales/en.yml
CHANGED
@@ -1,9 +1,16 @@
|
|
1
1
|
en:
|
2
2
|
vagrant_parallels:
|
3
|
+
parallels:
|
4
|
+
checking_guest_tools: |-
|
5
|
+
Checking for Parallels Tools installed on the VM...
|
6
|
+
network_adapter: |-
|
7
|
+
Adapter %{adapter}: %{type}%{extra}
|
3
8
|
#-------------------------------------------------------------------------------
|
4
9
|
# Translations for exception classes
|
5
10
|
#-------------------------------------------------------------------------------
|
6
11
|
errors:
|
12
|
+
mac_os_x_required: |-
|
13
|
+
Parallels provider only works on OS X (or Mac OS X).
|
7
14
|
prlctl_error: |-
|
8
15
|
There was an error while executing `prlctl`, a CLI used by Vagrant
|
9
16
|
for controlling Parallels Desktop. The command and stderr is shown below.
|
@@ -11,18 +18,15 @@ en:
|
|
11
18
|
Command: %{command}
|
12
19
|
|
13
20
|
Stderr: %{stderr}
|
14
|
-
prlctl_not_found_error: |-
|
15
|
-
The "prlctl" command or one of its dependencies could not
|
16
|
-
be found. Please verify Parallels Desktop is properly installed. You can verify
|
17
|
-
everything is okay by running "prlctl --version" and verifying
|
18
|
-
that the Parallels Desktop version is outputted.
|
19
|
-
parallels_kernel_module_not_loaded: |-
|
20
|
-
Parallels Desktop is complaining that the kernel module is not loaded. Please
|
21
|
-
run `prlctl --version` or open the Parallels Desktop GUI to see the error
|
22
|
-
message which should contain instructions on how to fix this error.
|
23
21
|
parallels_install_incomplete: |-
|
24
22
|
Parallels Desktop is complaining that the installation is incomplete.
|
25
23
|
Try to reinstall Parallels Desktop or contact Parallels support.
|
24
|
+
parallels_invalid_version: |-
|
25
|
+
Vagrant has detected that you have a version of Parallels Desktop installed
|
26
|
+
that is not supported. Please install or upgrade to one of the supported
|
27
|
+
versions listed below to use Vagrant:
|
28
|
+
|
29
|
+
%{supported_versions}
|
26
30
|
parallels_no_room_for_high_level_network: |-
|
27
31
|
There is no available slots on the Parallels Desktop VM for the configured
|
28
32
|
high-level network interfaces. "private_network" and "public_network"
|
@@ -30,6 +34,21 @@ en:
|
|
30
34
|
Parallels Desktop VM. Parallels Desktop limits the number of slots to 8, and it
|
31
35
|
appears that every slot is in use. Please lower the number of used
|
32
36
|
network adapters.
|
37
|
+
parallels_not_detected: |-
|
38
|
+
Vagrant could not detect Parallels Desktop! Make sure it is properly installed.
|
39
|
+
Vagrant uses the `prlctl` binary that ships with Parallels Desktop, and requires
|
40
|
+
this to be available on the PATH. If Parallels Desktop is installed, please find
|
41
|
+
the `prlctl` binary and add it to the PATH environmental variable.
|
42
|
+
vm_inaccessible: |-
|
43
|
+
Your VM has become "inaccessible." Unfortunately, this is a critical error
|
44
|
+
with Parallels Desktop that Vagrant can not cleanly recover from.
|
45
|
+
Please open VirtualBox and clear out your inaccessible virtual machines
|
46
|
+
or find a way to fix them.
|
47
|
+
vm_name_exists: |-
|
48
|
+
Parallels Desktop virtual machine with the name '%{name}' already exists.
|
49
|
+
Please use another name or delete the machine with the existing
|
50
|
+
name, and try again.
|
51
|
+
|
33
52
|
#-------------------------------------------------------------------------------
|
34
53
|
# Translations for config validation errors
|
35
54
|
#-------------------------------------------------------------------------------
|
@@ -69,7 +88,7 @@ en:
|
|
69
88
|
suspend the virtual machine. In either case, to restart it again,
|
70
89
|
simply run `vagrant up`.
|
71
90
|
#-------------------------------------------------------------------------------
|
72
|
-
# Translations for Vagrant middleware
|
91
|
+
# Translations for Vagrant middleware actions
|
73
92
|
#-------------------------------------------------------------------------------
|
74
93
|
actions:
|
75
94
|
vm:
|
@@ -92,9 +111,4 @@ en:
|
|
92
111
|
Parallels Tools Version: %{tools_version}
|
93
112
|
Parallels Desktop Version: %{parallels_version}
|
94
113
|
export:
|
95
|
-
compacting: Compacting exported
|
96
|
-
match_mac:
|
97
|
-
generate: |-
|
98
|
-
The specified base MAC is already in use. Generating a new unique MAC
|
99
|
-
address for Shared network...
|
100
|
-
matching: Matching MAC address for Shared network...
|
114
|
+
compacting: Compacting exported HDDs...
|
data/test/unit/base.rb
CHANGED
@@ -10,8 +10,8 @@ require 'vagrant-parallels'
|
|
10
10
|
$:.unshift File.expand_path("../../", __FILE__)
|
11
11
|
|
12
12
|
# Load in helpers
|
13
|
-
require "support/tempdir"
|
14
13
|
require "unit/support/shared/parallels_context"
|
14
|
+
require "unit/support/shared/pd_driver_examples"
|
15
15
|
|
16
16
|
# Do not buffer output
|
17
17
|
$stdout.sync = true
|
@@ -21,7 +21,3 @@ $stderr.sync = true
|
|
21
21
|
RSpec.configure do |c|
|
22
22
|
c.expect_with :rspec, :stdlib
|
23
23
|
end
|
24
|
-
|
25
|
-
# Configure VAGRANT_CWD so that the tests never find an actual
|
26
|
-
# Vagrantfile anywhere, or at least this minimizes those chances.
|
27
|
-
ENV["VAGRANT_CWD"] = Tempdir.new.path
|
data/test/unit/config_test.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require_relative "
|
1
|
+
require_relative "base"
|
2
2
|
|
3
3
|
require VagrantPlugins::Parallels.source_root.join('lib/vagrant-parallels/config')
|
4
4
|
|
@@ -7,9 +7,12 @@ describe VagrantPlugins::Parallels::Config do
|
|
7
7
|
context "defaults" do
|
8
8
|
before { subject.finalize! }
|
9
9
|
|
10
|
+
its(:check_guest_tools) { should be_true }
|
11
|
+
its(:name) { should be_nil }
|
12
|
+
|
10
13
|
it "should have one Shared adapter" do
|
11
14
|
expect(subject.network_adapters).to eql({
|
12
|
-
0 => [:shared,
|
15
|
+
0 => [:shared, {}],
|
13
16
|
})
|
14
17
|
end
|
15
18
|
end
|
@@ -27,4 +30,12 @@ describe VagrantPlugins::Parallels::Config do
|
|
27
30
|
expect(subject.customizations).to include(["pre-boot", ["set", :id, "--cpus", 4]])
|
28
31
|
end
|
29
32
|
end
|
33
|
+
|
34
|
+
describe "#network_adapter" do
|
35
|
+
it "configures additional adapters" do
|
36
|
+
subject.network_adapter(2, :bridged, auto_config: true)
|
37
|
+
expect(subject.network_adapters[2]).to eql(
|
38
|
+
[:bridged, auto_config: true])
|
39
|
+
end
|
40
|
+
end
|
30
41
|
end
|
@@ -0,0 +1,196 @@
|
|
1
|
+
require_relative "../base"
|
2
|
+
|
3
|
+
describe VagrantPlugins::Parallels::Driver::PD_8 do
|
4
|
+
include_context "parallels"
|
5
|
+
let(:parallels_version) { "8" }
|
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(:hostonly_iface) {'vnic10'}
|
13
|
+
|
14
|
+
let(:vnic_options) do {
|
15
|
+
:name => 'vagrant_vnic6',
|
16
|
+
:adapter_ip => '11.11.11.11',
|
17
|
+
:netmask => '255.255.252.0',
|
18
|
+
:dhcp => {
|
19
|
+
:ip => '11.11.11.11',
|
20
|
+
:lower => '11.11.8.1',
|
21
|
+
:upper => '11.11.11.254'
|
22
|
+
}
|
23
|
+
} end
|
24
|
+
|
25
|
+
subject { VagrantPlugins::Parallels::Driver::Meta.new(uuid) }
|
26
|
+
|
27
|
+
it_behaves_like "parallels desktop driver"
|
28
|
+
|
29
|
+
before do
|
30
|
+
# Returns short info about all registered VMs
|
31
|
+
# `prlctl list --all --json`
|
32
|
+
subprocess.stub(:execute).
|
33
|
+
with("prlctl", "list", "--all", "--json", kind_of(Hash)) do
|
34
|
+
out = <<-eos
|
35
|
+
INFO[
|
36
|
+
{
|
37
|
+
"uuid": "#{uuid}",
|
38
|
+
"status": "stopped",
|
39
|
+
"name": "#{vm_name}"
|
40
|
+
}
|
41
|
+
]
|
42
|
+
eos
|
43
|
+
subprocess_result(stdout: out)
|
44
|
+
end
|
45
|
+
|
46
|
+
# Returns short info about all registered templates
|
47
|
+
# `prlctl list --all --json --template`
|
48
|
+
subprocess.stub(:execute).
|
49
|
+
with("prlctl", "list", "--all", "--json", "--template", kind_of(Hash)) do
|
50
|
+
out = <<-eos
|
51
|
+
INFO[
|
52
|
+
{
|
53
|
+
"uuid": "1234-some-template-uuid-5678",
|
54
|
+
"name": "Some_Template_Name"
|
55
|
+
}
|
56
|
+
]
|
57
|
+
eos
|
58
|
+
subprocess_result(stdout: out)
|
59
|
+
end
|
60
|
+
|
61
|
+
|
62
|
+
# Returns detailed info about specified VM or all registered VMs
|
63
|
+
# `prlctl list <vm_uuid> --info --json`
|
64
|
+
# `prlctl list --all --info --json`
|
65
|
+
subprocess.stub(:execute).
|
66
|
+
with("prlctl", "list", kind_of(String), "--info", "--json",
|
67
|
+
kind_of(Hash)) do
|
68
|
+
out = <<-eos
|
69
|
+
INFO[
|
70
|
+
{
|
71
|
+
"ID": "#{uuid}",
|
72
|
+
"Name": "#{vm_name}",
|
73
|
+
"State": "stopped",
|
74
|
+
"Home": "/path/to/#{vm_name}.pvm/",
|
75
|
+
"GuestTools": {
|
76
|
+
"version": "8.0.18615"
|
77
|
+
},
|
78
|
+
"Hardware": {
|
79
|
+
"cpu": {
|
80
|
+
"cpus": 1
|
81
|
+
},
|
82
|
+
"memory": {
|
83
|
+
"size": "512Mb"
|
84
|
+
},
|
85
|
+
"hdd0": {
|
86
|
+
"enabled": true,
|
87
|
+
"image": "/path/to/disk1.hdd"
|
88
|
+
},
|
89
|
+
"net0": {
|
90
|
+
"enabled": true,
|
91
|
+
"type": "shared",
|
92
|
+
"mac": "001C42B4B074",
|
93
|
+
"card": "e1000",
|
94
|
+
"dhcp": "yes"
|
95
|
+
},
|
96
|
+
"net1": {
|
97
|
+
"enabled": true,
|
98
|
+
"type": "bridged",
|
99
|
+
"iface": "vnic2",
|
100
|
+
"mac": "001C42EC0068",
|
101
|
+
"card": "e1000",
|
102
|
+
"ips": "33.33.33.5/255.255.255.0 "
|
103
|
+
}
|
104
|
+
},
|
105
|
+
"Host Shared Folders": {
|
106
|
+
"enabled": true,
|
107
|
+
"shared_folder_1": {
|
108
|
+
"enabled": true,
|
109
|
+
"path": "/path/to/shared/folder/1"
|
110
|
+
},
|
111
|
+
"shared_folder_2": {
|
112
|
+
"enabled": true,
|
113
|
+
"path": "/path/to/shared/folder/2"
|
114
|
+
}
|
115
|
+
}
|
116
|
+
}
|
117
|
+
]
|
118
|
+
eos
|
119
|
+
subprocess_result(stdout: out)
|
120
|
+
end
|
121
|
+
|
122
|
+
# Returns detailed info about specified template or all registered templates
|
123
|
+
# `prlctl list <tpl_uuid> --info --json --template`
|
124
|
+
# `prlctl list --all --info --json --template`
|
125
|
+
subprocess.stub(:execute).
|
126
|
+
with("prlctl", "list", kind_of(String), "--info", "--json", "--template",
|
127
|
+
kind_of(Hash)) do
|
128
|
+
out = <<-eos
|
129
|
+
INFO[
|
130
|
+
{
|
131
|
+
"ID": "#{tpl_uuid}",
|
132
|
+
"Name": "#{tpl_name}",
|
133
|
+
"State": "stopped",
|
134
|
+
"Home": "/path/to/#{tpl_name}.pvm/",
|
135
|
+
"GuestTools": {
|
136
|
+
"version": "8.0.18615"
|
137
|
+
},
|
138
|
+
"Hardware": {
|
139
|
+
"cpu": {
|
140
|
+
"cpus": 1
|
141
|
+
},
|
142
|
+
"memory": {
|
143
|
+
"size": "512Mb"
|
144
|
+
},
|
145
|
+
"hdd0": {
|
146
|
+
"enabled": true,
|
147
|
+
"image": "/path/to/harddisk.hdd"
|
148
|
+
},
|
149
|
+
"net0": {
|
150
|
+
"enabled": true,
|
151
|
+
"type": "shared",
|
152
|
+
"mac": "001C42F6E500",
|
153
|
+
"card": "e1000",
|
154
|
+
"dhcp": "yes"
|
155
|
+
},
|
156
|
+
"net1": {
|
157
|
+
"enabled": true,
|
158
|
+
"type": "bridged",
|
159
|
+
"iface": "vnic4",
|
160
|
+
"mac": "001C42AB0071",
|
161
|
+
"card": "e1000",
|
162
|
+
"ips": "33.33.33.10/255.255.255.0 "
|
163
|
+
}
|
164
|
+
}
|
165
|
+
}
|
166
|
+
]
|
167
|
+
eos
|
168
|
+
subprocess_result(stdout: out)
|
169
|
+
end
|
170
|
+
|
171
|
+
# Returns detailed info about virtual network interface
|
172
|
+
# `prlsrvctl net info <net_name>, '--json', retryable: true)
|
173
|
+
subprocess.stub(:execute).
|
174
|
+
with("prlsrvctl", "net", "info", kind_of(String), "--json",
|
175
|
+
kind_of(Hash)) do
|
176
|
+
out = <<-eos
|
177
|
+
{
|
178
|
+
"Network ID": "#{vnic_options[:name]}",
|
179
|
+
"Type": "host-only",
|
180
|
+
"Bound To": "#{hostonly_iface}",
|
181
|
+
"Parallels adapter": {
|
182
|
+
"IP address": "#{vnic_options[:adapter_ip]}",
|
183
|
+
"Subnet mask": "#{vnic_options[:netmask]}"
|
184
|
+
},
|
185
|
+
"DHCPv4 server": {
|
186
|
+
"Server address": "#{vnic_options[:dhcp][:ip] || "10.37.132.1"}",
|
187
|
+
"IP scope start address": "#{vnic_options[:dhcp][:lower] || "10.37.132.1"}",
|
188
|
+
"IP scope end address": "#{vnic_options[:dhcp][:upper] || "10.37.132.254"}"
|
189
|
+
}
|
190
|
+
}
|
191
|
+
eos
|
192
|
+
subprocess_result(stdout: out)
|
193
|
+
end
|
194
|
+
|
195
|
+
end
|
196
|
+
end
|
@@ -0,0 +1,196 @@
|
|
1
|
+
require_relative "../base"
|
2
|
+
|
3
|
+
describe VagrantPlugins::Parallels::Driver::PD_9 do
|
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(:hostonly_iface) {'vnic10'}
|
13
|
+
|
14
|
+
let(:vnic_options) do {
|
15
|
+
:name => 'vagrant_vnic6',
|
16
|
+
:adapter_ip => '11.11.11.11',
|
17
|
+
:netmask => '255.255.252.0',
|
18
|
+
:dhcp => {
|
19
|
+
:ip => '11.11.11.11',
|
20
|
+
:lower => '11.11.8.1',
|
21
|
+
:upper => '11.11.11.254'
|
22
|
+
}
|
23
|
+
} end
|
24
|
+
|
25
|
+
subject { VagrantPlugins::Parallels::Driver::Meta.new(uuid) }
|
26
|
+
|
27
|
+
it_behaves_like "parallels desktop driver"
|
28
|
+
|
29
|
+
before do
|
30
|
+
# Returns short info about all registered VMs
|
31
|
+
# `prlctl list --all --json`
|
32
|
+
subprocess.stub(:execute).
|
33
|
+
with("prlctl", "list", "--all", "--json", kind_of(Hash)) do
|
34
|
+
out = <<-eos
|
35
|
+
[
|
36
|
+
{
|
37
|
+
"uuid": "#{uuid}",
|
38
|
+
"status": "stopped",
|
39
|
+
"name": "#{vm_name}"
|
40
|
+
}
|
41
|
+
]
|
42
|
+
eos
|
43
|
+
subprocess_result(stdout: out)
|
44
|
+
end
|
45
|
+
|
46
|
+
# Returns short info about all registered templates
|
47
|
+
# `prlctl list --all --json --template`
|
48
|
+
subprocess.stub(:execute).
|
49
|
+
with("prlctl", "list", "--all", "--json", "--template", kind_of(Hash)) do
|
50
|
+
out = <<-eos
|
51
|
+
[
|
52
|
+
{
|
53
|
+
"uuid": "1234-some-template-uuid-5678",
|
54
|
+
"name": "Some_Template_Name"
|
55
|
+
}
|
56
|
+
]
|
57
|
+
eos
|
58
|
+
subprocess_result(stdout: out)
|
59
|
+
end
|
60
|
+
|
61
|
+
|
62
|
+
# Returns detailed info about specified VM or all registered VMs
|
63
|
+
# `prlctl list <vm_uuid> --info --json`
|
64
|
+
# `prlctl list --all --info --json`
|
65
|
+
subprocess.stub(:execute).
|
66
|
+
with("prlctl", "list", kind_of(String), "--info", "--json",
|
67
|
+
kind_of(Hash)) do
|
68
|
+
out = <<-eos
|
69
|
+
[
|
70
|
+
{
|
71
|
+
"ID": "#{uuid}",
|
72
|
+
"Name": "#{vm_name}",
|
73
|
+
"State": "stopped",
|
74
|
+
"Home": "/path/to/#{vm_name}.pvm/",
|
75
|
+
"GuestTools": {
|
76
|
+
"version": "9.0.23062"
|
77
|
+
},
|
78
|
+
"Hardware": {
|
79
|
+
"cpu": {
|
80
|
+
"cpus": 1
|
81
|
+
},
|
82
|
+
"memory": {
|
83
|
+
"size": "512Mb"
|
84
|
+
},
|
85
|
+
"hdd0": {
|
86
|
+
"enabled": true,
|
87
|
+
"image": "/path/to/disk1.hdd"
|
88
|
+
},
|
89
|
+
"net0": {
|
90
|
+
"enabled": true,
|
91
|
+
"type": "shared",
|
92
|
+
"mac": "001C42B4B074",
|
93
|
+
"card": "e1000",
|
94
|
+
"dhcp": "yes"
|
95
|
+
},
|
96
|
+
"net1": {
|
97
|
+
"enabled": true,
|
98
|
+
"type": "bridged",
|
99
|
+
"iface": "vnic2",
|
100
|
+
"mac": "001C42EC0068",
|
101
|
+
"card": "e1000",
|
102
|
+
"ips": "33.33.33.5/255.255.255.0 "
|
103
|
+
}
|
104
|
+
},
|
105
|
+
"Host Shared Folders": {
|
106
|
+
"enabled": true,
|
107
|
+
"shared_folder_1": {
|
108
|
+
"enabled": true,
|
109
|
+
"path": "/path/to/shared/folder/1"
|
110
|
+
},
|
111
|
+
"shared_folder_2": {
|
112
|
+
"enabled": true,
|
113
|
+
"path": "/path/to/shared/folder/2"
|
114
|
+
}
|
115
|
+
}
|
116
|
+
}
|
117
|
+
]
|
118
|
+
eos
|
119
|
+
subprocess_result(stdout: out)
|
120
|
+
end
|
121
|
+
|
122
|
+
# Returns detailed info about specified template or all registered templates
|
123
|
+
# `prlctl list <tpl_uuid> --info --json --template`
|
124
|
+
# `prlctl list --all --info --json --template`
|
125
|
+
subprocess.stub(:execute).
|
126
|
+
with("prlctl", "list", kind_of(String), "--info", "--json", "--template",
|
127
|
+
kind_of(Hash)) do
|
128
|
+
out = <<-eos
|
129
|
+
[
|
130
|
+
{
|
131
|
+
"ID": "#{tpl_uuid}",
|
132
|
+
"Name": "#{tpl_name}",
|
133
|
+
"State": "stopped",
|
134
|
+
"Home": "/path/to/#{tpl_name}.pvm/",
|
135
|
+
"GuestTools": {
|
136
|
+
"version": "9.0.24172"
|
137
|
+
},
|
138
|
+
"Hardware": {
|
139
|
+
"cpu": {
|
140
|
+
"cpus": 1
|
141
|
+
},
|
142
|
+
"memory": {
|
143
|
+
"size": "512Mb"
|
144
|
+
},
|
145
|
+
"hdd0": {
|
146
|
+
"enabled": true,
|
147
|
+
"image": "/path/to/harddisk.hdd"
|
148
|
+
},
|
149
|
+
"net0": {
|
150
|
+
"enabled": true,
|
151
|
+
"type": "shared",
|
152
|
+
"mac": "001C42F6E500",
|
153
|
+
"card": "e1000",
|
154
|
+
"dhcp": "yes"
|
155
|
+
},
|
156
|
+
"net1": {
|
157
|
+
"enabled": true,
|
158
|
+
"type": "bridged",
|
159
|
+
"iface": "vnic4",
|
160
|
+
"mac": "001C42AB0071",
|
161
|
+
"card": "e1000",
|
162
|
+
"ips": "33.33.33.10/255.255.255.0 "
|
163
|
+
}
|
164
|
+
}
|
165
|
+
}
|
166
|
+
]
|
167
|
+
eos
|
168
|
+
subprocess_result(stdout: out)
|
169
|
+
end
|
170
|
+
|
171
|
+
# Returns detailed info about virtual network interface
|
172
|
+
# `prlsrvctl net info <net_name>, '--json', retryable: true)
|
173
|
+
subprocess.stub(:execute).
|
174
|
+
with("prlsrvctl", "net", "info", kind_of(String), "--json",
|
175
|
+
kind_of(Hash)) do
|
176
|
+
out = <<-eos
|
177
|
+
{
|
178
|
+
"Network ID": "#{vnic_options[:name]}",
|
179
|
+
"Type": "host-only",
|
180
|
+
"Bound To": "#{hostonly_iface}",
|
181
|
+
"Parallels adapter": {
|
182
|
+
"IP address": "#{vnic_options[:adapter_ip]}",
|
183
|
+
"Subnet mask": "#{vnic_options[:netmask]}"
|
184
|
+
},
|
185
|
+
"DHCPv4 server": {
|
186
|
+
"Server address": "#{vnic_options[:dhcp][:ip] || "10.37.132.1"}",
|
187
|
+
"IP scope start address": "#{vnic_options[:dhcp][:lower] || "10.37.132.1"}",
|
188
|
+
"IP scope end address": "#{vnic_options[:dhcp][:upper] || "10.37.132.254"}"
|
189
|
+
}
|
190
|
+
}
|
191
|
+
eos
|
192
|
+
subprocess_result(stdout: out)
|
193
|
+
end
|
194
|
+
|
195
|
+
end
|
196
|
+
end
|