From 6dcdab3d5cf6e8f69b1c174878e49c62d8d2974e Mon Sep 17 00:00:00 2001 From: Jason Frey Date: Wed, 28 Aug 2024 14:00:35 -0400 Subject: [PATCH] Merge pull request #558 from agrare/fix_cloud_subnet_address_prefix Fix Azure CloudSubnet missing address_prefix (cherry picked from commit f031b89cb5f8858a2a3f359a00d26f906d86c899) --- .../azure/inventory/parser/network_manager.rb | 11 ++++++++++- config/settings.yml | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/app/models/manageiq/providers/azure/inventory/parser/network_manager.rb b/app/models/manageiq/providers/azure/inventory/parser/network_manager.rb index 56a02563..aff337d7 100644 --- a/app/models/manageiq/providers/azure/inventory/parser/network_manager.rb +++ b/app/models/manageiq/providers/azure/inventory/parser/network_manager.rb @@ -81,10 +81,19 @@ def cloud_networks def cloud_subnets(persister_cloud_networks, cloud_network) cloud_network.properties.subnets.each do |subnet| uid = subnet.id + + # Older apiVersions of Microsoft.Network returned Subnet addressPrefix as + # a single value, but newer versions have an array of addressPrefixes. + # If you try to create a second addressPrefix Azure will create a new subnet + # rather than add a second entry into this array so we can use .first as + # at the current time there only ever is a single value here. + cidr = subnet.properties.try(:address_prefix) + cidr ||= subnet.properties.address_prefixes.first + persister.cloud_subnets.build( :ems_ref => uid, :name => subnet.name, - :cidr => subnet.properties.address_prefix, + :cidr => cidr, :cloud_network => persister_cloud_networks, :availability_zone => persister.availability_zones.lazy_find('default'), :network_router => persister.network_routers.lazy_find(subnet.properties.try(:route_table).try(:id)) diff --git a/config/settings.yml b/config/settings.yml index deaaf281..7c851b4d 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -16,7 +16,7 @@ :storage_disk: "2017-03-30" :template_deployment: "2017-08-01" :virtual_machine: "2017-12-01" - :virtual_network: "2017-11-01" + :virtual_network: "2023-11-01" :blacklisted_event_names: - storageAccounts_listKeys_BeginRequest - storageAccounts_listKeys_EndRequest