Module: Azure::VirtualMachineImageManagement::Serialization

Extended by:
Core::Utility
Defined in:
lib/azure/virtual_machine_image_management/serialization.rb

Class Method Summary collapse

Methods included from Core::Utility

enable_winrm?, export_der, export_fingerprint, get_certificate, initialize_external_logger, locate_file, random_string, xml_content

Class Method Details

.disks_from_xml(diskXML) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/azure/virtual_machine_image_management/serialization.rb', line 54

def self.disks_from_xml(diskXML)
  os_disks = []
  disks = diskXML.css('Disks Disk')
  disks.each do |disk_node|
    disk = VirtualMachineDisk.new
    disk.name = xml_content(disk_node, 'Name')
    disk.os_type = xml_content(disk_node, 'OS')
    disk.attached = !xml_content(disk_node, 'AttachedTo').empty?
    disk.image = xml_content(disk_node, 'SourceImageName')
    disk.size = xml_content(disk_node, 'LogicalDiskSizeInGB')
    os_disks << disk
  end
  os_disks
end

.virtual_machine_images_from_xml(imageXML) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/azure/virtual_machine_image_management/serialization.rb', line 22

def self.virtual_machine_images_from_xml(imageXML)
  os_images = []
  virtual_machine_images = imageXML.css('Images OSImage')
  virtual_machine_images.each do |image_node|
    image = VirtualMachineImage.new
    image.os_type = xml_content(image_node, 'OS')
    image.name = xml_content(image_node, 'Name')
    image.category = xml_content(image_node, 'Category')
    image.media_link = xml_content(image_node, 'MediaLink')
    image.locations = xml_content(image_node, 'Location')
    image.image_type = 'OS'
    os_images << image
  end
  os_images
end

.virtual_machine_vm_images_from_xml(imageXML) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/azure/virtual_machine_image_management/serialization.rb', line 38

def self.virtual_machine_vm_images_from_xml(imageXML)
  os_images = []
  virtual_machine_images = imageXML.css('VMImages VMImage')
  virtual_machine_images.each do |image_node|
    image = VirtualMachineImage.new
    image.name = xml_content(image_node, 'Name')
    image.category = xml_content(image_node, 'Category')
    image.locations = xml_content(image_node, 'Location')
    image.os_type = xml_content(image_node, 'OSDiskConfiguration OS')
    image.media_link = xml_content(image_node, 'OSDiskConfiguration MediaLink')
    image.image_type = 'VM'
    os_images << image
  end
  os_images
end