63688a14e5
This change implements storage policies as defined by swift: http://docs.openstack.org/developer/swift/overview_policies.html There are two primary areas of change in this review - Add storage policy support to the ringbuilder and ring devices, along with associated spec tests. - Adding storage policy support and enforcing rules in swift.conf using the swift_storage_policy type and provider. Also: updated spec tests and an update to swift acceptance test to use storage policies to configure an additional 3 replica based ring. See release notes and the README update for more details/instructions. Change-Id: I2b8db751790704df3f1027a14f61e231591537f3
46 lines
1.0 KiB
Ruby
46 lines
1.0 KiB
Ruby
Puppet::Type.newtype(:ring_object_device) do
|
|
require 'ipaddr'
|
|
require 'uri'
|
|
|
|
ensurable
|
|
|
|
newparam(:name, :namevar => true) do
|
|
validate 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 = value.split(/^\d+:/)[1]
|
|
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)
|
|
end
|
|
end
|
|
|
|
newproperty(:region)
|
|
|
|
newproperty(:zone)
|
|
|
|
newproperty(:weight) do
|
|
munge do |value|
|
|
"%.2f" % value
|
|
end
|
|
end
|
|
|
|
newproperty(:meta)
|
|
|
|
[:id, :partitions, :balance].each do |param|
|
|
newproperty(param) do
|
|
validate do |value|
|
|
raise(Puppet::Error, "#{param} is a read only property, cannot be assigned")
|
|
end
|
|
end
|
|
end
|
|
|
|
end
|