Sha256: c001c733bafa04bf5b30ebbf5a81fa51ef9983271fd687a146ac8e06544bfb93

Contents?: true

Size: 1.86 KB

Versions: 1

Compression:

Stored size: 1.86 KB

Contents

#-------------------------------------------------------------------------
# Copyright 2013 Microsoft Open Technologies, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#--------------------------------------------------------------------------
require 'azure/virtual_machine_image_management/virtual_machine_image'
require 'azure/virtual_machine_image_management/virtual_machine_disk'

module Azure
  module VirtualMachineImageManagement
    module Serialization

      def self.virtual_machine_images_from_xml(imageXML)
        os_images = Array.new
        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.locations = xml_content(image_node, 'Location')
          os_images << image
        end
        os_images
      end

      def self.disks_from_xml(diskXML)
        os_disks = Array.new
        disks = diskXML.css('Disks Disk')
        disks.each do |disk_node|
          disk = VirtualMachineDisk.new
          disk.name = xml_content(disk_node, 'Name')
          disk.attached = !xml_content(disk_node,'AttachedTo').empty?
          os_disks << disk
        end
        os_disks
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
azure-0.6.1 lib/azure/virtual_machine_image_management/serialization.rb