vagrant-hp 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -1,21 +1,21 @@
1
- require 'rubygems'
2
- require 'bundler/setup'
3
- require 'rspec/core/rake_task'
4
-
5
- # Immediately sync all stdout so that tools like buildbot can
6
- # immediately load in the output.
7
- $stdout.sync = true
8
- $stderr.sync = true
9
-
10
- # Change to the directory of this file.
11
- Dir.chdir(File.expand_path("../", __FILE__))
12
-
13
- # This installs the tasks that help with gem creation and
14
- # publishing.
15
- Bundler::GemHelper.install_tasks
16
-
17
- # Install the `spec` task so that we can run tests.
18
- RSpec::Core::RakeTask.new
19
-
20
- # Default task is to run the unit tests
21
- task :default => "spec"
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+ require 'rspec/core/rake_task'
4
+
5
+ # Immediately sync all stdout so that tools like buildbot can
6
+ # immediately load in the output.
7
+ $stdout.sync = true
8
+ $stderr.sync = true
9
+
10
+ # Change to the directory of this file.
11
+ Dir.chdir(File.expand_path("../", __FILE__))
12
+
13
+ # This installs the tasks that help with gem creation and
14
+ # publishing.
15
+ Bundler::GemHelper.install_tasks
16
+
17
+ # Install the `spec` task so that we can run tests.
18
+ RSpec::Core::RakeTask.new
19
+
20
+ # Default task is to run the unit tests
21
+ task :default => "spec"
@@ -1,13 +1,13 @@
1
- # Vagrant HP Example Box
2
-
3
- Vagrant providers each require a custom provider-specific box format.
4
- This folder shows the example contents of a box for the `hp` provider.
5
- To turn this into a box:
6
-
7
- ```
8
- $ tar cvzf hp.box ./metadata.json ./Vagrantfile
9
- ```
10
-
11
- This box works by using Vagrant's built-in Vagrantfile merging to setup
12
- defaults for HP. These defaults can easily be overwritten by higher-level
13
- Vagrantfiles (such as project root Vagrantfiles).
1
+ # Vagrant HP Example Box
2
+
3
+ Vagrant providers each require a custom provider-specific box format.
4
+ This folder shows the example contents of a box for the `hp` provider.
5
+ To turn this into a box:
6
+
7
+ ```
8
+ $ tar cvzf hp.box ./metadata.json ./Vagrantfile
9
+ ```
10
+
11
+ This box works by using Vagrant's built-in Vagrantfile merging to setup
12
+ defaults for HP. These defaults can easily be overwritten by higher-level
13
+ Vagrantfiles (such as project root Vagrantfiles).
@@ -1,7 +1,7 @@
1
- # -*- mode: ruby -*-
2
- # vi: set ft=ruby :
3
-
4
- Vagrant.configure("2") do |config|
5
- config.vm.provider :hp do |rs|
6
- end
7
- end
1
+ # -*- mode: ruby -*-
2
+ # vi: set ft=ruby :
3
+
4
+ Vagrant.configure("2") do |config|
5
+ config.vm.provider :hp do |rs|
6
+ end
7
+ end
@@ -1,3 +1,3 @@
1
- {
2
- "provider": "hp"
3
- }
1
+ {
2
+ "provider": "hp"
3
+ }
data/lib/vagrant-hp.rb CHANGED
@@ -1,18 +1,18 @@
1
- require "pathname"
2
-
3
- require "vagrant-hp/plugin"
4
-
5
- module VagrantPlugins
6
- module HP
7
- lib_path = Pathname.new(File.expand_path("../vagrant-hp", __FILE__))
8
- autoload :Action, lib_path.join("action")
9
- autoload :Errors, lib_path.join("errors")
10
-
11
- # This returns the path to the source of this plugin.
12
- #
13
- # @return [Pathname]
14
- def self.source_root
15
- @source_root ||= Pathname.new(File.expand_path("../../", __FILE__))
16
- end
17
- end
18
- end
1
+ require "pathname"
2
+
3
+ require "vagrant-hp/plugin"
4
+
5
+ module VagrantPlugins
6
+ module HP
7
+ lib_path = Pathname.new(File.expand_path("../vagrant-hp", __FILE__))
8
+ autoload :Action, lib_path.join("action")
9
+ autoload :Errors, lib_path.join("errors")
10
+
11
+ # This returns the path to the source of this plugin.
12
+ #
13
+ # @return [Pathname]
14
+ def self.source_root
15
+ @source_root ||= Pathname.new(File.expand_path("../../", __FILE__))
16
+ end
17
+ end
18
+ end
@@ -1,110 +1,110 @@
1
- #
2
- # Author:: Mohit Sethi (<mohit@sethis.in>)
3
- # Copyright:: Copyright (c) 2013 Mohit Sethi.
4
- #
5
-
6
- require "pathname"
7
- require "vagrant/action/builder"
8
-
9
- module VagrantPlugins
10
- module HP
11
- module Action
12
- # Include the built-in modules so we can use them as top-level things.
13
- include Vagrant::Action::Builtin
14
-
15
- # This action is called to terminate the remote machine.
16
- def self.action_destroy
17
- Vagrant::Action::Builder.new.tap do |b|
18
- b.use ConfigValidate
19
- b.use ConnectHP
20
- b.use DeleteServer
21
- end
22
- end
23
-
24
- # This action is called when `vagrant provision` is called.
25
- def self.action_provision
26
- Vagrant::Action::Builder.new.tap do |b|
27
- b.use ConfigValidate
28
- b.use Call, IsCreated do |env, b2|
29
- if !env[:result]
30
- b2.use MessageNotCreated
31
- next
32
- end
33
- b2.use SyncFolders
34
- b2.use Provision
35
- end
36
- end
37
- end
38
-
39
- # This action is called to read the SSH info of the machine. The
40
- # resulting state is expected to be put into the `:machine_ssh_info`
41
- # key.
42
- def self.action_read_ssh_info
43
- Vagrant::Action::Builder.new.tap do |b|
44
- b.use ConfigValidate
45
- b.use ConnectHP
46
- b.use ReadSSHInfo
47
- end
48
- end
49
-
50
- # This action is called to read the state of the machine. The
51
- # resulting state is expected to be put into the `:machine_state_id`
52
- # key.
53
- def self.action_read_state
54
- Vagrant::Action::Builder.new.tap do |b|
55
- b.use ConfigValidate
56
- b.use ConnectHP
57
- b.use ReadState
58
- end
59
- end
60
-
61
- # This action is called to SSH into the machine.
62
- def self.action_ssh
63
- Vagrant::Action::Builder.new.tap do |b|
64
- b.use ConfigValidate
65
- b.use Call, IsCreated do |env, b2|
66
- if !env[:result]
67
- b2.use MessageNotCreated
68
- next
69
- end
70
-
71
- b2.use SSHExec
72
- end
73
- end
74
- end
75
-
76
- def self.action_up
77
- Vagrant::Action::Builder.new.tap do |b|
78
- b.use ConfigValidate
79
- b.use Call, IsCreated do |env, b2|
80
- if env[:result]
81
- b2.use MessageAlreadyCreated
82
- next
83
- end
84
-
85
- b2.use ConnectHP
86
- b2.use Provision
87
- b2.use SyncFolders
88
- b2.use WarnNetworks
89
- b2.use CreateServer
90
- end
91
- end
92
- end
93
-
94
- # The autoload farm
95
- action_root = Pathname.new(File.expand_path("../action", __FILE__))
96
- autoload :ConnectHP, action_root.join("connect_hp")
97
- autoload :IsCreated, action_root.join("is_created")
98
- autoload :MessageAlreadyCreated, action_root.join("message_already_created")
99
- autoload :MessageNotCreated, action_root.join("message_not_created")
100
- autoload :ReadSSHInfo, action_root.join("read_ssh_info")
101
- autoload :ReadState, action_root.join("read_state")
102
- autoload :RunInstance, action_root.join("run_instance")
103
- autoload :SyncFolders, action_root.join("sync_folders")
104
- autoload :TimedProvision, action_root.join("timed_provision")
105
- autoload :WarnNetworks, action_root.join("warn_networks")
106
- autoload :CreateServer, action_root.join("create_server")
107
- autoload :DeleteServer, action_root.join("delete_server")
108
- end
109
- end
110
- end
1
+ #
2
+ # Author:: Mohit Sethi (<mohit@sethis.in>)
3
+ # Copyright:: Copyright (c) 2013 Mohit Sethi.
4
+ #
5
+
6
+ require "pathname"
7
+ require "vagrant/action/builder"
8
+
9
+ module VagrantPlugins
10
+ module HP
11
+ module Action
12
+ # Include the built-in modules so we can use them as top-level things.
13
+ include Vagrant::Action::Builtin
14
+
15
+ # This action is called to terminate the remote machine.
16
+ def self.action_destroy
17
+ Vagrant::Action::Builder.new.tap do |b|
18
+ b.use ConfigValidate
19
+ b.use ConnectHP
20
+ b.use DeleteServer
21
+ end
22
+ end
23
+
24
+ # This action is called when `vagrant provision` is called.
25
+ def self.action_provision
26
+ Vagrant::Action::Builder.new.tap do |b|
27
+ b.use ConfigValidate
28
+ b.use Call, IsCreated do |env, b2|
29
+ if !env[:result]
30
+ b2.use MessageNotCreated
31
+ next
32
+ end
33
+ b2.use SyncFolders
34
+ b2.use Provision
35
+ end
36
+ end
37
+ end
38
+
39
+ # This action is called to read the SSH info of the machine. The
40
+ # resulting state is expected to be put into the `:machine_ssh_info`
41
+ # key.
42
+ def self.action_read_ssh_info
43
+ Vagrant::Action::Builder.new.tap do |b|
44
+ b.use ConfigValidate
45
+ b.use ConnectHP
46
+ b.use ReadSSHInfo
47
+ end
48
+ end
49
+
50
+ # This action is called to read the state of the machine. The
51
+ # resulting state is expected to be put into the `:machine_state_id`
52
+ # key.
53
+ def self.action_read_state
54
+ Vagrant::Action::Builder.new.tap do |b|
55
+ b.use ConfigValidate
56
+ b.use ConnectHP
57
+ b.use ReadState
58
+ end
59
+ end
60
+
61
+ # This action is called to SSH into the machine.
62
+ def self.action_ssh
63
+ Vagrant::Action::Builder.new.tap do |b|
64
+ b.use ConfigValidate
65
+ b.use Call, IsCreated do |env, b2|
66
+ if !env[:result]
67
+ b2.use MessageNotCreated
68
+ next
69
+ end
70
+
71
+ b2.use SSHExec
72
+ end
73
+ end
74
+ end
75
+
76
+ def self.action_up
77
+ Vagrant::Action::Builder.new.tap do |b|
78
+ b.use ConfigValidate
79
+ b.use Call, IsCreated do |env, b2|
80
+ if env[:result]
81
+ b2.use MessageAlreadyCreated
82
+ next
83
+ end
84
+
85
+ b2.use ConnectHP
86
+ b2.use Provision
87
+ b2.use SyncFolders
88
+ b2.use WarnNetworks
89
+ b2.use CreateServer
90
+ end
91
+ end
92
+ end
93
+
94
+ # The autoload farm
95
+ action_root = Pathname.new(File.expand_path("../action", __FILE__))
96
+ autoload :ConnectHP, action_root.join("connect_hp")
97
+ autoload :IsCreated, action_root.join("is_created")
98
+ autoload :MessageAlreadyCreated, action_root.join("message_already_created")
99
+ autoload :MessageNotCreated, action_root.join("message_not_created")
100
+ autoload :ReadSSHInfo, action_root.join("read_ssh_info")
101
+ autoload :ReadState, action_root.join("read_state")
102
+ autoload :RunInstance, action_root.join("run_instance")
103
+ autoload :SyncFolders, action_root.join("sync_folders")
104
+ autoload :TimedProvision, action_root.join("timed_provision")
105
+ autoload :WarnNetworks, action_root.join("warn_networks")
106
+ autoload :CreateServer, action_root.join("create_server")
107
+ autoload :DeleteServer, action_root.join("delete_server")
108
+ end
109
+ end
110
+ end
@@ -1,54 +1,54 @@
1
- #
2
- # Author:: Mohit Sethi (<mohit@sethis.in>)
3
- # Copyright:: Copyright (c) 2013 Mohit Sethi.
4
- #
5
-
6
- require "fog"
7
- require "log4r"
8
-
9
- module VagrantPlugins
10
- module HP
11
- module Action
12
- # This action connects to HP, verifies credentials work, and
13
- # puts the HP connection object into the `:hp_compute` key
14
- # in the environment.
15
- class ConnectHP
16
- def initialize(app, env)
17
- @app = app
18
- @logger = Log4r::Logger.new("vagrant_hp::action::connect_hp")
19
- end
20
-
21
- def call(env)
22
- # Get the configs
23
- config = env[:machine].provider_config
24
- access_key = config.access_key
25
- secret_key = config.secret_key
26
- tenant_id = config.tenant_id
27
- availability_zone = availability_zone(config.availability_zone)
28
-
29
- @logger.info("Connecting to HP...")
30
- env[:hp_compute] = Fog::Compute.new({
31
- :provider => :hp,
32
- :hp_access_key => access_key,
33
- :hp_secret_key => secret_key,
34
- :hp_tenant_id => tenant_id,
35
- :hp_avl_zone => availability_zone,
36
- })
37
-
38
- @app.call(env)
39
- end
40
-
41
- def availability_zone(availability_zone)
42
- case availability_zone
43
- when 'az3'
44
- return 'az-3.region-a.geo-1'
45
- when 'az2'
46
- return 'az-2.region-a.geo-1'
47
- else
48
- return 'az-1.region-a.geo-1'
49
- end
50
- end
51
- end
52
- end
53
- end
54
- end
1
+ #
2
+ # Author:: Mohit Sethi (<mohit@sethis.in>)
3
+ # Copyright:: Copyright (c) 2013 Mohit Sethi.
4
+ #
5
+
6
+ require "fog/hp"
7
+ require "log4r"
8
+
9
+ module VagrantPlugins
10
+ module HP
11
+ module Action
12
+ # This action connects to HP, verifies credentials work, and
13
+ # puts the HP connection object into the `:hp_compute` key
14
+ # in the environment.
15
+ class ConnectHP
16
+ def initialize(app, env)
17
+ @app = app
18
+ @logger = Log4r::Logger.new("vagrant_hp::action::connect_hp")
19
+ end
20
+
21
+ def call(env)
22
+ # Get the configs
23
+ config = env[:machine].provider_config
24
+ access_key = config.access_key
25
+ secret_key = config.secret_key
26
+ tenant_id = config.tenant_id
27
+ availability_zone = availability_zone(config.availability_zone)
28
+
29
+ @logger.info("Connecting to HP...")
30
+ env[:hp_compute] = Fog::Compute.new({
31
+ :provider => :hp,
32
+ :hp_access_key => access_key,
33
+ :hp_secret_key => secret_key,
34
+ :hp_tenant_id => tenant_id,
35
+ :hp_avl_zone => availability_zone,
36
+ })
37
+
38
+ @app.call(env)
39
+ end
40
+
41
+ def availability_zone(availability_zone)
42
+ case availability_zone
43
+ when 'az3'
44
+ return 'az-3.region-a.geo-1'
45
+ when 'az2'
46
+ return 'az-2.region-a.geo-1'
47
+ else
48
+ return 'az-1.region-a.geo-1'
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end