1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/lib/fog/vcloud_director/models/compute/vm_customizations.rb
Adam Leff 7a0bf2fa70 Adding #get_by_id for Fog::Compute::VcloudDirector::VmCustomizations
This method is necessary for functions such as #reload to function on
a VM customization.  This also allows users who set and save a customization
to re-fetch it to get values such as the VM administrator password.
2015-08-21 13:16:40 -04:00

29 lines
828 B
Ruby

require 'fog/core/collection'
require 'fog/vcloud_director/models/compute/vm_customization'
module Fog
module Compute
class VcloudDirector
class VmCustomizations < Collection
model Fog::Compute::VcloudDirector::VmCustomization
attribute :vm
private
def get_by_id(item_id)
item = service.get_vm_customization(item_id).body
add_id_from_href!(item)
item
end
# The HREF returned for a VM customization object is actually the VM
# HREF suffixed with '/guestCustomizationSection/' so we cannot use
# service.add_id_from_href! like all other collections.
def add_id_from_href!(item={})
item[:id] = item[:href].gsub('/guestCustomizationSection/', '').split('/').last
end
end
end
end
end