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 commit249f466f94
) (cherry picked from commit4b37f4c4df
) (cherry picked from commit81f930723b
) (cherry picked from commite4a28d2806
)
This commit is contained in:
parent
c4e12034e1
commit
ee05a90246
@ -11,7 +11,7 @@ class Puppet::Provider::SwiftRingBuilder < Puppet::Provider
|
||||
def address_string(address)
|
||||
ip = IPAddr.new(address)
|
||||
if ip.ipv6?
|
||||
'[' + ip.to_s + ']'
|
||||
'[' + ip.to_s + ']'
|
||||
else
|
||||
ip.to_s
|
||||
end
|
||||
|
@ -11,12 +11,21 @@ Puppet::Type.newtype(:ring_account_device) do
|
||||
end
|
||||
# we have to have URI Scheme so we just add http:// and ignore it later
|
||||
uri = URI('http://' + value)
|
||||
address = uri.host
|
||||
port_device = uri.port
|
||||
if ['','/'].include?(uri.path)
|
||||
raise(Puppet::Error, "namevar should contain a device")
|
||||
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
|
||||
|
||||
|
@ -11,12 +11,21 @@ Puppet::Type.newtype(:ring_container_device) do
|
||||
end
|
||||
# we have to have URI Scheme so we just add http:// and ignore it later
|
||||
uri = URI('http://' + value)
|
||||
address = uri.host
|
||||
port_device = uri.port
|
||||
if ['','/'].include?(uri.path)
|
||||
raise(Puppet::Error, "namevar should contain a device")
|
||||
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
|
||||
|
||||
|
@ -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
|
||||
uri = URI('http://' + value)
|
||||
address = uri.host
|
||||
port_device = uri.port
|
||||
if ['','/'].include?(uri.path)
|
||||
raise(Puppet::Error, "namevar should contain a device")
|
||||
end
|
||||
IPAddr.new(address)
|
||||
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
|
||||
|
||||
newproperty(:region)
|
||||
|
Loading…
Reference in New Issue
Block a user