bosh_vcloud_cpi 0.4.8 → 0.4.9

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.
@@ -36,7 +36,7 @@ module VCloudCloud
36
36
  at_exit { destroy_client }
37
37
  end
38
38
 
39
- def client()
39
+ def client
40
40
  @client_lock.synchronize {
41
41
  if @client.nil?
42
42
  create_client
@@ -145,8 +145,8 @@ module VCloudCloud
145
145
  @client = client
146
146
 
147
147
  with_thread_name("create_vm(#{agent_id}, ...)") do
148
- Util.retry_operation("create_vm(#{agent_id}, ...)", @retries['cpi'],
149
- @control['backoff']) do
148
+ Util.retry_operation("create_vm(#{agent_id}, ...)", @retries["cpi"],
149
+ @control["backoff"]) do
150
150
  @logger.info("Creating VM: #{agent_id}")
151
151
  @logger.debug("networks: #{networks.inspect}")
152
152
 
@@ -172,8 +172,8 @@ module VCloudCloud
172
172
  @client = client
173
173
 
174
174
  with_thread_name("delete_vm(#{vapp_id}, ...)") do
175
- Util.retry_operation("delete_vm(#{vapp_id}, ...)", @retries['cpi'],
176
- @control['backoff']) do
175
+ Util.retry_operation("delete_vm(#{vapp_id}, ...)", @retries["cpi"],
176
+ @control["backoff"]) do
177
177
  @logger.info("Deleting vApp: #{vapp_id}")
178
178
  vapp = @client.get_vapp(vapp_id)
179
179
  vm = get_vm(vapp)
@@ -185,7 +185,7 @@ module VCloudCloud
185
185
  @client.discard_suspended_state_vapp(vapp)
186
186
  @client.power_off_vapp(vapp)
187
187
  end
188
- del_vapp = @vcd['debug']['delete_vapp']
188
+ del_vapp = @vcd["debug"]["delete_vapp"]
189
189
  @client.delete_vapp(vapp) if del_vapp
190
190
  @logger.info("Deleting ISO #{vm_name}")
191
191
  @client.delete_catalog_media(vm_name) if del_vapp
@@ -201,8 +201,8 @@ module VCloudCloud
201
201
  @client = client
202
202
 
203
203
  with_thread_name("reboot_vm(#{vapp_id}, ...)") do
204
- Util.retry_operation("reboot_vm(#{vapp_id}, ...)", @retries['cpi'],
205
- @control['backoff']) do
204
+ Util.retry_operation("reboot_vm(#{vapp_id}, ...)", @retries["cpi"],
205
+ @control["backoff"]) do
206
206
  @logger.info("Rebooting vApp: #{vapp_id}")
207
207
  vapp = @client.get_vapp(vapp_id)
208
208
  begin
@@ -226,7 +226,7 @@ module VCloudCloud
226
226
 
227
227
  with_thread_name("configure_networks(#{vapp_id}, ...)") do
228
228
  Util.retry_operation("configure_networks(#{vapp_id}, ...)",
229
- @retries['cpi'], @control['backoff']) do
229
+ @retries["cpi"], @control["backoff"]) do
230
230
  @logger.info("Reconfiguring vApp networks: #{vapp_id}")
231
231
  vapp, vm = get_vapp_vm_by_vapp_id(vapp_id)
232
232
  @logger.debug("Powering off #{vapp.name}.")
@@ -266,7 +266,7 @@ module VCloudCloud
266
266
 
267
267
  with_thread_name("attach_disk(#{vapp_id} #{disk_id})") do
268
268
  Util.retry_operation("attach_disk(#{vapp_id}, #{disk_id})",
269
- @retries['cpi'], @control['backoff']) do
269
+ @retries["cpi"], @control["backoff"]) do
270
270
  @logger.info("Attaching disk: #{disk_id} on vm: #{vapp_id}")
271
271
 
272
272
  vapp, vm = get_vapp_vm_by_vapp_id(vapp_id)
@@ -297,7 +297,7 @@ module VCloudCloud
297
297
 
298
298
  with_thread_name("detach_disk(#{vapp_id} #{disk_id})") do
299
299
  Util.retry_operation("detach_disk(#{vapp_id}, #{disk_id})",
300
- @retries['cpi'], @control['backoff']) do
300
+ @retries["cpi"], @control["backoff"]) do
301
301
  @logger.info("Detaching disk: #{disk_id} from vm: #{vapp_id}")
302
302
 
303
303
  vapp, vm = get_vapp_vm_by_vapp_id(vapp_id)
@@ -328,7 +328,7 @@ module VCloudCloud
328
328
 
329
329
  with_thread_name("create_disk(#{size_mb}, vm_locality)") do
330
330
  Util.retry_operation("create_disk(#{size_mb}, vm_locality)",
331
- @retries['cpi'], @control['backoff']) do
331
+ @retries["cpi"], @control["backoff"]) do
332
332
  @logger.info("Create disk: #{size_mb}, #{vm_locality}")
333
333
  disk_name = "#{generate_unique_name}"
334
334
  disk = nil
@@ -355,8 +355,8 @@ module VCloudCloud
355
355
  @client = client
356
356
 
357
357
  with_thread_name("delete_disk(#{disk_id})") do
358
- Util.retry_operation("delete_disk(#{disk_id})", @retries['cpi'],
359
- @control['backoff']) do
358
+ Util.retry_operation("delete_disk(#{disk_id})", @retries["cpi"],
359
+ @control["backoff"]) do
360
360
  @logger.info("Deleting disk: #{disk_id}")
361
361
  disk = @client.get_disk(disk_id)
362
362
  @client.delete_disk(disk)
@@ -372,8 +372,8 @@ module VCloudCloud
372
372
  @client = client
373
373
 
374
374
  with_thread_name("get_disk_size(#{disk_id})") do
375
- Util.retry_operation("get_disk_size(#{disk_id})", @retries['cpi'],
376
- @control['backoff']) do
375
+ Util.retry_operation("get_disk_size(#{disk_id})", @retries["cpi"],
376
+ @control["backoff"]) do
377
377
  @logger.info("Getting disk size: #{disk_id}")
378
378
  disk = @client.get_disk(disk_id)
379
379
  @logger.info("Disk #{disk_id} size: #{disk.size_mb} MB")
@@ -393,44 +393,43 @@ module VCloudCloud
393
393
  private
394
394
 
395
395
  def finalize_options
396
- @vcd['control'] = {} unless @vcd['control']
397
- @vcd['control']['retries'] = {} unless @vcd['control']['retries']
398
- @vcd['control']['retries']['default'] ||= RETRIES_DEFAULT
399
- @vcd['control']['retries']['upload_vapp_files'] ||=
396
+ @vcd["control"] = {} unless @vcd["control"]
397
+ @vcd["control"]["retries"] = {} unless @vcd["control"]["retries"]
398
+ @vcd["control"]["retries"]["default"] ||= RETRIES_DEFAULT
399
+ @vcd["control"]["retries"]["upload_vapp_files"] ||=
400
400
  RETRIES_UPLOAD_VAPP_FILES
401
- @vcd['control']['retries']['cpi'] ||= RETRIES_CPI
402
- @vcd['control']['delay'] ||= DELAY
403
- @vcd['control']['time_limit_sec'] = {} unless
404
- @vcd['control']['time_limit_sec']
405
- @vcd['control']['time_limit_sec']['default'] ||= TIMELIMIT_DEFAULT
406
- @vcd['control']['time_limit_sec']['delete_vapp_template'] ||=
401
+ @vcd["control"]["retries"]["cpi"] ||= RETRIES_CPI
402
+ @vcd["control"]["delay"] ||= DELAY
403
+ @vcd["control"]["time_limit_sec"] = {} unless
404
+ @vcd["control"]["time_limit_sec"]
405
+ @vcd["control"]["time_limit_sec"]["default"] ||= TIMELIMIT_DEFAULT
406
+ @vcd["control"]["time_limit_sec"]["delete_vapp_template"] ||=
407
407
  TIMELIMIT_DELETE_VAPP_TEMPLATE
408
- @vcd['control']['time_limit_sec']['delete_vapp'] ||= TIMELIMIT_DELETE_VAPP
409
- @vcd['control']['time_limit_sec']['delete_media'] ||=
408
+ @vcd["control"]["time_limit_sec"]["delete_vapp"] ||= TIMELIMIT_DELETE_VAPP
409
+ @vcd["control"]["time_limit_sec"]["delete_media"] ||=
410
410
  TIMELIMIT_DELETE_MEDIA
411
- @vcd['control']['time_limit_sec']['instantiate_vapp_template'] ||=
411
+ @vcd["control"]["time_limit_sec"]["instantiate_vapp_template"] ||=
412
412
  TIMELIMIT_INSTANTIATE_VAPP_TEMPLATE
413
- @vcd['control']['time_limit_sec']['power_on'] ||= TIMELIMIT_POWER_ON
414
- @vcd['control']['time_limit_sec']['power_off'] ||= TIMELIMIT_POWER_OFF
415
- @vcd['control']['time_limit_sec']['undeploy'] ||= TIMELIMIT_UNDEPLOY
416
- @vcd['control']['time_limit_sec']['process_descriptor_vapp_template'] ||=
413
+ @vcd["control"]["time_limit_sec"]["power_on"] ||= TIMELIMIT_POWER_ON
414
+ @vcd["control"]["time_limit_sec"]["power_off"] ||= TIMELIMIT_POWER_OFF
415
+ @vcd["control"]["time_limit_sec"]["undeploy"] ||= TIMELIMIT_UNDEPLOY
416
+ @vcd["control"]["time_limit_sec"]["process_descriptor_vapp_template"] ||=
417
417
  TIMELIMIT_PROCESS_DESCRIPTOR_VAPP_TEMPLATE
418
- @vcd['control']['time_limit_sec']['http_request'] ||=
418
+ @vcd["control"]["time_limit_sec"]["http_request"] ||=
419
419
  TIMELIMIT_HTTP_REQUEST
420
- @vcd['control']['backoff'] ||= BACKOFF
421
- @vcd['control']['rest_throttle'] = {} unless
422
- @vcd['control']['rest_throttle']
423
- @vcd['control']['rest_throttle']['min'] ||= REST_THROTTLE_MIN
424
- @vcd['control']['rest_throttle']['max'] ||= REST_THROTTLE_MAX
425
- @vcd['debug'] = {} unless @vcd['debug']
426
- @vcd['debug']['delete_vapp'] = DEBUG_DELETE_VAPP unless
427
- @vcd['debug']['delete_vapp']
420
+ @vcd["control"]["backoff"] ||= BACKOFF
421
+ @vcd["control"]["rest_throttle"] = {} unless
422
+ @vcd["control"]["rest_throttle"]
423
+ @vcd["control"]["rest_throttle"]["min"] ||= REST_THROTTLE_MIN
424
+ @vcd["control"]["rest_throttle"]["max"] ||= REST_THROTTLE_MAX
425
+ @vcd["debug"] = {} unless @vcd["debug"]
426
+ @vcd["debug"]["delete_vapp"] = DEBUG_DELETE_VAPP unless
427
+ @vcd["debug"]["delete_vapp"]
428
428
  end
429
429
 
430
- def create_client()
430
+ def create_client
431
431
  url = @vcd["url"]
432
432
  @logger.debug("Create session to VCD cloud: #{url}")
433
- #@rest_logger.debug("Session to VCD cloud: #{url}")
434
433
 
435
434
  @client = VCloudSdk::Client.new(url, @vcd["user"],
436
435
  @vcd["password"], @vcd["entities"], @vcd["control"])
@@ -443,7 +442,7 @@ module VCloudCloud
443
442
  raise e
444
443
  end
445
444
 
446
- def destroy_client()
445
+ def destroy_client
447
446
  url = @vcd["url"]
448
447
  @logger.debug("Destroy session to VCD cloud: #{url}")
449
448
  # TODO VCloudSdk::Client should permit logout.
@@ -535,7 +534,7 @@ module VCloudCloud
535
534
  @client.set_metadata(vm, @vcd["entities"]["vm_metadata_key"], env_json)
536
535
 
537
536
  storage_profiles = @client.get_ovdc.storage_profiles || []
538
- media_storage_profile = storage_profiles.find { |sp| sp['name'] ==
537
+ media_storage_profile = storage_profiles.find { |sp| sp["name"] ==
539
538
  @vcd["entities"]["media_storage_profile"] }
540
539
  @logger.info("Uploading and inserting ISO #{iso_path} as #{vm.name} " +
541
540
  "to #{media_storage_profile.inspect}")
@@ -546,7 +545,7 @@ module VCloudCloud
546
545
  end
547
546
 
548
547
  def delete_vapp_networks(vapp, exclude_nets)
549
- exclude = exclude_nets.map {|k,v| v["cloud_properties"]["name"]}.uniq
548
+ exclude = exclude_nets.map { |k,v| v["cloud_properties"]["name"] }.uniq
550
549
  @client.delete_networks(vapp, exclude)
551
550
  @logger.debug("Deleted vApp #{vapp.name} networks excluding " +
552
551
  "#{exclude.inspect}.")
@@ -562,7 +561,7 @@ module VCloudCloud
562
561
  cloud_networks.each do |configured_network|
563
562
  @logger.debug("Adding configured network: #{configured_network}")
564
563
  org_net = accessible_org_networks.find {
565
- |n| n['name'] == configured_network }
564
+ |n| n["name"] == configured_network }
566
565
  unless org_net
567
566
  raise VCloudSdk::CloudError, "Configured network: " +
568
567
  "#{configured_network}, is not accessible to VDC:#{ovdc.name}."
@@ -621,7 +620,7 @@ module VCloudCloud
621
620
  def independent_disks(disk_locality)
622
621
  disk_locality ||= []
623
622
  @logger.info("Instantiate vApp accessible to disks: " +
624
- "#{disk_locality.join(',')}")
623
+ "#{disk_locality.join(",")}")
625
624
  disks = []
626
625
  disk_locality.each do |disk_id|
627
626
  disks << @client.get_disk(disk_id)
@@ -630,4 +629,5 @@ module VCloudCloud
630
629
  end
631
630
 
632
631
  end
632
+
633
633
  end
@@ -1,4 +1,5 @@
1
1
  module VCloudCloud
2
+
2
3
  class Util
3
4
  class << self
4
5
 
@@ -9,8 +10,8 @@ module VCloudCloud
9
10
  rescue VCloudSdk::ApiError => e
10
11
  raise e if attempt >= attempts-1
11
12
  delay = backoff ** attempt
12
- Config.logger.error("Retry-attempt #{attempt+1}/#{attempts} " +
13
- "failed to #{op}, retrying in #{delay} seconds.\t#{e}")
13
+ Bosh::Clouds.Config.logger.error("Retry-attempt #{attempt+1}/" +
14
+ "#{attempts} failed to #{op}, retrying in #{delay} seconds.\t#{e}")
14
15
  sleep (delay)
15
16
  end
16
17
  end
@@ -18,4 +19,5 @@ module VCloudCloud
18
19
 
19
20
  end
20
21
  end
22
+
21
23
  end
@@ -1,7 +1,9 @@
1
1
  module Bosh
2
2
  module Clouds
3
+
3
4
  class VCloud
4
- VERSION = "0.4.8"
5
+ VERSION = "0.4.9"
5
6
  end
7
+
6
8
  end
7
9
  end
data/lib/cloud/vcloud.rb CHANGED
@@ -17,6 +17,7 @@ module Bosh
17
17
  :configure_networks,
18
18
  :create_disk, :delete_disk,
19
19
  :attach_disk, :detach_disk,
20
+ :get_disk_size_mb,
20
21
  :validate_deployment
21
22
 
22
23
  def initialize(options)
data/spec/spec_helper.rb CHANGED
@@ -1,10 +1,10 @@
1
1
  $:.unshift(File.expand_path("..", __FILE__))
2
- $:.unshift(File.join(File.dirname(__FILE__), '.'))
3
- $:.unshift(File.join(File.dirname(__FILE__), '../lib/cloud'))
4
- $:.unshift(File.join(File.dirname(__FILE__), 'unit'))
2
+ $:.unshift(File.join(File.dirname(__FILE__), "."))
3
+ $:.unshift(File.join(File.dirname(__FILE__), "../lib/cloud"))
4
+ $:.unshift(File.join(File.dirname(__FILE__), "unit"))
5
5
 
6
- require 'yaml'
7
- require 'vcloud'
6
+ require "yaml"
7
+ require "vcloud"
8
8
 
9
9
 
10
10
  module VCloudCloud
@@ -43,8 +43,8 @@ module VCloudCloud
43
43
 
44
44
  def compare_xml(a, b)
45
45
  a.diff(b) do |change, node|
46
- # ' ' Means no difference. '+' means addition and '-' means deletion.
47
- return false if change != ' ' && node.to_s.strip().length != 0
46
+ # " " Means no difference. "+" means addition and "-" means deletion.
47
+ return false if change != " " && node.to_s.strip().length != 0
48
48
  end
49
49
  true
50
50
  end
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
1
+ require File.dirname(__FILE__) + "/../spec_helper"
2
2
  require "yaml"
3
3
 
4
4
  module VCloudCloud
@@ -270,7 +270,7 @@ module VCloudCloud
270
270
  mc.should_receive(:get_vapp).with(anything).and_return { vapp }
271
271
  mc.should_receive(:power_off_vapp).with(vapp).and_return {}
272
272
  mc.should_receive(:delete_vapp).with(vapp).and_return {} if
273
- vcd_settings['debug']['delete_vapp'] == true
273
+ vcd_settings["debug"]["delete_vapp"] == true
274
274
  mc.should_receive(:delete_catalog_media).with(
275
275
  an_instance_of(String)).and_return {}
276
276
 
@@ -294,7 +294,7 @@ module VCloudCloud
294
294
  end
295
295
  }
296
296
  mc.should_receive(:delete_vapp).with(vapp).and_return {} if
297
- vcd_settings['debug']['delete_vapp'] == true
297
+ vcd_settings["debug"]["delete_vapp"] == true
298
298
  mc.should_receive(:delete_catalog_media).with(
299
299
  an_instance_of(String)).and_return {}
300
300
 
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: bosh_vcloud_cpi
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.4.8
5
+ version: 0.4.9
6
6
  platform: ruby
7
7
  authors:
8
8
  - VMware
@@ -10,8 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2012-11-12 00:00:00 -08:00
14
- default_executable:
13
+ date: 2012-12-05 00:00:00 Z
15
14
  dependencies:
16
15
  - !ruby/object:Gem::Dependency
17
16
  name: bosh_common
@@ -89,7 +88,6 @@ files:
89
88
  - spec/assets/valid_stemcell.tgz
90
89
  - spec/spec_helper.rb
91
90
  - spec/unit/cloud_spec.rb
92
- has_rdoc: true
93
91
  homepage: http://www.vmware.com
94
92
  licenses: []
95
93
 
@@ -103,7 +101,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
103
101
  requirements:
104
102
  - - ">="
105
103
  - !ruby/object:Gem::Version
106
- hash: -157759317589376717
104
+ hash: -1905250305917973427
107
105
  segments:
108
106
  - 0
109
107
  version: "0"
@@ -112,14 +110,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
112
110
  requirements:
113
111
  - - ">="
114
112
  - !ruby/object:Gem::Version
115
- hash: -157759317589376717
113
+ hash: -1905250305917973427
116
114
  segments:
117
115
  - 0
118
116
  version: "0"
119
117
  requirements: []
120
118
 
121
119
  rubyforge_project:
122
- rubygems_version: 1.6.2
120
+ rubygems_version: 1.8.24
123
121
  signing_key:
124
122
  specification_version: 3
125
123
  summary: BOSH vCloud CPI