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/parsers/compute/vm_customization.rb

57 lines
1.9 KiB
Ruby
Raw Normal View History

2013-06-24 13:46:30 +02:00
module Fog
module Parsers
module Compute
2013-08-27 11:19:54 +02:00
module VcloudDirector
2013-06-24 13:46:30 +02:00
2013-08-27 11:19:54 +02:00
class VmCustomization < VcloudDirectorParser
2013-06-24 13:46:30 +02:00
def reset
@response = { }
end
def start_element(name, attributes)
super
case name
when 'GuestCustomizationSection'
customizations = extract_attributes(attributes)
2013-07-09 17:45:55 +02:00
@response[:href] = customizations[:href]
@response[:type] = customizations[:type]
# href looks like this:
2013-07-10 13:24:24 +02:00
# "https://example.com/api/vApp/vm-2bbbf556-55dc-4974-82e6-aa6e814f0b64/guestCustomizationSection/"
@response[:id] = @response[:href].split('/')[-2]
2013-06-24 13:46:30 +02:00
end
end
def end_element(name)
case name
2013-09-16 18:13:09 +01:00
when 'Enabled',
@response[:enabled] = (value == "true")
2013-06-24 13:46:30 +02:00
when 'ChangeSid'
@response[:change_sid] = (value == "true")
2013-06-24 13:46:30 +02:00
when 'JoinDomainEnabled'
@response[:join_domain_enabled] = (value == "true")
2013-06-24 13:46:30 +02:00
when 'UseOrgSettings'
@response[:use_org_settings] = (value == "true")
2013-06-24 13:46:30 +02:00
when 'AdminPasswordEnabled'
@response[:admin_password_enabled] = (value == "true")
2013-06-24 13:46:30 +02:00
when 'AdminPasswordAuto'
@response[:admin_password_auto] = (value == "true")
2013-06-24 13:46:30 +02:00
when 'ResetPasswordRequired'
@response[:reset_password_required] = (value == "true")
2013-06-24 13:46:30 +02:00
when 'VirtualMachineId'
@response[:virtual_machine_id] = value
2013-06-24 13:46:30 +02:00
when 'ComputerName'
@response[:computer_name] = value
2013-06-24 13:46:30 +02:00
when 'CustomizationScript'
@response[:has_customization_script] = !value.empty?
2013-09-16 18:13:09 +01:00
@response[:customization_script] = CGI::unescapeHTML(value) if @response[:has_customization_script]
2013-06-24 13:46:30 +02:00
end
end
2013-09-16 18:13:09 +01:00
2013-06-24 13:46:30 +02:00
end
end
end
end
end