vagrant-profitbricks 1.0.0 → 4.0.0

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.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +4 -4
  3. data/README.md +326 -174
  4. data/Rakefile +4 -2
  5. data/Vagrantfile +18 -13
  6. data/example_box/Vagrantfile +9 -0
  7. data/example_box/profitbricks.box +0 -0
  8. data/lib/vagrant-profitbricks.rb +12 -11
  9. data/lib/vagrant-profitbricks/action.rb +79 -40
  10. data/lib/vagrant-profitbricks/action/connect_profitbricks.rb +14 -12
  11. data/lib/vagrant-profitbricks/action/create_server.rb +74 -67
  12. data/lib/vagrant-profitbricks/action/delete_server.rb +33 -13
  13. data/lib/vagrant-profitbricks/action/is_created.rb +3 -1
  14. data/lib/vagrant-profitbricks/action/list_flavors.rb +5 -3
  15. data/lib/vagrant-profitbricks/action/list_images.rb +6 -4
  16. data/lib/vagrant-profitbricks/action/message_already_created.rb +4 -2
  17. data/lib/vagrant-profitbricks/action/message_not_created.rb +4 -2
  18. data/lib/vagrant-profitbricks/action/read_ssh_info.rb +10 -16
  19. data/lib/vagrant-profitbricks/action/read_state.rb +19 -12
  20. data/lib/vagrant-profitbricks/action/reboot_server.rb +45 -0
  21. data/lib/vagrant-profitbricks/action/run_init_script.rb +5 -3
  22. data/lib/vagrant-profitbricks/action/start_server.rb +50 -0
  23. data/lib/vagrant-profitbricks/action/stop_server.rb +51 -0
  24. data/lib/vagrant-profitbricks/command/datacenters.rb +34 -0
  25. data/lib/vagrant-profitbricks/command/flavors.rb +19 -6
  26. data/lib/vagrant-profitbricks/command/images.rb +21 -20
  27. data/lib/vagrant-profitbricks/command/locations.rb +34 -0
  28. data/lib/vagrant-profitbricks/command/root.rb +28 -23
  29. data/lib/vagrant-profitbricks/command/servers.rb +7 -4
  30. data/lib/vagrant-profitbricks/command/snapshots.rb +34 -0
  31. data/lib/vagrant-profitbricks/command/utils.rb +27 -0
  32. data/lib/vagrant-profitbricks/config.rb +44 -39
  33. data/lib/vagrant-profitbricks/errors.rb +14 -5
  34. data/lib/vagrant-profitbricks/plugin.rb +13 -11
  35. data/lib/vagrant-profitbricks/provider.rb +8 -6
  36. data/lib/vagrant-profitbricks/version.rb +3 -1
  37. data/locales/en.yml +28 -7
  38. data/spec/spec_helper.rb +4 -2
  39. data/spec/vagrant-profitbricks/config_spec.rb +65 -96
  40. data/vagrant-profitbricks.gemspec +17 -14
  41. metadata +42 -47
  42. data/Appraisals +0 -35
  43. data/CHANGELOG.md +0 -3
  44. data/RELEASE.md +0 -15
  45. data/bootstrap.cmd +0 -16
  46. data/features/provision.feature +0 -36
  47. data/features/steps/sdk_steps.rb +0 -13
  48. data/features/steps/server_steps.rb +0 -25
  49. data/features/support/env.rb +0 -35
  50. data/features/support/fog_mock.rb +0 -17
  51. data/features/vagrant-profitbricks.feature +0 -66
  52. data/lib/vagrant-profitbricks/action/create_image.rb +0 -53
  53. data/lib/vagrant-profitbricks/action/list_keypairs.rb +0 -20
  54. data/lib/vagrant-profitbricks/action/list_networks.rb +0 -20
  55. data/lib/vagrant-profitbricks/action/list_servers.rb +0 -21
  56. data/lib/vagrant-profitbricks/command/create_image.rb +0 -21
  57. data/lib/vagrant-profitbricks/command/keypairs.rb +0 -21
  58. data/lib/vagrant-profitbricks/command/list_images.rb +0 -21
  59. data/lib/vagrant-profitbricks/command/networks.rb +0 -21
  60. data/spec/vagrant-profitbricks/actions/list_flavors_spec.rb +0 -48
  61. 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