Class: Fog::Parsers::Compute::VcloudDirector::VmCustomization

Inherits:
VcloudDirectorParser show all
Defined in:
lib/fog/vcloud_director/parsers/compute/vm_customization.rb

Instance Attribute Summary

Attributes inherited from Base

#response

Instance Method Summary collapse

Methods inherited from VcloudDirectorParser

#extract_attributes

Methods inherited from Base

#attr_value, #characters, #end_element_namespace, #initialize, #start_element_namespace, #value

Constructor Details

This class inherits a constructor from Fog::Parsers::Base

Instance Method Details

#end_element(name) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/fog/vcloud_director/parsers/compute/vm_customization.rb', line 25

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

#resetObject



8
9
10
# File 'lib/fog/vcloud_director/parsers/compute/vm_customization.rb', line 8

def reset
  @response = { }
end

#start_element(name, attributes) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/fog/vcloud_director/parsers/compute/vm_customization.rb', line 12

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