Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions lib/ruby_vcloud_sdk/vdc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ def create_disk(
capacity,
vm = nil,
bus_type = "scsi",
bus_sub_type = "lsilogic")
bus_sub_type = "lsilogic",
storage_profile = nil)

fail(CloudError,
"Invalid size in MB #{capacity}") if capacity <= 0
Expand All @@ -163,7 +164,7 @@ def create_disk(
.info "Creating independent disk #{name} of #{capacity}MB."

disk = connection.post(entity_xml.add_disk_link,
disk_create_params(name, capacity, bus_type, bus_sub_type, vm),
disk_create_params(name, capacity, bus_type, bus_sub_type, vm, storage_profile),
Xml::MEDIA_TYPE[:DISK_CREATE_PARAMS])

wait_for_running_tasks(disk, "Disk #{name}")
Expand Down Expand Up @@ -217,13 +218,14 @@ def storage_profile_records
.org_vdc_storage_profile_records
end

def disk_create_params(name, capacity, bus_type, bus_sub_type, vm)
def disk_create_params(name, capacity, bus_type, bus_sub_type, vm, storage_profile = nil)
Xml::WrapperFactory.create_instance("DiskCreateParams").tap do |params|
params.name = name
params.size_bytes = capacity * 1024 * 1024 # VCD expects bytes
params.bus_type = bus_type
params.bus_sub_type = bus_sub_type
params.add_locality(connection.get(vm.href)) if vm # Use xml form of vm
params.add_storage_profile(storage_profile) if storage_profile
end
end

Expand Down
3 changes: 2 additions & 1 deletion lib/ruby_vcloud_sdk/vdc_storage_profile.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
module VCloudSdk

class VdcStorageProfile
attr_reader :name
attr_reader :name,:href

def initialize(storage_profile_xml_obj)
@storage_profile_xml_obj = storage_profile_xml_obj
@name = @storage_profile_xml_obj[:name]
@href = @storage_profile_xml_obj[:href]
@storage_used_mb = @storage_profile_xml_obj[:storageUsedMB].to_i
@storage_limit_mb = @storage_profile_xml_obj[:storageLimitMB].to_i
@vdc_name = @storage_profile_xml_obj[:vdcName]
Expand Down
6 changes: 6 additions & 0 deletions lib/ruby_vcloud_sdk/xml/wrapper_classes/disk_create_params.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ def add_locality(local)
disk.node.after(node)
end

def add_storage_profile(storage_profile)
node = create_child("StorageProfile")
node["href"] = storage_profile.href
node["name"] = storage_profile.name
disk.node.add_child(node)
end
private

def disk
Expand Down