vagrant-cloudstack 1.4.0 → 1.5.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/.gitignore +0 -1
- data/.travis.yml +13 -9
- data/CHANGELOG.md +30 -0
- data/Docker/Dockerfile +5 -8
- data/Docker/Dockerfile.chefdk_0_17 +2 -2
- data/Docker/Dockerfile.latest_dependencies +2 -2
- data/Docker/README.md +63 -35
- data/Gemfile +2 -2
- data/Gemfile.lock +307 -0
- data/README.md +3 -3
- data/Rakefile +2 -2
- data/build_rpm.sh +1 -1
- data/functional-tests/rsync/Vagrantfile.advanced_networking +1 -0
- data/functional-tests/vmlifecycle/Vagrantfile.advanced_networking +5 -7
- data/functional-tests/vmlifecycle/vmlifecycle_spec.rb +14 -2
- data/lib/vagrant-cloudstack/action/read_rdp_info.rb +9 -43
- data/lib/vagrant-cloudstack/action/read_ssh_info.rb +10 -44
- data/lib/vagrant-cloudstack/action/read_transport_info.rb +59 -0
- data/lib/vagrant-cloudstack/action/read_winrm_info.rb +10 -44
- data/lib/vagrant-cloudstack/action/run_instance.rb +607 -498
- data/lib/vagrant-cloudstack/action/terminate_instance.rb +17 -41
- data/lib/vagrant-cloudstack/config.rb +41 -166
- data/lib/vagrant-cloudstack/exceptions/exceptions.rb +7 -2
- data/lib/vagrant-cloudstack/service/cloudstack_resource_service.rb +17 -5
- data/lib/vagrant-cloudstack/version.rb +1 -1
- data/spec/spec_helper.rb +45 -0
- data/spec/vagrant-cloudstack/action/retrieve_public_ip_port_spec.rb +94 -0
- data/spec/vagrant-cloudstack/action/run_instance_spec.rb +609 -0
- data/spec/vagrant-cloudstack/action/terminate_instance_spec.rb +248 -0
- data/spec/vagrant-cloudstack/config_spec.rb +7 -7
- data/vagrant-cloudstack.gemspec +2 -1
- metadata +22 -10
- data/bootstrap.key +0 -27
@@ -37,15 +37,7 @@ module VagrantPlugins
|
|
37
37
|
options['expunge'] = expunge_on_destroy
|
38
38
|
|
39
39
|
job = server.destroy(options)
|
40
|
-
|
41
|
-
response = env[:cloudstack_compute].query_async_job_result({:jobid => job.id})
|
42
|
-
if response['queryasyncjobresultresponse']['jobstatus'] != 0
|
43
|
-
break
|
44
|
-
else
|
45
|
-
env[:ui].info('Waiting for instance to be deleted')
|
46
|
-
sleep 2
|
47
|
-
end
|
48
|
-
end
|
40
|
+
wait_for_job_ready(env, job.id, 'Waiting for instance to be deleted')
|
49
41
|
end
|
50
42
|
|
51
43
|
remove_volumes(env)
|
@@ -73,14 +65,7 @@ module VagrantPlugins
|
|
73
65
|
begin
|
74
66
|
resp = env[:cloudstack_compute].detach_volume({:id => volume_id})
|
75
67
|
job_id = resp['detachvolumeresponse']['jobid']
|
76
|
-
|
77
|
-
response = env[:cloudstack_compute].query_async_job_result({:jobid => job_id})
|
78
|
-
if response['queryasyncjobresultresponse']['jobstatus'] != 0
|
79
|
-
break
|
80
|
-
else
|
81
|
-
sleep 2
|
82
|
-
end
|
83
|
-
end
|
68
|
+
wait_for_job_ready(env, job_id)
|
84
69
|
rescue Fog::Compute::Cloudstack::Error => e
|
85
70
|
if e.message =~ /Unable to execute API command detachvolume.*entity does not exist/
|
86
71
|
env[:ui].warn(I18n.t('vagrant_cloudstack.detach_volume_failed', message: e.message))
|
@@ -163,14 +148,7 @@ module VagrantPlugins
|
|
163
148
|
begin
|
164
149
|
resp = env[:cloudstack_compute].delete_port_forwarding_rule({:id => rule_id})
|
165
150
|
job_id = resp['deleteportforwardingruleresponse']['jobid']
|
166
|
-
|
167
|
-
response = env[:cloudstack_compute].query_async_job_result({:jobid => job_id})
|
168
|
-
if response['queryasyncjobresultresponse']['jobstatus'] != 0
|
169
|
-
break
|
170
|
-
else
|
171
|
-
sleep 2
|
172
|
-
end
|
173
|
-
end
|
151
|
+
wait_for_job_ready(env, job_id)
|
174
152
|
rescue Fog::Compute::Cloudstack::Error => e
|
175
153
|
if e.message =~ /Unable to execute API command deleteportforwardingrule.*entity does not exist/
|
176
154
|
env[:ui].warn(" -- Failed to delete portforwarding rule: #{e.message}")
|
@@ -204,14 +182,7 @@ module VagrantPlugins
|
|
204
182
|
}
|
205
183
|
resp = env[:cloudstack_compute].request(options)
|
206
184
|
job_id = resp['disablestaticnatresponse']['jobid']
|
207
|
-
|
208
|
-
response = env[:cloudstack_compute].query_async_job_result({:jobid => job_id})
|
209
|
-
if response['queryasyncjobresultresponse']['jobstatus'] != 0
|
210
|
-
break
|
211
|
-
else
|
212
|
-
sleep 2
|
213
|
-
end
|
214
|
-
end
|
185
|
+
wait_for_job_ready(env, job_id)
|
215
186
|
rescue Fog::Compute::Cloudstack::Error => e
|
216
187
|
raise Errors::FogError, :message => e.message
|
217
188
|
end
|
@@ -244,14 +215,7 @@ module VagrantPlugins
|
|
244
215
|
}
|
245
216
|
resp = env[:cloudstack_compute].request(options)
|
246
217
|
job_id = resp[response_string]['jobid']
|
247
|
-
|
248
|
-
response = env[:cloudstack_compute].query_async_job_result({:jobid => job_id})
|
249
|
-
if response['queryasyncjobresultresponse']['jobstatus'] != 0
|
250
|
-
break
|
251
|
-
else
|
252
|
-
sleep 2
|
253
|
-
end
|
254
|
-
end
|
218
|
+
wait_for_job_ready(env, job_id)
|
255
219
|
rescue Fog::Compute::Cloudstack::Error => e
|
256
220
|
if e.message =~ /Unable to execute API command deletefirewallrule.*entity does not exist/
|
257
221
|
env[:ui].warn(" -- Failed to delete #{type_string}: #{e.message}")
|
@@ -263,6 +227,18 @@ module VagrantPlugins
|
|
263
227
|
firewall_file.delete
|
264
228
|
end
|
265
229
|
end
|
230
|
+
|
231
|
+
def wait_for_job_ready(env, job_id, message=nil)
|
232
|
+
while true
|
233
|
+
response = env[:cloudstack_compute].query_async_job_result({:jobid => job_id})
|
234
|
+
if response['queryasyncjobresultresponse']['jobstatus'] != 0
|
235
|
+
break
|
236
|
+
else
|
237
|
+
env[:ui].info(message) if message
|
238
|
+
sleep 2
|
239
|
+
end
|
240
|
+
end
|
241
|
+
end
|
266
242
|
end
|
267
243
|
end
|
268
244
|
end
|
@@ -3,6 +3,12 @@ require "vagrant"
|
|
3
3
|
module VagrantPlugins
|
4
4
|
module Cloudstack
|
5
5
|
class Config < Vagrant.plugin("2", :config)
|
6
|
+
INSTANCE_VAR_DEFAULT_NIL = %w(host name path port domain_id network_id network_name project_id service_offering_id service_offering_name
|
7
|
+
template_id template_name zone_id zone_name keypair pf_ip_address_id pf_ip_address pf_public_port
|
8
|
+
pf_public_rdp_port pf_private_port pf_trusted_networks display_name group user_data ssh_key ssh_user
|
9
|
+
ssh_network_id ssh_network_name vm_user vm_password private_ip_address).freeze
|
10
|
+
INSTANCE_VAR_DEFAULT_EMPTY_ARRAY = %w(static_nat port_forwarding_rules firewall_rules security_group_ids security_group_names security_groups).freeze
|
11
|
+
|
6
12
|
# Cloudstack api host.
|
7
13
|
#
|
8
14
|
# @return [String]
|
@@ -252,53 +258,25 @@ module VagrantPlugins
|
|
252
258
|
# @return [Boolean]
|
253
259
|
attr_accessor :expunge_on_destroy
|
254
260
|
|
255
|
-
def initialize(domain_specific=false)
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
@
|
266
|
-
@
|
267
|
-
@
|
268
|
-
@
|
269
|
-
@
|
270
|
-
@
|
271
|
-
@
|
272
|
-
@
|
273
|
-
@
|
274
|
-
@zone_name = UNSET_VALUE
|
275
|
-
@keypair = UNSET_VALUE
|
276
|
-
@static_nat = UNSET_VALUE
|
277
|
-
@pf_ip_address_id = UNSET_VALUE
|
278
|
-
@pf_ip_address = UNSET_VALUE
|
279
|
-
@pf_public_port = UNSET_VALUE
|
280
|
-
@pf_public_rdp_port = UNSET_VALUE
|
281
|
-
@pf_private_rdp_port = UNSET_VALUE
|
282
|
-
@pf_public_port_randomrange= UNSET_VALUE
|
283
|
-
@pf_private_port = UNSET_VALUE
|
284
|
-
@pf_open_firewall = UNSET_VALUE
|
285
|
-
@pf_trusted_networks = UNSET_VALUE
|
286
|
-
@port_forwarding_rules = UNSET_VALUE
|
287
|
-
@firewall_rules = UNSET_VALUE
|
288
|
-
@security_group_ids = UNSET_VALUE
|
289
|
-
@display_name = UNSET_VALUE
|
290
|
-
@group = UNSET_VALUE
|
291
|
-
@security_group_names = UNSET_VALUE
|
292
|
-
@security_groups = UNSET_VALUE
|
293
|
-
@user_data = UNSET_VALUE
|
294
|
-
@ssh_key = UNSET_VALUE
|
295
|
-
@ssh_user = UNSET_VALUE
|
296
|
-
@ssh_network_id = UNSET_VALUE
|
297
|
-
@ssh_network_name = UNSET_VALUE
|
298
|
-
@vm_user = UNSET_VALUE
|
299
|
-
@vm_password = UNSET_VALUE
|
300
|
-
@private_ip_address = UNSET_VALUE
|
301
|
-
@expunge_on_destroy = UNSET_VALUE
|
261
|
+
def initialize(domain_specific = false)
|
262
|
+
# Initialize groups in bulk, re-use these groups to set defaults in bulk
|
263
|
+
INSTANCE_VAR_DEFAULT_NIL.each do |instance_variable|
|
264
|
+
instance_variable_set("@#{instance_variable}", UNSET_VALUE)
|
265
|
+
end
|
266
|
+
# Initialize groups in bulk, re-use these groups to set defaults in bulk
|
267
|
+
INSTANCE_VAR_DEFAULT_EMPTY_ARRAY.each do |instance_variable|
|
268
|
+
instance_variable_set("@#{instance_variable}", UNSET_VALUE)
|
269
|
+
end
|
270
|
+
|
271
|
+
@scheme = UNSET_VALUE
|
272
|
+
@api_key = UNSET_VALUE
|
273
|
+
@secret_key = UNSET_VALUE
|
274
|
+
@instance_ready_timeout = UNSET_VALUE
|
275
|
+
@network_type = UNSET_VALUE
|
276
|
+
@pf_private_rdp_port = UNSET_VALUE
|
277
|
+
@pf_public_port_randomrange = UNSET_VALUE
|
278
|
+
@pf_open_firewall = UNSET_VALUE
|
279
|
+
@expunge_on_destroy = UNSET_VALUE
|
302
280
|
|
303
281
|
# Internal state (prefix with __ so they aren't automatically
|
304
282
|
# merged)
|
@@ -369,17 +347,17 @@ module VagrantPlugins
|
|
369
347
|
end
|
370
348
|
|
371
349
|
def finalize!
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
# Path must be nil, since we can't default that
|
379
|
-
@path = nil if @path == UNSET_VALUE
|
350
|
+
INSTANCE_VAR_DEFAULT_NIL.each do |instance_variable|
|
351
|
+
# ... must be nil, since we can't default that
|
352
|
+
instance_variable_set("@#{instance_variable}", nil) if
|
353
|
+
instance_variable_get("@#{instance_variable}") == UNSET_VALUE
|
354
|
+
end
|
380
355
|
|
381
|
-
|
382
|
-
|
356
|
+
INSTANCE_VAR_DEFAULT_EMPTY_ARRAY.each do |instance_variable|
|
357
|
+
# ... must be empty array
|
358
|
+
instance_variable_set("@#{instance_variable}", []) if
|
359
|
+
instance_variable_get("@#{instance_variable}") == UNSET_VALUE
|
360
|
+
end
|
383
361
|
|
384
362
|
# We default the scheme to whatever the user has specifid in the .fog file
|
385
363
|
# *OR* whatever is default for the provider in the fog library
|
@@ -393,131 +371,31 @@ module VagrantPlugins
|
|
393
371
|
# Set the default timeout for waiting for an instance to be ready
|
394
372
|
@instance_ready_timeout = 120 if @instance_ready_timeout == UNSET_VALUE
|
395
373
|
|
396
|
-
# Domain id must be nil, since we can't default that
|
397
|
-
@domain_id = nil if @domain_id == UNSET_VALUE
|
398
|
-
|
399
|
-
# Network uuid must be nil, since we can't default that
|
400
|
-
@network_id = nil if @network_id == UNSET_VALUE
|
401
|
-
|
402
|
-
# Network uuid must be nil, since we can't default that
|
403
|
-
@network_name = nil if @network_name == UNSET_VALUE
|
404
|
-
|
405
374
|
# NetworkType is 'Advanced' by default
|
406
375
|
@network_type = "Advanced" if @network_type == UNSET_VALUE
|
407
376
|
|
408
|
-
# Project uuid must be nil, since we can't default that
|
409
|
-
@project_id = nil if @project_id == UNSET_VALUE
|
410
|
-
|
411
|
-
# Service offering uuid must be nil, since we can't default that
|
412
|
-
@service_offering_id = nil if @service_offering_id == UNSET_VALUE
|
413
|
-
|
414
|
-
# Service offering name must be nil, since we can't default that
|
415
|
-
@service_offering_name = nil if @service_offering_name == UNSET_VALUE
|
416
|
-
|
417
|
-
# Template uuid must be nil, since we can't default that
|
418
|
-
@template_id = nil if @template_id == UNSET_VALUE
|
419
|
-
|
420
|
-
# Template name must be nil, since we can't default that
|
421
|
-
@template_name = nil if @template_name == UNSET_VALUE
|
422
|
-
|
423
|
-
# Zone uuid must be nil, since we can't default that
|
424
|
-
@zone_id = nil if @zone_id == UNSET_VALUE
|
425
|
-
|
426
|
-
# Zone uuid must be nil, since we can't default that
|
427
|
-
@zone_name = nil if @zone_name == UNSET_VALUE
|
428
|
-
|
429
|
-
# Keypair defaults to nil
|
430
|
-
@keypair = nil if @keypair == UNSET_VALUE
|
431
|
-
|
432
|
-
# Static NAT must be empty array
|
433
|
-
@static_nat = [] if @static_nat == UNSET_VALUE
|
434
|
-
|
435
|
-
# IP address id must be nil, since we can't default that
|
436
|
-
@pf_ip_address_id = nil if @pf_ip_address_id == UNSET_VALUE
|
437
|
-
|
438
|
-
# IP address must be nil, since we can't default that
|
439
|
-
@pf_ip_address = nil if @pf_ip_address == UNSET_VALUE
|
440
|
-
|
441
|
-
# Public port must be nil, since we can't default that
|
442
|
-
@pf_public_port = nil if @pf_public_port == UNSET_VALUE
|
443
|
-
|
444
|
-
# Public port must be nil, since we can't default that
|
445
|
-
@pf_public_rdp_port = nil if @pf_public_rdp_port == UNSET_VALUE
|
446
|
-
|
447
377
|
# Private rdp port defaults to 3389
|
448
378
|
@pf_private_rdp_port = 3389 if @pf_private_rdp_port == UNSET_VALUE
|
449
379
|
|
450
380
|
# Public port random-range, default to rfc6335 'Dynamic Ports'; "(never assigned)"
|
451
|
-
@pf_public_port_randomrange = {:start=>
|
452
|
-
|
453
|
-
# Private port must be nil, since we can't default that
|
454
|
-
@pf_private_port = nil if @pf_private_port == UNSET_VALUE
|
381
|
+
@pf_public_port_randomrange = {:start=>49152, :end=>65535} if @pf_public_port_randomrange == UNSET_VALUE
|
455
382
|
|
456
383
|
# Open firewall is true by default (for backwards compatibility)
|
457
384
|
@pf_open_firewall = true if @pf_open_firewall == UNSET_VALUE
|
458
385
|
|
459
|
-
# Trusted networks must be nil, since we can't default that
|
460
|
-
@pf_trusted_networks = nil if @pf_trusted_networks == UNSET_VALUE
|
461
|
-
|
462
|
-
# Port forwarding rules must be empty array
|
463
|
-
@port_forwarding_rules = [] if @port_forwarding_rules == UNSET_VALUE
|
464
|
-
|
465
|
-
# Firewall rules must be empty array
|
466
|
-
@firewall_rules = [] if @firewall_rules == UNSET_VALUE
|
467
|
-
|
468
|
-
# Security Group IDs must be nil, since we can't default that
|
469
|
-
@security_group_ids = [] if @security_group_ids == UNSET_VALUE
|
470
|
-
|
471
|
-
# Security Group Names must be nil, since we can't default that
|
472
|
-
@security_group_names = [] if @security_group_names == UNSET_VALUE
|
473
|
-
|
474
|
-
# Security Groups must be nil, since we can't default that
|
475
|
-
@security_groups = [] if @security_groups == UNSET_VALUE
|
476
|
-
|
477
|
-
# Display name must be nil, since we can't default that
|
478
|
-
@display_name = nil if @display_name == UNSET_VALUE
|
479
|
-
|
480
|
-
# Group must be nil, since we can't default that
|
481
|
-
@group = nil if @group == UNSET_VALUE
|
482
|
-
|
483
|
-
# User Data is nil by default
|
484
|
-
@user_data = nil if @user_data == UNSET_VALUE
|
485
|
-
|
486
|
-
# ssh key is nil by default
|
487
|
-
@ssh_key = nil if @ssh_key == UNSET_VALUE
|
488
|
-
|
489
|
-
# ssh user is nil by default
|
490
|
-
@ssh_user = nil if @ssh_user == UNSET_VALUE
|
491
|
-
|
492
|
-
# ssh network_id is nil by default
|
493
|
-
@ssh_network_id = nil if @ssh_network_id == UNSET_VALUE
|
494
|
-
|
495
|
-
# ssh network_name is nil by default
|
496
|
-
@ssh_network_name = nil if @ssh_network_name == UNSET_VALUE
|
497
|
-
|
498
|
-
# vm user is nil by default
|
499
|
-
@vm_user = nil if @vm_user == UNSET_VALUE
|
500
|
-
|
501
|
-
# vm password is nil by default
|
502
|
-
@vm_password = nil if @vm_password == UNSET_VALUE
|
503
|
-
|
504
|
-
# private ip is nil by default
|
505
|
-
@private_ip_address = nil if @private_ip_address == UNSET_VALUE
|
506
|
-
|
507
386
|
# expunge on destroy is nil by default
|
508
387
|
@expunge_on_destroy = false if @expunge_on_destroy == UNSET_VALUE
|
509
388
|
|
510
389
|
# Compile our domain specific configurations only within
|
511
390
|
# NON-DOMAIN-SPECIFIC configurations.
|
512
|
-
|
391
|
+
unless @__domain_specific
|
513
392
|
@__domain_config.each do |domain, blocks|
|
514
393
|
config = self.class.new(true).merge(self)
|
515
394
|
|
516
395
|
# Execute the configuration for each block
|
517
396
|
blocks.each { |b| b.call(config) }
|
518
397
|
|
519
|
-
# The domain name of the configuration always equals the
|
520
|
-
# domain config name:
|
398
|
+
# The domain name of the configuration always equals the domain config name:
|
521
399
|
config.domain = domain
|
522
400
|
|
523
401
|
# Finalize the configuration
|
@@ -536,11 +414,10 @@ module VagrantPlugins
|
|
536
414
|
errors = []
|
537
415
|
|
538
416
|
if @domain
|
539
|
-
# Get the configuration for the domain we're using and validate only
|
540
|
-
# that domain.
|
417
|
+
# Get the configuration for the domain we're using and validate only that domain.
|
541
418
|
config = get_domain_config(@domain)
|
542
419
|
|
543
|
-
|
420
|
+
unless config.use_fog_profile
|
544
421
|
errors << I18n.t("vagrant_cloudstack.config.api_key_required") if \
|
545
422
|
config.access_key_id.nil?
|
546
423
|
errors << I18n.t("vagrant_cloudstack.config.secret_key_required") if \
|
@@ -554,9 +431,7 @@ module VagrantPlugins
|
|
554
431
|
# This gets the configuration for a specific domain. It shouldn't
|
555
432
|
# be called by the general public and is only used internally.
|
556
433
|
def get_domain_config(name)
|
557
|
-
|
558
|
-
raise "Configuration must be finalized before calling this method."
|
559
|
-
end
|
434
|
+
raise 'Configuration must be finalized before calling this method.' unless @__finalized
|
560
435
|
|
561
436
|
# Return the compiled domain config
|
562
437
|
@__compiled_domain_configs[name] || self
|
@@ -1,9 +1,14 @@
|
|
1
1
|
module VagrantPlugins
|
2
2
|
module Cloudstack
|
3
3
|
module Exceptions
|
4
|
-
class IpNotFoundException <
|
4
|
+
class IpNotFoundException < StandardError
|
5
5
|
end
|
6
|
-
class DuplicatePFRule <
|
6
|
+
class DuplicatePFRule < StandardError
|
7
|
+
end
|
8
|
+
class CloudstackResourceNotFound < StandardError
|
9
|
+
def initialize(msg='Resource not found in cloudstack')
|
10
|
+
super
|
11
|
+
end
|
7
12
|
end
|
8
13
|
end
|
9
14
|
end
|
@@ -1,7 +1,11 @@
|
|
1
|
+
require 'vagrant-cloudstack/exceptions/exceptions'
|
2
|
+
|
1
3
|
module VagrantPlugins
|
2
4
|
module Cloudstack
|
3
5
|
module Service
|
4
6
|
class CloudstackResourceService
|
7
|
+
include VagrantPlugins::Cloudstack::Exceptions
|
8
|
+
|
5
9
|
def initialize(cloudstack_compute, ui)
|
6
10
|
@cloudstack_compute = cloudstack_compute
|
7
11
|
@ui = ui
|
@@ -9,13 +13,13 @@ module VagrantPlugins
|
|
9
13
|
|
10
14
|
def sync_resource(resource, api_parameters = {})
|
11
15
|
@resource_details = nil
|
12
|
-
if resource.id.nil? and resource.name
|
16
|
+
if resource.id.nil? and !(resource.name.nil? || resource.name.empty? )
|
13
17
|
resource.id = name_to_id(resource.name, resource.kind, api_parameters)
|
14
18
|
elsif resource.id
|
15
19
|
resource.name = id_to_name(resource.id, resource.kind, api_parameters)
|
16
20
|
end
|
17
21
|
|
18
|
-
unless resource.
|
22
|
+
unless resource.is_id_undefined? || resource.is_name_undefined?
|
19
23
|
resource.details = @resource_details
|
20
24
|
@ui.detail("Syncronized resource: #{resource}")
|
21
25
|
end
|
@@ -37,14 +41,22 @@ module VagrantPlugins
|
|
37
41
|
def resourcefield_to_id(resource_type, resource_field, resource_field_value, options={})
|
38
42
|
@ui.info("Fetching UUID for #{resource_type} with #{resource_field} '#{resource_field_value}'")
|
39
43
|
full_response = translate_from_to(resource_type, options)
|
40
|
-
@resource_details = full_response.find {|type| type[resource_field] == resource_field_value }
|
41
|
-
@resource_details
|
44
|
+
@resource_details = full_response.find {|type| type[resource_field] == resource_field_value } if full_response
|
45
|
+
if @resource_details
|
46
|
+
@resource_details['id']
|
47
|
+
else
|
48
|
+
raise CloudstackResourceNotFound.new("No UUID found for #{resource_type} with #{resource_field} '#{resource_field_value}'")
|
49
|
+
end
|
42
50
|
end
|
43
51
|
|
44
52
|
def id_to_resourcefield(resource_id, resource_type, resource_field, options={})
|
45
53
|
@ui.info("Fetching #{resource_field} for #{resource_type} with UUID '#{resource_id}'")
|
46
54
|
options = options.merge({'id' => resource_id})
|
47
|
-
|
55
|
+
begin
|
56
|
+
full_response = translate_from_to(resource_type, options)
|
57
|
+
rescue Fog::Compute::Cloudstack::BadRequest => e
|
58
|
+
raise CloudstackResourceNotFound.new("No Name found for #{resource_type} with UUID '#{resource_id}', #{e.class.to_s} reports:\n #{e.message}")
|
59
|
+
end
|
48
60
|
@resource_details = full_response[0]
|
49
61
|
@resource_details[resource_field]
|
50
62
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,8 +1,53 @@
|
|
1
1
|
require 'simplecov'
|
2
2
|
require 'coveralls'
|
3
3
|
require 'rspec/its'
|
4
|
+
require 'i18n'
|
4
5
|
|
5
6
|
Dir["#{__dir__}/vagrant-cloudstack/support/**/*.rb"].each { |f| require f }
|
6
7
|
|
7
8
|
SimpleCov.start
|
8
9
|
Coveralls.wear!
|
10
|
+
|
11
|
+
ZONE_NAME = 'Zone Name'.freeze
|
12
|
+
ZONE_ID = 'Zone UUID'.freeze
|
13
|
+
SERVICE_OFFERING_NAME = 'Service Offering Name'.freeze
|
14
|
+
SERVICE_OFFERING_ID = 'Service Offering UUID'.freeze
|
15
|
+
TEMPLATE_NAME = 'Template Name'.freeze
|
16
|
+
TEMPLATE_ID = 'Template UUID'.freeze
|
17
|
+
NETWORK_NAME = 'Network Name'.freeze
|
18
|
+
NETWORK_ID = 'Network UUID'.freeze
|
19
|
+
VPC_ID = 'VPC UUID'.freeze
|
20
|
+
DISPLAY_NAME = 'Display Name'.freeze
|
21
|
+
DISK_OFFERING_NAME = 'Disk Offering Name'.freeze
|
22
|
+
DISK_OFFERING_ID = 'Disk Offering UUID'.freeze
|
23
|
+
|
24
|
+
SERVER_ID = 'Server UUID'.freeze
|
25
|
+
NETWORK_TYPE_ADVANCED = 'Advanced'.freeze
|
26
|
+
NETWORK_TYPE_BASIC = 'Basic'.freeze
|
27
|
+
SECURITY_GROUPS_ENABLED = true
|
28
|
+
SECURITY_GROUPS_DISABLED = false
|
29
|
+
SECURITY_GROUP_ID = 'UUID of Security Group'.freeze
|
30
|
+
SECURITY_GROUP_NAME = 'Name of Security Group'.freeze
|
31
|
+
SECURITY_GROUP_DESC = 'Description of Security Group'.freeze
|
32
|
+
|
33
|
+
PF_IP_ADDRESS = 'Public IP for port forwarding'.freeze
|
34
|
+
PF_IP_ADDRESS_ID = 'UUID of Public IP for port forwarding'.freeze
|
35
|
+
PF_TRUSTED_NETWORKS = 'IP Ranges to allow public access from'.freeze
|
36
|
+
PF_RANDOM_START = 49_152
|
37
|
+
GUEST_PORT_SSH = 22
|
38
|
+
GUEST_PORT_WINRM = 5985
|
39
|
+
GUEST_PORT_RDP = 3389
|
40
|
+
|
41
|
+
COMMUNICATOR_SSH = 'VagrantPlugins::CommunicatorSSH::Communicator'.freeze
|
42
|
+
COMMUNICATOR_WINRM = 'VagrantPlugins::CommunicatorWinRM::Communicator'.freeze
|
43
|
+
|
44
|
+
SSH_GENERATED_PRIVATE_KEY = '-----BEGIN RSA PRIVATE KEY-----\nMIICWwIBA==\n-----END RSA PRIVATE KEY-----'.freeze
|
45
|
+
SSH_GENERATED_KEY_NAME = 'SSH Generated Key Name'.freeze
|
46
|
+
JOB_ID = 'UUID of a Job'.freeze
|
47
|
+
PORT_FORWARDING_RULE_ID = 'UUID of port forwarding rule'.freeze
|
48
|
+
ACL_ID = 'UUID of an ACL'.freeze
|
49
|
+
GENERATED_PASSWORD = 'Generated password'.freeze
|
50
|
+
VOLUME_ID = 'UUID of volume'.freeze
|
51
|
+
|
52
|
+
I18n.load_path << File.expand_path('../../locales/en.yml', __FILE__)
|
53
|
+
I18n.reload!
|