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

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

Instance Method Summary collapse

Methods inherited from VcloudDirectorParser

#extract_attributes

Instance Method Details

#end_element(name) ⇒ Object



23
24
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
# File 'lib/fog/vcloud_director/parsers/compute/vm_customization.rb', line 23

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



6
7
8
# File 'lib/fog/vcloud_director/parsers/compute/vm_customization.rb', line 6

def reset
  @response = { }
end

#start_element(name, attributes) ⇒ Object



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

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