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
This commit is contained in:
Takashi Kajinami 2024-10-10 11:04:19 +09:00
parent 4094046f7d
commit 31862093eb
2 changed files with 6 additions and 16 deletions
lib/puppet/provider

@ -24,20 +24,13 @@ class Puppet::Provider::Neutron < Puppet::Provider::Openstack
fixed_ips.each do |fixed_ip| fixed_ips.each do |fixed_ip|
subnet_ids << fixed_ip['subnet_id'] subnet_ids << fixed_ip['subnet_id']
end end
# TODO(tkajinam): Support multiple values
if subnet_ids.length > 1 subnet_ids.first
subnet_ids
else
subnet_ids.first
end
end end
def self.parse_availability_zone_hint(value) def self.parse_availability_zone_hint(value)
hints = JSON.parse(value.gsub(/\\"/,'"').gsub('\'','"')) hints = JSON.parse(value.gsub(/\\"/,'"').gsub('\'','"'))
if hints.length > 1 # TODO(tkajinam): Support multiple values
hints hints.first
else
hints.first
end
end end
end end

@ -182,11 +182,8 @@ Puppet::Type.type(:neutron_port).provide(
ips << fixed_ip['ip_address'] ips << fixed_ip['ip_address']
end end
if ips.length > 1 # TODO(tkajinam): Support multiple values
ips ips.first
else
ips.first
end
end end
def self.parse_binding_profile_interface_name(value) def self.parse_binding_profile_interface_name(value)