extract copy_attrs_to_chef_resource for reuse

This commit is contained in:
Adam Spiers 2014-02-03 13:09:02 +00:00
parent 0b0dc4f384
commit c3be9fefb4
2 changed files with 10 additions and 7 deletions

View File

@ -75,6 +75,14 @@ module Pacemaker
self
end
def copy_attrs_to_chef_resource(resource, *attrs)
attrs.each do |attr|
value = send(attr.to_sym)
writer = attr.to_sym
resource.send(writer, value)
end
end
def load_definition
@definition = self.class.get_definition(name)

View File

@ -87,13 +87,8 @@ end
def init_current_resource
name = @new_resource.name
@current_resource = Chef::Resource::PacemakerPrimitive.new(name)
@current_resource.agent(@current_cib_object.agent)
%w(params meta).each do |data_type|
method = data_type.to_sym
value = @current_cib_object.send(method)
@current_resource.send(method, value)
Chef::Log.debug "detected #{name} has #{data_type} #{value}"
end
@current_cib_object.copy_attrs_to_chef_resource(@current_resource,
:agent, :params, :meta)
end
def create_resource(name)