mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
18ef1ecb61
Admin passwords can be retrieved and modified using the VMWare console, so it's useful to allow the same operations here. Moreover, when an admin password is enabled and "admin password auto" is false, it's impossible to modify Guest settings. i.e., "The administrator password cannot be empty when it is enabled and automatic password generation is not selected." This patch also fixes `put_guest_customization_section_vapp` where an AdminPassword element was never created.
58 lines
2 KiB
Ruby
58 lines
2 KiB
Ruby
module Fog
|
|
module Parsers
|
|
module Compute
|
|
module VcloudDirector
|
|
|
|
class VmCustomization < VcloudDirectorParser
|
|
|
|
def reset
|
|
@response = { }
|
|
end
|
|
|
|
def start_element(name, attributes)
|
|
super
|
|
case name
|
|
when 'GuestCustomizationSection'
|
|
customizations = extract_attributes(attributes)
|
|
@response[:href] = customizations[:href]
|
|
@response[:type] = customizations[:type]
|
|
# href looks like this:
|
|
# "https://example.com/api/vApp/vm-2bbbf556-55dc-4974-82e6-aa6e814f0b64/guestCustomizationSection/"
|
|
@response[:id] = @response[:href].split('/')[-2]
|
|
end
|
|
end
|
|
|
|
def end_element(name)
|
|
case name
|
|
when 'Enabled'
|
|
@response[:enabled] = (value == "true")
|
|
when 'ChangeSid'
|
|
@response[:change_sid] = (value == "true")
|
|
when 'JoinDomainEnabled'
|
|
@response[:join_domain_enabled] = (value == "true")
|
|
when 'UseOrgSettings'
|
|
@response[:use_org_settings] = (value == "true")
|
|
when 'AdminPassword'
|
|
@response[:admin_password] = value
|
|
when 'AdminPasswordEnabled'
|
|
@response[:admin_password_enabled] = (value == "true")
|
|
when 'AdminPasswordAuto'
|
|
@response[:admin_password_auto] = (value == "true")
|
|
when 'ResetPasswordRequired'
|
|
@response[:reset_password_required] = (value == "true")
|
|
when 'VirtualMachineId'
|
|
@response[:virtual_machine_id] = value
|
|
when 'ComputerName'
|
|
@response[:computer_name] = value
|
|
when 'CustomizationScript'
|
|
@response[:has_customization_script] = !value.empty?
|
|
@response[:customization_script] = CGI::unescapeHTML(value) if @response[:has_customization_script]
|
|
end
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
end
|
|
end
|
|
end
|