vagrant-hp 0.1.0 → 0.1.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.
- data/.gitignore +59 -59
- data/CHANGELOG.md +6 -3
- data/Gemfile +10 -10
- data/LICENSE +9 -0
- data/README.md +172 -167
- data/Rakefile +21 -21
- data/example_box/README.md +13 -13
- data/example_box/Vagrantfile +7 -7
- data/example_box/metadata.json +3 -3
- data/lib/vagrant-hp.rb +18 -18
- data/lib/vagrant-hp/action.rb +110 -110
- data/lib/vagrant-hp/action/connect_hp.rb +54 -54
- data/lib/vagrant-hp/action/create_server.rb +124 -121
- data/lib/vagrant-hp/action/delete_server.rb +30 -30
- data/lib/vagrant-hp/action/halt_server.rb +30 -30
- data/lib/vagrant-hp/action/is_created.rb +23 -23
- data/lib/vagrant-hp/action/is_running.rb +23 -23
- data/lib/vagrant-hp/action/message_already_created.rb +21 -21
- data/lib/vagrant-hp/action/message_not_created.rb +21 -21
- data/lib/vagrant-hp/action/read_ssh_info.rb +51 -51
- data/lib/vagrant-hp/action/read_state.rb +43 -43
- data/lib/vagrant-hp/action/sync_folders.rb +63 -63
- data/lib/vagrant-hp/action/timed_provision.rb +27 -27
- data/lib/vagrant-hp/action/warn_networks.rb +24 -24
- data/lib/vagrant-hp/config.rb +159 -157
- data/lib/vagrant-hp/errors.rb +24 -24
- data/lib/vagrant-hp/plugin.rb +78 -78
- data/lib/vagrant-hp/provider.rb +55 -55
- data/lib/vagrant-hp/util/timer.rb +17 -17
- data/lib/vagrant-hp/version.rb +10 -10
- data/locales/en.yml +91 -91
- data/spec/vagrant-hp/config_spec.rb +42 -42
- data/vagrant-hp.gemspec +59 -59
- metadata +4 -3
@@ -1,121 +1,124 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Mohit Sethi (<mohit@sethis.in>)
|
3
|
-
# Copyright:: Copyright (c) 2013 Mohit Sethi.
|
4
|
-
#
|
5
|
-
|
6
|
-
require 'vagrant/util/retryable'
|
7
|
-
require "
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
module
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
@
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
env[:
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
env[:
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
env[:ui].info(
|
42
|
-
env[:ui].info(" --
|
43
|
-
env[:ui].info(" --
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
:
|
51
|
-
:
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
#
|
58
|
-
env[:
|
59
|
-
|
60
|
-
#
|
61
|
-
env[:
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
#
|
67
|
-
env[:
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
#
|
86
|
-
env[:ui].
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
end
|
1
|
+
#
|
2
|
+
# Author:: Mohit Sethi (<mohit@sethis.in>)
|
3
|
+
# Copyright:: Copyright (c) 2013 Mohit Sethi.
|
4
|
+
#
|
5
|
+
|
6
|
+
require 'vagrant/util/retryable'
|
7
|
+
require "log4r"
|
8
|
+
|
9
|
+
|
10
|
+
module VagrantPlugins
|
11
|
+
module HP
|
12
|
+
module Action
|
13
|
+
# This creates server on HP Cloud.
|
14
|
+
class CreateServer
|
15
|
+
include Vagrant::Util::Retryable
|
16
|
+
|
17
|
+
def initialize(app, env)
|
18
|
+
@app = app
|
19
|
+
@logger = Log4r::Logger.new("vagrant_hp::action::create_server")
|
20
|
+
end
|
21
|
+
|
22
|
+
def call(env)
|
23
|
+
# Get the configs
|
24
|
+
config = env[:machine].provider_config
|
25
|
+
|
26
|
+
# Find the flavor
|
27
|
+
env[:ui].info(I18n.t("vagrant_hp.finding_flavor"))
|
28
|
+
flavor = find_match(env[:hp_compute].flavors.all, config.flavor)
|
29
|
+
raise Errors::NoMatchingFlavor if !flavor
|
30
|
+
|
31
|
+
# Find the image
|
32
|
+
env[:ui].info(I18n.t("vagrant_hp.finding_image"))
|
33
|
+
image = find_match(env[:hp_compute].images, config.image)
|
34
|
+
raise Errors::NoMatchingImage if !image
|
35
|
+
|
36
|
+
# Figure out the name for the server
|
37
|
+
server_name = config.server_name || env[:machine].name if env[:machine].name != "default" || get_server_name()
|
38
|
+
|
39
|
+
# Output the settings we're going to use to the user
|
40
|
+
env[:ui].info(I18n.t("vagrant_hp.launching_server"))
|
41
|
+
env[:ui].info(" -- Flavor: #{flavor.name}")
|
42
|
+
env[:ui].info(" -- Image: #{image.name}")
|
43
|
+
env[:ui].info(" -- Name: #{server_name}")
|
44
|
+
if config.security_groups
|
45
|
+
env[:ui].info(" -- Security Groups: #{config.security_groups}")
|
46
|
+
end
|
47
|
+
|
48
|
+
# Build the options for launching...
|
49
|
+
options = {
|
50
|
+
:flavor_id => flavor.id,
|
51
|
+
:image_id => image.id,
|
52
|
+
:name => server_name,
|
53
|
+
:key_name => config.keypair_name,
|
54
|
+
:security_groups => config.security_groups
|
55
|
+
}
|
56
|
+
|
57
|
+
# Create the server
|
58
|
+
server = env[:hp_compute].servers.create(options)
|
59
|
+
|
60
|
+
# Store the ID right away so we can track it
|
61
|
+
env[:machine].id = server.id
|
62
|
+
|
63
|
+
# Wait for the server to finish building
|
64
|
+
env[:ui].info(I18n.t("vagrant_hp.waiting_for_build"))
|
65
|
+
retryable(:on => Timeout::Error, :tries => 200) do
|
66
|
+
# If we're interrupted don't worry about waiting
|
67
|
+
next if env[:interrupted]
|
68
|
+
|
69
|
+
# Set the progress
|
70
|
+
env[:ui].clear_line
|
71
|
+
env[:ui].report_progress(server.progress, 100, false)
|
72
|
+
|
73
|
+
# Wait for the server to be ready
|
74
|
+
begin
|
75
|
+
server.wait_for(15) { ready? }
|
76
|
+
rescue RuntimeError, Fog::Errors::TimeoutError => e
|
77
|
+
# If we don't have an error about a state transition, then
|
78
|
+
# we just move on.
|
79
|
+
#raise if e.message !~ /should have transitioned/
|
80
|
+
env[:ui].info("Error: #{e.message}")
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
if !env[:interrupted]
|
85
|
+
# Clear the line one more time so the progress is removed
|
86
|
+
env[:ui].clear_line
|
87
|
+
|
88
|
+
# Wait for SSH to become available
|
89
|
+
env[:ui].info(I18n.t("vagrant_hp.waiting_for_ssh"))
|
90
|
+
while true
|
91
|
+
begin
|
92
|
+
# If we're interrupted then just back out
|
93
|
+
break if env[:interrupted]
|
94
|
+
break if env[:machine].communicate.ready?
|
95
|
+
rescue Errno::ENETUNREACH
|
96
|
+
end
|
97
|
+
sleep 2
|
98
|
+
end
|
99
|
+
|
100
|
+
env[:ui].info(I18n.t("vagrant_hp.ready"))
|
101
|
+
end
|
102
|
+
|
103
|
+
@app.call(env)
|
104
|
+
end
|
105
|
+
|
106
|
+
protected
|
107
|
+
|
108
|
+
# generate a random name if server_name is empty
|
109
|
+
def get_server_name()
|
110
|
+
server_name = "vagrant_hp-#{rand.to_s.split('.')[1]}"
|
111
|
+
server_name.to_s
|
112
|
+
end
|
113
|
+
|
114
|
+
def find_match(collection, name)
|
115
|
+
collection.each do |single|
|
116
|
+
return single if single.id == name
|
117
|
+
return single if single.name == name
|
118
|
+
end
|
119
|
+
nil
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
@@ -1,30 +1,30 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Mohit Sethi (<mohit@sethis.in>)
|
3
|
-
# Copyright:: Copyright (c) 2013 Mohit Sethi.
|
4
|
-
#
|
5
|
-
|
6
|
-
require "log4r"
|
7
|
-
|
8
|
-
module VagrantPlugins
|
9
|
-
module HP
|
10
|
-
module Action
|
11
|
-
# This deletes the running server, if there is one.
|
12
|
-
class DeleteServer
|
13
|
-
def initialize(app, env)
|
14
|
-
@app = app
|
15
|
-
@logger = Log4r::Logger.new("vagrant_hp::action::delete_server")
|
16
|
-
end
|
17
|
-
|
18
|
-
def call(env)
|
19
|
-
if env[:machine].id
|
20
|
-
@logger.info(I18n.t("vagrant_hp.deleting_server"))
|
21
|
-
server = env[:hp_compute].servers.get(env[:machine].id)
|
22
|
-
server.destroy
|
23
|
-
env[:machine].id = nil
|
24
|
-
end
|
25
|
-
@app.call(env)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
1
|
+
#
|
2
|
+
# Author:: Mohit Sethi (<mohit@sethis.in>)
|
3
|
+
# Copyright:: Copyright (c) 2013 Mohit Sethi.
|
4
|
+
#
|
5
|
+
|
6
|
+
require "log4r"
|
7
|
+
|
8
|
+
module VagrantPlugins
|
9
|
+
module HP
|
10
|
+
module Action
|
11
|
+
# This deletes the running server, if there is one.
|
12
|
+
class DeleteServer
|
13
|
+
def initialize(app, env)
|
14
|
+
@app = app
|
15
|
+
@logger = Log4r::Logger.new("vagrant_hp::action::delete_server")
|
16
|
+
end
|
17
|
+
|
18
|
+
def call(env)
|
19
|
+
if env[:machine].id
|
20
|
+
@logger.info(I18n.t("vagrant_hp.deleting_server"))
|
21
|
+
server = env[:hp_compute].servers.get(env[:machine].id)
|
22
|
+
server.destroy
|
23
|
+
env[:machine].id = nil
|
24
|
+
end
|
25
|
+
@app.call(env)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -1,30 +1,30 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Mohit Sethi (<mohit@sethis.in>)
|
3
|
-
# Copyright:: Copyright (c) 2013 Mohit Sethi.
|
4
|
-
#
|
5
|
-
|
6
|
-
require "log4r"
|
7
|
-
|
8
|
-
module VagrantPlugins
|
9
|
-
module HP
|
10
|
-
module Action
|
11
|
-
# This deletes the running server, if there is one.
|
12
|
-
class HaltServer
|
13
|
-
def initialize(app, env)
|
14
|
-
@app = app
|
15
|
-
@logger = Log4r::Logger.new("vagrant_hp::action::delete_server")
|
16
|
-
end
|
17
|
-
|
18
|
-
def call(env)
|
19
|
-
if env[:machine].id
|
20
|
-
@logger.info(I18n.t("vagrant_hp.deleting_server"))
|
21
|
-
server = env[:hp_compute].servers.get(env[:machine].id)
|
22
|
-
server.stop # verify this
|
23
|
-
env[:machine].id = nil
|
24
|
-
end
|
25
|
-
@app.call(env)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
1
|
+
#
|
2
|
+
# Author:: Mohit Sethi (<mohit@sethis.in>)
|
3
|
+
# Copyright:: Copyright (c) 2013 Mohit Sethi.
|
4
|
+
#
|
5
|
+
|
6
|
+
require "log4r"
|
7
|
+
|
8
|
+
module VagrantPlugins
|
9
|
+
module HP
|
10
|
+
module Action
|
11
|
+
# This deletes the running server, if there is one.
|
12
|
+
class HaltServer
|
13
|
+
def initialize(app, env)
|
14
|
+
@app = app
|
15
|
+
@logger = Log4r::Logger.new("vagrant_hp::action::delete_server")
|
16
|
+
end
|
17
|
+
|
18
|
+
def call(env)
|
19
|
+
if env[:machine].id
|
20
|
+
@logger.info(I18n.t("vagrant_hp.deleting_server"))
|
21
|
+
server = env[:hp_compute].servers.get(env[:machine].id)
|
22
|
+
server.stop # verify this
|
23
|
+
env[:machine].id = nil
|
24
|
+
end
|
25
|
+
@app.call(env)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -1,23 +1,23 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Mohit Sethi (<mohit@sethis.in>)
|
3
|
-
# Copyright:: Copyright (c) 2013 Mohit Sethi.
|
4
|
-
#
|
5
|
-
|
6
|
-
module VagrantPlugins
|
7
|
-
module HP
|
8
|
-
module Action
|
9
|
-
# This can be used with "Call" built-in to check if the machine
|
10
|
-
# is created and branch in the middleware.
|
11
|
-
class IsCreated
|
12
|
-
def initialize(app, env)
|
13
|
-
@app = app
|
14
|
-
end
|
15
|
-
|
16
|
-
def call(env)
|
17
|
-
env[:result] = env[:machine].state.id != :not_created
|
18
|
-
@app.call(env)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
1
|
+
#
|
2
|
+
# Author:: Mohit Sethi (<mohit@sethis.in>)
|
3
|
+
# Copyright:: Copyright (c) 2013 Mohit Sethi.
|
4
|
+
#
|
5
|
+
|
6
|
+
module VagrantPlugins
|
7
|
+
module HP
|
8
|
+
module Action
|
9
|
+
# This can be used with "Call" built-in to check if the machine
|
10
|
+
# is created and branch in the middleware.
|
11
|
+
class IsCreated
|
12
|
+
def initialize(app, env)
|
13
|
+
@app = app
|
14
|
+
end
|
15
|
+
|
16
|
+
def call(env)
|
17
|
+
env[:result] = env[:machine].state.id != :not_created
|
18
|
+
@app.call(env)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -1,23 +1,23 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Mohit Sethi (<mohit@sethis.in>)
|
3
|
-
# Copyright:: Copyright (c) 2013 Mohit Sethi.
|
4
|
-
#
|
5
|
-
|
6
|
-
module VagrantPlugins
|
7
|
-
module HP
|
8
|
-
module Action
|
9
|
-
# This can be used with "Call" built-in to check if the machine
|
10
|
-
# is created and branch in the middleware.
|
11
|
-
class IsRunning
|
12
|
-
def initialize(app, env)
|
13
|
-
@app = app
|
14
|
-
end
|
15
|
-
|
16
|
-
def call(env)
|
17
|
-
env[:result] = env[:machine].state.id != :running
|
18
|
-
@app.call(env)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
1
|
+
#
|
2
|
+
# Author:: Mohit Sethi (<mohit@sethis.in>)
|
3
|
+
# Copyright:: Copyright (c) 2013 Mohit Sethi.
|
4
|
+
#
|
5
|
+
|
6
|
+
module VagrantPlugins
|
7
|
+
module HP
|
8
|
+
module Action
|
9
|
+
# This can be used with "Call" built-in to check if the machine
|
10
|
+
# is created and branch in the middleware.
|
11
|
+
class IsRunning
|
12
|
+
def initialize(app, env)
|
13
|
+
@app = app
|
14
|
+
end
|
15
|
+
|
16
|
+
def call(env)
|
17
|
+
env[:result] = env[:machine].state.id != :running
|
18
|
+
@app.call(env)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|