vagrant-openstack-provider-illuin 0.11.1
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.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/.rubocop.yml +40 -0
- data/CHANGELOG.md +276 -0
- data/Gemfile +22 -0
- data/RELEASE.md +15 -0
- data/Rakefile +25 -0
- data/Vagrantfile +20 -0
- data/dummy.box +0 -0
- data/example_box/README.md +13 -0
- data/example_box/metadata.json +3 -0
- data/functional_tests/Vagrantfile +58 -0
- data/functional_tests/keys/vagrant-openstack +27 -0
- data/functional_tests/keys/vagrant-openstack.pub +1 -0
- data/functional_tests/run_tests.sh +142 -0
- data/lib/vagrant-openstack-provider.rb +29 -0
- data/lib/vagrant-openstack-provider/action.rb +344 -0
- data/lib/vagrant-openstack-provider/action/abstract_action.rb +22 -0
- data/lib/vagrant-openstack-provider/action/connect_openstack.rb +60 -0
- data/lib/vagrant-openstack-provider/action/create_server.rb +184 -0
- data/lib/vagrant-openstack-provider/action/create_stack.rb +76 -0
- data/lib/vagrant-openstack-provider/action/delete_server.rb +53 -0
- data/lib/vagrant-openstack-provider/action/delete_stack.rb +73 -0
- data/lib/vagrant-openstack-provider/action/message.rb +19 -0
- data/lib/vagrant-openstack-provider/action/provision.rb +60 -0
- data/lib/vagrant-openstack-provider/action/read_ssh_info.rb +74 -0
- data/lib/vagrant-openstack-provider/action/read_state.rb +43 -0
- data/lib/vagrant-openstack-provider/action/resume.rb +24 -0
- data/lib/vagrant-openstack-provider/action/snapshot_cleanup.rb +32 -0
- data/lib/vagrant-openstack-provider/action/snapshot_delete.rb +32 -0
- data/lib/vagrant-openstack-provider/action/snapshot_list.rb +22 -0
- data/lib/vagrant-openstack-provider/action/snapshot_restore.rb +29 -0
- data/lib/vagrant-openstack-provider/action/snapshot_save.rb +51 -0
- data/lib/vagrant-openstack-provider/action/start_server.rb +24 -0
- data/lib/vagrant-openstack-provider/action/stop_server.rb +25 -0
- data/lib/vagrant-openstack-provider/action/suspend.rb +24 -0
- data/lib/vagrant-openstack-provider/action/sync_folders.rb +138 -0
- data/lib/vagrant-openstack-provider/action/wait_active.rb +33 -0
- data/lib/vagrant-openstack-provider/action/wait_stop.rb +33 -0
- data/lib/vagrant-openstack-provider/cap/snapshot_list.rb +15 -0
- data/lib/vagrant-openstack-provider/catalog/openstack_catalog.rb +90 -0
- data/lib/vagrant-openstack-provider/client/cinder.rb +39 -0
- data/lib/vagrant-openstack-provider/client/domain.rb +163 -0
- data/lib/vagrant-openstack-provider/client/glance.rb +65 -0
- data/lib/vagrant-openstack-provider/client/heat.rb +49 -0
- data/lib/vagrant-openstack-provider/client/http_utils.rb +116 -0
- data/lib/vagrant-openstack-provider/client/keystone.rb +128 -0
- data/lib/vagrant-openstack-provider/client/neutron.rb +48 -0
- data/lib/vagrant-openstack-provider/client/nova.rb +303 -0
- data/lib/vagrant-openstack-provider/client/openstack.rb +59 -0
- data/lib/vagrant-openstack-provider/client/request_logger.rb +23 -0
- data/lib/vagrant-openstack-provider/client/rest_utils.rb +28 -0
- data/lib/vagrant-openstack-provider/command/abstract_command.rb +51 -0
- data/lib/vagrant-openstack-provider/command/flavor_list.rb +24 -0
- data/lib/vagrant-openstack-provider/command/floatingip_list.rb +32 -0
- data/lib/vagrant-openstack-provider/command/image_list.rb +29 -0
- data/lib/vagrant-openstack-provider/command/main.rb +52 -0
- data/lib/vagrant-openstack-provider/command/network_list.rb +25 -0
- data/lib/vagrant-openstack-provider/command/openstack_command.rb +16 -0
- data/lib/vagrant-openstack-provider/command/reset.rb +20 -0
- data/lib/vagrant-openstack-provider/command/subnet_list.rb +22 -0
- data/lib/vagrant-openstack-provider/command/utils.rb +22 -0
- data/lib/vagrant-openstack-provider/command/volume_list.rb +25 -0
- data/lib/vagrant-openstack-provider/config.rb +498 -0
- data/lib/vagrant-openstack-provider/config/http.rb +39 -0
- data/lib/vagrant-openstack-provider/config_resolver.rb +334 -0
- data/lib/vagrant-openstack-provider/errors.rb +187 -0
- data/lib/vagrant-openstack-provider/logging.rb +39 -0
- data/lib/vagrant-openstack-provider/plugin.rb +58 -0
- data/lib/vagrant-openstack-provider/provider.rb +50 -0
- data/lib/vagrant-openstack-provider/utils.rb +36 -0
- data/lib/vagrant-openstack-provider/version.rb +15 -0
- data/lib/vagrant-openstack-provider/version_checker.rb +76 -0
- data/locales/en.yml +412 -0
- data/spec/vagrant-openstack-provider/action/connect_openstack_spec.rb +770 -0
- data/spec/vagrant-openstack-provider/action/create_server_spec.rb +260 -0
- data/spec/vagrant-openstack-provider/action/create_stack_spec.rb +99 -0
- data/spec/vagrant-openstack-provider/action/delete_server_spec.rb +89 -0
- data/spec/vagrant-openstack-provider/action/delete_stack_spec.rb +63 -0
- data/spec/vagrant-openstack-provider/action/message_spec.rb +33 -0
- data/spec/vagrant-openstack-provider/action/provision_spec.rb +97 -0
- data/spec/vagrant-openstack-provider/action/read_ssh_info_spec.rb +201 -0
- data/spec/vagrant-openstack-provider/action/read_state_spec.rb +81 -0
- data/spec/vagrant-openstack-provider/action/resume_server_spec.rb +49 -0
- data/spec/vagrant-openstack-provider/action/start_server_spec.rb +49 -0
- data/spec/vagrant-openstack-provider/action/stop_server_spec.rb +49 -0
- data/spec/vagrant-openstack-provider/action/suspend_server_spec.rb +49 -0
- data/spec/vagrant-openstack-provider/action/sync_folders_spec.rb +155 -0
- data/spec/vagrant-openstack-provider/action/wait_active_spec.rb +53 -0
- data/spec/vagrant-openstack-provider/action/wait_stop_spec.rb +53 -0
- data/spec/vagrant-openstack-provider/action_spec.rb +120 -0
- data/spec/vagrant-openstack-provider/client/cinder_spec.rb +129 -0
- data/spec/vagrant-openstack-provider/client/glance_spec.rb +145 -0
- data/spec/vagrant-openstack-provider/client/heat_spec.rb +130 -0
- data/spec/vagrant-openstack-provider/client/keystone_spec.rb +226 -0
- data/spec/vagrant-openstack-provider/client/neutron_spec.rb +173 -0
- data/spec/vagrant-openstack-provider/client/nova_spec.rb +760 -0
- data/spec/vagrant-openstack-provider/client/utils_spec.rb +176 -0
- data/spec/vagrant-openstack-provider/command/flavor_list_spec.rb +43 -0
- data/spec/vagrant-openstack-provider/command/floatingip_list_spec.rb +74 -0
- data/spec/vagrant-openstack-provider/command/image_list_spec.rb +95 -0
- data/spec/vagrant-openstack-provider/command/network_list_spec.rb +65 -0
- data/spec/vagrant-openstack-provider/command/reset_spec.rb +24 -0
- data/spec/vagrant-openstack-provider/command/subnet_list_spec.rb +45 -0
- data/spec/vagrant-openstack-provider/command/volume_list_spec.rb +40 -0
- data/spec/vagrant-openstack-provider/config_resolver_spec.rb +879 -0
- data/spec/vagrant-openstack-provider/config_spec.rb +414 -0
- data/spec/vagrant-openstack-provider/e2e_spec.rb.save +27 -0
- data/spec/vagrant-openstack-provider/provider_spec.rb +13 -0
- data/spec/vagrant-openstack-provider/spec_helper.rb +37 -0
- data/spec/vagrant-openstack-provider/utils_spec.rb +128 -0
- data/spec/vagrant-openstack-provider/version_checker_spec.rb +39 -0
- data/stackrc +25 -0
- data/vagrant-openstack-provider-illuin.gemspec +34 -0
- metadata +362 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
require 'vagrant-openstack-provider/spec_helper'
|
|
2
|
+
|
|
3
|
+
describe VagrantPlugins::Openstack::Action::StartServer do
|
|
4
|
+
let(:nova) do
|
|
5
|
+
double('nova').tap do |nova|
|
|
6
|
+
nova.stub(:start_server)
|
|
7
|
+
end
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
let(:env) do
|
|
11
|
+
{}.tap do |env|
|
|
12
|
+
env[:ui] = double('ui').tap do |ui|
|
|
13
|
+
ui.stub(:info).with(anything)
|
|
14
|
+
ui.stub(:error).with(anything)
|
|
15
|
+
end
|
|
16
|
+
env[:openstack_client] = double('openstack_client').tap do |os|
|
|
17
|
+
os.stub(:nova) { nova }
|
|
18
|
+
end
|
|
19
|
+
env[:machine] = OpenStruct.new
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
let(:app) do
|
|
24
|
+
double('app').tap do |app|
|
|
25
|
+
app.stub(:call).with(anything)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
describe 'call' do
|
|
30
|
+
context 'when server id is present' do
|
|
31
|
+
it 'starts the server' do
|
|
32
|
+
env[:machine].id = 'server_id'
|
|
33
|
+
expect(nova).to receive(:start_server).with(env, 'server_id')
|
|
34
|
+
expect(app).to receive(:call)
|
|
35
|
+
@action = StartServer.new(app, nil)
|
|
36
|
+
@action.call(env)
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
context 'when server id is not present' do
|
|
40
|
+
it 'does nothing' do
|
|
41
|
+
env[:machine].id = nil
|
|
42
|
+
expect(nova).to_not receive(:start_server)
|
|
43
|
+
expect(app).to receive(:call)
|
|
44
|
+
@action = StartServer.new(app, nil)
|
|
45
|
+
@action.call(env)
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
require 'vagrant-openstack-provider/spec_helper'
|
|
2
|
+
|
|
3
|
+
describe VagrantPlugins::Openstack::Action::StopServer do
|
|
4
|
+
let(:nova) do
|
|
5
|
+
double('nova').tap do |nova|
|
|
6
|
+
nova.stub(:stop_server)
|
|
7
|
+
end
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
let(:env) do
|
|
11
|
+
{}.tap do |env|
|
|
12
|
+
env[:ui] = double('ui').tap do |ui|
|
|
13
|
+
ui.stub(:info).with(anything)
|
|
14
|
+
ui.stub(:error).with(anything)
|
|
15
|
+
end
|
|
16
|
+
env[:openstack_client] = double('openstack_client').tap do |os|
|
|
17
|
+
os.stub(:nova) { nova }
|
|
18
|
+
end
|
|
19
|
+
env[:machine] = OpenStruct.new
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
let(:app) do
|
|
24
|
+
double('app').tap do |app|
|
|
25
|
+
app.stub(:call).with(anything)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
describe 'call' do
|
|
30
|
+
context 'when server id is present' do
|
|
31
|
+
it 'stops the server' do
|
|
32
|
+
env[:machine].id = 'server_id'
|
|
33
|
+
expect(nova).to receive(:stop_server).with(env, 'server_id')
|
|
34
|
+
expect(app).to receive(:call)
|
|
35
|
+
@action = StopServer.new(app, nil)
|
|
36
|
+
@action.call(env)
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
context 'when server id is not present' do
|
|
40
|
+
it 'does nothing' do
|
|
41
|
+
env[:machine].id = nil
|
|
42
|
+
expect(nova).to_not receive(:stop_server)
|
|
43
|
+
expect(app).to receive(:call)
|
|
44
|
+
@action = StopServer.new(app, nil)
|
|
45
|
+
@action.call(env)
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
require 'vagrant-openstack-provider/spec_helper'
|
|
2
|
+
|
|
3
|
+
describe VagrantPlugins::Openstack::Action::Suspend do
|
|
4
|
+
let(:nova) do
|
|
5
|
+
double('nova').tap do |nova|
|
|
6
|
+
nova.stub(:suspend_server)
|
|
7
|
+
end
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
let(:env) do
|
|
11
|
+
{}.tap do |env|
|
|
12
|
+
env[:ui] = double('ui').tap do |ui|
|
|
13
|
+
ui.stub(:info).with(anything)
|
|
14
|
+
ui.stub(:error).with(anything)
|
|
15
|
+
end
|
|
16
|
+
env[:openstack_client] = double('openstack_client').tap do |os|
|
|
17
|
+
os.stub(:nova) { nova }
|
|
18
|
+
end
|
|
19
|
+
env[:machine] = OpenStruct.new
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
let(:app) do
|
|
24
|
+
double('app').tap do |app|
|
|
25
|
+
app.stub(:call).with(anything)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
describe 'call' do
|
|
30
|
+
context 'when server id is present' do
|
|
31
|
+
it 'starts the server' do
|
|
32
|
+
env[:machine].id = 'server_id'
|
|
33
|
+
expect(nova).to receive(:suspend_server).with(env, 'server_id')
|
|
34
|
+
expect(app).to receive(:call)
|
|
35
|
+
@action = Suspend.new(app, nil)
|
|
36
|
+
@action.call(env)
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
context 'when server id is not present' do
|
|
40
|
+
it 'does nothing' do
|
|
41
|
+
env[:machine].id = nil
|
|
42
|
+
expect(nova).to_not receive(:suspend_server)
|
|
43
|
+
expect(app).to receive(:call)
|
|
44
|
+
@action = Suspend.new(app, nil)
|
|
45
|
+
@action.call(env)
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
require 'vagrant-openstack-provider/spec_helper'
|
|
2
|
+
require 'log4r'
|
|
3
|
+
require 'rbconfig'
|
|
4
|
+
require 'vagrant/util/subprocess'
|
|
5
|
+
|
|
6
|
+
include VagrantPlugins::Openstack::Action
|
|
7
|
+
|
|
8
|
+
describe VagrantPlugins::Openstack::Action::SyncFolders do
|
|
9
|
+
let(:app) do
|
|
10
|
+
double('app').tap do |app|
|
|
11
|
+
app.stub(:call).with(anything)
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
let(:vm) do
|
|
16
|
+
double('vm').tap do |vm|
|
|
17
|
+
vm.stub(:synced_folders) { { '/vagrant' => { hostpath: '/home/john/vagrant', guestpath: '/vagrant' } } }
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
let(:provider_config) do
|
|
22
|
+
double('provider_config').tap do |c|
|
|
23
|
+
c.stub(:rsync_includes) { nil }
|
|
24
|
+
c.stub(:ssh_disabled) { false }
|
|
25
|
+
c.stub(:rsync_ignore_files) { ['.gitignore'] }
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
let(:communicate) do
|
|
30
|
+
double('communicate').tap do |c|
|
|
31
|
+
c.stub(:sudo)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
let(:env) do
|
|
36
|
+
{}.tap do |env|
|
|
37
|
+
env[:ui] = double('ui').tap do |ui|
|
|
38
|
+
ui.stub(:info).with(anything)
|
|
39
|
+
ui.stub(:error).with(anything)
|
|
40
|
+
end
|
|
41
|
+
env[:openstack_client] = double('openstack_client').tap do |os|
|
|
42
|
+
os.stub(:nova) { nova }
|
|
43
|
+
end
|
|
44
|
+
env[:machine] = OpenStruct.new.tap do |m|
|
|
45
|
+
m.ssh_info = {
|
|
46
|
+
username: 'user',
|
|
47
|
+
port: '23',
|
|
48
|
+
host: '1.2.3.4',
|
|
49
|
+
private_key_path: '/tmp/key.pem'
|
|
50
|
+
}
|
|
51
|
+
m.provider_config = provider_config
|
|
52
|
+
m.config = double('config').tap do |c|
|
|
53
|
+
c.stub(:vm) { vm }
|
|
54
|
+
end
|
|
55
|
+
m.communicate = communicate
|
|
56
|
+
end
|
|
57
|
+
env[:root_path] = '.'
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
before :each do
|
|
62
|
+
@action = SyncFolders.new(app, nil)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
describe 'call' do
|
|
66
|
+
context 'sync method is set to none and ssh_disabled is false' do
|
|
67
|
+
it 'does not sync folders' do
|
|
68
|
+
Vagrant::Util::Subprocess.stub(:execute)
|
|
69
|
+
provider_config.stub(:sync_method) { 'none' }
|
|
70
|
+
provider_config.stub(:ssh_disabled) { false }
|
|
71
|
+
expect(Vagrant::Util::Subprocess).to_not receive :execute
|
|
72
|
+
@action.call(env)
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
context 'sync method is set to none and ssh_disabled is true' do
|
|
76
|
+
it 'does not sync folders' do
|
|
77
|
+
Vagrant::Util::Subprocess.stub(:execute)
|
|
78
|
+
provider_config.stub(:sync_method) { 'none' }
|
|
79
|
+
provider_config.stub(:ssh_disabled) { true }
|
|
80
|
+
expect(Vagrant::Util::Subprocess).to_not receive :execute
|
|
81
|
+
@action.call(env)
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
context 'sync method is set to rsync and ssh_disabled is true' do
|
|
85
|
+
it 'does not sync folders' do
|
|
86
|
+
Vagrant::Util::Subprocess.stub(:execute)
|
|
87
|
+
provider_config.stub(:sync_method) { 'rsync' }
|
|
88
|
+
provider_config.stub(:ssh_disabled) { true }
|
|
89
|
+
expect(Vagrant::Util::Subprocess).to_not receive :execute
|
|
90
|
+
@action.call(env)
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
context 'sync method is set to rsync and ssh_disabled is false' do
|
|
94
|
+
it 'runs a rsync command' do
|
|
95
|
+
provider_config.stub(:sync_method) { 'rsync' }
|
|
96
|
+
Vagrant::Util::Subprocess.stub(:execute) do
|
|
97
|
+
OpenStruct.new.tap do |r|
|
|
98
|
+
r.exit_code = 0
|
|
99
|
+
r.stderr = nil
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
expected_command = ['rsync',
|
|
103
|
+
'--verbose',
|
|
104
|
+
'--archive',
|
|
105
|
+
'-z',
|
|
106
|
+
'--cvs-exclude',
|
|
107
|
+
'--exclude',
|
|
108
|
+
'.hg/',
|
|
109
|
+
'--exclude',
|
|
110
|
+
'.git/',
|
|
111
|
+
'--chmod',
|
|
112
|
+
'ugo=rwX',
|
|
113
|
+
'-e',
|
|
114
|
+
"ssh -p 23 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o IdentitiesOnly=yes -i '/tmp/key.pem' ",
|
|
115
|
+
'/home/john/vagrant/',
|
|
116
|
+
'user@1.2.3.4:/vagrant',
|
|
117
|
+
'--exclude-from',
|
|
118
|
+
'./.gitignore']
|
|
119
|
+
expect(communicate).to receive(:sudo).with "mkdir -p '/vagrant'"
|
|
120
|
+
expect(communicate).to receive(:sudo).with "chown -R user '/vagrant'"
|
|
121
|
+
expect(Vagrant::Util::Subprocess).to receive(:execute).with(*expected_command)
|
|
122
|
+
@action.call(env)
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
context 'rsync command returns a non zero status code' do
|
|
126
|
+
it 'raise an error' do
|
|
127
|
+
provider_config.stub(:sync_method) { 'rsync' }
|
|
128
|
+
Vagrant::Util::Subprocess.stub(:execute) do
|
|
129
|
+
OpenStruct.new.tap do |r|
|
|
130
|
+
r.exit_code = 1
|
|
131
|
+
r.stderr = 'Fatal error'
|
|
132
|
+
end
|
|
133
|
+
end
|
|
134
|
+
expect(Vagrant::Util::Subprocess).to receive(:execute)
|
|
135
|
+
expect { @action.call(env) }.to raise_error Errors::RsyncError
|
|
136
|
+
end
|
|
137
|
+
end
|
|
138
|
+
context 'sync method value is not valid' do
|
|
139
|
+
it 'raise an error' do
|
|
140
|
+
provider_config.stub(:sync_method) { 'nfs' }
|
|
141
|
+
expect { @action.call(env) }.to raise_error Errors::SyncMethodError
|
|
142
|
+
end
|
|
143
|
+
end
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
describe 'convert_path_to_windows_format' do
|
|
147
|
+
context 'hostpath in starting with C:/ ' do
|
|
148
|
+
it 'returns hostpath starting with /cygdrive/c/ and in downcase' do
|
|
149
|
+
RsyncFolders.send(:public, *RsyncFolders.private_instance_methods)
|
|
150
|
+
action = RsyncFolders.new(app, nil)
|
|
151
|
+
expect(action.add_cygdrive_prefix_to_path('C:/Directory')).to eq '/cygdrive/c/directory'
|
|
152
|
+
end
|
|
153
|
+
end
|
|
154
|
+
end
|
|
155
|
+
end
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
require 'vagrant-openstack-provider/spec_helper'
|
|
2
|
+
|
|
3
|
+
describe VagrantPlugins::Openstack::Action::WaitForServerToBeActive do
|
|
4
|
+
let(:nova) do
|
|
5
|
+
double('nova')
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
let(:config) do
|
|
9
|
+
double('config')
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
let(:env) do
|
|
13
|
+
{}.tap do |env|
|
|
14
|
+
env[:ui] = double('ui').tap do |ui|
|
|
15
|
+
ui.stub(:info).with(anything)
|
|
16
|
+
ui.stub(:error).with(anything)
|
|
17
|
+
end
|
|
18
|
+
env[:openstack_client] = double('openstack_client').tap do |os|
|
|
19
|
+
os.stub(:nova) { nova }
|
|
20
|
+
end
|
|
21
|
+
env[:machine] = OpenStruct.new.tap do |m|
|
|
22
|
+
m.provider_config = config
|
|
23
|
+
m.id = 'server_id'
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
let(:app) do
|
|
29
|
+
double('app').tap do |app|
|
|
30
|
+
app.stub(:call).with(anything)
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
describe 'call' do
|
|
35
|
+
context 'when server is not yet active' do
|
|
36
|
+
it 'become active after one retry' do
|
|
37
|
+
nova.stub(:get_server_details).and_return({ 'status' => 'BUILD' }, 'status' => 'ACTIVE')
|
|
38
|
+
expect(nova).to receive(:get_server_details).with(env, 'server_id').exactly(2).times
|
|
39
|
+
expect(app).to receive(:call)
|
|
40
|
+
config.stub(:server_active_timeout) { 5 }
|
|
41
|
+
@action = WaitForServerToBeActive.new(app, nil, 1)
|
|
42
|
+
@action.call(env)
|
|
43
|
+
end
|
|
44
|
+
it 'timeout after one retry' do
|
|
45
|
+
nova.stub(:get_server_details).and_return({ 'status' => 'BUILD' }, 'status' => 'BUILD')
|
|
46
|
+
expect(nova).to receive(:get_server_details).with(env, 'server_id').at_least(2).times
|
|
47
|
+
config.stub(:server_active_timeout) { 2 }
|
|
48
|
+
@action = WaitForServerToBeActive.new(app, nil, 1)
|
|
49
|
+
expect { @action.call(env) }.to raise_error Errors::Timeout
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
require 'vagrant-openstack-provider/spec_helper'
|
|
2
|
+
|
|
3
|
+
describe VagrantPlugins::Openstack::Action::WaitForServerToStop do
|
|
4
|
+
let(:nova) do
|
|
5
|
+
double('nova')
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
let(:config) do
|
|
9
|
+
double('config')
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
let(:env) do
|
|
13
|
+
{}.tap do |env|
|
|
14
|
+
env[:ui] = double('ui').tap do |ui|
|
|
15
|
+
ui.stub(:info).with(anything)
|
|
16
|
+
ui.stub(:error).with(anything)
|
|
17
|
+
end
|
|
18
|
+
env[:openstack_client] = double('openstack_client').tap do |os|
|
|
19
|
+
os.stub(:nova) { nova }
|
|
20
|
+
end
|
|
21
|
+
env[:machine] = OpenStruct.new.tap do |m|
|
|
22
|
+
m.provider_config = config
|
|
23
|
+
m.id = 'server_id'
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
let(:app) do
|
|
29
|
+
double('app').tap do |app|
|
|
30
|
+
app.stub(:call).with(anything)
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
describe 'call' do
|
|
35
|
+
context 'when server is active' do
|
|
36
|
+
it 'become shutoff after one retry' do
|
|
37
|
+
nova.stub(:get_server_details).and_return({ 'status' => 'ACTIVE' }, 'status' => 'SHUTOFF')
|
|
38
|
+
expect(nova).to receive(:get_server_details).with(env, 'server_id').exactly(2).times
|
|
39
|
+
expect(app).to receive(:call)
|
|
40
|
+
config.stub(:server_stop_timeout) { 5 }
|
|
41
|
+
@action = WaitForServerToStop.new(app, nil, 1)
|
|
42
|
+
@action.call(env)
|
|
43
|
+
end
|
|
44
|
+
it 'timeout after one retry' do
|
|
45
|
+
nova.stub(:get_server_details).and_return({ 'status' => 'ACTIVE' }, 'status' => 'ACTIVE')
|
|
46
|
+
expect(nova).to receive(:get_server_details).with(env, 'server_id').at_least(2).times
|
|
47
|
+
config.stub(:server_stop_timeout) { 2 }
|
|
48
|
+
@action = WaitForServerToStop.new(app, nil, 1)
|
|
49
|
+
expect { @action.call(env) }.to raise_error Errors::Timeout
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
require 'vagrant-openstack-provider/spec_helper'
|
|
2
|
+
|
|
3
|
+
describe VagrantPlugins::Openstack::Action do
|
|
4
|
+
let(:builder) do
|
|
5
|
+
double('builder').tap do |builder|
|
|
6
|
+
builder.stub(:use)
|
|
7
|
+
end
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
before :each do
|
|
11
|
+
Action.stub(:new_builder) { builder }
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
describe 'action_destroy' do
|
|
15
|
+
it 'add others middleware to builder' do
|
|
16
|
+
expect(builder).to receive(:use).with(ConfigValidate)
|
|
17
|
+
expect(builder).to receive(:use).with(ConnectOpenstack)
|
|
18
|
+
expect(builder).to receive(:use).with(Call, ReadState)
|
|
19
|
+
# TODO, Impove this test to check what's happen after ReadState
|
|
20
|
+
Action.action_destroy
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
describe 'action_provision' do
|
|
25
|
+
it 'add others middleware to builder' do
|
|
26
|
+
expect(builder).to receive(:use).with(ConfigValidate)
|
|
27
|
+
expect(builder).to receive(:use).with(ConnectOpenstack)
|
|
28
|
+
expect(builder).to receive(:use).with(Call, ReadState)
|
|
29
|
+
# TODO, Impove this test to check what's happen after ReadState
|
|
30
|
+
Action.action_provision
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
describe 'action_read_ssh_info' do
|
|
35
|
+
it 'add others middleware to builder' do
|
|
36
|
+
expect(builder).to receive(:use).with(ConfigValidate)
|
|
37
|
+
expect(builder).to receive(:use).with(ConnectOpenstack)
|
|
38
|
+
expect(builder).to receive(:use).with(ReadSSHInfo)
|
|
39
|
+
Action.action_read_ssh_info
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
describe 'action_read_state' do
|
|
44
|
+
it 'add others middleware to builder' do
|
|
45
|
+
expect(builder).to receive(:use).with(ConfigValidate)
|
|
46
|
+
expect(builder).to receive(:use).with(ConnectOpenstack)
|
|
47
|
+
expect(builder).to receive(:use).with(ReadState)
|
|
48
|
+
Action.action_read_state
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
describe 'action_ssh' do
|
|
53
|
+
it 'add others middleware to builder' do
|
|
54
|
+
expect(builder).to receive(:use).with(ConfigValidate)
|
|
55
|
+
expect(builder).to receive(:use).with(ConnectOpenstack)
|
|
56
|
+
expect(builder).to receive(:use).with(Call, ReadState)
|
|
57
|
+
Action.action_ssh
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
describe 'action_ssh_run' do
|
|
62
|
+
it 'add others middleware to builder' do
|
|
63
|
+
expect(builder).to receive(:use).with(ConfigValidate)
|
|
64
|
+
expect(builder).to receive(:use).with(ConnectOpenstack)
|
|
65
|
+
expect(builder).to receive(:use).with(Call, ReadState)
|
|
66
|
+
# TODO, Impove this test to check what's happen after ReadState
|
|
67
|
+
Action.action_ssh_run
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
describe 'action_up' do
|
|
72
|
+
it 'add others middleware to builder' do
|
|
73
|
+
expect(builder).to receive(:use).with(ConfigValidate)
|
|
74
|
+
expect(builder).to receive(:use).with(ConnectOpenstack)
|
|
75
|
+
expect(builder).to receive(:use).with(Call, ReadState)
|
|
76
|
+
# TODO, Impove this test to check what's happen after ReadState
|
|
77
|
+
Action.action_up
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
describe 'action_halt' do
|
|
82
|
+
it 'add others middleware to builder' do
|
|
83
|
+
expect(builder).to receive(:use).with(ConfigValidate)
|
|
84
|
+
expect(builder).to receive(:use).with(ConnectOpenstack)
|
|
85
|
+
expect(builder).to receive(:use).with(Call, ReadState)
|
|
86
|
+
# TODO, Impove this test to check what's happen after ReadState
|
|
87
|
+
Action.action_halt
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
describe 'action_suspend' do
|
|
92
|
+
it 'add others middleware to builder' do
|
|
93
|
+
expect(builder).to receive(:use).with(ConfigValidate)
|
|
94
|
+
expect(builder).to receive(:use).with(ConnectOpenstack)
|
|
95
|
+
expect(builder).to receive(:use).with(Call, ReadState)
|
|
96
|
+
# TODO, Impove this test to check what's happen after ReadState
|
|
97
|
+
Action.action_suspend
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
describe 'action_resume' do
|
|
102
|
+
it 'add others middleware to builder' do
|
|
103
|
+
expect(builder).to receive(:use).with(ConfigValidate)
|
|
104
|
+
expect(builder).to receive(:use).with(ConnectOpenstack)
|
|
105
|
+
expect(builder).to receive(:use).with(Call, ReadState)
|
|
106
|
+
# TODO, Impove this test to check what's happen after ReadState
|
|
107
|
+
Action.action_resume
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
describe 'action_reload' do
|
|
112
|
+
it 'add others middleware to builder' do
|
|
113
|
+
expect(builder).to receive(:use).with(ConfigValidate)
|
|
114
|
+
expect(builder).to receive(:use).with(ConnectOpenstack)
|
|
115
|
+
expect(builder).to receive(:use).with(Call, ReadState)
|
|
116
|
+
# TODO, Impove this test to check what's happen after ReadState
|
|
117
|
+
Action.action_reload
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
end
|