vagrant-profitbricks 1.0.0 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +4 -4
- data/README.md +326 -174
- data/Rakefile +4 -2
- data/Vagrantfile +18 -13
- data/example_box/Vagrantfile +9 -0
- data/example_box/profitbricks.box +0 -0
- data/lib/vagrant-profitbricks.rb +12 -11
- data/lib/vagrant-profitbricks/action.rb +79 -40
- data/lib/vagrant-profitbricks/action/connect_profitbricks.rb +14 -12
- data/lib/vagrant-profitbricks/action/create_server.rb +74 -67
- data/lib/vagrant-profitbricks/action/delete_server.rb +33 -13
- data/lib/vagrant-profitbricks/action/is_created.rb +3 -1
- data/lib/vagrant-profitbricks/action/list_flavors.rb +5 -3
- data/lib/vagrant-profitbricks/action/list_images.rb +6 -4
- data/lib/vagrant-profitbricks/action/message_already_created.rb +4 -2
- data/lib/vagrant-profitbricks/action/message_not_created.rb +4 -2
- data/lib/vagrant-profitbricks/action/read_ssh_info.rb +10 -16
- data/lib/vagrant-profitbricks/action/read_state.rb +19 -12
- data/lib/vagrant-profitbricks/action/reboot_server.rb +45 -0
- data/lib/vagrant-profitbricks/action/run_init_script.rb +5 -3
- data/lib/vagrant-profitbricks/action/start_server.rb +50 -0
- data/lib/vagrant-profitbricks/action/stop_server.rb +51 -0
- data/lib/vagrant-profitbricks/command/datacenters.rb +34 -0
- data/lib/vagrant-profitbricks/command/flavors.rb +19 -6
- data/lib/vagrant-profitbricks/command/images.rb +21 -20
- data/lib/vagrant-profitbricks/command/locations.rb +34 -0
- data/lib/vagrant-profitbricks/command/root.rb +28 -23
- data/lib/vagrant-profitbricks/command/servers.rb +7 -4
- data/lib/vagrant-profitbricks/command/snapshots.rb +34 -0
- data/lib/vagrant-profitbricks/command/utils.rb +27 -0
- data/lib/vagrant-profitbricks/config.rb +44 -39
- data/lib/vagrant-profitbricks/errors.rb +14 -5
- data/lib/vagrant-profitbricks/plugin.rb +13 -11
- data/lib/vagrant-profitbricks/provider.rb +8 -6
- data/lib/vagrant-profitbricks/version.rb +3 -1
- data/locales/en.yml +28 -7
- data/spec/spec_helper.rb +4 -2
- data/spec/vagrant-profitbricks/config_spec.rb +65 -96
- data/vagrant-profitbricks.gemspec +17 -14
- metadata +42 -47
- data/Appraisals +0 -35
- data/CHANGELOG.md +0 -3
- data/RELEASE.md +0 -15
- data/bootstrap.cmd +0 -16
- data/features/provision.feature +0 -36
- data/features/steps/sdk_steps.rb +0 -13
- data/features/steps/server_steps.rb +0 -25
- data/features/support/env.rb +0 -35
- data/features/support/fog_mock.rb +0 -17
- data/features/vagrant-profitbricks.feature +0 -66
- data/lib/vagrant-profitbricks/action/create_image.rb +0 -53
- data/lib/vagrant-profitbricks/action/list_keypairs.rb +0 -20
- data/lib/vagrant-profitbricks/action/list_networks.rb +0 -20
- data/lib/vagrant-profitbricks/action/list_servers.rb +0 -21
- data/lib/vagrant-profitbricks/command/create_image.rb +0 -21
- data/lib/vagrant-profitbricks/command/keypairs.rb +0 -21
- data/lib/vagrant-profitbricks/command/list_images.rb +0 -21
- data/lib/vagrant-profitbricks/command/networks.rb +0 -21
- data/spec/vagrant-profitbricks/actions/list_flavors_spec.rb +0 -48
- data/spec/vagrant-profitbricks/actions/list_images_spec.rb +0 -48
@@ -1,53 +0,0 @@
|
|
1
|
-
require "fog/profitbricks"
|
2
|
-
require "log4r"
|
3
|
-
|
4
|
-
require 'vagrant/util/retryable'
|
5
|
-
|
6
|
-
module VagrantPlugins
|
7
|
-
module ProfitBricks
|
8
|
-
module Action
|
9
|
-
# Creates an Image
|
10
|
-
class CreateImage
|
11
|
-
include Vagrant::Util::Retryable
|
12
|
-
|
13
|
-
attr_reader :env
|
14
|
-
|
15
|
-
def initialize(app, env)
|
16
|
-
@app, @env = app, env
|
17
|
-
end
|
18
|
-
|
19
|
-
def call(env)
|
20
|
-
env[:ui].info(I18n.t("vagrant_profitbricks.creating_image"))
|
21
|
-
|
22
|
-
server = env[:profitbricks_compute].servers.get(env[:machine].id)
|
23
|
-
|
24
|
-
config = env[:machine].provider_config
|
25
|
-
image_name = config.server_name || env[:machine].name
|
26
|
-
|
27
|
-
image = server.create_image(image_name)
|
28
|
-
|
29
|
-
retryable(:on => Fog::Errors::TimeoutError, :tries => 200) do
|
30
|
-
# If we're interrupted don't worry about waiting
|
31
|
-
next if env[:interrupted]
|
32
|
-
|
33
|
-
env[:ui].clear_line
|
34
|
-
env[:ui].report_progress(image.progress, 100, false)
|
35
|
-
|
36
|
-
begin
|
37
|
-
image.wait_for(5) { ready? }
|
38
|
-
rescue RuntimeError => e
|
39
|
-
# If we don't have an error about a state transition, then
|
40
|
-
# we just move on.
|
41
|
-
raise if e.message !~ /should have transitioned/
|
42
|
-
raise Errors::CreateBadState, :state => server.state
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
env[:ui].info(I18n.t("vagrant_profitbricks.image_ready"))
|
47
|
-
|
48
|
-
@app.call(env)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
module VagrantPlugins
|
2
|
-
module ProfitBricks
|
3
|
-
module Action
|
4
|
-
class ListKeyPairs
|
5
|
-
def initialize(app, env)
|
6
|
-
@app = app
|
7
|
-
end
|
8
|
-
|
9
|
-
def call(env)
|
10
|
-
compute_service = env[:profitbricks_compute]
|
11
|
-
env[:ui].info ('%s' % ['KeyPair Name'])
|
12
|
-
compute_service.key_pairs.sort_by(&:name).each do |keypair|
|
13
|
-
env[:ui].info ('%s' % [keypair.name])
|
14
|
-
end
|
15
|
-
@app.call(env)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
module VagrantPlugins
|
2
|
-
module ProfitBricks
|
3
|
-
module Action
|
4
|
-
class ListInterfaces
|
5
|
-
def initialize(app, env)
|
6
|
-
@app = app
|
7
|
-
end
|
8
|
-
|
9
|
-
def call(env)
|
10
|
-
compute_service = env[:profitbricks_compute]
|
11
|
-
env[:ui].info ('%-36s %-24s %s' % ['Lan Id', 'NIC IPs', 'Internet'])
|
12
|
-
compute_service.interfaces.sort_by(&:server_id).each do |network|
|
13
|
-
env[:ui].info ('%-36s %-24s %s' % [network.lan_id, network.ips, network.internet_access])
|
14
|
-
end
|
15
|
-
@app.call(env)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
module VagrantPlugins
|
2
|
-
module ProfitBricks
|
3
|
-
module Action
|
4
|
-
class ListServers
|
5
|
-
def initialize(app, env)
|
6
|
-
@app = app
|
7
|
-
end
|
8
|
-
|
9
|
-
def call(env)
|
10
|
-
compute_service = env[:profitbricks_compute]
|
11
|
-
env[:ui].info ('%-20s %-20s %s' % ['Server Name', 'State', 'IPv4 address'])
|
12
|
-
compute_service.servers.sort_by(&:name).each do |server|
|
13
|
-
ip = server.interfaces[0] ? server.interfaces[0].ips : "-"
|
14
|
-
env[:ui].info ('%-20s %-20s %s' % [server.name, server.state, ip])
|
15
|
-
end
|
16
|
-
@app.call(env)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
module VagrantPlugins
|
2
|
-
module ProfitBricks
|
3
|
-
module Command
|
4
|
-
class CreateImage < Vagrant.plugin("2", :command)
|
5
|
-
def execute
|
6
|
-
options = {}
|
7
|
-
opts = OptionParser.new do |o|
|
8
|
-
o.banner = "Usage: vagrant profitbricks images create [options]"
|
9
|
-
end
|
10
|
-
|
11
|
-
argv = parse_options(opts)
|
12
|
-
return if !argv
|
13
|
-
|
14
|
-
with_target_vms(argv, :provider => :profitbricks) do |machine|
|
15
|
-
machine.action('create_image')
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
module VagrantPlugins
|
2
|
-
module ProfitBricks
|
3
|
-
module Command
|
4
|
-
class KeyPairs < Vagrant.plugin("2", :command)
|
5
|
-
def execute
|
6
|
-
options = {}
|
7
|
-
opts = OptionParser.new do |o|
|
8
|
-
o.banner = "Usage: vagrant profitbricks keypairs [options]"
|
9
|
-
end
|
10
|
-
|
11
|
-
argv = parse_options(opts)
|
12
|
-
return if !argv
|
13
|
-
|
14
|
-
with_target_vms(argv, :provider => :profitbricks) do |machine|
|
15
|
-
machine.action('list_keypairs')
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
module VagrantPlugins
|
2
|
-
module ProfitBricks
|
3
|
-
module Command
|
4
|
-
class ListImages < Vagrant.plugin("2", :command)
|
5
|
-
def execute
|
6
|
-
options = {}
|
7
|
-
opts = OptionParser.new do |o|
|
8
|
-
o.banner = "Usage: vagrant profitbricks images list [options]"
|
9
|
-
end
|
10
|
-
|
11
|
-
argv = parse_options(opts)
|
12
|
-
return if !argv
|
13
|
-
|
14
|
-
with_target_vms(argv, :provider => :profitbricks) do |machine|
|
15
|
-
machine.action('list_images')
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
module VagrantPlugins
|
2
|
-
module ProfitBricks
|
3
|
-
module Command
|
4
|
-
class Networks < Vagrant.plugin("2", :command)
|
5
|
-
def execute
|
6
|
-
options = {}
|
7
|
-
opts = OptionParser.new do |o|
|
8
|
-
o.banner = "Usage: vagrant profitbricks networks [options]"
|
9
|
-
end
|
10
|
-
|
11
|
-
argv = parse_options(opts)
|
12
|
-
return if !argv
|
13
|
-
|
14
|
-
with_target_vms(argv, :provider => :profitbricks) do |machine|
|
15
|
-
machine.action('list_networks')
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require "vagrant-profitbricks/action/list_flavors"
|
3
|
-
|
4
|
-
describe VagrantPlugins::ProfitBricks::Action::ListFlavors do
|
5
|
-
let(:app) { lambda { |env| } }
|
6
|
-
let(:ui) { Vagrant::UI::Silent.new }
|
7
|
-
let(:flavors) {
|
8
|
-
Fog.mock!
|
9
|
-
Fog::Compute.new({
|
10
|
-
:provider => :profitbricks,
|
11
|
-
:profitbricks_username => 'anything',
|
12
|
-
:profitbricks_password => 'anything'
|
13
|
-
}).flavors
|
14
|
-
}
|
15
|
-
let(:compute_connection) { double('fog connection') }
|
16
|
-
let(:env) do
|
17
|
-
{
|
18
|
-
:profitbricks_compute => compute_connection,
|
19
|
-
:ui => ui
|
20
|
-
}
|
21
|
-
end
|
22
|
-
|
23
|
-
subject(:action) { described_class.new(app, env) }
|
24
|
-
|
25
|
-
before do
|
26
|
-
allow(compute_connection).to receive(:flavors).and_return flavors
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'get flavors from Fog' do
|
30
|
-
expect(compute_connection).to receive(:flavors).and_return flavors
|
31
|
-
action.call(env)
|
32
|
-
end
|
33
|
-
|
34
|
-
it 'writes a sorted, formatted flavor table to Vagrant::UI' do
|
35
|
-
header_line = '%-36s %s' % ['Flavor ID', 'Flavor Name']
|
36
|
-
expect(ui).to receive(:info).with(header_line)
|
37
|
-
flavors.sort_by(&:id).each do |flavor|
|
38
|
-
formatted_line = '%-36s %s' % [flavor.id, flavor.name]
|
39
|
-
expect(ui).to receive(:info).with formatted_line
|
40
|
-
end
|
41
|
-
action.call(env)
|
42
|
-
end
|
43
|
-
|
44
|
-
it 'continues the middleware chain' do
|
45
|
-
expect(app).to receive(:call).with(env)
|
46
|
-
action.call(env)
|
47
|
-
end
|
48
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require "vagrant-profitbricks/action/list_images"
|
3
|
-
|
4
|
-
describe VagrantPlugins::ProfitBricks::Action::ListImages do
|
5
|
-
let(:app) { lambda { |env| } }
|
6
|
-
let(:ui) { Vagrant::UI::Silent.new }
|
7
|
-
let(:images) {
|
8
|
-
Fog.mock!
|
9
|
-
Fog::Compute.new({
|
10
|
-
:provider => :profitbricks,
|
11
|
-
:profitbricks_password => 'anything',
|
12
|
-
:profitbricks_username => 'anything',
|
13
|
-
}).images
|
14
|
-
}
|
15
|
-
let(:compute_connection) { double('fog connection') }
|
16
|
-
let(:env) do
|
17
|
-
{
|
18
|
-
:profitbricks_compute => compute_connection,
|
19
|
-
:ui => ui
|
20
|
-
}
|
21
|
-
end
|
22
|
-
|
23
|
-
subject(:action) { described_class.new(app, env) }
|
24
|
-
|
25
|
-
before do
|
26
|
-
allow(compute_connection).to receive(:images).and_return images
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'get images from Fog' do
|
30
|
-
expect(compute_connection).to receive(:images).and_return images
|
31
|
-
action.call(env)
|
32
|
-
end
|
33
|
-
|
34
|
-
it 'writes a sorted, formatted image table to Vagrant::UI' do
|
35
|
-
header_line = '%-36s %s' % ['Image ID', 'Image Name']
|
36
|
-
expect(ui).to receive(:info).with(header_line)
|
37
|
-
images.sort_by(&:name).each do |image|
|
38
|
-
formatted_line = '%-36s %s' % [image.id.to_s, image.name]
|
39
|
-
expect(ui).to receive(:info).with formatted_line
|
40
|
-
end
|
41
|
-
action.call(env)
|
42
|
-
end
|
43
|
-
|
44
|
-
it 'continues the middleware chain' do
|
45
|
-
expect(app).to receive(:call).with(env)
|
46
|
-
action.call(env)
|
47
|
-
end
|
48
|
-
end
|