Use common function to parse python dict/list

Depends-on: https://review.opendev.org/931749
Change-Id: I507061571d7fd0081fd8308cc70bb8a663d4907c
This commit is contained in:
Takashi Kajinami 2024-10-10 11:00:30 +09:00
parent 31862093eb
commit a09db1dceb
3 changed files with 6 additions and 6 deletions

View File

@ -19,7 +19,7 @@ class Puppet::Provider::Neutron < Puppet::Provider::Openstack
end
def self.parse_subnet_id(value)
fixed_ips = JSON.parse(value.gsub(/\\"/,'"').gsub('\'','"'))
fixed_ips = parse_python_list(value)
subnet_ids = []
fixed_ips.each do |fixed_ip|
subnet_ids << fixed_ip['subnet_id']

View File

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

View File

@ -70,7 +70,7 @@ Puppet::Type.type(:neutron_subnet).provide(
def self.parse_allocation_pool(values)
allocation_pools = []
JSON.parse(values.gsub("'", '"')).each do |pool|
parse_python_list(values).each do |pool|
start_ip = pool['start']
end_ip = pool['end']
allocation_pools << "start=#{start_ip},end=#{end_ip}"
@ -80,7 +80,7 @@ Puppet::Type.type(:neutron_subnet).provide(
def self.parse_host_routes(values)
host_routes = []
JSON.parse(values.gsub("'", '"')).each do |route|
parse_python_list(values).each do |route|
nexthop = route['nexthop']
destination = route['destination']
host_routes << "destination=#{destination},nexthop=#{nexthop}"
@ -89,7 +89,7 @@ Puppet::Type.type(:neutron_subnet).provide(
end
def self.parse_dns_nameservers(values)
return JSON.parse(values.gsub("'", '"'))
return parse_python_list(values)
end
def exists?