Remove handling of 'u' prefix

... because the prefix is no longer printed in Python 3.

In python 2
>>> print({u'foo': u'baa'})
{u'foo': u'baa'}
>>> print([u'foo', 'baa'])
[u'foo', 'baa']

In python 3
>>> print({u'foo': u'baa'})
{'foo': 'baa'}
>>> print([u'foo', 'baa'])
['foo', 'baa']

Change-Id: I8dc8f83b3be836f201b1df4bfaaa781a77d08557
This commit is contained in:
Takashi Kajinami 2022-05-18 10:40:58 +09:00
parent e046811edb
commit 5c6045d05e
3 changed files with 8 additions and 10 deletions

View File

@ -115,7 +115,7 @@ class Puppet::Provider::Neutron < Puppet::Provider::Openstack
end end
def self.parse_subnet_id(value) def self.parse_subnet_id(value)
fixed_ips = JSON.parse(value.gsub(/\\"/,'"').gsub('u\'', '"').gsub('\'','"')) fixed_ips = JSON.parse(value.gsub(/\\"/,'"').gsub('\'','"'))
subnet_ids = [] subnet_ids = []
fixed_ips.each do |fixed_ip| fixed_ips.each do |fixed_ip|
subnet_ids << fixed_ip['subnet_id'] subnet_ids << fixed_ip['subnet_id']
@ -129,7 +129,7 @@ class Puppet::Provider::Neutron < Puppet::Provider::Openstack
end end
def self.parse_availability_zone_hint(value) def self.parse_availability_zone_hint(value)
hints = JSON.parse(value.gsub(/\\"/,'"').gsub('u\'', '"').gsub('\'','"')) hints = JSON.parse(value.gsub(/\\"/,'"').gsub('\'','"'))
if hints.length > 1 if hints.length > 1
hints hints
else else

View File

@ -182,7 +182,7 @@ Puppet::Type.type(:neutron_port).provide(
end end
def self.parse_ip_address(value) def self.parse_ip_address(value)
fixed_ips = JSON.parse(value.gsub(/\\"/,'"').gsub('u\'', '"').gsub('\'','"')) fixed_ips = JSON.parse(value.gsub(/\\"/,'"').gsub('\'','"'))
ips = [] ips = []
fixed_ips.each do |fixed_ip| fixed_ips.each do |fixed_ip|
ips << fixed_ip['ip_address'] ips << fixed_ip['ip_address']
@ -196,7 +196,7 @@ Puppet::Type.type(:neutron_port).provide(
end end
def self.parse_binding_profile_interface_name(value) def self.parse_binding_profile_interface_name(value)
profile = JSON.parse(value.gsub(/\\"/,'"').gsub('u\'', '"').gsub('\'','"')) profile = JSON.parse(value.gsub(/\\"/,'"').gsub('\'','"'))
profile['interface_name'] profile['interface_name']
end end

View File

@ -74,8 +74,7 @@ Puppet::Type.type(:neutron_subnet).provide(
return [] if values.empty? or values == '[]' return [] if values.empty? or values == '[]'
values = values.gsub('[', '').gsub(']', '') values = values.gsub('[', '').gsub(']', '')
for value in Array(values) for value in Array(values)
allocation_pool = JSON.parse(value.gsub(/\\"/,'"').gsub('u\'', '"') allocation_pool = JSON.parse(value.gsub(/\\"/,'"').gsub('\'','"'))
.gsub('\'','"'))
start_ip = allocation_pool['start'] start_ip = allocation_pool['start']
end_ip = allocation_pool['end'] end_ip = allocation_pool['end']
allocation_pools << "start=#{start_ip},end=#{end_ip}" allocation_pools << "start=#{start_ip},end=#{end_ip}"
@ -88,8 +87,7 @@ Puppet::Type.type(:neutron_subnet).provide(
return [] if values.empty? or values == '[]' return [] if values.empty? or values == '[]'
values = values.gsub('[', '').gsub(']', '') values = values.gsub('[', '').gsub(']', '')
for value in Array(values) for value in Array(values)
host_route = JSON.parse(value.gsub(/\\"/,'"').gsub('u\'', '"') host_route = JSON.parse(value.gsub(/\\"/,'"').gsub('\'','"'))
.gsub('\'','"'))
nexthop = host_route['nexthop'] nexthop = host_route['nexthop']
destination = host_route['destination'] destination = host_route['destination']
host_routes << "destination=#{destination},nexthop=#{nexthop}" host_routes << "destination=#{destination},nexthop=#{nexthop}"
@ -99,8 +97,8 @@ Puppet::Type.type(:neutron_subnet).provide(
def self.parse_dns_nameservers(values) def self.parse_dns_nameservers(values)
if values.is_a? String if values.is_a? String
values = values.gsub('u\'', '').gsub('\'','').gsub('[', '') values = values.gsub('\'','').gsub('[', '').gsub(']', '')
.gsub(']', '').gsub(',', '').split(' ') .gsub(',', '').split(' ')
end end
# just enforce that this is actually an array # just enforce that this is actually an array
return Array(values) return Array(values)