From 45c77ce51048de5e93fbcb67c5e875313fc61439 Mon Sep 17 00:00:00 2001 From: KevinLoiseau Date: Mon, 29 Oct 2018 16:52:05 +0100 Subject: [PATCH] Add VirtualMachineSizes collection --- lib/fog/azurerm/compute.rb | 1 + .../azurerm/models/compute/virtual_machine_size.rb | 4 ++++ .../azurerm/models/compute/virtual_machine_sizes.rb | 10 ++++++++++ test/models/compute/test_virtual_machine_size.rb | 7 +++++++ test/models/compute/test_virtual_machine_sizes.rb | 12 ++++++++++++ 5 files changed, 34 insertions(+) create mode 100644 lib/fog/azurerm/models/compute/virtual_machine_sizes.rb create mode 100644 test/models/compute/test_virtual_machine_sizes.rb diff --git a/lib/fog/azurerm/compute.rb b/lib/fog/azurerm/compute.rb index a780d8704..6778e4f8f 100644 --- a/lib/fog/azurerm/compute.rb +++ b/lib/fog/azurerm/compute.rb @@ -54,6 +54,7 @@ class AzureRM < Fog::Service model :virtual_machine_extension collection :virtual_machine_extensions model :virtual_machine_size + collection :virtual_machine_sizes model :managed_disk collection :managed_disks model :data_disk diff --git a/lib/fog/azurerm/models/compute/virtual_machine_size.rb b/lib/fog/azurerm/models/compute/virtual_machine_size.rb index c7fd8b39a..e1bd202dd 100644 --- a/lib/fog/azurerm/models/compute/virtual_machine_size.rb +++ b/lib/fog/azurerm/models/compute/virtual_machine_size.rb @@ -7,6 +7,10 @@ class VirtualMachineSize < Fog::Model attribute :number_of_cores attribute :os_disk_size_in_mb attribute :resource_disk_size_in_mb + + def self.parse(virtual_machine_size) + get_hash_from_object(virtual_machine_size) + end end end end diff --git a/lib/fog/azurerm/models/compute/virtual_machine_sizes.rb b/lib/fog/azurerm/models/compute/virtual_machine_sizes.rb new file mode 100644 index 000000000..889ec48ef --- /dev/null +++ b/lib/fog/azurerm/models/compute/virtual_machine_sizes.rb @@ -0,0 +1,10 @@ +module Fog + module Compute + class AzureRM + class VirtualMachineSizes < Fog::Collection + attribute :location + model Fog::Compute::AzureRM::VirtualMachineSize + end + end + end +end diff --git a/test/models/compute/test_virtual_machine_size.rb b/test/models/compute/test_virtual_machine_size.rb index 08fc1105c..867a4132a 100644 --- a/test/models/compute/test_virtual_machine_size.rb +++ b/test/models/compute/test_virtual_machine_size.rb @@ -18,4 +18,11 @@ def test_model_attributes assert_respond_to @virtual_machine_size, attribute end end + + def test_parse_method + virtual_machine_size_hash = Fog::Compute::AzureRM::VirtualMachineSize.parse(@response) + @response.instance_variables.each do |attribute| + assert_equal @response.instance_variable_get(attribute), virtual_machine_size_hash[attribute.to_s.delete('@')] + end + end end diff --git a/test/models/compute/test_virtual_machine_sizes.rb b/test/models/compute/test_virtual_machine_sizes.rb new file mode 100644 index 000000000..548aa8b9d --- /dev/null +++ b/test/models/compute/test_virtual_machine_sizes.rb @@ -0,0 +1,12 @@ +require File.expand_path '../../test_helper', __dir__ +# Test class for Managed Disk Collection +class TestVirtualMachineSizes < Minitest::Test + def setup + @service = Fog::Compute::AzureRM.new(credentials) + @virtual_machine_sizes = Fog::Compute::AzureRM::VirtualMachineSizes.new(location: 'location', service: @service) + end + + def test_collection_attributes + assert_respond_to @virtual_machine_sizes, :location + end +end