vagrant-brightbox 0.1.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 (37) hide show
  1. data/.gitignore +15 -0
  2. data/CHANGELOG.md +4 -0
  3. data/Gemfile +10 -0
  4. data/LICENSE +8 -0
  5. data/README.md +217 -0
  6. data/Rakefile +21 -0
  7. data/Vagrantfile.example +105 -0
  8. data/dummy.box +0 -0
  9. data/example_box/README.md +9 -0
  10. data/example_box/metadata.json +3 -0
  11. data/lib/vagrant-brightbox/action/connect_brightbox.rb +53 -0
  12. data/lib/vagrant-brightbox/action/create_server.rb +137 -0
  13. data/lib/vagrant-brightbox/action/delete_server.rb +26 -0
  14. data/lib/vagrant-brightbox/action/forced_halt.rb +27 -0
  15. data/lib/vagrant-brightbox/action/is_created.rb +18 -0
  16. data/lib/vagrant-brightbox/action/is_running.rb +18 -0
  17. data/lib/vagrant-brightbox/action/map_cloud_ip.rb +68 -0
  18. data/lib/vagrant-brightbox/action/message_already_created.rb +16 -0
  19. data/lib/vagrant-brightbox/action/message_not_created.rb +16 -0
  20. data/lib/vagrant-brightbox/action/read_ssh_info.rb +69 -0
  21. data/lib/vagrant-brightbox/action/read_state.rb +38 -0
  22. data/lib/vagrant-brightbox/action/start_server.rb +28 -0
  23. data/lib/vagrant-brightbox/action/sync_folders.rb +58 -0
  24. data/lib/vagrant-brightbox/action/timed_provision.rb +21 -0
  25. data/lib/vagrant-brightbox/action/unsupported.rb +18 -0
  26. data/lib/vagrant-brightbox/action.rb +166 -0
  27. data/lib/vagrant-brightbox/config.rb +268 -0
  28. data/lib/vagrant-brightbox/errors.rb +34 -0
  29. data/lib/vagrant-brightbox/plugin.rb +73 -0
  30. data/lib/vagrant-brightbox/provider.rb +50 -0
  31. data/lib/vagrant-brightbox/util/timer.rb +17 -0
  32. data/lib/vagrant-brightbox/version.rb +5 -0
  33. data/lib/vagrant-brightbox.rb +18 -0
  34. data/locales/en.yml +88 -0
  35. data/spec/vagrant-brightbox/config_spec.rb +179 -0
  36. data/vagrant-brightbox.gemspec +23 -0
  37. metadata +122 -0
@@ -0,0 +1,179 @@
1
+ require "vagrant-brightbox/config"
2
+
3
+ describe VagrantPlugins::Brightbox::Config do
4
+ let(:instance) { described_class.new }
5
+
6
+ describe "defaults" do
7
+ subject do
8
+ instance.tap do |o|
9
+ o.finalize!
10
+ end
11
+ end
12
+
13
+ # Connection
14
+ its("client_id") { should be_nil }
15
+ its("secret") { should be_nil }
16
+ its("auth_url") { should be_nil }
17
+ its("api_url") { should be_nil }
18
+ its("username") { should be_nil }
19
+ its("password") { should be_nil }
20
+ its("account") { should be_nil }
21
+
22
+ # Server
23
+ its("image_id") { should be_nil }
24
+ its("zone") { should be_nil }
25
+ its("server_type") { should be_nil }
26
+ its("server_name") { should be_nil }
27
+ its("region") { should == "gb1" }
28
+ its("server_groups") { should == [] }
29
+
30
+ # Access
31
+ its("ssh_private_key_path") { should be_nil }
32
+ its("ssh_username") { should be_nil }
33
+ end
34
+
35
+ describe "overriding defaults" do
36
+ [:client_id, :secret, :auth_url, :api_url, :username, :password, :account,
37
+ :image_id, :zone, :server_type, :server_name, :region, :server_groups,
38
+ :ssh_private_key_path, :ssh_username].each do |attribute|
39
+
40
+ it "should not default #{attribute} if overridden" do
41
+ instance.send("#{attribute}=".to_sym, "foo")
42
+ instance.finalize!
43
+ instance.send(attribute).should == "foo"
44
+ end
45
+ end
46
+ end
47
+
48
+ describe "region config" do
49
+ let(:config_client_id) { "foo" }
50
+ let(:config_secret) { "foo" }
51
+ let(:config_auth_url) { "foo" }
52
+ let(:config_api_url) { "foo" }
53
+ let(:config_username) { "foo" }
54
+ let(:config_password) { "foo" }
55
+ let(:config_account) { "foo" }
56
+
57
+ let(:config_image_id) { "foo" }
58
+ let(:config_server_type) { "foo" }
59
+ let(:config_server_name) { "foo" }
60
+ let(:config_server_groups) { ["foo", "bar"] }
61
+ let(:config_zone) { "foo" }
62
+ let(:config_region) { "foo" }
63
+
64
+ def set_test_values(instance)
65
+ instance.client_id = config_client_id
66
+ instance.secret = config_secret
67
+ instance.auth_url = config_auth_url
68
+ instance.api_url = config_api_url
69
+ instance.username = config_username
70
+ instance.password = config_password
71
+ instance.account = config_account
72
+
73
+ instance.image_id = config_image_id
74
+ instance.server_type = config_server_type
75
+ instance.server_name = config_server_name
76
+ instance.region = config_region
77
+ instance.zone = config_zone
78
+ instance.server_groups = config_server_groups
79
+ end
80
+
81
+ it "should raise an exception if not finalized" do
82
+ expect { instance.get_region_config("gb1") }.
83
+ to raise_error
84
+ end
85
+
86
+ context "with no specific config set" do
87
+ subject do
88
+ # Set the values on the top-level object
89
+ set_test_values(instance)
90
+
91
+ # Finalize so we can get the region config
92
+ instance.finalize!
93
+
94
+ # Get a lower level region
95
+ instance.get_region_config("gb1")
96
+ end
97
+
98
+ its("client_id") { should == config_client_id }
99
+ its("secret") { should == config_secret }
100
+ its("auth_url") { should == config_auth_url }
101
+ its("api_url") { should == config_api_url }
102
+ its("username") { should == config_username }
103
+ its("password") { should == config_password }
104
+ its("account") { should == config_account }
105
+
106
+ its("image_id") { should == config_image_id }
107
+ its("server_name") { should == config_server_name }
108
+ its("server_type") { should == config_server_type }
109
+ its("region") { should == config_region }
110
+ its("zone") { should == config_zone }
111
+ its("server_groups") { should == config_server_groups }
112
+ end
113
+
114
+ context "with a specific config set" do
115
+ let(:region_name) { "hashi-region" }
116
+
117
+ subject do
118
+ # Set the values on a specific region
119
+ instance.region_config region_name do |config|
120
+ set_test_values(config)
121
+ end
122
+
123
+ # Finalize so we can get the region config
124
+ instance.finalize!
125
+
126
+ # Get the region
127
+ instance.get_region_config(region_name)
128
+ end
129
+
130
+ its("client_id") { should == config_client_id }
131
+ its("secret") { should == config_secret }
132
+ its("auth_url") { should == config_auth_url }
133
+ its("api_url") { should == config_api_url }
134
+ its("username") { should == config_username }
135
+ its("password") { should == config_password }
136
+ its("account") { should == config_account }
137
+
138
+ its("image_id") { should == config_image_id }
139
+ its("server_name") { should == config_server_name }
140
+ its("server_type") { should == config_server_type }
141
+ its("zone") { should == config_zone }
142
+ its("server_groups") { should == config_server_groups }
143
+ end
144
+
145
+ describe "inheritance of parent config" do
146
+ let(:region_name) { "hashi-region" }
147
+
148
+ subject do
149
+ # Set the values on a specific region
150
+ instance.region_config region_name do |config|
151
+ config.image_id = "child"
152
+ end
153
+
154
+ # Set some top-level values
155
+ instance.client_id = "parent"
156
+ instance.image_id = "parent"
157
+
158
+ # Finalize and get the region
159
+ instance.finalize!
160
+ instance.get_region_config(region_name)
161
+ end
162
+
163
+ its("client_id") { should == "parent" }
164
+ its("image_id") { should == "child" }
165
+ end
166
+
167
+ describe "shortcut configuration" do
168
+ subject do
169
+ # Use the shortcut configuration to set some values
170
+ instance.region_config "gb1", :image_id => "child"
171
+ instance.finalize!
172
+ instance.get_region_config("gb1")
173
+ end
174
+
175
+ its("image_id") { should == "child" }
176
+ end
177
+
178
+ end
179
+ end
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'vagrant-brightbox/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "vagrant-brightbox"
8
+ gem.version = VagrantPlugins::Brightbox::VERSION
9
+ gem.authors = ["Mitchell Hashimoto", "Neil Wilson"]
10
+ gem.email = ["neil@aldur.co.uk"]
11
+ gem.description = "Enables Vagrant to manage servers in Brightbox Cloud."
12
+ gem.summary = "Enables Vagrant to manage servers in Brightbox Cloud."
13
+
14
+ gem.add_runtime_dependency "fog", "~> 1.10.0"
15
+
16
+ gem.add_development_dependency "rake"
17
+ gem.add_development_dependency "rspec", "~> 2.13.0"
18
+
19
+ gem.files = `git ls-files`.split($/)
20
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
21
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
22
+ gem.require_paths = ["lib"]
23
+ end
metadata ADDED
@@ -0,0 +1,122 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vagrant-brightbox
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Mitchell Hashimoto
9
+ - Neil Wilson
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2013-04-05 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: fog
17
+ requirement: &17243720 !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ~>
21
+ - !ruby/object:Gem::Version
22
+ version: 1.10.0
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: *17243720
26
+ - !ruby/object:Gem::Dependency
27
+ name: rake
28
+ requirement: &17241820 !ruby/object:Gem::Requirement
29
+ none: false
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: *17241820
37
+ - !ruby/object:Gem::Dependency
38
+ name: rspec
39
+ requirement: &17277700 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ~>
43
+ - !ruby/object:Gem::Version
44
+ version: 2.13.0
45
+ type: :development
46
+ prerelease: false
47
+ version_requirements: *17277700
48
+ description: Enables Vagrant to manage servers in Brightbox Cloud.
49
+ email:
50
+ - neil@aldur.co.uk
51
+ executables: []
52
+ extensions: []
53
+ extra_rdoc_files: []
54
+ files:
55
+ - .gitignore
56
+ - CHANGELOG.md
57
+ - Gemfile
58
+ - LICENSE
59
+ - README.md
60
+ - Rakefile
61
+ - Vagrantfile.example
62
+ - dummy.box
63
+ - example_box/README.md
64
+ - example_box/metadata.json
65
+ - lib/vagrant-brightbox.rb
66
+ - lib/vagrant-brightbox/action.rb
67
+ - lib/vagrant-brightbox/action/connect_brightbox.rb
68
+ - lib/vagrant-brightbox/action/create_server.rb
69
+ - lib/vagrant-brightbox/action/delete_server.rb
70
+ - lib/vagrant-brightbox/action/forced_halt.rb
71
+ - lib/vagrant-brightbox/action/is_created.rb
72
+ - lib/vagrant-brightbox/action/is_running.rb
73
+ - lib/vagrant-brightbox/action/map_cloud_ip.rb
74
+ - lib/vagrant-brightbox/action/message_already_created.rb
75
+ - lib/vagrant-brightbox/action/message_not_created.rb
76
+ - lib/vagrant-brightbox/action/read_ssh_info.rb
77
+ - lib/vagrant-brightbox/action/read_state.rb
78
+ - lib/vagrant-brightbox/action/start_server.rb
79
+ - lib/vagrant-brightbox/action/sync_folders.rb
80
+ - lib/vagrant-brightbox/action/timed_provision.rb
81
+ - lib/vagrant-brightbox/action/unsupported.rb
82
+ - lib/vagrant-brightbox/config.rb
83
+ - lib/vagrant-brightbox/errors.rb
84
+ - lib/vagrant-brightbox/plugin.rb
85
+ - lib/vagrant-brightbox/provider.rb
86
+ - lib/vagrant-brightbox/util/timer.rb
87
+ - lib/vagrant-brightbox/version.rb
88
+ - locales/en.yml
89
+ - spec/vagrant-brightbox/config_spec.rb
90
+ - vagrant-brightbox.gemspec
91
+ homepage:
92
+ licenses: []
93
+ post_install_message:
94
+ rdoc_options: []
95
+ require_paths:
96
+ - lib
97
+ required_ruby_version: !ruby/object:Gem::Requirement
98
+ none: false
99
+ requirements:
100
+ - - ! '>='
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ segments:
104
+ - 0
105
+ hash: 2290728058853834092
106
+ required_rubygems_version: !ruby/object:Gem::Requirement
107
+ none: false
108
+ requirements:
109
+ - - ! '>='
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ segments:
113
+ - 0
114
+ hash: 2290728058853834092
115
+ requirements: []
116
+ rubyforge_project:
117
+ rubygems_version: 1.8.11
118
+ signing_key:
119
+ specification_version: 3
120
+ summary: Enables Vagrant to manage servers in Brightbox Cloud.
121
+ test_files:
122
+ - spec/vagrant-brightbox/config_spec.rb