From 31862093eb128c263f11926388f3eb7325c6ae80 Mon Sep 17 00:00:00 2001
From: Takashi Kajinami <kajinamit@oss.nttdata.com>
Date: Thu, 10 Oct 2024 11:04:19 +0900
Subject: [PATCH] Fix incorrect handling of list values

Neutron accepts multiple values for availability zone hint, subnet, and
fixed-ip and return lists with multiple elements. At this moment
the corresponding properties in our resource types do not support
array value so we should always pick the first element to fill
the interface mismatch.

Change-Id: I3bcca8b7824be1c56661bef56ed523cc4dfb5d7a
---
 lib/puppet/provider/neutron.rb                | 15 ++++-----------
 lib/puppet/provider/neutron_port/openstack.rb |  7 ++-----
 2 files changed, 6 insertions(+), 16 deletions(-)

diff --git a/lib/puppet/provider/neutron.rb b/lib/puppet/provider/neutron.rb
index a425cf428..af9e60b4c 100644
--- a/lib/puppet/provider/neutron.rb
+++ b/lib/puppet/provider/neutron.rb
@@ -24,20 +24,13 @@ class Puppet::Provider::Neutron < Puppet::Provider::Openstack
     fixed_ips.each do |fixed_ip|
       subnet_ids << fixed_ip['subnet_id']
     end
-
-    if subnet_ids.length > 1
-      subnet_ids
-    else
-      subnet_ids.first
-    end
+    # TODO(tkajinam): Support multiple values
+    subnet_ids.first
   end
 
   def self.parse_availability_zone_hint(value)
     hints = JSON.parse(value.gsub(/\\"/,'"').gsub('\'','"'))
-    if hints.length > 1
-      hints
-    else
-      hints.first
-    end
+    # TODO(tkajinam): Support multiple values
+    hints.first
   end
 end
diff --git a/lib/puppet/provider/neutron_port/openstack.rb b/lib/puppet/provider/neutron_port/openstack.rb
index 6d4b73ea7..32bf464b5 100644
--- a/lib/puppet/provider/neutron_port/openstack.rb
+++ b/lib/puppet/provider/neutron_port/openstack.rb
@@ -182,11 +182,8 @@ Puppet::Type.type(:neutron_port).provide(
       ips << fixed_ip['ip_address']
     end
 
-    if ips.length > 1
-      ips
-    else
-      ips.first
-    end
+    # TODO(tkajinam): Support multiple values
+    ips.first
   end
 
   def self.parse_binding_profile_interface_name(value)