Class: VCloudCloud::Steps::CreateDisk
Instance Attribute Summary
#client, #state
Instance Method Summary
collapse
#cleanup, #initialize
Instance Method Details
4
5
6
7
8
9
10
11
12
13
14
15
16
|
# File 'lib/cloud/vcloud/steps/create_disk.rb', line 4
def perform(name, size_mb, vm, storage_profile, &_block)
params = VCloudSdk::Xml::WrapperFactory.create_instance 'DiskCreateParams'
params.name = name
params.size_bytes = size_mb << 20 params.bus_type = VCloudSdk::Xml::HARDWARE_TYPE[:SCSI_CONTROLLER]
params.bus_sub_type = VCloudSdk::Xml::BUS_SUB_TYPE[:LSILOGIC]
params.add_locality vm if vm
params.storage_profile = storage_profile if storage_profile
disk = client.invoke :post, client.vdc.add_disk_link,
:payload => params,
:headers => { :content_type => VCloudSdk::Xml::MEDIA_TYPE[:DISK_CREATE_PARAMS] }
state[:disk] = client.wait_entity disk
end
|
#rollback ⇒ Object
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/cloud/vcloud/steps/create_disk.rb', line 18
def rollback
disk = state[:disk]
if disk
link = disk.remove_link
client.invoke_and_wait :delete, link if link
state.delete :disk
end
end
|