Skip to content

Commit

Permalink
Merge pull request #558 from agrare/fix_cloud_subnet_address_prefix
Browse files Browse the repository at this point in the history
Fix Azure CloudSubnet missing address_prefix
  • Loading branch information
Fryguy authored Aug 28, 2024
2 parents 6cc3d9c + 6a4c303 commit f031b89
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f031b89

Please sign in to comment.