vagrant-proxmox 0.0.6 → 0.0.7
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/lib/vagrant-proxmox/action/select_node.rb +24 -16
- data/lib/vagrant-proxmox/config.rb +7 -0
- data/lib/vagrant-proxmox/errors.rb +4 -0
- data/lib/vagrant-proxmox/version.rb +1 -1
- data/locales/en.yml +1 -0
- data/spec/actions/select_node_spec.rb +35 -11
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2147dcafed88c358a388e15bff90b58f468b95ad
|
4
|
+
data.tar.gz: 60f3c2c0c6045353dec19188ddaa164fd1dc99d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 09c263224795ea1f5bb85e10f3795c83d5351a339fc5c998879540e817397c19c6bb323e38abda26b96f2b079f0f8d4a924e54f1a45dfeb7b7ffe10d25604dd7
|
7
|
+
data.tar.gz: 563fcab8eba3640b08477576d4a1d7cf7209ebd99d1ea6edc624a509ebd6d8dce149ea575d33fc0b33b24ca494b837cbfacc5cfbda87b7ff6c6fbd0d4dd5809d
|
@@ -1,23 +1,31 @@
|
|
1
1
|
module VagrantPlugins
|
2
|
-
|
3
|
-
|
2
|
+
module Proxmox
|
3
|
+
module Action
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
# This action reads the state of a Proxmox virtual machine and stores it
|
6
|
+
# in env[:machine_state_id].
|
7
|
+
class SelectNode < ProxmoxAction
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
9
|
+
def initialize app, env
|
10
|
+
@app = app
|
11
|
+
@logger = Log4r::Logger.new 'vagrant_proxmox::action::select_node'
|
12
|
+
end
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
14
|
+
def call env
|
15
|
+
if env[:machine].provider_config.selected_node != Config::UNSET_VALUE
|
16
|
+
if env[:proxmox_nodes].include?(env[:machine].provider_config.selected_node)
|
17
|
+
env[:proxmox_selected_node] = env[:machine].provider_config.selected_node
|
18
|
+
else
|
19
|
+
raise Errors::InvalidNodeError, node: env[:machine].provider_config.selected_node
|
20
|
+
end
|
21
|
+
else
|
22
|
+
env[:proxmox_selected_node] = env[:proxmox_nodes].sample
|
23
|
+
end
|
24
|
+
next_action env
|
25
|
+
end
|
18
26
|
|
19
|
-
|
27
|
+
end
|
20
28
|
|
21
|
-
|
22
|
-
|
29
|
+
end
|
30
|
+
end
|
23
31
|
end
|
@@ -7,6 +7,11 @@ module VagrantPlugins
|
|
7
7
|
# @return [String]
|
8
8
|
attr_accessor :endpoint
|
9
9
|
|
10
|
+
# The Proxmox preferred cluster node
|
11
|
+
#
|
12
|
+
# @return [String]
|
13
|
+
attr_accessor :selected_node
|
14
|
+
|
10
15
|
# The Proxmox user name
|
11
16
|
#
|
12
17
|
# @return [String]
|
@@ -94,6 +99,7 @@ module VagrantPlugins
|
|
94
99
|
|
95
100
|
def initialize
|
96
101
|
@endpoint = UNSET_VALUE
|
102
|
+
@selected_node = UNSET_VALUE
|
97
103
|
@user_name = UNSET_VALUE
|
98
104
|
@password = UNSET_VALUE
|
99
105
|
@vm_type = UNSET_VALUE
|
@@ -116,6 +122,7 @@ module VagrantPlugins
|
|
116
122
|
# This is the hook that is called to finalize the object before it is put into use.
|
117
123
|
def finalize!
|
118
124
|
@endpoint = nil if @endpoint == UNSET_VALUE
|
125
|
+
@selected_node = nil if @endpoint == UNSET_VALUE
|
119
126
|
@user_name = nil if @user_name == UNSET_VALUE
|
120
127
|
@password = nil if @password == UNSET_VALUE
|
121
128
|
@vm_type = nil if @vm_type == UNSET_VALUE
|
data/locales/en.yml
CHANGED
@@ -71,6 +71,7 @@ en:
|
|
71
71
|
no_qemu_iso_or_qemu_iso_file_specified_for_vm_type_qemu: "No qemu_iso or qemu_iso_file specified for vm_type=:qemu"
|
72
72
|
no_qemu_os_specified_for_vm_type_qemu: "No qemu_os specified for vm_type=:qemu"
|
73
73
|
no_qemu_disk_size_specified_for_vm_type_qemu: "No qemu_disk_size specified for vm_type=:qemu"
|
74
|
+
invalid_node_error: 'Invalid node specified: %{node}'
|
74
75
|
not_created: 'The virtual machine is not created on the server!'
|
75
76
|
rsync_folder: |-
|
76
77
|
Rsyncing folder: %{hostpath} => %{guestpath}
|
@@ -9,22 +9,46 @@ module VagrantPlugins::Proxmox
|
|
9
9
|
let(:connection) { Connection.new 'https://proxmox.example.com/api2/json' }
|
10
10
|
let(:env) { {machine: environment.machine(environment.primary_machine_name, :proxmox),
|
11
11
|
proxmox_connection: connection, proxmox_nodes: nodes} }
|
12
|
-
let(:nodes) { ['node1', 'node2'] }
|
12
|
+
let(:nodes) { ['node1', 'node2', 'selected_node'] }
|
13
13
|
|
14
14
|
subject(:action) { described_class.new(-> (_) {}, environment) }
|
15
15
|
|
16
16
|
describe '#call' do
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
18
|
+
it_behaves_like 'a proxmox action call'
|
19
|
+
|
20
|
+
context "when no selected_node is specified in the configuration" do
|
21
|
+
it 'randomly selects a node from the list of available nodes' do
|
22
|
+
expect(nodes).to receive(:sample).and_return 'node2'
|
23
|
+
action.call env
|
24
|
+
expect(env[:proxmox_selected_node]).to eq('node2')
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context "when a specific node is specified in the configuration" do
|
29
|
+
|
30
|
+
context "when this node is included in the nodes list" do
|
31
|
+
before do
|
32
|
+
env[:machine].provider_config.selected_node = 'selected_node'
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'selects the selected_node' do
|
36
|
+
expect(nodes).not_to receive(:sample)
|
37
|
+
action.call env
|
38
|
+
expect(env[:proxmox_selected_node]).to eq('selected_node')
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
context "when this node is not included in the nodes list" do
|
43
|
+
before do
|
44
|
+
env[:machine].provider_config.selected_node = 'invalid_node'
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'should raise an error' do
|
48
|
+
expect { action.call env }.to raise_error Errors::InvalidNodeError
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
28
52
|
|
29
53
|
end
|
30
54
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-proxmox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dirk Grappendorf
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2015-01-12 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rest-client
|