vagrant-hp 0.1.2 → 0.1.3
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 +7 -0
- data/.coveragerc +4 -0
- data/.rubocop.yml +885 -0
- data/.travis.yml +4 -0
- data/CHANGELOG.md +4 -0
- data/CHANGELOG.md_ +13 -0
- data/Gemfile +3 -2
- data/README.md +7 -3
- data/Rakefile +3 -0
- data/Vagrantfile +28 -0
- data/lib/vagrant-hp.rb +6 -7
- data/lib/vagrant-hp/action.rb +18 -17
- data/lib/vagrant-hp/action/connect_hp.rb +15 -16
- data/lib/vagrant-hp/action/create_server.rb +28 -24
- data/lib/vagrant-hp/action/delete_server.rb +6 -3
- data/lib/vagrant-hp/action/halt_server.rb +3 -3
- data/lib/vagrant-hp/action/message_already_created.rb +1 -1
- data/lib/vagrant-hp/action/message_not_created.rb +1 -1
- data/lib/vagrant-hp/action/read_ssh_info.rb +10 -9
- data/lib/vagrant-hp/action/read_state.rb +6 -4
- data/lib/vagrant-hp/action/sync_folders.rb +17 -14
- data/lib/vagrant-hp/action/test.rb +22 -0
- data/lib/vagrant-hp/action/timed_provision.rb +4 -4
- data/lib/vagrant-hp/action/warn_networks.rb +1 -1
- data/lib/vagrant-hp/config.rb +19 -19
- data/lib/vagrant-hp/errors.rb +2 -2
- data/lib/vagrant-hp/plugin.rb +13 -13
- data/lib/vagrant-hp/provider.rb +6 -6
- data/lib/vagrant-hp/version.rb +1 -1
- data/locales/en.yml +4 -0
- data/spec/vagrant-hp/config_spec.rb +20 -18
- data/test.rb +49 -0
- data/test_address.rb +38 -0
- data/test_key.pem +27 -0
- data/vagrant-hp.gemspec +5 -4
- metadata +68 -62
data/.travis.yml
ADDED
data/CHANGELOG.md
CHANGED
data/CHANGELOG.md_
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# 0.1.3 (Jan 17 2014)
|
2
|
+
* Upgraded to fog 1.19.0
|
3
|
+
* Upgraded to HP-Compute-v13.5
|
4
|
+
|
5
|
+
# 0.1.2 (Oct 26 2013)
|
6
|
+
* Upgraded to fog 1.15.0
|
7
|
+
|
8
|
+
# 0.1.1 (May 22, 2013)
|
9
|
+
* Added support to specify security groups.
|
10
|
+
|
11
|
+
# 0.1.0 (March 31, 2013)
|
12
|
+
* Vagrant-Hp
|
13
|
+
* Initial release.
|
data/Gemfile
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
source
|
1
|
+
source 'https://rubygems.org'
|
2
2
|
|
3
3
|
gemspec
|
4
4
|
|
@@ -6,5 +6,6 @@ group :development do
|
|
6
6
|
# We depend on Vagrant for development, but we don't add it as a
|
7
7
|
# gem dependency because we expect to be installed within the
|
8
8
|
# Vagrant environment itself using `vagrant plugin`.
|
9
|
-
gem
|
9
|
+
gem 'vagrant', git: 'git://github.com/mohitsethi/vagrant.git'
|
10
|
+
gem 'coveralls', require: false
|
10
11
|
end
|
data/README.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# Vagrant HP Provider
|
2
2
|
|
3
|
+
[](http://badge.fury.io/rb/vagrant-hp) [](https://gemnasium.com/mohitsethi/vagrant-hp) [](https://codeclimate.com/github/mohitsethi/vagrant-hp) [](https://travis-ci.org/mohitsethi/vagrant-hp) [](https://coveralls.io/r/mohitsethi/vagrant-hp)
|
4
|
+
|
5
|
+
|
3
6
|
This is a [Vagrant](http://www.vagrantup.com) 1.1+ plugin that adds an [HP](http://www.hpcloud.com)
|
4
7
|
provider to Vagrant, allowing Vagrant to control and provision machines on HP Cloud.
|
5
8
|
|
@@ -8,6 +11,7 @@ provider to Vagrant, allowing Vagrant to control and provision machines on HP Cl
|
|
8
11
|
## Features
|
9
12
|
|
10
13
|
* Boot Servers on HP Cloud
|
14
|
+
* Auto Floating-IP management
|
11
15
|
* SSH into the instances.
|
12
16
|
* Provision the instances with any built-in Vagrant provisioner.
|
13
17
|
* Minimal synced folder support via `rsync`.
|
@@ -90,10 +94,10 @@ provider-specific configuration for this provider.
|
|
90
94
|
This provider exposes quite a few provider-specific configuration options:
|
91
95
|
|
92
96
|
* `access_key` - The access key for accessing HP Cloud
|
93
|
-
* `image` - The Image-id or Image-Name to boot, such as
|
97
|
+
* `image` - The Image-id or Image-Name to boot, such as
|
94
98
|
"Ubuntu Precise 12.04 LTS Server 64-bit 20121026 (b)"
|
95
|
-
* `availability_zone` - The availability zone to launch the server.
|
96
|
-
If nil, it will use '
|
99
|
+
* `availability_zone` - The availability zone to launch the server ['us-east', 'us-west'].
|
100
|
+
If nil, it will use 'us-west'.
|
97
101
|
* `flavor` - The type of flavor, such as "standard.xsmall"
|
98
102
|
* `keypair_name` - The name of the keypair to use to bootstrap image
|
99
103
|
which support it.
|
data/Rakefile
CHANGED
data/Vagrantfile
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# -*- mode: ruby -*-
|
2
|
+
# vi: set ft=ruby :
|
3
|
+
|
4
|
+
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
|
5
|
+
VAGRANTFILE_API_VERSION = "2"
|
6
|
+
|
7
|
+
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
8
|
+
# Every Vagrant virtual environment requires a box to build off of.
|
9
|
+
config.vm.box = "dummy"
|
10
|
+
config.vm.provider :hp do |rs|
|
11
|
+
rs.access_key = "Y5SKH1MU6HZ2PEM9ZNZL"
|
12
|
+
rs.secret_key = "YA2BJr98R3hDK7IwpIkHXlDCDo9GG+GIuqhflPqQ"
|
13
|
+
rs.flavor = "standard.xsmall"
|
14
|
+
rs.tenant_id = "87309806546461"
|
15
|
+
rs.server_name = "test_server"
|
16
|
+
#rs.image = "Ubuntu Precise 12.04 LTS Server 64-bit 20121026 (b)"
|
17
|
+
rs.image = "CentOS 6.3 Server 64-bit 20130116 (b)"
|
18
|
+
rs.keypair_name = "test_hp"
|
19
|
+
#rs.keypair_name = "ms"
|
20
|
+
rs.ssh_private_key_path = "./test_key.pem"
|
21
|
+
#rs.ssh_private_key_path = "~anne/.ssh/id_rsa"
|
22
|
+
rs.ssh_username = "root"
|
23
|
+
#rs.availability_zone = "az1"
|
24
|
+
# Security Groups defaults to ["default"]
|
25
|
+
# rs.security_groups = ["group1", "group2"]
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
data/lib/vagrant-hp.rb
CHANGED
@@ -1,18 +1,17 @@
|
|
1
|
-
require
|
2
|
-
|
3
|
-
require "vagrant-hp/plugin"
|
1
|
+
require 'pathname'
|
2
|
+
require 'vagrant-hp/plugin'
|
4
3
|
|
5
4
|
module VagrantPlugins
|
6
5
|
module HP
|
7
|
-
lib_path = Pathname.new(File.expand_path(
|
8
|
-
autoload :Action, lib_path.join(
|
9
|
-
autoload :Errors, lib_path.join(
|
6
|
+
lib_path = Pathname.new(File.expand_path('../vagrant-hp', __FILE__))
|
7
|
+
autoload :Action, lib_path.join('action')
|
8
|
+
autoload :Errors, lib_path.join('errors')
|
10
9
|
|
11
10
|
# This returns the path to the source of this plugin.
|
12
11
|
#
|
13
12
|
# @return [Pathname]
|
14
13
|
def self.source_root
|
15
|
-
@source_root ||= Pathname.new(File.expand_path(
|
14
|
+
@source_root ||= Pathname.new(File.expand_path('../../', __FILE__))
|
16
15
|
end
|
17
16
|
end
|
18
17
|
end
|
data/lib/vagrant-hp/action.rb
CHANGED
@@ -3,8 +3,8 @@
|
|
3
3
|
# Copyright:: Copyright (c) 2013 Mohit Sethi.
|
4
4
|
#
|
5
5
|
|
6
|
-
require
|
7
|
-
require
|
6
|
+
require 'pathname'
|
7
|
+
require 'vagrant/action/builder'
|
8
8
|
|
9
9
|
module VagrantPlugins
|
10
10
|
module HP
|
@@ -26,7 +26,7 @@ module VagrantPlugins
|
|
26
26
|
Vagrant::Action::Builder.new.tap do |b|
|
27
27
|
b.use ConfigValidate
|
28
28
|
b.use Call, IsCreated do |env, b2|
|
29
|
-
|
29
|
+
unless env[:result]
|
30
30
|
b2.use MessageNotCreated
|
31
31
|
next
|
32
32
|
end
|
@@ -63,7 +63,7 @@ module VagrantPlugins
|
|
63
63
|
Vagrant::Action::Builder.new.tap do |b|
|
64
64
|
b.use ConfigValidate
|
65
65
|
b.use Call, IsCreated do |env, b2|
|
66
|
-
|
66
|
+
unless env[:result]
|
67
67
|
b2.use MessageNotCreated
|
68
68
|
next
|
69
69
|
end
|
@@ -92,19 +92,20 @@ module VagrantPlugins
|
|
92
92
|
end
|
93
93
|
|
94
94
|
# The autoload farm
|
95
|
-
action_root = Pathname.new(File.expand_path(
|
96
|
-
autoload :ConnectHP, action_root.join(
|
97
|
-
autoload :IsCreated, action_root.join(
|
98
|
-
autoload :MessageAlreadyCreated, action_root.join(
|
99
|
-
|
100
|
-
autoload :
|
101
|
-
autoload :
|
102
|
-
autoload :
|
103
|
-
autoload :
|
104
|
-
autoload :
|
105
|
-
autoload :
|
106
|
-
autoload :
|
107
|
-
autoload :
|
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(
|
99
|
+
'message_already_created')
|
100
|
+
autoload :MessageNotCreated, action_root.join('message_not_created')
|
101
|
+
autoload :ReadSSHInfo, action_root.join('read_ssh_info')
|
102
|
+
autoload :ReadState, action_root.join('read_state')
|
103
|
+
autoload :RunInstance, action_root.join('run_instance')
|
104
|
+
autoload :SyncFolders, action_root.join('sync_folders')
|
105
|
+
autoload :TimedProvision, action_root.join('timed_provision')
|
106
|
+
autoload :WarnNetworks, action_root.join('warn_networks')
|
107
|
+
autoload :CreateServer, action_root.join('create_server')
|
108
|
+
autoload :DeleteServer, action_root.join('delete_server')
|
108
109
|
end
|
109
110
|
end
|
110
111
|
end
|
@@ -3,8 +3,8 @@
|
|
3
3
|
# Copyright:: Copyright (c) 2013 Mohit Sethi.
|
4
4
|
#
|
5
5
|
|
6
|
-
require
|
7
|
-
require
|
6
|
+
require 'fog/hp'
|
7
|
+
require 'log4r'
|
8
8
|
|
9
9
|
module VagrantPlugins
|
10
10
|
module HP
|
@@ -15,7 +15,7 @@ module VagrantPlugins
|
|
15
15
|
class ConnectHP
|
16
16
|
def initialize(app, env)
|
17
17
|
@app = app
|
18
|
-
@logger = Log4r::Logger.new(
|
18
|
+
@logger = Log4r::Logger.new('vagrant_hp::action::connect_hp')
|
19
19
|
end
|
20
20
|
|
21
21
|
def call(env)
|
@@ -26,26 +26,25 @@ module VagrantPlugins
|
|
26
26
|
tenant_id = config.tenant_id
|
27
27
|
availability_zone = availability_zone(config.availability_zone)
|
28
28
|
|
29
|
-
@logger.info(
|
30
|
-
env[:hp_compute] = Fog::Compute.new(
|
31
|
-
:
|
32
|
-
:
|
33
|
-
:
|
34
|
-
:
|
35
|
-
:
|
36
|
-
|
29
|
+
@logger.info('Connecting to HP...')
|
30
|
+
env[:hp_compute] = Fog::Compute.new(
|
31
|
+
provider: 'HP',
|
32
|
+
version: 'v2',
|
33
|
+
hp_access_key: access_key,
|
34
|
+
hp_secret_key: secret_key,
|
35
|
+
hp_tenant_id: tenant_id,
|
36
|
+
hp_avl_zone: availability_zone,
|
37
|
+
)
|
37
38
|
|
38
39
|
@app.call(env)
|
39
40
|
end
|
40
41
|
|
41
42
|
def availability_zone(availability_zone)
|
42
43
|
case availability_zone
|
43
|
-
when '
|
44
|
-
return '
|
45
|
-
when 'az2'
|
46
|
-
return 'az-2.region-a.geo-1'
|
44
|
+
when 'us-east'
|
45
|
+
return 'region-b.geo-1'
|
47
46
|
else
|
48
|
-
return '
|
47
|
+
return 'region-a.geo-1'
|
49
48
|
end
|
50
49
|
end
|
51
50
|
end
|
@@ -4,8 +4,7 @@
|
|
4
4
|
#
|
5
5
|
|
6
6
|
require 'vagrant/util/retryable'
|
7
|
-
require
|
8
|
-
|
7
|
+
require 'log4r'
|
9
8
|
|
10
9
|
module VagrantPlugins
|
11
10
|
module HP
|
@@ -16,7 +15,7 @@ module VagrantPlugins
|
|
16
15
|
|
17
16
|
def initialize(app, env)
|
18
17
|
@app = app
|
19
|
-
@logger = Log4r::Logger.new(
|
18
|
+
@logger = Log4r::Logger.new('vagrant_hp::action::create_server')
|
20
19
|
end
|
21
20
|
|
22
21
|
def call(env)
|
@@ -24,34 +23,36 @@ module VagrantPlugins
|
|
24
23
|
config = env[:machine].provider_config
|
25
24
|
|
26
25
|
# Find the flavor
|
27
|
-
env[:ui].info(I18n.t(
|
26
|
+
env[:ui].info(I18n.t('vagrant_hp.finding_flavor'))
|
28
27
|
flavor = find_match(env[:hp_compute].flavors.all, config.flavor)
|
29
|
-
raise Errors::NoMatchingFlavor
|
28
|
+
raise Errors::NoMatchingFlavor unless flavor
|
30
29
|
|
31
30
|
# Find the image
|
32
|
-
env[:ui].info(I18n.t(
|
31
|
+
env[:ui].info(I18n.t('vagrant_hp.finding_image'))
|
33
32
|
image = find_match(env[:hp_compute].images, config.image)
|
34
|
-
raise Errors::NoMatchingImage
|
33
|
+
raise Errors::NoMatchingImage unless image
|
35
34
|
|
36
35
|
# Figure out the name for the server
|
37
|
-
server_name = config.server_name || env[:machine].name if
|
36
|
+
server_name = config.server_name || env[:machine].name if \
|
37
|
+
env[:machine].name != 'default' || get_server_name
|
38
38
|
|
39
39
|
# Output the settings we're going to use to the user
|
40
|
-
env[:ui].info(I18n.t(
|
40
|
+
env[:ui].info(I18n.t('vagrant_hp.launching_server'))
|
41
41
|
env[:ui].info(" -- Flavor: #{flavor.name}")
|
42
42
|
env[:ui].info(" -- Image: #{image.name}")
|
43
43
|
env[:ui].info(" -- Name: #{server_name}")
|
44
|
-
|
44
|
+
env[:ui].info(" -- Key-name: #{config.keypair_name}")
|
45
|
+
if config.security_groups
|
45
46
|
env[:ui].info(" -- Security Groups: #{config.security_groups}")
|
46
47
|
end
|
47
48
|
|
48
49
|
# Build the options for launching...
|
49
50
|
options = {
|
50
|
-
:
|
51
|
-
:
|
52
|
-
:
|
53
|
-
:
|
54
|
-
|
51
|
+
flavor_id: flavor.id,
|
52
|
+
image_id: image.id,
|
53
|
+
name: server_name,
|
54
|
+
key_name: config.keypair_name,
|
55
|
+
security_groups: config.security_groups
|
55
56
|
}
|
56
57
|
|
57
58
|
# Create the server
|
@@ -61,8 +62,8 @@ module VagrantPlugins
|
|
61
62
|
env[:machine].id = server.id
|
62
63
|
|
63
64
|
# Wait for the server to finish building
|
64
|
-
env[:ui].info(I18n.t(
|
65
|
-
retryable(:
|
65
|
+
env[:ui].info(I18n.t('vagrant_hp.waiting_for_build'))
|
66
|
+
retryable(on: Timeout::Error, tries: 200) do
|
66
67
|
# If we're interrupted don't worry about waiting
|
67
68
|
next if env[:interrupted]
|
68
69
|
|
@@ -72,21 +73,24 @@ module VagrantPlugins
|
|
72
73
|
|
73
74
|
# Wait for the server to be ready
|
74
75
|
begin
|
75
|
-
server.wait_for(
|
76
|
+
server.wait_for(30) { ready? }
|
76
77
|
rescue RuntimeError, Fog::Errors::TimeoutError => e
|
77
78
|
# If we don't have an error about a state transition, then
|
78
79
|
# we just move on.
|
79
|
-
#raise if e.message !~ /should have transitioned/
|
80
|
+
# raise if e.message !~ /should have transitioned/
|
80
81
|
env[:ui].info("Error: #{e.message}")
|
81
82
|
end
|
82
83
|
end
|
83
|
-
|
84
|
-
|
84
|
+
env[:ui].clear_line
|
85
|
+
env[:ui].info(I18n.t('vagrant_hp.associate_floating_ip_to_server'))
|
86
|
+
ip = env[:hp_compute].addresses.create
|
87
|
+
ip.server = server
|
88
|
+
unless env[:interrupted]
|
85
89
|
# Clear the line one more time so the progress is removed
|
86
90
|
env[:ui].clear_line
|
87
91
|
|
88
92
|
# Wait for SSH to become available
|
89
|
-
env[:ui].info(I18n.t(
|
93
|
+
env[:ui].info(I18n.t('vagrant_hp.waiting_for_ssh'))
|
90
94
|
while true
|
91
95
|
begin
|
92
96
|
# If we're interrupted then just back out
|
@@ -97,7 +101,7 @@ module VagrantPlugins
|
|
97
101
|
sleep 2
|
98
102
|
end
|
99
103
|
|
100
|
-
env[:ui].info(I18n.t(
|
104
|
+
env[:ui].info(I18n.t('vagrant_hp.ready'))
|
101
105
|
end
|
102
106
|
|
103
107
|
@app.call(env)
|
@@ -106,7 +110,7 @@ module VagrantPlugins
|
|
106
110
|
protected
|
107
111
|
|
108
112
|
# generate a random name if server_name is empty
|
109
|
-
def get_server_name
|
113
|
+
def get_server_name
|
110
114
|
server_name = "vagrant_hp-#{rand.to_s.split('.')[1]}"
|
111
115
|
server_name.to_s
|
112
116
|
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
# Copyright:: Copyright (c) 2013 Mohit Sethi.
|
4
4
|
#
|
5
5
|
|
6
|
-
require
|
6
|
+
require 'log4r'
|
7
7
|
|
8
8
|
module VagrantPlugins
|
9
9
|
module HP
|
@@ -12,12 +12,15 @@ module VagrantPlugins
|
|
12
12
|
class DeleteServer
|
13
13
|
def initialize(app, env)
|
14
14
|
@app = app
|
15
|
-
@logger = Log4r::Logger.new(
|
15
|
+
@logger = Log4r::Logger.new('vagrant_hp::action::delete_server')
|
16
16
|
end
|
17
17
|
|
18
18
|
def call(env)
|
19
19
|
if env[:machine].id
|
20
|
-
@logger.info(I18n.t(
|
20
|
+
@logger.info(I18n.t('vagrant_hp.deleting_floating_ip'))
|
21
|
+
ip = env[:hp_compute].addresses.find { |ip| ip.instance_id==env[:machine].id }
|
22
|
+
ip.destroy
|
23
|
+
@logger.info(I18n.t('vagrant_hp.deleting_server'))
|
21
24
|
server = env[:hp_compute].servers.get(env[:machine].id)
|
22
25
|
server.destroy
|
23
26
|
env[:machine].id = nil
|
@@ -3,7 +3,7 @@
|
|
3
3
|
# Copyright:: Copyright (c) 2013 Mohit Sethi.
|
4
4
|
#
|
5
5
|
|
6
|
-
require
|
6
|
+
require 'log4r'
|
7
7
|
|
8
8
|
module VagrantPlugins
|
9
9
|
module HP
|
@@ -12,12 +12,12 @@ module VagrantPlugins
|
|
12
12
|
class HaltServer
|
13
13
|
def initialize(app, env)
|
14
14
|
@app = app
|
15
|
-
@logger = Log4r::Logger.new(
|
15
|
+
@logger = Log4r::Logger.new('vagrant_hp::action::delete_server')
|
16
16
|
end
|
17
17
|
|
18
18
|
def call(env)
|
19
19
|
if env[:machine].id
|
20
|
-
@logger.info(I18n.t(
|
20
|
+
@logger.info(I18n.t('vagrant_hp.deleting_server'))
|
21
21
|
server = env[:hp_compute].servers.get(env[:machine].id)
|
22
22
|
server.stop # verify this
|
23
23
|
env[:machine].id = nil
|