vagrant-conoha 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.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/.rubocop.yml +35 -0
- data/CHANGELOG.md +3 -0
- data/Gemfile +19 -0
- data/LICENSE +23 -0
- data/Rakefile +25 -0
- data/Vagrantfile +71 -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-conoha.rb +29 -0
- data/lib/vagrant-conoha/action.rb +227 -0
- data/lib/vagrant-conoha/action/abstract_action.rb +22 -0
- data/lib/vagrant-conoha/action/connect_openstack.rb +60 -0
- data/lib/vagrant-conoha/action/create_server.rb +154 -0
- data/lib/vagrant-conoha/action/create_stack.rb +68 -0
- data/lib/vagrant-conoha/action/delete_server.rb +53 -0
- data/lib/vagrant-conoha/action/delete_stack.rb +73 -0
- data/lib/vagrant-conoha/action/message.rb +19 -0
- data/lib/vagrant-conoha/action/provision.rb +60 -0
- data/lib/vagrant-conoha/action/read_ssh_info.rb +72 -0
- data/lib/vagrant-conoha/action/read_state.rb +43 -0
- data/lib/vagrant-conoha/action/resume.rb +24 -0
- data/lib/vagrant-conoha/action/start_server.rb +24 -0
- data/lib/vagrant-conoha/action/stop_server.rb +25 -0
- data/lib/vagrant-conoha/action/suspend.rb +24 -0
- data/lib/vagrant-conoha/action/sync_folders.rb +129 -0
- data/lib/vagrant-conoha/action/wait_accessible.rb +61 -0
- data/lib/vagrant-conoha/action/wait_active.rb +33 -0
- data/lib/vagrant-conoha/action/wait_stop.rb +33 -0
- data/lib/vagrant-conoha/catalog/openstack_catalog.rb +67 -0
- data/lib/vagrant-conoha/client/cinder.rb +39 -0
- data/lib/vagrant-conoha/client/domain.rb +159 -0
- data/lib/vagrant-conoha/client/glance.rb +65 -0
- data/lib/vagrant-conoha/client/heat.rb +49 -0
- data/lib/vagrant-conoha/client/http_utils.rb +116 -0
- data/lib/vagrant-conoha/client/keystone.rb +77 -0
- data/lib/vagrant-conoha/client/neutron.rb +48 -0
- data/lib/vagrant-conoha/client/nova.rb +212 -0
- data/lib/vagrant-conoha/client/openstack.rb +59 -0
- data/lib/vagrant-conoha/client/request_logger.rb +23 -0
- data/lib/vagrant-conoha/client/rest_utils.rb +25 -0
- data/lib/vagrant-conoha/command/abstract_command.rb +51 -0
- data/lib/vagrant-conoha/command/flavor_list.rb +24 -0
- data/lib/vagrant-conoha/command/image_list.rb +29 -0
- data/lib/vagrant-conoha/command/main.rb +51 -0
- data/lib/vagrant-conoha/command/network_list.rb +25 -0
- data/lib/vagrant-conoha/command/openstack_command.rb +16 -0
- data/lib/vagrant-conoha/command/reset.rb +20 -0
- data/lib/vagrant-conoha/command/subnet_list.rb +22 -0
- data/lib/vagrant-conoha/command/utils.rb +22 -0
- data/lib/vagrant-conoha/command/volume_list.rb +25 -0
- data/lib/vagrant-conoha/config.rb +390 -0
- data/lib/vagrant-conoha/config/http.rb +39 -0
- data/lib/vagrant-conoha/config_resolver.rb +285 -0
- data/lib/vagrant-conoha/errors.rb +187 -0
- data/lib/vagrant-conoha/logging.rb +39 -0
- data/lib/vagrant-conoha/plugin.rb +48 -0
- data/lib/vagrant-conoha/provider.rb +50 -0
- data/lib/vagrant-conoha/utils.rb +26 -0
- data/lib/vagrant-conoha/version.rb +15 -0
- data/lib/vagrant-conoha/version_checker.rb +76 -0
- data/locales/en.yml +393 -0
- data/spec/vagrant-conoha/action/connect_openstack_spec.rb +695 -0
- data/spec/vagrant-conoha/action/create_server_spec.rb +225 -0
- data/spec/vagrant-conoha/action/create_stack_spec.rb +99 -0
- data/spec/vagrant-conoha/action/delete_server_spec.rb +89 -0
- data/spec/vagrant-conoha/action/delete_stack_spec.rb +63 -0
- data/spec/vagrant-conoha/action/message_spec.rb +33 -0
- data/spec/vagrant-conoha/action/provision_spec.rb +104 -0
- data/spec/vagrant-conoha/action/read_ssh_info_spec.rb +190 -0
- data/spec/vagrant-conoha/action/read_state_spec.rb +81 -0
- data/spec/vagrant-conoha/action/resume_server_spec.rb +49 -0
- data/spec/vagrant-conoha/action/start_server_spec.rb +49 -0
- data/spec/vagrant-conoha/action/stop_server_spec.rb +49 -0
- data/spec/vagrant-conoha/action/suspend_server_spec.rb +49 -0
- data/spec/vagrant-conoha/action/sync_folders_spec.rb +155 -0
- data/spec/vagrant-conoha/action/wait_accessible_spec.rb +67 -0
- data/spec/vagrant-conoha/action/wait_active_spec.rb +53 -0
- data/spec/vagrant-conoha/action/wait_stop_spec.rb +53 -0
- data/spec/vagrant-conoha/action_spec.rb +120 -0
- data/spec/vagrant-conoha/client/cinder_spec.rb +127 -0
- data/spec/vagrant-conoha/client/glance_spec.rb +143 -0
- data/spec/vagrant-conoha/client/heat_spec.rb +128 -0
- data/spec/vagrant-conoha/client/keystone_spec.rb +150 -0
- data/spec/vagrant-conoha/client/neutron_spec.rb +171 -0
- data/spec/vagrant-conoha/client/nova_spec.rb +757 -0
- data/spec/vagrant-conoha/client/utils_spec.rb +176 -0
- data/spec/vagrant-conoha/command/flavor_list_spec.rb +43 -0
- data/spec/vagrant-conoha/command/image_list_spec.rb +95 -0
- data/spec/vagrant-conoha/command/network_list_spec.rb +65 -0
- data/spec/vagrant-conoha/command/reset_spec.rb +24 -0
- data/spec/vagrant-conoha/command/subnet_list_spec.rb +45 -0
- data/spec/vagrant-conoha/command/volume_list_spec.rb +40 -0
- data/spec/vagrant-conoha/config_resolver_spec.rb +860 -0
- data/spec/vagrant-conoha/config_spec.rb +373 -0
- data/spec/vagrant-conoha/e2e_spec.rb.save +27 -0
- data/spec/vagrant-conoha/provider_spec.rb +13 -0
- data/spec/vagrant-conoha/spec_helper.rb +37 -0
- data/spec/vagrant-conoha/utils_spec.rb +129 -0
- data/spec/vagrant-conoha/version_checker_spec.rb +39 -0
- data/stackrc +25 -0
- data/vagrant-conoha.gemspec +32 -0
- metadata +343 -0
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
require 'vagrant-conoha/spec_helper'
|
|
2
|
+
|
|
3
|
+
describe VagrantPlugins::ConoHa::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
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
require 'vagrant-conoha/spec_helper'
|
|
2
|
+
|
|
3
|
+
describe VagrantPlugins::ConoHa::CinderClient do
|
|
4
|
+
let(:http) do
|
|
5
|
+
double('http').tap do |http|
|
|
6
|
+
http.stub(:read_timeout) { 42 }
|
|
7
|
+
http.stub(:open_timeout) { 43 }
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
let(:config) do
|
|
12
|
+
double('config').tap do |config|
|
|
13
|
+
config.stub(:http) { http }
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
let(:env) do
|
|
18
|
+
{}.tap do |env|
|
|
19
|
+
env[:machine] = double('machine')
|
|
20
|
+
env[:machine].stub(:provider_config) { config }
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
let(:session) do
|
|
25
|
+
VagrantPlugins::ConoHa.session
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
before :each do
|
|
29
|
+
session.token = '123456'
|
|
30
|
+
session.project_id = 'a1b2c3'
|
|
31
|
+
session.endpoints = { volumev2: 'http://cinder' }
|
|
32
|
+
@cinder_client = VagrantPlugins::ConoHa.cinder
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
describe 'get_all_volumes' do
|
|
36
|
+
context 'on api v1' do
|
|
37
|
+
it 'returns volumes with details' do
|
|
38
|
+
stub_request(:get, 'http://cinder/volumes/detail')
|
|
39
|
+
.with(
|
|
40
|
+
headers:
|
|
41
|
+
{
|
|
42
|
+
'Accept' => 'application/json',
|
|
43
|
+
'X-Auth-Token' => '123456'
|
|
44
|
+
})
|
|
45
|
+
.to_return(
|
|
46
|
+
status: 200,
|
|
47
|
+
body: '
|
|
48
|
+
{
|
|
49
|
+
"volumes": [
|
|
50
|
+
{
|
|
51
|
+
"id": "987",
|
|
52
|
+
"display_name": "vol-01",
|
|
53
|
+
"size": "2",
|
|
54
|
+
"status": "available",
|
|
55
|
+
"bootable": "true",
|
|
56
|
+
"attachments": []
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"id": "654",
|
|
60
|
+
"display_name": "vol-02",
|
|
61
|
+
"size": "4",
|
|
62
|
+
"status": "in-use",
|
|
63
|
+
"bootable": "false",
|
|
64
|
+
"attachments": [
|
|
65
|
+
{
|
|
66
|
+
"server_id": "inst-01",
|
|
67
|
+
"device": "/dev/vdc"
|
|
68
|
+
}
|
|
69
|
+
]
|
|
70
|
+
}
|
|
71
|
+
]
|
|
72
|
+
}
|
|
73
|
+
')
|
|
74
|
+
|
|
75
|
+
volumes = @cinder_client.get_all_volumes(env)
|
|
76
|
+
|
|
77
|
+
expect(volumes).to eq [Volume.new('987', 'vol-01', '2', 'available', 'true', nil, nil),
|
|
78
|
+
Volume.new('654', 'vol-02', '4', 'in-use', 'false', 'inst-01', '/dev/vdc')]
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
context 'on api v2' do
|
|
83
|
+
it 'returns volumes with details' do
|
|
84
|
+
stub_request(:get, 'http://cinder/volumes/detail')
|
|
85
|
+
.with(
|
|
86
|
+
headers:
|
|
87
|
+
{
|
|
88
|
+
'Accept' => 'application/json',
|
|
89
|
+
'X-Auth-Token' => '123456'
|
|
90
|
+
})
|
|
91
|
+
.to_return(
|
|
92
|
+
status: 200,
|
|
93
|
+
body: '
|
|
94
|
+
{
|
|
95
|
+
"volumes": [
|
|
96
|
+
{
|
|
97
|
+
"id": "987",
|
|
98
|
+
"name": "vol-01",
|
|
99
|
+
"size": "2",
|
|
100
|
+
"status": "available",
|
|
101
|
+
"bootable": "true",
|
|
102
|
+
"attachments": []
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
"id": "654",
|
|
106
|
+
"name": "vol-02",
|
|
107
|
+
"size": "4",
|
|
108
|
+
"status": "in-use",
|
|
109
|
+
"bootable": "false",
|
|
110
|
+
"attachments": [
|
|
111
|
+
{
|
|
112
|
+
"server_id": "inst-01",
|
|
113
|
+
"device": "/dev/vdc"
|
|
114
|
+
}
|
|
115
|
+
]
|
|
116
|
+
}
|
|
117
|
+
]
|
|
118
|
+
}')
|
|
119
|
+
|
|
120
|
+
volumes = @cinder_client.get_all_volumes(env)
|
|
121
|
+
|
|
122
|
+
expect(volumes).to eq [Volume.new('987', 'vol-01', '2', 'available', 'true', nil, nil),
|
|
123
|
+
Volume.new('654', 'vol-02', '4', 'in-use', 'false', 'inst-01', '/dev/vdc')]
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
end
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
require 'vagrant-conoha/spec_helper'
|
|
2
|
+
|
|
3
|
+
describe VagrantPlugins::ConoHa::GlanceClient do
|
|
4
|
+
let(:http) do
|
|
5
|
+
double('http').tap do |http|
|
|
6
|
+
http.stub(:read_timeout) { 42 }
|
|
7
|
+
http.stub(:open_timeout) { 43 }
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
let(:config) do
|
|
12
|
+
double('config').tap do |config|
|
|
13
|
+
config.stub(:http) { http }
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
let(:env) do
|
|
18
|
+
{}.tap do |env|
|
|
19
|
+
env[:machine] = double('machine')
|
|
20
|
+
env[:machine].stub(:provider_config) { config }
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
let(:session) do
|
|
25
|
+
VagrantPlugins::ConoHa.session
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
before :each do
|
|
29
|
+
session.token = '123456'
|
|
30
|
+
session.project_id = 'a1b2c3'
|
|
31
|
+
session.endpoints = { image: 'http://glance' }
|
|
32
|
+
@glance_client = VagrantPlugins::ConoHa.glance
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
describe 'get_all_images' do
|
|
36
|
+
context 'with token and project_id acquainted' do
|
|
37
|
+
context 'and api version is v2' do
|
|
38
|
+
it 'returns all images with details' do
|
|
39
|
+
stub_request(:get, 'http://glance/images')
|
|
40
|
+
.with(
|
|
41
|
+
headers:
|
|
42
|
+
{
|
|
43
|
+
'Accept' => 'application/json',
|
|
44
|
+
'X-Auth-Token' => '123456'
|
|
45
|
+
})
|
|
46
|
+
.to_return(
|
|
47
|
+
status: 200,
|
|
48
|
+
body: '
|
|
49
|
+
{
|
|
50
|
+
"images": [
|
|
51
|
+
{ "id": "i1", "name": "image1", "visibility": "public", "size": "1024", "min_ram": "1", "min_disk": "10" },
|
|
52
|
+
{ "id": "i2", "name": "image2", "visibility": "private", "size": "2048", "min_ram": "2", "min_disk": "20" }
|
|
53
|
+
]
|
|
54
|
+
}')
|
|
55
|
+
|
|
56
|
+
images = @glance_client.get_all_images(env)
|
|
57
|
+
|
|
58
|
+
expect(images).to eq [Image.new('i1', 'image1', 'public', '1024', '1', '10'),
|
|
59
|
+
Image.new('i2', 'image2', 'private', '2048', '2', '20')]
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
context 'and api version is v1' do
|
|
64
|
+
it 'returns all images with details' do
|
|
65
|
+
stub_request(:get, 'http://glance/images')
|
|
66
|
+
.with(
|
|
67
|
+
headers:
|
|
68
|
+
{
|
|
69
|
+
'Accept' => 'application/json',
|
|
70
|
+
'X-Auth-Token' => '123456'
|
|
71
|
+
})
|
|
72
|
+
.to_return(
|
|
73
|
+
status: 200,
|
|
74
|
+
body: '
|
|
75
|
+
{
|
|
76
|
+
"images": [
|
|
77
|
+
{ "id": "i1", "name": "image1", "is_public": true },
|
|
78
|
+
{ "id": "i2", "name": "image2", "is_public": false }
|
|
79
|
+
]
|
|
80
|
+
}')
|
|
81
|
+
|
|
82
|
+
stub_request(:get, 'http://glance/images/detail')
|
|
83
|
+
.with(
|
|
84
|
+
headers:
|
|
85
|
+
{
|
|
86
|
+
'Accept' => 'application/json',
|
|
87
|
+
'X-Auth-Token' => '123456'
|
|
88
|
+
})
|
|
89
|
+
.to_return(
|
|
90
|
+
status: 200,
|
|
91
|
+
body: '
|
|
92
|
+
{
|
|
93
|
+
"images": [
|
|
94
|
+
{ "id": "i1", "name": "image1", "is_public": true, "size": "1024", "min_ram": "1", "min_disk": "10" },
|
|
95
|
+
{ "id": "i2", "name": "image2", "is_public": false, "size": "2048", "min_ram": "2", "min_disk": "20" }
|
|
96
|
+
]
|
|
97
|
+
}')
|
|
98
|
+
|
|
99
|
+
images = @glance_client.get_all_images(env)
|
|
100
|
+
|
|
101
|
+
expect(images).to eq [Image.new('i1', 'image1', 'public', '1024', '1', '10'),
|
|
102
|
+
Image.new('i2', 'image2', 'private', '2048', '2', '20')]
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
describe 'get_api_version_list' do
|
|
109
|
+
it 'returns version list' do
|
|
110
|
+
stub_request(:get, 'http://glance/')
|
|
111
|
+
.with(header: { 'Accept' => 'application/json' })
|
|
112
|
+
.to_return(
|
|
113
|
+
status: 200,
|
|
114
|
+
body: '{
|
|
115
|
+
"versions": [
|
|
116
|
+
{
|
|
117
|
+
"status": "...",
|
|
118
|
+
"id": "v1.0",
|
|
119
|
+
"links": [
|
|
120
|
+
{
|
|
121
|
+
"href": "http://glance/v1.0",
|
|
122
|
+
"rel": "self"
|
|
123
|
+
}
|
|
124
|
+
]
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
"status": "CURRENT",
|
|
128
|
+
"id": "v2.0",
|
|
129
|
+
"links": [
|
|
130
|
+
{
|
|
131
|
+
"href": "http://glance/v2.0",
|
|
132
|
+
"rel": "self"
|
|
133
|
+
}
|
|
134
|
+
]
|
|
135
|
+
}
|
|
136
|
+
]}')
|
|
137
|
+
|
|
138
|
+
versions = @glance_client.get_api_version_list(env)
|
|
139
|
+
|
|
140
|
+
expect(versions.size).to eq(2)
|
|
141
|
+
end
|
|
142
|
+
end
|
|
143
|
+
end
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
require 'vagrant-conoha/spec_helper'
|
|
2
|
+
|
|
3
|
+
describe VagrantPlugins::ConoHa::NovaClient do
|
|
4
|
+
include FakeFS::SpecHelpers::All
|
|
5
|
+
|
|
6
|
+
let(:http) do
|
|
7
|
+
double('http').tap do |http|
|
|
8
|
+
http.stub(:read_timeout) { 42 }
|
|
9
|
+
http.stub(:open_timeout) { 43 }
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
let(:config) do
|
|
14
|
+
double('config').tap do |config|
|
|
15
|
+
config.stub(:openstack_auth_url) { 'http://heatAuthV2' }
|
|
16
|
+
config.stub(:openstack_orchestration_url) { nil }
|
|
17
|
+
config.stub(:tenant_name) { 'testTenant' }
|
|
18
|
+
config.stub(:username) { 'username' }
|
|
19
|
+
config.stub(:password) { 'password' }
|
|
20
|
+
config.stub(:http) { http }
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
let(:env) do
|
|
25
|
+
{}.tap do |env|
|
|
26
|
+
env[:ui] = double('ui')
|
|
27
|
+
env[:ui].stub(:info).with(anything)
|
|
28
|
+
env[:machine] = double('machine')
|
|
29
|
+
env[:machine].stub(:provider_config) { config }
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
let(:session) do
|
|
34
|
+
VagrantPlugins::ConoHa.session
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
before :each do
|
|
38
|
+
session.token = '123456'
|
|
39
|
+
session.project_id = 'a1b2c3'
|
|
40
|
+
session.endpoints = { orchestration: 'http://heat/a1b2c3' }
|
|
41
|
+
@heat_client = VagrantPlugins::ConoHa.heat
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
describe 'stack_exists' do
|
|
45
|
+
context 'stack not found' do
|
|
46
|
+
it 'raise an StackNotFound error' do
|
|
47
|
+
stub_request(:get, 'http://heat/a1b2c3/stacks/stack_name/stack_id')
|
|
48
|
+
.with(
|
|
49
|
+
headers:
|
|
50
|
+
{
|
|
51
|
+
'Accept' => 'application/json',
|
|
52
|
+
'Accept-Encoding' => 'gzip, deflate',
|
|
53
|
+
'X-Auth-Token' => '123456'
|
|
54
|
+
})
|
|
55
|
+
.to_return(
|
|
56
|
+
status: 404,
|
|
57
|
+
body: '{"itemNotFound": {"message": "Stack could not be found", "code": 404}}')
|
|
58
|
+
|
|
59
|
+
expect { @heat_client.get_stack_details(env, 'stack_name', 'stack_id') }.to raise_error(VagrantPlugins::ConoHa::Errors::StackNotFound)
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
describe 'create_stack' do
|
|
65
|
+
context 'with token and project_id acquainted' do
|
|
66
|
+
it 'returns new stack id' do
|
|
67
|
+
stub_request(:post, 'http://heat/a1b2c3/stacks')
|
|
68
|
+
.with(
|
|
69
|
+
body: '{"stack_name":"stck","template":"toto"}',
|
|
70
|
+
headers:
|
|
71
|
+
{
|
|
72
|
+
'Accept' => 'application/json',
|
|
73
|
+
'Content-Type' => 'application/json',
|
|
74
|
+
'X-Auth-Token' => '123456'
|
|
75
|
+
})
|
|
76
|
+
.to_return(status: 202, body: '{ "stack": { "id": "o1o2o3" } }')
|
|
77
|
+
|
|
78
|
+
stack_id = @heat_client.create_stack(env, name: 'stck', template: 'toto')
|
|
79
|
+
|
|
80
|
+
expect(stack_id).to eq('o1o2o3')
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
describe 'get_stack_details' do
|
|
86
|
+
context 'with token and project_id acquainted' do
|
|
87
|
+
it 'returns stack details' do
|
|
88
|
+
stub_request(:get, 'http://heat/a1b2c3/stacks/stack_id/stack_name')
|
|
89
|
+
.with(headers:
|
|
90
|
+
{
|
|
91
|
+
'Accept' => 'application/json',
|
|
92
|
+
'X-Auth-Token' => '123456'
|
|
93
|
+
})
|
|
94
|
+
.to_return(status: 200, body: '
|
|
95
|
+
{
|
|
96
|
+
"stack": {
|
|
97
|
+
"description": "sample stack",
|
|
98
|
+
"disable_rollback": "True",
|
|
99
|
+
"id": "stack_id",
|
|
100
|
+
"stack_name": "stack_name",
|
|
101
|
+
"stack_status": "CREATE_COMPLETE"
|
|
102
|
+
}
|
|
103
|
+
}')
|
|
104
|
+
|
|
105
|
+
stack = @heat_client.get_stack_details(env, 'stack_id', 'stack_name')
|
|
106
|
+
|
|
107
|
+
expect(stack['id']).to eq('stack_id')
|
|
108
|
+
expect(stack['stack_name']).to eq('stack_name')
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
describe 'delete_stack' do
|
|
114
|
+
context 'with token and project_id acquainted' do
|
|
115
|
+
it 'deletes the stack' do
|
|
116
|
+
stub_request(:delete, 'http://heat/a1b2c3/stacks/stack_id/stack_name')
|
|
117
|
+
.with(headers:
|
|
118
|
+
{
|
|
119
|
+
'Accept' => 'application/json',
|
|
120
|
+
'X-Auth-Token' => '123456'
|
|
121
|
+
})
|
|
122
|
+
.to_return(status: 204)
|
|
123
|
+
|
|
124
|
+
@heat_client.delete_stack(env, 'stack_id', 'stack_name')
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
end
|