vagrant-openstack-plugin 0.9.1 → 0.10.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 +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +5 -0
- data/lib/vagrant-openstack-plugin/action/connect_openstack.rb +12 -0
- data/lib/vagrant-openstack-plugin/action/create_server.rb +35 -1
- data/lib/vagrant-openstack-plugin/action/delete_server.rb +15 -0
- data/lib/vagrant-openstack-plugin/config.rb +16 -0
- data/lib/vagrant-openstack-plugin/errors.rb +8 -0
- data/lib/vagrant-openstack-plugin/version.rb +1 -1
- data/locales/en.yml +19 -0
- data/spec/vagrant-openstack-plugin/config_spec.rb +14 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f101fc3c74f7fb1e3d33a8ef15a48d0089f0d08e
|
4
|
+
data.tar.gz: 46372f4bb20d168e3cec85ef3dfdcc437ba46344
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d27c4cad80f1270a5d52a6c558d63e8406fb24d62e2dfddda0790a5576253e88fce41987be155d4f935e8f8b98de1d2f642cddce3c04d78a7763a515cdd504d8
|
7
|
+
data.tar.gz: f14c372717634e8d09ba1ccc6c9e1ca3d3468577b4004960a7890eb7482b76235d97d93729563e18f38b53b2ed94e5051adac36c759c592b0d86c3a6c95c11d7
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
# Changelog for vagrant-openstack-plugin
|
2
2
|
|
3
|
+
## 0.10.0
|
4
|
+
|
5
|
+
- Merge pull request #84 from cbaenziger/volume_support [view commit](http://github.com///commit/fc613a49cb5b2fecf2255d3050d1bff68956735d)
|
6
|
+
- Add support for creating OpenStack Volumes [view commit](http://github.com///commit/60ed3924957bb7eefa95e113336165d76da3a985)
|
7
|
+
|
3
8
|
## 0.9.1
|
4
9
|
|
5
10
|
- Merge pull request #91 from Chealion/master [view commit](http://github.com///commit/6285cae325afa378e90f06635a2cc39b1428a6dd)
|
data/README.md
CHANGED
@@ -79,6 +79,11 @@ Vagrant.configure("2") do |config|
|
|
79
79
|
os.floating_ip = "33.33.33.33" # optional (The floating IP to assign for this instance)
|
80
80
|
os.floating_ip_pool = "public" # optional (The floating IP pool to allocate addresses from, if floating_ip = :auto)
|
81
81
|
|
82
|
+
os.disks = [ # optional
|
83
|
+
{"name" => "volume_name_here", "description" => "First 10GB Volume", "size" => 10},
|
84
|
+
{"name" => "volume_name_here", "description" => "Second 10GB Volume", "size" => 10}
|
85
|
+
]
|
86
|
+
|
82
87
|
os.orchestration_stack_name = 'stack01' # optional
|
83
88
|
os.orchestration_cfn_template_file = '/tmp/cfn_heat_template.json' # optional
|
84
89
|
os.orchestration_cfn_template_parameters = { # optional
|
@@ -58,6 +58,18 @@ module VagrantPlugins
|
|
58
58
|
})
|
59
59
|
end
|
60
60
|
|
61
|
+
if config.disks && !config.disks.empty?
|
62
|
+
env[:openstack_volume] = Fog::Volume.new({
|
63
|
+
:provider => :openstack,
|
64
|
+
:connection_options => connection_options,
|
65
|
+
:openstack_username => username,
|
66
|
+
:openstack_api_key => api_key,
|
67
|
+
:openstack_auth_url => endpoint,
|
68
|
+
:openstack_tenant => tenant,
|
69
|
+
:openstack_region => region
|
70
|
+
})
|
71
|
+
end
|
72
|
+
|
61
73
|
@app.call(env)
|
62
74
|
end
|
63
75
|
end
|
@@ -79,7 +79,7 @@ module VagrantPlugins
|
|
79
79
|
end
|
80
80
|
env[:ui].info("options[:nics]: #{options[:nics]}")
|
81
81
|
end
|
82
|
-
|
82
|
+
|
83
83
|
# Output the settings we're going to use to the user
|
84
84
|
env[:ui].info(I18n.t("vagrant_openstack.launching_server"))
|
85
85
|
env[:ui].info(" -- Flavor: #{flavor.name}")
|
@@ -141,6 +141,40 @@ module VagrantPlugins
|
|
141
141
|
floater.server = server
|
142
142
|
end
|
143
143
|
|
144
|
+
# Process disks if provided
|
145
|
+
volumes = Array.new
|
146
|
+
if config.has_key?("disks") and not config.disks.empty?
|
147
|
+
env[:ui].info(I18n.t("vagrant_openstack.creating_disks"))
|
148
|
+
config.disks.each do |disk|
|
149
|
+
volume = env[:openstack_compute].volumes.all.find{|v| v.name ==
|
150
|
+
disk["name"] and
|
151
|
+
v.description ==
|
152
|
+
disk["description"] and
|
153
|
+
v.size ==
|
154
|
+
disk["size"] and
|
155
|
+
v.ready? }
|
156
|
+
if volume
|
157
|
+
env[:ui].info("re-using volume: #{disk["name"]}")
|
158
|
+
disk["volume_id"] = volume.id
|
159
|
+
else
|
160
|
+
env[:ui].info("creating volume: #{disk["name"]}")
|
161
|
+
disk["volume_id"] = env[:openstack_compute].create_volume(
|
162
|
+
disk["name"], disk["description"], disk["size"]).\
|
163
|
+
data[:body]["volume"]["id"]
|
164
|
+
volumes << { :id => disk["volume_id"] }
|
165
|
+
end
|
166
|
+
|
167
|
+
# mount points are not expected to be meaningful
|
168
|
+
# add useful support if your cloud respects them
|
169
|
+
begin
|
170
|
+
server.attach_volume(disk["volume_id"], "/dev/vd#{("a".."z").to_a[server.volume_attachments.length + 1]}")
|
171
|
+
server.wait_for{ volume_attachments.any?{|vol| vol["id"]==disk["volume_id"]} }
|
172
|
+
rescue Excon::Errors::Error => e
|
173
|
+
raise Errors::VolumeBadState, :volume => disk["name"], :state => e.message
|
174
|
+
end
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
144
178
|
# store this so we can use it later
|
145
179
|
env[:floating_ip] = floating_ip
|
146
180
|
|
@@ -15,6 +15,8 @@ module VagrantPlugins
|
|
15
15
|
id = machine.id || env[:openstack_compute].servers.all( :name => machine.name ).first.id
|
16
16
|
|
17
17
|
if id
|
18
|
+
volumes = env[:openstack_compute].servers.get(id).volume_attachments
|
19
|
+
|
18
20
|
env[:ui].info(I18n.t("vagrant_openstack.deleting_server"))
|
19
21
|
|
20
22
|
# TODO: Validate the fact that we get a server back from the API.
|
@@ -28,6 +30,19 @@ module VagrantPlugins
|
|
28
30
|
env[:openstack_compute].release_address(address["id"])
|
29
31
|
end
|
30
32
|
end
|
33
|
+
|
34
|
+
env[:ui].info(I18n.t("vagrant_openstack.deleting_volumes"))
|
35
|
+
volumes.each do |compute_volume|
|
36
|
+
volume = env[:openstack_volume].volumes.get(compute_volume["id"])
|
37
|
+
if volume
|
38
|
+
env[:ui].info("Deleting volume: #{volume.display_name}")
|
39
|
+
begin
|
40
|
+
volume.destroy
|
41
|
+
rescue Excon::Errors::Error => e
|
42
|
+
raise Errors::VolumeBadState, :volume => volume.display_name, :state => e.message
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
31
46
|
end
|
32
47
|
end
|
33
48
|
|
@@ -104,6 +104,11 @@ module VagrantPlugins
|
|
104
104
|
# @return [String]
|
105
105
|
attr_accessor :proxy
|
106
106
|
|
107
|
+
# The disks to create as OpenStack volumes.
|
108
|
+
#
|
109
|
+
# @return [Array]
|
110
|
+
attr_accessor :disks
|
111
|
+
|
107
112
|
# Value for SSL_VERIFY_PEER, defaults to true. Set to false for self
|
108
113
|
# signed ssl certificate
|
109
114
|
attr_accessor :ssl_verify_peer
|
@@ -139,6 +144,7 @@ module VagrantPlugins
|
|
139
144
|
@region = UNSET_VALUE
|
140
145
|
@proxy = UNSET_VALUE
|
141
146
|
@ssl_verify_peer = UNSET_VALUE
|
147
|
+
@disks = UNSET_VALUE
|
142
148
|
@orchestration_stack_name = UNSET_VALUE
|
143
149
|
@orchestration_stack_destroy = UNSET_VALUE
|
144
150
|
@orchestration_cfn_template = UNSET_VALUE
|
@@ -175,6 +181,8 @@ module VagrantPlugins
|
|
175
181
|
@floating_ip = nil if @floating_ip == UNSET_VALUE
|
176
182
|
@floating_ip = nil if @floating_ip_pool == UNSET_VALUE
|
177
183
|
|
184
|
+
@disks = nil if @disks == UNSET_VALUE
|
185
|
+
|
178
186
|
@region = nil if @region == UNSET_VALUE
|
179
187
|
@proxy = nil if @proxy == UNSET_VALUE
|
180
188
|
@ssl_verify_peer = nil if @ssl_verify_peer == UNSET_VALUE
|
@@ -193,6 +201,14 @@ module VagrantPlugins
|
|
193
201
|
errors << I18n.t("vagrant_openstack.config.api_key_required") if !@api_key
|
194
202
|
errors << I18n.t("vagrant_openstack.config.username_required") if !@username
|
195
203
|
|
204
|
+
if @disks and @disks.any?{|a| not a.respond_to?("include?")}
|
205
|
+
errors << I18n.t("vagrant_openstack.config.disks.specification_required")
|
206
|
+
elsif @disks
|
207
|
+
errors << I18n.t("vagrant_openstack.config.disks.name_required") if @disks.any?{|a| not a.include?("name")}
|
208
|
+
errors << I18n.t("vagrant_openstack.config.disks.description_required") if @disks.any?{|a| not a.include?("description")}
|
209
|
+
errors << I18n.t("vagrant_openstack.config.disks.size_required") if @disks.any?{|a| not a.include?("size")}
|
210
|
+
end
|
211
|
+
|
196
212
|
{ "OpenStack Provider" => errors }
|
197
213
|
end
|
198
214
|
end
|
@@ -7,6 +7,10 @@ module VagrantPlugins
|
|
7
7
|
error_namespace("vagrant_openstack.errors")
|
8
8
|
end
|
9
9
|
|
10
|
+
class VolumeBadState < VagrantOpenStackError
|
11
|
+
error_key(:volume_bad_state)
|
12
|
+
end
|
13
|
+
|
10
14
|
class CreateBadState < VagrantOpenStackError
|
11
15
|
error_key(:create_bad_state)
|
12
16
|
end
|
@@ -46,6 +50,10 @@ module VagrantPlugins
|
|
46
50
|
class OrchestrationNoTemplateFileError < VagrantOpenStackError
|
47
51
|
error_key(:orchestration_no_template_file_error)
|
48
52
|
end
|
53
|
+
|
54
|
+
class ServerNotDestroyed < VagrantOpenStackError
|
55
|
+
error_key(:server_not_destroyed)
|
56
|
+
end
|
49
57
|
end
|
50
58
|
end
|
51
59
|
end
|
data/locales/en.yml
CHANGED
@@ -6,8 +6,12 @@ en:
|
|
6
6
|
The server is already paused.
|
7
7
|
already_suspended: |-
|
8
8
|
The server is already suspended.
|
9
|
+
creating_disks: |-
|
10
|
+
Creating disks with the folowing settings...
|
9
11
|
deleting_server: |-
|
10
12
|
Deleting server...
|
13
|
+
deleting_volumes: |-
|
14
|
+
Deleting volumes...
|
11
15
|
finding_flavor: |-
|
12
16
|
Finding flavor for server...
|
13
17
|
finding_image: |-
|
@@ -62,8 +66,21 @@ en:
|
|
62
66
|
A username is required.
|
63
67
|
metadata_must_be_hash: |-
|
64
68
|
Metadata must be a hash.
|
69
|
+
disks:
|
70
|
+
specification_required: |-
|
71
|
+
A disk specification is required for a disk configuration (array of hashes including name, description and size keys).
|
72
|
+
name_required: |-
|
73
|
+
A disk name is required for all disk specifications.
|
74
|
+
description_required: |-
|
75
|
+
A disk description is required for all disk specifications.
|
76
|
+
size_required: |-
|
77
|
+
A disk size is required for all disk specifications.
|
65
78
|
|
66
79
|
errors:
|
80
|
+
volume_bad_state: |-
|
81
|
+
The OpenStack volume '%{volume}' requested is in an unexpected state:
|
82
|
+
'%{state}'
|
83
|
+
Please run `vagrant destroy` if you want to start over.
|
67
84
|
create_bad_state: |-
|
68
85
|
While creating the server, it transitioned to an unexpected
|
69
86
|
state: '%{state}', instead of properly booting. Run `vagrant status`
|
@@ -100,6 +117,8 @@ en:
|
|
100
117
|
Error: %{err}
|
101
118
|
orchestration_no_template_file_error: |-
|
102
119
|
Orchestration template file not found (%{fname}).
|
120
|
+
server_not_destroyed: |-
|
121
|
+
OpenStack server was not fully destroyed.
|
103
122
|
|
104
123
|
states:
|
105
124
|
short_active: |-
|
@@ -23,6 +23,7 @@ describe VagrantPlugins::OpenStack::Config do
|
|
23
23
|
its(:scheduler_hints) { should be_nil }
|
24
24
|
its(:tenant) { should be_nil }
|
25
25
|
its(:proxy) { should be_nil }
|
26
|
+
its(:disks) { should be_nil }
|
26
27
|
its(:ssl_verify_peer) { should be_nil }
|
27
28
|
end
|
28
29
|
|
@@ -47,6 +48,11 @@ describe VagrantPlugins::OpenStack::Config do
|
|
47
48
|
subject.send(attribute).should == "foo"
|
48
49
|
end
|
49
50
|
end
|
51
|
+
it "should not default disks if overridden" do
|
52
|
+
subject.send("disks=".to_sym, {"name" => "foo", "size" => 10, "description" => "bar"})
|
53
|
+
subject.finalize!
|
54
|
+
subject.send("disks").should == {"name" => "foo", "size" => 10, "description" => "bar"}
|
55
|
+
end
|
50
56
|
end
|
51
57
|
|
52
58
|
describe "validation" do
|
@@ -75,5 +81,13 @@ describe VagrantPlugins::OpenStack::Config do
|
|
75
81
|
context "the username" do
|
76
82
|
it "should error if not given"
|
77
83
|
end
|
84
|
+
|
85
|
+
context "the disks" do
|
86
|
+
it "should not error if not given"
|
87
|
+
it "should error if non-array given"
|
88
|
+
it "should error if non-hash array element given"
|
89
|
+
it "should error if array element hash does not contain all three name, description or size keys"
|
90
|
+
it "should not error if array element hash does contain all three name, description and size keys"
|
91
|
+
end
|
78
92
|
end
|
79
93
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-openstack-plugin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Edmund Haselwanter
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-11-
|
11
|
+
date: 2014-11-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fog
|