vagrant-haipa 0.2.2 → 0.3.1
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-haipa/action.rb +0 -2
- data/lib/vagrant-haipa/action/converge_machine.rb +7 -10
- data/lib/vagrant-haipa/driver.rb +38 -15
- data/lib/vagrant-haipa/version.rb +1 -1
- data/test/Vagrantfile +11 -10
- data/test/console.key +27 -27
- data/vagrant +27 -27
- data/vagrant-haipa.gemspec +1 -1
- metadata +4 -5
- data/lib/vagrant-haipa/action/set_name.rb +0 -50
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8eee5308a57ce3061bb3126c80df2f0ab35f40dd1453a45a36fe7daa9d13f1df
|
4
|
+
data.tar.gz: dc43555a1ac9e7ebf63dd10351bc768a4ff4cd865075a05cc72987b2e3c45b4e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 23555a3590f4d71b59e011444a7b568268e1f38ef7ea05d6d786b31028c492123c1b8b9f660926d931cce53bd696d724bf23d48cf3b621e02191c46c5d34235b
|
7
|
+
data.tar.gz: 746251a86a253fcaf627a6ff3981869a7528426f288bf7016aeb2daf03bf89244534bbebe2a0f0712399f41faee7965c5742e414ee353c6418dff4a3611d0f8f
|
data/lib/vagrant-haipa/action.rb
CHANGED
@@ -10,7 +10,6 @@ module VagrantPlugins
|
|
10
10
|
b.use Call, IsCreated do |env, b2|
|
11
11
|
|
12
12
|
if !env[:result]
|
13
|
-
b2.use SetName
|
14
13
|
b2.use ConvergeMachine
|
15
14
|
end
|
16
15
|
end
|
@@ -165,7 +164,6 @@ module VagrantPlugins
|
|
165
164
|
autoload :ReadState, action_root.join('read_state')
|
166
165
|
autoload :IsCreated, action_root.join('is_created')
|
167
166
|
autoload :IsRunning, action_root.join('is_running')
|
168
|
-
autoload :SetName, action_root.join('set_name')
|
169
167
|
autoload :ConvergeMachine, action_root.join('converge_machine')
|
170
168
|
autoload :DeleteMachine, action_root.join('delete_machine')
|
171
169
|
autoload :StartMachine, action_root.join('start_machine')
|
@@ -9,26 +9,23 @@ module VagrantPlugins
|
|
9
9
|
@logger = Log4r::Logger.new('vagrant::haipa::converge_machine')
|
10
10
|
end
|
11
11
|
|
12
|
-
def call(env)
|
12
|
+
def call(env)
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
name = haipa_machine.name
|
14
|
+
# terminate only if machine has been created by this action
|
15
|
+
if @machine.id.nil?
|
16
|
+
env[:converge_cleanup] = true
|
18
17
|
end
|
19
|
-
|
20
|
-
operation_result = @machine.provider.driver.converge(env
|
18
|
+
|
19
|
+
operation_result = @machine.provider.driver.converge(env)
|
21
20
|
@machine.id = operation_result.machine_guid if @machine.id.nil?
|
22
21
|
|
23
22
|
|
24
23
|
@app.call(env)
|
25
24
|
end
|
26
25
|
|
27
|
-
# Both the recover and terminate are stolen almost verbatim from
|
28
|
-
# the Vagrant AWS provider up action
|
29
26
|
def recover(env)
|
30
27
|
return if env['vagrant.error'].is_a?(Vagrant::Errors::VagrantError)
|
31
|
-
terminate(env) if @machine.state.id != :not_created
|
28
|
+
terminate(env) if @machine.state.id != :not_created && env[:converge_cleanup] == true
|
32
29
|
end
|
33
30
|
|
34
31
|
def terminate(env)
|
data/lib/vagrant-haipa/driver.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'haipa_compute'
|
2
|
+
require 'time'
|
2
3
|
|
3
4
|
module VagrantPlugins
|
4
5
|
module Haipa
|
@@ -9,6 +10,8 @@ module VagrantPlugins
|
|
9
10
|
|
10
11
|
def initialize(machine)
|
11
12
|
@machine = machine
|
13
|
+
@logger = Log4r::Logger.new('vagrant::haipa::driver')
|
14
|
+
|
12
15
|
end
|
13
16
|
|
14
17
|
# @return [::Haipa::Client::Compute::ApiConfiguration] Haipa Compute API
|
@@ -50,24 +53,31 @@ module VagrantPlugins
|
|
50
53
|
haipa_machine.status
|
51
54
|
end
|
52
55
|
|
53
|
-
def machine_by_name(name)
|
54
|
-
haipa_machine_list = compute_api.client.machines.list(:filter=>"name eq '#{name}'")
|
55
|
-
haipa_machine_list.value.first
|
56
|
-
end
|
57
|
-
|
58
56
|
def machine(expand = nil)
|
59
57
|
compute_api.client.machines.get(@machine.id, :expand => expand)
|
60
58
|
end
|
61
59
|
|
62
|
-
def
|
60
|
+
def machine_name
|
61
|
+
unless @machine.provider_config.name.nil?
|
62
|
+
@machine.provider_config.name
|
63
|
+
else
|
64
|
+
@machine.name
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def converge(env)
|
63
69
|
|
64
70
|
machine_config_hash = {
|
65
|
-
|
66
|
-
|
67
|
-
|
71
|
+
:name => machine_name,
|
72
|
+
:id => @machine.id,
|
73
|
+
:vm => @machine.provider_config.vm_config,
|
74
|
+
:provisioning => @machine.provider_config.provision
|
68
75
|
}
|
69
76
|
|
70
|
-
|
77
|
+
# this will convert all symbols to strings as required by deserialize
|
78
|
+
machine_config_string_hash = JSON.parse(machine_config_hash.to_json)
|
79
|
+
|
80
|
+
machine_config = compute_api.deserialize(:MachineConfig, machine_config_string_hash)
|
71
81
|
operation = compute_api.client.machines.update_or_create(:config => machine_config)
|
72
82
|
|
73
83
|
wait_for_operation(env,operation)
|
@@ -91,7 +101,7 @@ module VagrantPlugins
|
|
91
101
|
protected
|
92
102
|
|
93
103
|
def wait_for_operation(env,operation)
|
94
|
-
timestamp = '2018-09-01T23:47:17.50094+02:00'
|
104
|
+
timestamp = DateTime.parse('2018-09-01T23:47:17.50094+02:00')
|
95
105
|
|
96
106
|
operation_error = nil
|
97
107
|
|
@@ -114,13 +124,19 @@ module VagrantPlugins
|
|
114
124
|
next if env[:interrupted]
|
115
125
|
|
116
126
|
# check action status
|
117
|
-
result = compute_api.client.operations.get(operation.id, :expand => "LogEntries($filter=Timestamp gt #{timestamp})")
|
127
|
+
result = compute_api.client.operations.get(operation.id, :expand => "LogEntries($filter=Timestamp gt #{timestamp.iso8601})")
|
118
128
|
|
119
129
|
result.log_entries.each do |entry|
|
120
|
-
|
121
|
-
|
130
|
+
if timestamp < entry.timestamp
|
131
|
+
env[:ui].info(entry.message)
|
132
|
+
timestamp = entry.timestamp
|
133
|
+
|
134
|
+
# randomized delay for smoother output
|
135
|
+
delay = rand(4) * 0.2
|
136
|
+
sleep delay
|
137
|
+
end
|
122
138
|
end
|
123
|
-
|
139
|
+
|
124
140
|
yield result if block_given?
|
125
141
|
|
126
142
|
raise 'Operation not completed' if result.status == 'Running'
|
@@ -130,6 +146,13 @@ module VagrantPlugins
|
|
130
146
|
|
131
147
|
raise "Operation failed: #{result.status_message}" if result.status == 'Failed'
|
132
148
|
|
149
|
+
#write latest log entries
|
150
|
+
result = compute_api.client.operations.get(operation.id, :expand => "LogEntries($filter=Timestamp gt #{timestamp.iso8601})")
|
151
|
+
result.log_entries.each do |entry|
|
152
|
+
env[:ui].info(entry.message) if timestamp < entry.timestamp
|
153
|
+
timestamp = entry.timestamp if timestamp < entry.timestamp
|
154
|
+
end
|
155
|
+
|
133
156
|
#refresh operation result
|
134
157
|
compute_api.client.operations.get(operation.id)
|
135
158
|
end
|
data/test/Vagrantfile
CHANGED
@@ -2,9 +2,9 @@ REQUIRED_PLUGINS = %w(vagrant-haipa)
|
|
2
2
|
|
3
3
|
Vagrant.configure('2') do |config|
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
# config.ssh.username = 'ubuntu'
|
6
|
+
# config.ssh.password = 'ubuntu'
|
7
|
+
|
8
8
|
config.vm.synced_folder ".", "/vagrant", disabled: true
|
9
9
|
|
10
10
|
#config.vm.provision :shell, :path => 'scripts/provision.sh'
|
@@ -18,15 +18,15 @@ Vagrant.configure('2') do |config|
|
|
18
18
|
provider.client_key_file = 'console.key'
|
19
19
|
provider.identity_endpoint = 'https://localhost:62189/identity'
|
20
20
|
provider.api_endpoint = 'https://localhost:62189/api'
|
21
|
-
|
22
21
|
provider.vm_config = {
|
23
|
-
|
24
|
-
'startup' =>
|
22
|
+
'memory' => {
|
23
|
+
'startup' => 2096
|
25
24
|
},
|
26
|
-
'
|
25
|
+
'drives' => [
|
27
26
|
{
|
28
|
-
'
|
29
|
-
'
|
27
|
+
'name' => 'sda',
|
28
|
+
'template' => 'C:\Users\fwagner\.vagrant.d\boxes\bento-VAGRANTSLASH-ubuntu-16.04\201812.27.0\hyperv\Virtual Hard Disks\ubuntu-16.04-amd64.vhdx',
|
29
|
+
'size' => 40
|
30
30
|
}
|
31
31
|
],
|
32
32
|
'networkAdapters' => [
|
@@ -38,9 +38,10 @@ Vagrant.configure('2') do |config|
|
|
38
38
|
}
|
39
39
|
|
40
40
|
provider.provision = {
|
41
|
+
'method' => 'none',
|
41
42
|
'hostname' => 'basic',
|
42
43
|
'userData' => {
|
43
|
-
"package_upgrade":
|
44
|
+
"package_upgrade": false,
|
44
45
|
"chpasswd" => {
|
45
46
|
"expire": false
|
46
47
|
},
|
data/test/console.key
CHANGED
@@ -1,27 +1,27 @@
|
|
1
|
-
-----BEGIN RSA PRIVATE KEY-----
|
2
|
-
MIIEogIBAAKCAQEAw+q1IZy3iYRsjzZuitP4+2UYVY+AO/OZq5/O5erlseayss7g
|
3
|
-
zomY2NIg/kYKcrJkUZ04Y9RknWLHEw9iHGIxEMIChdaJTlM0IYgaVToWKZeWi2+h
|
4
|
-
yogPzAYziL/+fG0r6GnEvI7AHztsZUbZe7PcXL/NP0ZIamsMzXSAEt1Y8Fi50reV
|
5
|
-
XkNO9h60oI79crOIH+bcfgIpRYMkHcxrAFGBkfFMcIjup/G4GPEpKl7pbeTHm87u
|
6
|
-
3QwQivIlYCX/fkdmggLcWaOpA4GtkLOzWgjekIulj1pGymbCsdOd48Pnp/+zWttA
|
7
|
-
SxVLMq6egGXya/I8mQcAMBx4tm5HiMi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Q2+rE7bONY60PaB4Y6mAY9SMS9r2QAI8sipuwraj5l8=
|
27
|
+
-----END RSA PRIVATE KEY-----
|
data/vagrant
CHANGED
@@ -1,27 +1,27 @@
|
|
1
|
-
#!C:/Users/vagrant/AppData/Local/Temp/hecdnuu3.bee/embedded/mingw64/bin/ruby.exe
|
2
|
-
#
|
3
|
-
# This file was generated by RubyGems.
|
4
|
-
#
|
5
|
-
# The application 'vagrant' is installed as part of a gem, and
|
6
|
-
# this file is here to facilitate running it.
|
7
|
-
#
|
8
|
-
|
9
|
-
require 'rubygems'
|
10
|
-
|
11
|
-
version = ">= 0.a"
|
12
|
-
|
13
|
-
if ARGV.first
|
14
|
-
str = ARGV.first
|
15
|
-
str = str.dup.force_encoding("BINARY") if str.respond_to? :force_encoding
|
16
|
-
if str =~ /\A_(.*)_\z/ and Gem::Version.correct?($1) then
|
17
|
-
version = $1
|
18
|
-
ARGV.shift
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
if Gem.respond_to?(:activate_bin_path)
|
23
|
-
load Gem.activate_bin_path('vagrant', 'vagrant', version)
|
24
|
-
else
|
25
|
-
gem "vagrant", version
|
26
|
-
load Gem.bin_path("vagrant", "vagrant", version)
|
27
|
-
end
|
1
|
+
#!C:/Users/vagrant/AppData/Local/Temp/hecdnuu3.bee/embedded/mingw64/bin/ruby.exe
|
2
|
+
#
|
3
|
+
# This file was generated by RubyGems.
|
4
|
+
#
|
5
|
+
# The application 'vagrant' is installed as part of a gem, and
|
6
|
+
# this file is here to facilitate running it.
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'rubygems'
|
10
|
+
|
11
|
+
version = ">= 0.a"
|
12
|
+
|
13
|
+
if ARGV.first
|
14
|
+
str = ARGV.first
|
15
|
+
str = str.dup.force_encoding("BINARY") if str.respond_to? :force_encoding
|
16
|
+
if str =~ /\A_(.*)_\z/ and Gem::Version.correct?($1) then
|
17
|
+
version = $1
|
18
|
+
ARGV.shift
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
if Gem.respond_to?(:activate_bin_path)
|
23
|
+
load Gem.activate_bin_path('vagrant', 'vagrant', version)
|
24
|
+
else
|
25
|
+
gem "vagrant", version
|
26
|
+
load Gem.bin_path("vagrant", "vagrant", version)
|
27
|
+
end
|
data/vagrant-haipa.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-haipa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Haipa contributors
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-09-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: log4r
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.
|
33
|
+
version: 0.2.2
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.
|
40
|
+
version: 0.2.2
|
41
41
|
description: Enables Vagrant to manage Hyper-V with Haipa
|
42
42
|
email:
|
43
43
|
- package-maintainers@haipa.io
|
@@ -63,7 +63,6 @@ files:
|
|
63
63
|
- lib/vagrant-haipa/action/message_not_created.rb
|
64
64
|
- lib/vagrant-haipa/action/message_will_not_destroy.rb
|
65
65
|
- lib/vagrant-haipa/action/read_state.rb
|
66
|
-
- lib/vagrant-haipa/action/set_name.rb
|
67
66
|
- lib/vagrant-haipa/action/start_machine.rb
|
68
67
|
- lib/vagrant-haipa/action/stop_machine.rb
|
69
68
|
- lib/vagrant-haipa/action/wait_for_ip_address.rb
|
@@ -1,50 +0,0 @@
|
|
1
|
-
require 'vagrant-haipa'
|
2
|
-
|
3
|
-
module VagrantPlugins
|
4
|
-
module Haipa
|
5
|
-
module Action
|
6
|
-
class SetName
|
7
|
-
def initialize(app, env)
|
8
|
-
@app = app
|
9
|
-
@machine = env[:machine]
|
10
|
-
@logger = Log4r::Logger.new('vagrant::haipa::set_name')
|
11
|
-
end
|
12
|
-
|
13
|
-
def call(env)
|
14
|
-
name = @machine.provider_config.name
|
15
|
-
|
16
|
-
# If we already set the name before, then don't do anything
|
17
|
-
sentinel = @machine.data_dir.join("action_set_name")
|
18
|
-
if !name && sentinel.file?
|
19
|
-
@logger.info("Default name was already set before, not doing it again.")
|
20
|
-
return @app.call(env)
|
21
|
-
end
|
22
|
-
|
23
|
-
# If no name was manually set, then use a default
|
24
|
-
if !name
|
25
|
-
prefix = "#{env[:root_path].basename.to_s}_#{@machine.name}"
|
26
|
-
prefix.gsub!(/[^-a-z0-9_]/i, "")
|
27
|
-
|
28
|
-
# milliseconds + random number suffix to allow for simultaneous
|
29
|
-
# `vagrant up` of the same box in different dirs
|
30
|
-
name = prefix + "_#{(Time.now.to_f * 1000.0).to_i}_#{rand(100000)}"
|
31
|
-
end
|
32
|
-
|
33
|
-
# Verify the name is not taken
|
34
|
-
haipa_machine = @machine.provider.driver.machine_by_name(name)
|
35
|
-
raise Vagrant::Errors::VMNameExists, name: name if haipa_machine
|
36
|
-
|
37
|
-
env[:generated_name] = name
|
38
|
-
# Create the sentinel
|
39
|
-
sentinel.open("w") do |f|
|
40
|
-
f.write(Time.now.to_i.to_s)
|
41
|
-
end
|
42
|
-
|
43
|
-
@app.call(env)
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
|