vagrant-arubacloud 0.0.2dev

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 (42) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +19 -0
  3. data/Gemfile +14 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +95 -0
  6. data/Rakefile +22 -0
  7. data/Vagrantfile +41 -0
  8. data/dummy.box +0 -0
  9. data/example_box/metadata.json +3 -0
  10. data/gemfiles/vagrant-arubacloud-0.0.1dev.gem +0 -0
  11. data/gemfiles/vagrant-arubacloud-0.0.2dev.gem +0 -0
  12. data/lib/vagrant-arubacloud/action/aruba_provision.rb +37 -0
  13. data/lib/vagrant-arubacloud/action/connect_arubacloud.rb +38 -0
  14. data/lib/vagrant-arubacloud/action/create_server.rb +105 -0
  15. data/lib/vagrant-arubacloud/action/delete_server.rb +33 -0
  16. data/lib/vagrant-arubacloud/action/disable_requiretty.rb +24 -0
  17. data/lib/vagrant-arubacloud/action/halt_server.rb +55 -0
  18. data/lib/vagrant-arubacloud/action/is_created.rb +19 -0
  19. data/lib/vagrant-arubacloud/action/list_servers.rb +23 -0
  20. data/lib/vagrant-arubacloud/action/list_templates.rb +34 -0
  21. data/lib/vagrant-arubacloud/action/message_already_created.rb +16 -0
  22. data/lib/vagrant-arubacloud/action/message_not_created.rb +16 -0
  23. data/lib/vagrant-arubacloud/action/read_ssh_info.rb +43 -0
  24. data/lib/vagrant-arubacloud/action/read_state.rb +46 -0
  25. data/lib/vagrant-arubacloud/action.rb +163 -0
  26. data/lib/vagrant-arubacloud/cap/disable_requiretty.rb +13 -0
  27. data/lib/vagrant-arubacloud/command/root.rb +67 -0
  28. data/lib/vagrant-arubacloud/command/servers.rb +21 -0
  29. data/lib/vagrant-arubacloud/command/templates.rb +21 -0
  30. data/lib/vagrant-arubacloud/config.rb +124 -0
  31. data/lib/vagrant-arubacloud/errors.rb +19 -0
  32. data/lib/vagrant-arubacloud/plugin.rb +48 -0
  33. data/lib/vagrant-arubacloud/provider.rb +51 -0
  34. data/lib/vagrant-arubacloud/version.rb +5 -0
  35. data/lib/vagrant-arubacloud.rb +53 -0
  36. data/locales/en.yml +64 -0
  37. data/spec/spec_helper.rb +2 -0
  38. data/spec/vagrant-arubacloud/action/connect_arubacloud_spec.rb +36 -0
  39. data/spec/vagrant-arubacloud/action_spec.rb +25 -0
  40. data/spec/vagrant-arubacloud/config_spec.rb +192 -0
  41. data/vagrant-arubacloud.gemspec +28 -0
  42. metadata +158 -0
data/locales/en.yml ADDED
@@ -0,0 +1,64 @@
1
+ en:
2
+ vagrant_arubacloud:
3
+ not_created: |-
4
+ The server hasn't been created yet. Run `vagrant up` first.
5
+ already_created: |-
6
+ The server is already created.
7
+ halting_server:
8
+ The server will be powered off.
9
+ deleting_server: |-
10
+ The server will be deleted.
11
+ bad_state: |-
12
+ The server is not in the correct state for this operation.
13
+ server_powered_off: |-
14
+ The server is now powered off.
15
+ disable_require_tty_cap_not_found: |-
16
+ Cannot find disable_requiretty capability.
17
+ disabling_requiretty: |-
18
+ Disabling requiretty on CentOS distribution.
19
+ operation_already_in_queue: |-
20
+ The operation you are calling on the server, is already present in queue.
21
+
22
+ config:
23
+ arubacloud_username_required: |-
24
+ An username is required (arubacloud_username).
25
+ arubacloud_password_required: |-
26
+ A password is required (arubacloud_password).
27
+ admin_password_required: |-
28
+ An SSH root Password is required (admin_password).
29
+ template_id_required: |-
30
+ A template_id is required.
31
+ package_id_required: |-
32
+ A package_id is required.
33
+ service_type_required: |-
34
+ Service type is required.
35
+ cpu_number_required: |-
36
+ Cpu number is required.
37
+ ram_qty_required: |-
38
+ Ram quantity is required.
39
+ hds_conf_required: |-
40
+ An hard disk configuration is required.
41
+ hds_conf_must_be_array: |-
42
+ Hard disks configuration must be an array of Hash
43
+
44
+ states:
45
+ short_1: |-
46
+ creating
47
+ long_1: |-
48
+ The server is creating. Wait for the server to be ready.
49
+ short_2: |-
50
+ stopped
51
+ long_build: |-
52
+ The server is currently stopped.
53
+ short_3: |-
54
+ running
55
+ long_3: |-
56
+ The server is ready. Use `vagrant ssh` to interact with the server.
57
+ short_5: |-
58
+ deleted
59
+ long_5: |-
60
+ The server is deleted.
61
+ short_not_created: |-
62
+ not created
63
+ long_not_created: |-
64
+ The server is not created. Run `vagrant up` to create it.
@@ -0,0 +1,2 @@
1
+ require 'fog/arubacloud'
2
+ require 'vagrant'
@@ -0,0 +1,36 @@
1
+ require 'vagrant-arubacloud/action'
2
+ require 'spec_helper'
3
+
4
+ include VagrantPlugins::ArubaCloud::Action
5
+
6
+ describe VagrantPlugins::ArubaCloud::Action::ConnectArubaCloud do
7
+ let(:app) do
8
+ double.tap do |app|
9
+ app.stub(:call)
10
+ end
11
+ end
12
+
13
+ let(:config) do
14
+ double.tap do |config|
15
+ config.stub(:arubacloud_username) {'test'}
16
+ config.stub(:arubacloud_password) {'password'}
17
+ config.stub(:template_id) {'1'}
18
+ config.stub(:service_type) {'1'}
19
+ end
20
+ end
21
+
22
+ let(:env) do
23
+ {}.tap do |env|
24
+ env[:ui] = double
25
+ env[:ui].stub(:info).with(anything)
26
+ env[:ui].stub(:warn).with(anything)
27
+ env[:machine] = double('machine')
28
+ env[:machine].stub(:provider_config) { config }
29
+ env[:arubacloud_compute] = double('arubacloud_compute')
30
+ end
31
+ end
32
+
33
+ before(:all) do
34
+ ConnectArubaCloud.send(:public, *ConnectArubaCloud.private_instance_methods)
35
+ end
36
+ end
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+ require 'vagrant'
3
+ require 'vagrant-arubacloud/action'
4
+
5
+ describe VagrantPlugins::ArubaCloud::Action do
6
+ let(:builder) do
7
+ double('builder').tap do |builder|
8
+ builder.stub(:use)
9
+ end
10
+ end
11
+
12
+ before :each do
13
+ Action.stub(:new_builder) { builder }
14
+ end
15
+
16
+ describe 'action_destroy' do
17
+ it 'add others middleware to builder' do
18
+ expect(builder).to receive(:use).with(ConfigValidate)
19
+ expect(builder).to receive(:use).with(ConnectArubaCloud)
20
+ expect(builder).to receive(:use).with(Call, ReadState)
21
+ # TODO, Impove this test to check what's happen after ReadState
22
+ Action.action_destroy
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,192 @@
1
+ require 'spec_helper'
2
+ require 'vagrant-arubacloud/config'
3
+ require 'fog/arubacloud'
4
+
5
+
6
+ describe VagrantPlugins::ArubaCloud::Config do
7
+ describe 'defaults' do
8
+ subject do
9
+ super().tap do |o|
10
+ o.finalize!
11
+ end
12
+ end
13
+
14
+ its(:arubacloud_username) { should be_nil }
15
+ its(:arubacloud_password) { should be_nil }
16
+ its(:url) { should be_nil }
17
+ its(:server_name) { should be_nil }
18
+ its(:template_id) { should be_nil}
19
+ its(:package_id) { should be_nil }
20
+ its(:admin_password) { should be_nil }
21
+
22
+ describe 'overriding default' do
23
+ [:arubacloud_username,
24
+ :arubacloud_password,
25
+ :url,
26
+ :server_name,
27
+ :template_id,
28
+ :package_id,
29
+ :admin_password].each do |attribute|
30
+ it "should not default #{attribute} if overridden" do
31
+ subject.send("#{attribute}=".to_sym, 'foo')
32
+ subject.finalize!
33
+ subject.send(attribute).should == 'foo'
34
+ end
35
+ end
36
+ end
37
+
38
+ describe 'validation' do
39
+ let(:machine) { double('machine') }
40
+ let(:validation_errors) { subject.validate(machine)['ArubaCloud Provider'] }
41
+ let(:error_message) { double('error message') }
42
+
43
+ # prepare the subject with all expected properties
44
+ before(:each) do
45
+ machine.stub_chain(:env, :root_path).and_return '/'
46
+ subject.arubacloud_username = 'foo'
47
+ subject.arubacloud_password = 'bar'
48
+ subject.admin_password = 'foobar'
49
+ subject.template_id = 1
50
+ subject.package_id = 1
51
+ subject.service_type = 1
52
+ subject.cpu_number = 1
53
+ subject.ram_qty = 1
54
+ subject.hds = [{:type => 1, :size => 500}]
55
+ end
56
+
57
+ subject do
58
+ super().tap do |o|
59
+ o.finalize!
60
+ end
61
+ end
62
+
63
+ context 'with invalid key' do
64
+ it 'should raise an error' do
65
+ subject.nonsense1 = true
66
+ subject.nonsense2 = false
67
+ I18n.should_receive(:t).with(
68
+ 'vagrant.config.common.bad_field',
69
+ { :fields => 'nonsense1, nonsense2' }
70
+ ).and_return error_message
71
+ validation_errors.first.should == error_message
72
+ end
73
+ end
74
+
75
+ context 'with good values' do
76
+ it 'should validate' do
77
+ validation_errors.should be_empty
78
+ end
79
+ end
80
+
81
+ context 'the arubacloud_username' do
82
+ it 'should error if not given' do
83
+ subject.arubacloud_username = nil
84
+ I18n.should_receive(:t).with('vagrant_arubacloud.config.arubacloud_username_required')
85
+ .and_return error_message
86
+ validation_errors.first.should == error_message
87
+ end
88
+ end
89
+
90
+ context 'the arubacloud_password' do
91
+ it 'should error if not given' do
92
+ subject.arubacloud_password = nil
93
+ I18n.should_receive(:t).with('vagrant_arubacloud.config.arubacloud_password_required')
94
+ .and_return error_message
95
+ validation_errors.first.should == error_message
96
+ end
97
+ end
98
+
99
+ context 'the admin_password' do
100
+ it 'should error it not given' do
101
+ subject.admin_password = nil
102
+ I18n.should_receive(:t).with('vagrant_arubacloud.config.admin_password_required')
103
+ .and_return error_message
104
+ validation_errors.first.should == error_message
105
+ end
106
+ end
107
+
108
+ context 'the template_id' do
109
+ it 'should error if not given' do
110
+ subject.template_id = nil
111
+ I18n.should_receive(:t).with('vagrant_arubacloud.config.template_id_required')
112
+ .and_return error_message
113
+ validation_errors.first.should == error_message
114
+ end
115
+ end
116
+
117
+ context 'the service_type' do
118
+ it 'should error if not given' do
119
+ subject.service_type = nil
120
+ I18n.should_receive(:t).with('vagrant_arubacloud.config.service_type_required')
121
+ .and_return error_message
122
+ validation_errors.first.should == error_message
123
+ end
124
+ end
125
+
126
+ describe 'smart create' do
127
+ context 'the package_id' do
128
+ it 'should error if not given' do
129
+ subject.package_id = nil
130
+ subject.service_type = 4
131
+ I18n.should_receive(:t).with('vagrant_arubacloud.config.package_id_required')
132
+ .and_return error_message
133
+ validation_errors.first.should == error_message
134
+ end
135
+ end
136
+ end
137
+
138
+ describe 'pro create' do
139
+ before(:each) do
140
+ subject.service_type = 1
141
+ end
142
+
143
+ context 'the cpu_number' do
144
+ it 'should error if not given' do
145
+ subject.cpu_number = nil
146
+ I18n.should_receive(:t).with('vagrant_arubacloud.config.cpu_number_required')
147
+ .and_return error_message
148
+ validation_errors.first.should == error_message
149
+ end
150
+ end
151
+ context 'the ram_qty' do
152
+ it 'should error if not given' do
153
+ subject.ram_qty = nil
154
+ I18n.should_receive(:t).with('vagrant_arubacloud.config.ram_qty_required')
155
+ .and_return error_message
156
+ validation_errors.first.should == error_message
157
+ end
158
+ end
159
+ context 'the package_id' do
160
+ it 'should valida if not given' do
161
+ subject.package_id = nil
162
+ validation_errors.should be_empty
163
+ end
164
+ end
165
+ context 'the hds configuration' do
166
+ it 'should error if its not an array' do
167
+ subject.hds = 'test'
168
+ I18n.should_receive(:t).with('vagrant_arubacloud.config.hds_conf_must_be_array')
169
+ .and_return error_message
170
+ validation_errors.first.should == error_message
171
+ end
172
+ end
173
+ context 'the hds configuration' do
174
+ it 'should error if not given' do
175
+ subject.hds = nil
176
+ I18n.should_receive(:t).with('vagrant_arubacloud.config.hds_conf_required')
177
+ .and_return error_message
178
+ validation_errors.first.should == error_message
179
+ end
180
+ end
181
+ end
182
+
183
+ context 'the url' do
184
+ it 'should validate if nil' do
185
+ subject.url = nil
186
+ validation_errors.should be_empty
187
+ end
188
+ end
189
+ end
190
+ end
191
+ end
192
+
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ require 'vagrant-arubacloud/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'vagrant-arubacloud'
9
+ spec.version = Vagrant::ArubaCloud::VERSION
10
+ spec.authors = ['Alessio Rocchi']
11
+ spec.email = ['alessio.rocchi@staff.aruba.it']
12
+ spec.summary = %q{Enables Vagrant to manage servers in ArubaCloud IaaS.}
13
+ spec.description = %q{Enables Vagrant to manage servers in ArubaCloud IaaS.}
14
+ spec.homepage = 'https://www.github.com/arubacloud/vagrant-arubacloud'
15
+ spec.license = 'MIT'
16
+
17
+ spec.add_runtime_dependency 'fog', '~> 1.22'
18
+ spec.add_runtime_dependency 'fog-arubacloud', '~> 0.0.2'
19
+
20
+ spec.add_development_dependency 'bundler', '~> 1.7'
21
+ spec.add_development_dependency 'rake'
22
+ spec.add_development_dependency 'rspec', '~> 2.14.0'
23
+
24
+ spec.files = `git ls-files -z`.split("\x0")
25
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
26
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
27
+ spec.require_paths = ['lib']
28
+ end
metadata ADDED
@@ -0,0 +1,158 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vagrant-arubacloud
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2dev
5
+ platform: ruby
6
+ authors:
7
+ - Alessio Rocchi
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-03-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: fog
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.22'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.22'
27
+ - !ruby/object:Gem::Dependency
28
+ name: fog-arubacloud
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.0.2
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.0.2
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.7'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.7'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 2.14.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 2.14.0
83
+ description: Enables Vagrant to manage servers in ArubaCloud IaaS.
84
+ email:
85
+ - alessio.rocchi@staff.aruba.it
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - Gemfile
92
+ - LICENSE.txt
93
+ - README.md
94
+ - Rakefile
95
+ - Vagrantfile
96
+ - dummy.box
97
+ - example_box/metadata.json
98
+ - gemfiles/vagrant-arubacloud-0.0.1dev.gem
99
+ - gemfiles/vagrant-arubacloud-0.0.2dev.gem
100
+ - lib/vagrant-arubacloud.rb
101
+ - lib/vagrant-arubacloud/action.rb
102
+ - lib/vagrant-arubacloud/action/aruba_provision.rb
103
+ - lib/vagrant-arubacloud/action/connect_arubacloud.rb
104
+ - lib/vagrant-arubacloud/action/create_server.rb
105
+ - lib/vagrant-arubacloud/action/delete_server.rb
106
+ - lib/vagrant-arubacloud/action/disable_requiretty.rb
107
+ - lib/vagrant-arubacloud/action/halt_server.rb
108
+ - lib/vagrant-arubacloud/action/is_created.rb
109
+ - lib/vagrant-arubacloud/action/list_servers.rb
110
+ - lib/vagrant-arubacloud/action/list_templates.rb
111
+ - lib/vagrant-arubacloud/action/message_already_created.rb
112
+ - lib/vagrant-arubacloud/action/message_not_created.rb
113
+ - lib/vagrant-arubacloud/action/read_ssh_info.rb
114
+ - lib/vagrant-arubacloud/action/read_state.rb
115
+ - lib/vagrant-arubacloud/cap/disable_requiretty.rb
116
+ - lib/vagrant-arubacloud/command/root.rb
117
+ - lib/vagrant-arubacloud/command/servers.rb
118
+ - lib/vagrant-arubacloud/command/templates.rb
119
+ - lib/vagrant-arubacloud/config.rb
120
+ - lib/vagrant-arubacloud/errors.rb
121
+ - lib/vagrant-arubacloud/plugin.rb
122
+ - lib/vagrant-arubacloud/provider.rb
123
+ - lib/vagrant-arubacloud/version.rb
124
+ - locales/en.yml
125
+ - spec/spec_helper.rb
126
+ - spec/vagrant-arubacloud/action/connect_arubacloud_spec.rb
127
+ - spec/vagrant-arubacloud/action_spec.rb
128
+ - spec/vagrant-arubacloud/config_spec.rb
129
+ - vagrant-arubacloud.gemspec
130
+ homepage: https://www.github.com/arubacloud/vagrant-arubacloud
131
+ licenses:
132
+ - MIT
133
+ metadata: {}
134
+ post_install_message:
135
+ rdoc_options: []
136
+ require_paths:
137
+ - lib
138
+ required_ruby_version: !ruby/object:Gem::Requirement
139
+ requirements:
140
+ - - ">="
141
+ - !ruby/object:Gem::Version
142
+ version: '0'
143
+ required_rubygems_version: !ruby/object:Gem::Requirement
144
+ requirements:
145
+ - - ">"
146
+ - !ruby/object:Gem::Version
147
+ version: 1.3.1
148
+ requirements: []
149
+ rubyforge_project:
150
+ rubygems_version: 2.4.5.1
151
+ signing_key:
152
+ specification_version: 4
153
+ summary: Enables Vagrant to manage servers in ArubaCloud IaaS.
154
+ test_files:
155
+ - spec/spec_helper.rb
156
+ - spec/vagrant-arubacloud/action/connect_arubacloud_spec.rb
157
+ - spec/vagrant-arubacloud/action_spec.rb
158
+ - spec/vagrant-arubacloud/config_spec.rb