bosh_vcloud_cpi 0.5.5 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d8221918d582915c2eea63a73e84da36e406564e
4
- data.tar.gz: ebcdc1bb6b631d7921bae2980a1d87397d2d778b
3
+ metadata.gz: cf849aca94b875385ed294be390fb8f9e69ab2fa
4
+ data.tar.gz: 32c666a6702a4f3000441bd074ecedcb70bc0530
5
5
  SHA512:
6
- metadata.gz: 7978e222cdecb48feeffdbd3a6307f030a52633e5e61c045494fa349b890ac6566995e6ad171626bd9a0ccd788d05871069bfd1f47a1ed9ea01f47fba35f1bb8
7
- data.tar.gz: fd063bb3a2e60b890d408f0967f5cff7a464f65a898b44e376ae48e3fd709fc5b9a9475bccb39b2ccdccd7c51fd87a2941cb6321642f02f53c1f8cce99cc4dad
6
+ metadata.gz: eb7a0ee08d1289702d516b90c285647c64caf0604bdc665c9a132e3027ff16782e9d2e19e6e2a8bcb909e2ed23b8c1a6148e80a02b3b62329719996c66f45a8f
7
+ data.tar.gz: 9d40d0aead537318a279bbfdaa8fe2558cf6720e91bbc37b393d66fad81c62b7ffc8c0aa267e5e2363ba447a9d79bced779c33eb751f9fb45a7ebde7d636c772
@@ -57,7 +57,10 @@ module VCloudCloud
57
57
  requested_name = environment && environment['vapp']
58
58
  vapp_name = requested_name ? "vapp-tmp-#{unique_name}" : agent_id
59
59
 
60
- s.next Steps::Instantiate, catalog_vapp_id, vapp_name, description, disk_locality
60
+ storage_profiles = client.vdc.storage_profiles || []
61
+ storage_profile = storage_profiles.find { |sp| sp['name'] == @entities['vapp_storage_profile'] }
62
+
63
+ s.next Steps::Instantiate, catalog_vapp_id, vapp_name, description, disk_locality, storage_profile
61
64
  client.flush_cache # flush cached vdc which contains vapp list
62
65
  vapp = s.state[:vapp]
63
66
  vm = s.state[:vm] = vapp.vms[0]
@@ -220,11 +223,13 @@ module VCloudCloud
220
223
  end
221
224
  end
222
225
 
223
- def create_disk(size_mb, vm_locality = nil)
224
- (steps "create_disk(#{size_mb}, #{vm_locality.inspect})" do |s|
226
+ def create_disk(size_mb, cloud_properties, vm_locality = nil)
227
+ (steps "create_disk(#{size_mb}, #{cloud_properties.inspect}, #{vm_locality.inspect})" do |s|
225
228
  # vm_locality is used as vm_id
226
229
  vm = vm_locality.nil? ? nil : client.resolve_entity(vm_locality)
227
- s.next Steps::CreateDisk, unique_name, size_mb, vm
230
+ storage_profiles = client.vdc.storage_profiles || []
231
+ storage_profile = storage_profiles.find { |sp| sp['name'] == @entities['vapp_storage_profile'] }
232
+ s.next Steps::CreateDisk, unique_name, size_mb, vm, storage_profile
228
233
  end)[:disk].urn
229
234
  end
230
235
 
@@ -1,13 +1,14 @@
1
1
  module VCloudCloud
2
2
  module Steps
3
3
  class CreateDisk < Step
4
- def perform(name, size_mb, vm, &block)
4
+ def perform(name, size_mb, vm, storage_profile, &block)
5
5
  params = VCloudSdk::Xml::WrapperFactory.create_instance 'DiskCreateParams'
6
6
  params.name = name
7
7
  params.size_bytes = size_mb << 20 # VCD expects bytes
8
8
  params.bus_type = VCloudSdk::Xml::HARDWARE_TYPE[:SCSI_CONTROLLER]
9
9
  params.bus_sub_type = VCloudSdk::Xml::BUS_SUB_TYPE[:LSILOGIC]
10
10
  params.add_locality vm if vm
11
+ params.storage_profile = storage_profile if storage_profile
11
12
  disk = client.invoke :post, client.vdc.add_disk_link,
12
13
  :payload => params,
13
14
  :headers => { :content_type => VCloudSdk::Xml::MEDIA_TYPE[:DISK_CREATE_PARAMS] }
@@ -3,7 +3,7 @@ module VCloudCloud
3
3
  # Create a vApp from a vApp template
4
4
  # Ref: http://pubs.vmware.com/vcd-51/index.jsp?topic=%2Fcom.vmware.vcloud.api.reference.doc_51%2Fdoc%2Foperations%2FPOST-InstantiateVAppTemplate.html
5
5
  class Instantiate < Step
6
- def perform(template_id, vapp_name, description, disk_locality, &block)
6
+ def perform(template_id, vapp_name, description, disk_locality, storage_profile, &block)
7
7
  catalog_item = client.resolve_entity template_id
8
8
  raise ObjectNotFoundError, "Invalid vApp template Id: #{template_id}" unless catalog_item
9
9
  template = client.resolve_link catalog_item.entity
@@ -15,6 +15,7 @@ module VCloudCloud
15
15
  params.all_eulas_accepted = true
16
16
  params.linked_clone = false
17
17
  params.set_locality = locality_spec template, disk_locality
18
+ params.set_storage_profile = storage_profile_spec(template, storage_profile) if storage_profile
18
19
 
19
20
  state[:instantiate_vapp_name] = vapp_name
20
21
 
@@ -57,6 +58,14 @@ module VCloudCloud
57
58
  end
58
59
  locality
59
60
  end
61
+
62
+ def storage_profile_spec(template, storage_profile)
63
+ vm_storage_profiles = {}
64
+ template.vms.each do |vm|
65
+ vm_storage_profiles[vm] = storage_profile
66
+ end
67
+ vm_storage_profiles
68
+ end
60
69
  end
61
70
  end
62
71
  end
@@ -32,6 +32,19 @@ module VCloudSdk
32
32
  disk.node.after(node)
33
33
  end
34
34
 
35
+ def storage_profile=(storage_profile)
36
+ return unless storage_profile
37
+
38
+ raise "disk storage profile already set." if @storage_profile
39
+ @storage_profile = true
40
+
41
+ node = create_child("StorageProfile")
42
+ node["type"] = storage_profile.type
43
+ node["name"] = storage_profile.name
44
+ node["href"] = storage_profile.href
45
+ disk.node.add_child(node)
46
+ end
47
+
35
48
  private
36
49
 
37
50
  def disk
@@ -32,7 +32,6 @@ module VCloudSdk
32
32
  source_node["href"] = src["href"]
33
33
  source_node["id"] = src["id"]
34
34
  source_node["type"] = src["type"]
35
- source_node["id"] = src["id"]
36
35
  end
37
36
 
38
37
  def set_locality=(locality)
@@ -74,6 +73,39 @@ module VCloudSdk
74
73
  end
75
74
  end
76
75
 
76
+ def set_storage_profile=(storage_profile)
77
+ return unless storage_profile
78
+
79
+ raise "vApp storage profile already set." if @storage_profile
80
+ @storage_profile = true
81
+
82
+ storage_profile.each do |k,v|
83
+ node_sp = create_child("SourcedVmInstantiationParams",
84
+ namespace.prefix,
85
+ namespace.href)
86
+
87
+ is_source_delete.node.after(node_sp)
88
+
89
+ node_sv = add_child("Source",
90
+ namespace.prefix,
91
+ namespace.href,
92
+ node_sp)
93
+
94
+ node_sv["type"] = k.type
95
+ node_sv["name"] = k.name
96
+ node_sv["href"] = k.href
97
+
98
+ node_lp = create_child("StorageProfile",
99
+ namespace.prefix,
100
+ namespace.href)
101
+ node_lp["type"] = v.type
102
+ node_lp["name"] = v.name
103
+ node_lp["href"] = v.href
104
+
105
+ node_sv.after(node_lp)
106
+ end
107
+ end
108
+
77
109
  private
78
110
 
79
111
  def is_source_delete
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bosh_vcloud_cpi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.5
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - VMware
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-24 00:00:00.000000000 Z
11
+ date: 2014-08-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bosh_common
@@ -124,7 +124,7 @@ dependencies:
124
124
  version: '0'
125
125
  description: |-
126
126
  BOSH vCloud CPI
127
- 98dd77
127
+ 7133d0
128
128
  email: support@cloudfoundry.com
129
129
  executables: []
130
130
  extensions: []