Ensure swift hash is rebuilt for every puppet run

Previously, the swift caches were being built on the class
instances themselves.

This could result in stale values when puppet runs multiple times
using the same process (like in the case of puppet agent)

This commit uses prefetch to ensure that the retrieved swift ring
values are updated per puppet run.
This commit is contained in:
Dan Bode 2012-04-11 10:47:53 -07:00
parent 1841187164
commit c9389516ba
4 changed files with 24 additions and 3 deletions

View File

@ -6,6 +6,14 @@ Puppet::Type.type(:ring_account_device).provide(
optional_commands :swift_ring_builder => 'swift-ring-builder' optional_commands :swift_ring_builder => 'swift-ring-builder'
def self.prefetch(resource)
@my_ring = lookup_ring
end
def self.ring
@my_ring ||= lookup_ring
end
# TODO maybe this should be a parameter eventually so that # TODO maybe this should be a parameter eventually so that
# it can be configurable # it can be configurable
def self.builder_file_path def self.builder_file_path

View File

@ -6,6 +6,14 @@ Puppet::Type.type(:ring_container_device).provide(
optional_commands :swift_ring_builder => 'swift-ring-builder' optional_commands :swift_ring_builder => 'swift-ring-builder'
def self.prefetch(resource)
@my_ring = lookup_ring
end
def self.ring
@my_ring ||= lookup_ring
end
# TODO maybe this should be a parameter eventually so that # TODO maybe this should be a parameter eventually so that
# it can be configurable # it can be configurable
def self.builder_file_path def self.builder_file_path

View File

@ -6,6 +6,14 @@ Puppet::Type.type(:ring_object_device).provide(
optional_commands :swift_ring_builder => 'swift-ring-builder' optional_commands :swift_ring_builder => 'swift-ring-builder'
def self.prefetch(resource)
@my_ring = lookup_ring
end
def self.ring
@my_ring ||= lookup_ring
end
# TODO maybe this should be a parameter eventually so that # TODO maybe this should be a parameter eventually so that
# it can be configurable # it can be configurable
def self.builder_file_path def self.builder_file_path

View File

@ -8,9 +8,6 @@ class Puppet::Provider::SwiftRingBuilder < Puppet::Provider
end end
end end
def self.ring
@my_ring ||= lookup_ring
end
def self.lookup_ring def self.lookup_ring
object_hash = {} object_hash = {}