vagrant-cloudstack 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 +63 -0
- data/build_rpm.sh +1 -1
- data/lib/vagrant-cloudstack/action/run_instance.rb +70 -103
- data/lib/vagrant-cloudstack/config.rb +3 -3
- data/lib/vagrant-cloudstack/version.rb +1 -1
- data/spec/vagrant-cloudstack/config_spec.rb +3 -3
- 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: 41759a933a26fc03edb1e84909cf4dc04f63c46a
|
4
|
+
data.tar.gz: f77c0919074fd8a7c9694b8c8f55b1b672fcaa0f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a9d4dc84e206fc45e88647629858245be3e37d3c5be0a9a98a6b68727aaf5774019e17fb0482fa6abb8d733fc2a82f5b824e562c479b09f80955b8890898b73
|
7
|
+
data.tar.gz: 8001d1b9bddc343a9113a6c279693a4d810ffb72d4b501ae118ff1ddd5523038a5611fbd1a51e1192eb14b7ad50060dfbd2e82956c4c857af9cb6fb7ef191979
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -204,6 +204,69 @@ supported with `vagrant-cloudstack`, currently. If any of these are
|
|
204
204
|
specified, Vagrant will emit a warning, but will otherwise boot
|
205
205
|
the Cloudstack machine.
|
206
206
|
|
207
|
+
### Basic Networking
|
208
|
+
|
209
|
+
If you set the `network_type` to `basic`, you can use Security
|
210
|
+
Groups and associate rules in your Vagrantfile.
|
211
|
+
|
212
|
+
If you already have Security Groups, you can associate them to your
|
213
|
+
instance, with their IDs:
|
214
|
+
|
215
|
+
```ruby
|
216
|
+
Vagrant.configure("2") do |config|
|
217
|
+
# ... other stuff
|
218
|
+
|
219
|
+
config.vm.provider :cloudstack do |cloudstack|
|
220
|
+
cloudstack.api_key = "foo"
|
221
|
+
cloudstack.secret_key = "bar"
|
222
|
+
cloudstack.network_type = "basic"
|
223
|
+
cloudstack.security_group_ids = ['aaaa-bbbb-cccc-dddd', '1111-2222-3333-4444']
|
224
|
+
end
|
225
|
+
end
|
226
|
+
```
|
227
|
+
|
228
|
+
or their names:
|
229
|
+
|
230
|
+
```ruby
|
231
|
+
Vagrant.configure("2") do |config|
|
232
|
+
# ... other stuff
|
233
|
+
|
234
|
+
config.vm.provider :cloudstack do |cloudstack|
|
235
|
+
cloudstack.api_key = "foo"
|
236
|
+
cloudstack.secret_key = "bar"
|
237
|
+
cloudstack.network_type = "basic"
|
238
|
+
cloudstack.security_group_names = ['
|
239
|
+
min_fantastiska_security_group', 'another_security_grupp']
|
240
|
+
end
|
241
|
+
end
|
242
|
+
```
|
243
|
+
|
244
|
+
But you can also create your Security Groups in the Vagrantfile:
|
245
|
+
|
246
|
+
```ruby
|
247
|
+
Vagrant.configure("2") do |config|
|
248
|
+
# ... other stuff
|
249
|
+
|
250
|
+
config.vm.provider :cloudstack do |cloudstack|
|
251
|
+
cloudstack.api_key = "foo"
|
252
|
+
cloudstack.secret_key = "bar"
|
253
|
+
cloudstack.network_type = "basic"
|
254
|
+
cloudstack.security_groups = [
|
255
|
+
{
|
256
|
+
:name => "Awesome_security_group",
|
257
|
+
:description => "Created from the Vagrantfile",
|
258
|
+
:rules => [
|
259
|
+
{:type => "ingress", :protocol => "TCP", :startport => 22, :endport => 22, :cidrlist => "0.0.0.0/0"},
|
260
|
+
{:type => "ingress", :protocol => "TCP", :startport => 80, :endport => 80, :cidrlist => "0.0.0.0/0"},
|
261
|
+
{:type => "egress", :protocol => "TCP", :startport => 81, :endport => 82, :cidrlist => "1.2.3.4/24"},
|
262
|
+
]
|
263
|
+
}
|
264
|
+
]
|
265
|
+
end
|
266
|
+
end
|
267
|
+
```
|
268
|
+
|
269
|
+
|
207
270
|
## Synced Folders
|
208
271
|
|
209
272
|
There is minimal support for synced folders. Upon `vagrant up`,
|
data/build_rpm.sh
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#!/bin/bash
|
2
|
-
VERSION=0.
|
2
|
+
VERSION=0.10.0
|
3
3
|
mkdir -p /tmp/vagrant-cloudstack-build_rpm.$$/vagrant-cloudstack-$VERSION
|
4
4
|
cp -r . /tmp/vagrant-cloudstack-build_rpm.$$/vagrant-cloudstack-$VERSION/
|
5
5
|
tar -C /tmp/vagrant-cloudstack-build_rpm.$$/ -czf ~/rpmbuild/SOURCES/vagrant-cloudstack-$VERSION.tar.gz vagrant-cloudstack-$VERSION
|
@@ -74,6 +74,24 @@ module VagrantPlugins
|
|
74
74
|
'templatefilter' => 'executable'})
|
75
75
|
end
|
76
76
|
|
77
|
+
# Can't use Security Group IDs and Names at the same time
|
78
|
+
# Let's use IDs by default...
|
79
|
+
if security_group_ids.empty? and !security_group_names.empty?
|
80
|
+
security_group_ids = security_group_names.map { |name| name_to_id(env, name, "security_group") }
|
81
|
+
elsif !security_group_ids.empty?
|
82
|
+
security_group_names = security_group_ids.map { |id| id_to_name(env, id, "security_group") }
|
83
|
+
end
|
84
|
+
|
85
|
+
# Still no security group ids huh?
|
86
|
+
# Let's try to create some security groups from specifcation, if provided.
|
87
|
+
if !security_groups.empty? and security_group_ids.empty?
|
88
|
+
security_groups.each do |security_group|
|
89
|
+
sgname, sgid = create_security_group(env, security_group)
|
90
|
+
security_group_names.push(sgname)
|
91
|
+
security_group_ids.push(sgid)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
77
95
|
# If there is no keypair then warn the user
|
78
96
|
if !keypair
|
79
97
|
env[:ui].warn(I18n.t("vagrant_cloudstack.launch_no_keypair"))
|
@@ -87,25 +105,6 @@ module VagrantPlugins
|
|
87
105
|
display_name = local_user + "_" + prefix + "_#{Time.now.to_i}"
|
88
106
|
end
|
89
107
|
|
90
|
-
# Can't use Security Group IDs and Names at the same time
|
91
|
-
# Let's use IDs by default...
|
92
|
-
if !security_group_ids.nil?
|
93
|
-
if !security_group_names.nil?
|
94
|
-
env[:ui].warn("Security Group Names won't be used since Security Group IDs are declared")
|
95
|
-
security_group_names = nil
|
96
|
-
end
|
97
|
-
|
98
|
-
if !security_groups.nil?
|
99
|
-
env[:ui].warn("Security Groups defined in Vagrantfile won't be used since Security Group IDs are declared")
|
100
|
-
security_groups = nil
|
101
|
-
end
|
102
|
-
else # security_group_ids is nil
|
103
|
-
if !security_group_names.nil? && !security_groups.nil?
|
104
|
-
env[:ui].warn("Security Groups defined in Vagrantfile won't be used since Security Group Names are declared")
|
105
|
-
security_groups = nil
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
108
|
# Launch!
|
110
109
|
env[:ui].info(I18n.t("vagrant_cloudstack.launching_instance"))
|
111
110
|
env[:ui].info(" -- Display Name: #{display_name}")
|
@@ -117,99 +116,30 @@ module VagrantPlugins
|
|
117
116
|
env[:ui].info(" -- Network: #{network_name} (#{network_id})") if !network_id.nil? or !network_name.nil?
|
118
117
|
env[:ui].info(" -- Keypair: #{keypair}") if keypair
|
119
118
|
env[:ui].info(" -- User Data: Yes") if user_data
|
120
|
-
|
121
|
-
|
122
|
-
env[:ui].info(" -- Security Group ID: #{security_group_id}")
|
123
|
-
end
|
124
|
-
end
|
125
|
-
|
126
|
-
if !security_group_names.nil? && security_group_ids.nil?
|
127
|
-
security_group_ids = []
|
128
|
-
security_group_names.each do |security_group_name|
|
129
|
-
env[:ui].info(" -- Security Group Name: #{security_group_name}")
|
130
|
-
# since we can't access Security Groups by name, we grab the ID and add it to the security_group_ids
|
131
|
-
sg = env[:cloudstack_compute].list_security_groups["listsecuritygroupsresponse"]["securitygroup"].select { |sgrp| sgrp["name"] == security_group_name }
|
132
|
-
security_group_ids.push(sg[0]["id"])
|
133
|
-
end
|
134
|
-
end
|
135
|
-
|
136
|
-
if !security_groups.nil? && security_group_names.nil? && security_group_ids.nil?
|
137
|
-
security_group_ids = []
|
138
|
-
security_groups.each do |sg|
|
139
|
-
# Creating the security group and retrieving it's ID
|
140
|
-
sgid = nil
|
141
|
-
begin
|
142
|
-
sgid = env[:cloudstack_compute].create_security_group(:name => sg[:name],
|
143
|
-
:description => sg[:description])["createsecuritygroupresponse"]["securitygroup"]["id"]
|
144
|
-
env[:ui].info(" -- Security Group #{sg[:name]} created with ID: #{sgid}")
|
145
|
-
rescue Exception => e
|
146
|
-
if e.message =~ /already exis/
|
147
|
-
existingGroup = env[:cloudstack_compute].list_security_groups["listsecuritygroupsresponse"]["securitygroup"].select { |secgrp| secgrp["name"] == sg[:name] }
|
148
|
-
sgid = existingGroup[0]["id"]
|
149
|
-
env[:ui].info(" -- Security Group #{sg[:name]} found with ID: #{sgid}")
|
150
|
-
end
|
151
|
-
end
|
152
|
-
|
153
|
-
# security group is created and we have it's ID
|
154
|
-
# so we add the rules... Does it really matter if they already exist ? CLoudstack seems to take care of that!
|
155
|
-
sg[:rules].each do |rule|
|
156
|
-
case rule[:type]
|
157
|
-
when "ingress"
|
158
|
-
env[:cloudstack_compute].authorize_security_group_ingress(:securityGroupId => sgid,
|
159
|
-
:protocol => rule[:protocol],
|
160
|
-
:startport => rule[:startport],
|
161
|
-
:endport => rule[:endport],
|
162
|
-
:cidrlist => rule[:cidrlist])
|
163
|
-
env[:ui].info(" --- Ingress Rule added: #{rule[:protocol]} from #{rule[:startport]} to #{rule[:endport]} (#{rule[:cidrlist]})")
|
164
|
-
when "egress"
|
165
|
-
env[:cloudstack_compute].authorize_security_group_egress(:securityGroupId => sgid,
|
166
|
-
:protocol => rule[:protocol],
|
167
|
-
:startport => rule[:startport],
|
168
|
-
:endport => rule[:endport],
|
169
|
-
:cidrlist => rule[:cidrlist])
|
170
|
-
env[:ui].info(" --- Egress Rule added: #{rule[:protocol]} from #{rule[:startport]} to #{rule[:endport]} (#{rule[:cidrlist]})")
|
171
|
-
end
|
172
|
-
end
|
173
|
-
|
174
|
-
# We want to use the Security groups we created
|
175
|
-
security_group_ids.push(sgid)
|
176
|
-
|
177
|
-
# and record the security group ids for future deletion (of rules and groups if possible)
|
178
|
-
security_groups_file = env[:machine].data_dir.join('security_groups')
|
179
|
-
security_groups_file.open('a+') do |f|
|
180
|
-
f.write("#{sgid}\n")
|
181
|
-
end
|
182
|
-
end
|
119
|
+
security_group_names.zip(security_group_ids).each do |security_group_name, security_group_id|
|
120
|
+
env[:ui].info(" -- Security Group: #{security_group_name} (#{security_group_id})")
|
183
121
|
end
|
184
122
|
|
185
123
|
begin
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
:display_name => display_name,
|
199
|
-
:group => group,
|
200
|
-
:zone_id => zone_id,
|
201
|
-
:flavor_id => service_offering_id,
|
202
|
-
:image_id => template_id,
|
203
|
-
:security_group_ids => security_group_ids
|
204
|
-
}
|
124
|
+
options = {
|
125
|
+
:display_name => display_name,
|
126
|
+
:group => group,
|
127
|
+
:zone_id => zone_id,
|
128
|
+
:flavor_id => service_offering_id,
|
129
|
+
:image_id => template_id
|
130
|
+
}
|
131
|
+
|
132
|
+
if network_type == "Advanced"
|
133
|
+
options['network_ids'] = [network_id]
|
134
|
+
elsif network_type == "Basic"
|
135
|
+
options['security_group_ids'] = security_group_ids
|
205
136
|
end
|
206
|
-
|
207
137
|
options['project_id'] = project_id if project_id != nil
|
208
138
|
options['key_name'] = keypair if keypair != nil
|
209
139
|
options['name'] = hostname if hostname != nil
|
210
140
|
|
211
141
|
if user_data != nil
|
212
|
-
options['user_data'] = Base64.
|
142
|
+
options['user_data'] = Base64.urlsafe_encode64(user_data)
|
213
143
|
if options['user_data'].length > 2048
|
214
144
|
raise Errors::UserdataError,
|
215
145
|
:userdataLength => options['user_data'].length
|
@@ -288,6 +218,43 @@ module VagrantPlugins
|
|
288
218
|
@app.call(env)
|
289
219
|
end
|
290
220
|
|
221
|
+
def create_security_group(env, security_group)
|
222
|
+
begin
|
223
|
+
sgid = env[:cloudstack_compute].create_security_group(:name => security_group[:name],
|
224
|
+
:description => security_group[:description])["createsecuritygroupresponse"]["securitygroup"]["id"]
|
225
|
+
env[:ui].info(" -- Security Group #{security_group[:name]} created with ID: #{sgid}")
|
226
|
+
rescue Exception => e
|
227
|
+
if e.message =~ /already exis/
|
228
|
+
sgid = name_to_id(env, security_group[:name], "security_group")
|
229
|
+
env[:ui].info(" -- Security Group #{security_group[:name]} found with ID: #{sgid}")
|
230
|
+
end
|
231
|
+
end
|
232
|
+
|
233
|
+
# security group is created and we have it's ID
|
234
|
+
# so we add the rules... Does it really matter if they already exist ? CLoudstack seems to take care of that!
|
235
|
+
security_group[:rules].each do |rule|
|
236
|
+
rule_options = {
|
237
|
+
:securityGroupId => sgid,
|
238
|
+
:protocol => rule[:protocol],
|
239
|
+
:startport => rule[:startport],
|
240
|
+
:endport => rule[:endport],
|
241
|
+
:cidrlist => rule[:cidrlist]
|
242
|
+
}
|
243
|
+
|
244
|
+
# The rule[:type] is either ingress or egress, but the method call looks the same.
|
245
|
+
# We build a dynamic method name and then send it off.
|
246
|
+
env[:cloudstack_compute].send("authorize_security_group_#{rule[:type]}".to_sym, rule_options)
|
247
|
+
env[:ui].info(" --- #{rule[:type].capitalize} Rule added: #{rule[:protocol]} from #{rule[:startport]} to #{rule[:endport]} (#{rule[:cidrlist]})")
|
248
|
+
end
|
249
|
+
|
250
|
+
# and record the security group ids for future deletion (of rules and groups if possible)
|
251
|
+
security_groups_file = env[:machine].data_dir.join('security_groups')
|
252
|
+
security_groups_file.open('a+') do |f|
|
253
|
+
f.write("#{sgid}\n")
|
254
|
+
end
|
255
|
+
[security_group[:name], sgid]
|
256
|
+
end
|
257
|
+
|
291
258
|
def recover(env)
|
292
259
|
return if env["vagrant.error"].is_a?(Vagrant::Errors::VagrantError)
|
293
260
|
|
@@ -327,13 +327,13 @@ module VagrantPlugins
|
|
327
327
|
@pf_private_port = nil if @pf_private_port == UNSET_VALUE
|
328
328
|
|
329
329
|
# Security Group IDs must be nil, since we can't default that
|
330
|
-
@security_group_ids =
|
330
|
+
@security_group_ids = [] if @security_group_ids == UNSET_VALUE
|
331
331
|
|
332
332
|
# Security Group Names must be nil, since we can't default that
|
333
|
-
@security_group_names =
|
333
|
+
@security_group_names = [] if @security_group_names == UNSET_VALUE
|
334
334
|
|
335
335
|
# Security Groups must be nil, since we can't default that
|
336
|
-
@security_groups =
|
336
|
+
@security_groups = [] if @security_groups == UNSET_VALUE
|
337
337
|
|
338
338
|
# Display name must be nil, since we can't default that
|
339
339
|
@display_name = nil if @display_name == UNSET_VALUE
|
@@ -35,11 +35,11 @@ describe VagrantPlugins::Cloudstack::Config do
|
|
35
35
|
its("pf_ip_address_id") { should be_nil }
|
36
36
|
its("pf_public_port") { should be_nil }
|
37
37
|
its("pf_private_port") { should be_nil }
|
38
|
-
its("security_group_ids") { should
|
38
|
+
its("security_group_ids") { should == [] }
|
39
39
|
its("display_name") { should be_nil }
|
40
40
|
its("group") { should be_nil }
|
41
|
-
its("security_group_names") { should
|
42
|
-
its("security_groups") { should
|
41
|
+
its("security_group_names") { should == [] }
|
42
|
+
its("security_groups") { should == [] }
|
43
43
|
its("user_data") { should be_nil }
|
44
44
|
end
|
45
45
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-cloudstack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mitchell Hashimoto
|
@@ -18,7 +18,7 @@ authors:
|
|
18
18
|
autorequire:
|
19
19
|
bindir: bin
|
20
20
|
cert_chain: []
|
21
|
-
date: 2014-
|
21
|
+
date: 2014-09-11 00:00:00.000000000 Z
|
22
22
|
dependencies:
|
23
23
|
- !ruby/object:Gem::Dependency
|
24
24
|
name: fog
|