Ensure consistent IPv6 address format
This change ensures the shortened address representations are always
used for ring devices to avoid broken idempotency caused by different
representations (shortened[1] vs canonical[2]).
[1] ::1
[2] 0000:0000:0000:0000:0000:0000:0000:0001
Closes-Bug: #1997313
Change-Id: I762f0780ba25536aa616482a49d59c7db69924d6
(cherry picked from commit 249f466f94
)
This commit is contained in:
parent
2dd553497c
commit
4b37f4c4df
|
@ -11,12 +11,21 @@ Puppet::Type.newtype(:ring_account_device) do
|
||||||
end
|
end
|
||||||
# we have to have URI Scheme so we just add http:// and ignore it later
|
# we have to have URI Scheme so we just add http:// and ignore it later
|
||||||
uri = URI('http://' + value)
|
uri = URI('http://' + value)
|
||||||
address = uri.host
|
|
||||||
port_device = uri.port
|
|
||||||
if ['','/'].include?(uri.path)
|
if ['','/'].include?(uri.path)
|
||||||
raise(Puppet::Error, "namevar should contain a device")
|
raise(Puppet::Error, "namevar should contain a device")
|
||||||
end
|
end
|
||||||
IPAddr.new(address)
|
IPAddr.new(uri.host)
|
||||||
|
end
|
||||||
|
|
||||||
|
munge do |value|
|
||||||
|
# we have to have URI Scheme so we just add http:// and ignore it later
|
||||||
|
uri = URI('http://' + value)
|
||||||
|
ip = IPAddr.new(uri.host)
|
||||||
|
if ip.ipv6?
|
||||||
|
value.gsub(uri.host, '[' + ip.to_s + ']')
|
||||||
|
else
|
||||||
|
value
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -11,12 +11,21 @@ Puppet::Type.newtype(:ring_container_device) do
|
||||||
end
|
end
|
||||||
# we have to have URI Scheme so we just add http:// and ignore it later
|
# we have to have URI Scheme so we just add http:// and ignore it later
|
||||||
uri = URI('http://' + value)
|
uri = URI('http://' + value)
|
||||||
address = uri.host
|
|
||||||
port_device = uri.port
|
|
||||||
if ['','/'].include?(uri.path)
|
if ['','/'].include?(uri.path)
|
||||||
raise(Puppet::Error, "namevar should contain a device")
|
raise(Puppet::Error, "namevar should contain a device")
|
||||||
end
|
end
|
||||||
IPAddr.new(address)
|
IPAddr.new(uri.host)
|
||||||
|
end
|
||||||
|
|
||||||
|
munge do |value|
|
||||||
|
# we have to have URI Scheme so we just add http:// and ignore it later
|
||||||
|
uri = URI('http://' + value)
|
||||||
|
ip = IPAddr.new(uri.host)
|
||||||
|
if ip.ipv6?
|
||||||
|
value.gsub(uri.host, '[' + ip.to_s + ']')
|
||||||
|
else
|
||||||
|
value
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -14,12 +14,29 @@ Puppet::Type.newtype(:ring_object_device) do
|
||||||
# we have to have URI Scheme so we just add http:// and ignore it later
|
# we have to have URI Scheme so we just add http:// and ignore it later
|
||||||
uri = URI('http://' + value)
|
uri = URI('http://' + value)
|
||||||
address = uri.host
|
address = uri.host
|
||||||
port_device = uri.port
|
|
||||||
if ['','/'].include?(uri.path)
|
if ['','/'].include?(uri.path)
|
||||||
raise(Puppet::Error, "namevar should contain a device")
|
raise(Puppet::Error, "namevar should contain a device")
|
||||||
end
|
end
|
||||||
IPAddr.new(address)
|
IPAddr.new(address)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
munge do |value|
|
||||||
|
# If storage policy_index is specified first strip that off.
|
||||||
|
# Resource name is not required to start with a policy_index
|
||||||
|
if !value.split(/^\d+:/)[1].nil?
|
||||||
|
value_without_policy = value.split(/^\d+:/)[1]
|
||||||
|
else
|
||||||
|
value_without_policy = value
|
||||||
|
end
|
||||||
|
# we have to have URI Scheme so we just add http:// and ignore it later
|
||||||
|
uri = URI('http://' + value_without_policy)
|
||||||
|
ip = IPAddr.new(uri.host)
|
||||||
|
if ip.ipv6?
|
||||||
|
value.gsub(uri.host, '[' + ip.to_s + ']')
|
||||||
|
else
|
||||||
|
value
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
newproperty(:region)
|
newproperty(:region)
|
||||||
|
|
Loading…
Reference in New Issue