vagrant-arubacloud 0.0.4 → 0.0.5

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.
@@ -38,6 +38,14 @@ module VagrantPlugins
38
38
  Command::Root
39
39
  end
40
40
 
41
+ command('snapshot') do
42
+ ArubaCloud.init_i18n
43
+ ArubaCloud.init_logging
44
+
45
+ require_relative 'command/snapshot'
46
+ Command::Snapshot
47
+ end
48
+
41
49
  # Disable require tty for centOS
42
50
  guest_capability 'redhat', 'disable_requiretty' do
43
51
  require_relative 'cap/disable_requiretty'
@@ -45,4 +53,4 @@ module VagrantPlugins
45
53
  end
46
54
  end # Plugin
47
55
  end # ArubaCloud
48
- end # VagrantPlugins
56
+ end # VagrantPlugins
@@ -48,4 +48,4 @@ module VagrantPlugins
48
48
  end
49
49
  end # Provider
50
50
  end # ArubaCloud
51
- end # VagrantPlugins
51
+ end # VagrantPlugins
@@ -1,5 +1,5 @@
1
1
  module Vagrant
2
2
  module ArubaCloud
3
- VERSION = '0.0.4'
3
+ VERSION = '0.0.5'
4
4
  end
5
5
  end
data/locales/en.yml CHANGED
@@ -4,28 +4,70 @@ en:
4
4
  The server hasn't been created yet. Run `vagrant up` first.
5
5
  already_created: |-
6
6
  The server is already created.
7
- halting_server:
7
+ halting_server: |-
8
8
  The server will be powered off.
9
+ starting_server: |-
10
+ The server will be powered on.
9
11
  deleting_server: |-
10
12
  The server will be deleted.
11
13
  bad_state: |-
12
14
  The server is not in the correct state for this operation.
15
+ waiting_server_powered_off: |-
16
+ Wait until server is powered off.
13
17
  server_powered_off: |-
14
18
  The server is now powered off.
19
+ waiting_server_powered_on: |-
20
+ Wait until server is powered on.
21
+ server_powered_on: |-
22
+ The server is now powered on.
15
23
  disable_require_tty_cap_not_found: |-
16
24
  Cannot find disable_requiretty capability.
17
25
  disabling_requiretty: |-
18
26
  Disabling requiretty on CentOS distribution.
19
27
  operation_already_in_queue: |-
20
28
  The operation you are calling on the server, is already present in queue.
29
+ connecting_to_dc: |-
30
+ Connecting to DataCenter.
31
+ connect_to_dc: |-
32
+ Connected ( DataCenter where the VM is located)
33
+ wrong_dc: |-
34
+ Datacenter/url is wrong or userid/password missing/wrong.
35
+ snapshot_info_create: |-
36
+ create:
37
+ snapshot_info_expired: |-
38
+ expire:
39
+ snapshot_info_not_found: |-
40
+ no snapshot found.
41
+ snapshot_created: |-
42
+ Snapshot created.
43
+ snapshot_create_err_fog: |-
44
+ Snapshot return an error from 'fog' interface during create.
45
+ snapshot_create_err_not_on: |-
46
+ Snapshot create can be run only with VM active.
47
+ snapshot_deleted: |-
48
+ Snapshot delete is done (effective delete can take a few seconds).
49
+ snapshot_delete_err_fog: |-
50
+ Snapshot return an error from 'fog' interface during delete.
51
+ snapshot_restored: |-
52
+ Snapshot restore is done; now VM can be 'reload' (after restore snapshot is removed).
53
+ snapshot_restore_err_fog: |-
54
+ Snapshot return an error from 'fog' interface during restore.
55
+ snapshot_restore_err_not_off: |-
56
+ Snapshot restore can be run only with VM power off.
57
+ snapshot_type_unknow: |-
58
+ Snapshot type request unhandle
59
+ snapshot_server_unknow: |-
60
+ Snapshot not found for server
61
+ snapshot_req_type: |-
62
+ Snapshot request is
21
63
 
22
64
  config:
23
65
  arubacloud_username_required: |-
24
66
  An username is required (arubacloud_username).
25
67
  arubacloud_password_required: |-
26
68
  A password is required (arubacloud_password).
27
- admin_password_required: |-
28
- An SSH root Password is required (admin_password).
69
+ ssh_password_required: |-
70
+ An SSH root Password is required.
29
71
  template_id_required: |-
30
72
  A template_id is required.
31
73
  package_id_required: |-
@@ -1,25 +1,166 @@
1
+ # coding: utf-8
1
2
  require 'spec_helper'
2
3
  require 'vagrant'
3
4
  require 'vagrant-arubacloud/action'
4
5
 
5
- describe VagrantPlugins::ArubaCloud::Action do
6
+
7
+ RSpec.describe VagrantPlugins::ArubaCloud::Action do
8
+
6
9
  let(:builder) do
7
10
  double('builder').tap do |builder|
8
- builder.stub(:use)
11
+ #builder.stub(:use)
12
+ allow(builder).to receive(:use)
9
13
  end
10
14
  end
11
15
 
12
16
  before :each do
13
- Action.stub(:new_builder) { builder }
17
+ allow(Vagrant::Action::Builder).to receive(:new_builder) { builder }
18
+ end
19
+
20
+ describe 'action_read_ssh_info' do
21
+ it 'add others middleware to builder' do
22
+ expect(builder).to receive(:use).with(ConfigValidate)
23
+ expect(builder).to receive(:use).with(ConnectArubaCloud)
24
+ expect(builder).to receive(:use).with(ReadSSHInfo)
25
+ unless ( u = VagrantPlugins::ArubaCloud::Action.action_read_ssh_info).nil?
26
+ u.stack.each do |x|
27
+ builder.send("use", x.first)
28
+ end
29
+ end
30
+ end
31
+ end
32
+
33
+ describe 'action_read_state' do
34
+ it 'add others middleware to builder' do
35
+ expect(builder).to receive(:use).with(ConfigValidate)
36
+ expect(builder).to receive(:use).with(ConnectArubaCloud)
37
+ expect(builder).to receive(:use).with(ReadState)
38
+ unless ( u = VagrantPlugins::ArubaCloud::Action.action_read_state).nil?
39
+ u.stack.each do |x|
40
+ builder.send("use", x.first)
41
+ end
42
+ end
43
+ end
14
44
  end
15
45
 
16
46
  describe 'action_destroy' do
47
+ it 'add others middleware to builder' do
48
+ expect(builder).to receive(:use).with(ConfigValidate)
49
+ expect(builder).to receive(:use).with(Call)
50
+ unless ( u = VagrantPlugins::ArubaCloud::Action.action_destroy).nil?
51
+ u.stack.each do |x|
52
+ builder.send("use", x.first)
53
+ end
54
+ end
55
+ end
56
+ end
57
+
58
+ describe 'action_list_servers' do
59
+ it 'add others middleware to builder' do
60
+ expect(builder).to receive(:use).with(ConnectArubaCloud)
61
+ expect(builder).to receive(:use).with(ListServers)
62
+ unless ( u = VagrantPlugins::ArubaCloud::Action.action_list_servers).nil?
63
+ u.stack.each do |x|
64
+ builder.send("use", x.first)
65
+ end
66
+ end
67
+ end
68
+ end
69
+
70
+ describe 'action_list_templates' do
71
+ it 'add others middleware to builder' do
72
+ expect(builder).to receive(:use).with(ConnectArubaCloud)
73
+ expect(builder).to receive(:use).with(ListTemplates)
74
+ unless ( u = VagrantPlugins::ArubaCloud::Action.action_list_templates).nil?
75
+ u.stack.each do |x|
76
+ builder.send("use", x.first)
77
+ end
78
+ end
79
+ end
80
+ end
81
+
82
+ describe 'action_halt' do
83
+ it 'add others middleware to builder' do
84
+ expect(builder).to receive(:use).with(ConfigValidate)
85
+ expect(builder).to receive(:use).with(Call)
86
+ unless ( u = VagrantPlugins::ArubaCloud::Action.action_halt).nil?
87
+ u.stack.each do |x|
88
+ builder.send("use", x.first)
89
+ end
90
+ end
91
+ end
92
+ end
93
+
94
+ describe 'action_start' do
95
+ it 'add others middleware to builder' do
96
+ expect(builder).to receive(:use).with(ConfigValidate)
97
+ expect(builder).to receive(:use).with(Call)
98
+ unless ( u = VagrantPlugins::ArubaCloud::Action.action_start).nil?
99
+ u.stack.each do |x|
100
+ builder.send("use", x.first)
101
+ end
102
+ end
103
+ end
104
+ end
105
+
106
+ describe 'action_provision' do
107
+ it 'add others middleware to builder' do
108
+ expect(builder).to receive(:use).with(ConfigValidate)
109
+ expect(builder).to receive(:use).with(Call)
110
+ unless ( u = VagrantPlugins::ArubaCloud::Action.action_provision).nil?
111
+ u.stack.each do |x|
112
+ builder.send("use", x.first)
113
+ end
114
+ end
115
+ end
116
+ end
117
+
118
+ describe 'action_reload' do
17
119
  it 'add others middleware to builder' do
18
120
  expect(builder).to receive(:use).with(ConfigValidate)
19
121
  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
122
+ unless ( u = VagrantPlugins::ArubaCloud::Action.action_reload).nil?
123
+ u.stack.each do |x|
124
+ builder.send("use", x.first)
125
+ end
126
+ end
127
+ end
128
+ end
129
+
130
+ describe 'action_ssh' do
131
+ it 'add others middleware to builder' do
132
+ expect(builder).to receive(:use).with(ConfigValidate)
133
+ expect(builder).to receive(:use).with(Call)
134
+ unless ( u = VagrantPlugins::ArubaCloud::Action.action_ssh).nil?
135
+ u.stack.each do |x|
136
+ builder.send("use", x.first)
137
+ end
138
+ end
23
139
  end
24
140
  end
25
- end
141
+
142
+ describe 'action_ssh_run' do
143
+ it 'add others middleware to builder' do
144
+ expect(builder).to receive(:use).with(ConfigValidate)
145
+ expect(builder).to receive(:use).with(Call)
146
+ unless ( u = VagrantPlugins::ArubaCloud::Action.action_ssh_run).nil?
147
+ u.stack.each do |x|
148
+ builder.send("use", x.first)
149
+ end
150
+ end
151
+ end
152
+ end
153
+
154
+ describe 'action_up' do
155
+ it 'add others middleware to builder' do
156
+ expect(builder).to receive(:use).with(ConfigValidate)
157
+ expect(builder).to receive(:use).with(Call)
158
+ unless ( u = VagrantPlugins::ArubaCloud::Action.action_up).nil?
159
+ u.stack.each do |x|
160
+ builder.send("use", x.first)
161
+ end
162
+ end
163
+ end
164
+ end
165
+
166
+ end
@@ -1,40 +1,61 @@
1
1
  require 'spec_helper'
2
2
  require 'vagrant-arubacloud/config'
3
3
  require 'fog/arubacloud'
4
+ require 'vagrant'
4
5
 
5
-
6
- describe VagrantPlugins::ArubaCloud::Config do
6
+ RSpec.describe VagrantPlugins::ArubaCloud::Config do
7
7
  describe 'defaults' do
8
+
8
9
  subject do
9
10
  super().tap do |o|
10
11
  o.finalize!
11
12
  end
12
13
  end
13
14
 
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 }
15
+ it :arubacloud_username do
16
+ subject.expect(:arubacloud_username).to be_nil
17
+ end
18
+ it :arubacloud_password do
19
+ subject.expect(:arubacloud_password).to be_nil
20
+ end
21
+ it :url do
22
+ subject.expect(:url).to be_nil
23
+ end
24
+ it :endpoint do
25
+ subject.expect(:endpoint).to be_nil
26
+ end
27
+ it :server_name do
28
+ subject.expect(:server_name).to be_nil
29
+ end
30
+ it :template_id do
31
+ subject.expect(:template_id).to be_nil
32
+ end
33
+ it :package_id do
34
+ subject.expect(:package_id).to be_nil
35
+ end
21
36
 
22
37
  describe 'overriding default' do
23
38
  [:arubacloud_username,
24
39
  :arubacloud_password,
25
40
  :url,
41
+ :endpoint,
26
42
  :server_name,
27
43
  :template_id,
28
- :package_id,
29
- :admin_password].each do |attribute|
44
+ :package_id].each do |attribute|
30
45
  it "should not default #{attribute} if overridden" do
31
46
  subject.send("#{attribute}=".to_sym, 'foo')
32
47
  subject.finalize!
33
- subject.send(attribute).should == 'foo'
48
+ subject.expect("#{attribute}").to eq('foo')
34
49
  end
35
50
  end
36
51
  end
37
52
 
53
+ subject do
54
+ super().tap do |o|
55
+ o.finalize!
56
+ end
57
+ end
58
+
38
59
  describe 'validation' do
39
60
  let(:machine) { double('machine') }
40
61
  let(:validation_errors) { subject.validate(machine)['ArubaCloud Provider'] }
@@ -42,16 +63,16 @@ describe VagrantPlugins::ArubaCloud::Config do
42
63
 
43
64
  # prepare the subject with all expected properties
44
65
  before(:each) do
45
- machine.stub_chain(:env, :root_path).and_return '/'
66
+ allow(machine).to receive_message_chain(:env, :root_path) { '/' }
67
+ allow(machine).to receive_message_chain("config.ssh.password") { "pussysecret" }
46
68
  subject.arubacloud_username = 'foo'
47
69
  subject.arubacloud_password = 'bar'
48
- subject.admin_password = 'foobar'
49
70
  subject.template_id = 1
50
- subject.package_id = 1
71
+ subject.package_id = 'small'
51
72
  subject.service_type = 1
52
73
  subject.cpu_number = 1
53
74
  subject.ram_qty = 1
54
- subject.hds = [{:type => 1, :size => 500}]
75
+ subject.hds = [{:type => 1, :size => 50}]
55
76
  end
56
77
 
57
78
  subject do
@@ -60,66 +81,50 @@ describe VagrantPlugins::ArubaCloud::Config do
60
81
  end
61
82
  end
62
83
 
84
+ context 'with good values' do
85
+ it "arubacloud_username" do
86
+ expect(validation_errors).to be_empty
87
+ end
88
+ end
89
+
63
90
  context 'with invalid key' do
64
91
  it 'should raise an error' do
65
92
  subject.nonsense1 = true
66
93
  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
94
+ expect(I18n).to receive(:t).with('vagrant.config.common.bad_field', { :fields => 'nonsense1, nonsense2' }).and_return error_message
95
+ validation_errors.first == error_message
78
96
  end
79
97
  end
80
98
 
81
99
  context 'the arubacloud_username' do
82
100
  it 'should error if not given' do
83
101
  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
102
+ expect(I18n).to receive(:t).with('vagrant_arubacloud.config.arubacloud_username_required').and_return :error_message
103
+ validation_errors.first == error_message
87
104
  end
88
105
  end
89
106
 
90
107
  context 'the arubacloud_password' do
91
108
  it 'should error if not given' do
92
109
  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
110
+ expect(I18n).to receive(:t).with('vagrant_arubacloud.config.arubacloud_password_required').and_return error_message
111
+ validation_errors.first == error_message
105
112
  end
106
113
  end
107
114
 
108
115
  context 'the template_id' do
109
116
  it 'should error if not given' do
110
117
  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
118
+ expect(I18n).to receive(:t).with('vagrant_arubacloud.config.template_id_required').and_return error_message
119
+ validation_errors.first == error_message
114
120
  end
115
121
  end
116
122
 
117
123
  context 'the service_type' do
118
124
  it 'should error if not given' do
119
125
  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
126
+ expect(I18n).to receive(:t).with('vagrant_arubacloud.config.service_type_required').and_return error_message
127
+ validation_errors.first == error_message
123
128
  end
124
129
  end
125
130
 
@@ -128,9 +133,8 @@ describe VagrantPlugins::ArubaCloud::Config do
128
133
  it 'should error if not given' do
129
134
  subject.package_id = nil
130
135
  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
136
+ expect(I18n).to receive(:t).with('vagrant_arubacloud.config.package_id_required').and_return error_message
137
+ validation_errors.first == error_message
134
138
  end
135
139
  end
136
140
  end
@@ -143,49 +147,38 @@ describe VagrantPlugins::ArubaCloud::Config do
143
147
  context 'the cpu_number' do
144
148
  it 'should error if not given' do
145
149
  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
150
+ expect(I18n).to receive(:t).with('vagrant_arubacloud.config.cpu_number_required').and_return error_message
151
+ validation_errors.first == error_message
149
152
  end
150
153
  end
151
154
  context 'the ram_qty' do
152
155
  it 'should error if not given' do
153
156
  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
+ expect(I18n).to receive(:t).with('vagrant_arubacloud.config.ram_qty_required').and_return error_message
158
+ validation_errors.first == error_message
157
159
  end
158
160
  end
159
161
  context 'the package_id' do
160
- it 'should valida if not given' do
162
+ it 'should valid if not given' do
161
163
  subject.package_id = nil
162
- validation_errors.should be_empty
164
+ expect(validation_errors).to be_empty
163
165
  end
164
166
  end
165
167
  context 'the hds configuration' do
166
168
  it 'should error if its not an array' do
167
169
  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
170
+ expect(I18n).to receive(:t).with('vagrant_arubacloud.config.hds_conf_must_be_array').and_return error_message
171
+ validation_errors.first == error_message
171
172
  end
172
173
  end
173
174
  context 'the hds configuration' do
174
175
  it 'should error if not given' do
175
176
  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
177
+ expect(I18n).to receive(:t).with('vagrant_arubacloud.config.hds_conf_required').and_return error_message
178
+ validation_errors.first == error_message
179
179
  end
180
180
  end
181
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
182
  end
190
183
  end
191
184
  end