diff --git a/lib/puppet/provider/swift_ring_builder.rb b/lib/puppet/provider/swift_ring_builder.rb index 19be7488..fcddfbd9 100644 --- a/lib/puppet/provider/swift_ring_builder.rb +++ b/lib/puppet/provider/swift_ring_builder.rb @@ -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 diff --git a/lib/puppet/type/ring_account_device.rb b/lib/puppet/type/ring_account_device.rb index d27659c1..31f9f73c 100644 --- a/lib/puppet/type/ring_account_device.rb +++ b/lib/puppet/type/ring_account_device.rb @@ -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 diff --git a/lib/puppet/type/ring_container_device.rb b/lib/puppet/type/ring_container_device.rb index e1b954cd..ab469d10 100644 --- a/lib/puppet/type/ring_container_device.rb +++ b/lib/puppet/type/ring_container_device.rb @@ -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 diff --git a/lib/puppet/type/ring_object_device.rb b/lib/puppet/type/ring_object_device.rb index 1868c098..31d59cfe 100644 --- a/lib/puppet/type/ring_object_device.rb +++ b/lib/puppet/type/ring_object_device.rb @@ -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)