Skip to content

Commit

Permalink
Replace PuppetX::Voxpupuli::Corosync::Provider:: by self.class
Browse files Browse the repository at this point in the history
  • Loading branch information
btravouillon committed Jan 7, 2018
1 parent 9940eb9 commit b1ed93b
Show file tree
Hide file tree
Showing 20 changed files with 78 additions and 78 deletions.
8 changes: 4 additions & 4 deletions lib/puppet/provider/cs_clone/crm.rb
Expand Up @@ -23,7 +23,7 @@ def self.instances
instances = []

cmd = [command(:crm), 'configure', 'show', 'xml']
raw, = PuppetX::Voxpupuli::Corosync::Provider::Crmsh.run_command_in_cib(cmd)
raw, = self.class.run_command_in_cib(cmd)
doc = REXML::Document.new(raw)

REXML::XPath.each(doc, '//resources//clone') do |e|
Expand Down Expand Up @@ -75,9 +75,9 @@ def create
def destroy
debug('Removing clone')
cmd = [command(:crm), '-w', 'resource', 'stop', @resource[:name]]
PuppetX::Voxpupuli::Corosync::Provider::Crmsh.run_command_in_cib(cmd, @resource[:cib], false)
self.class.run_command_in_cib(cmd, @resource[:cib], false)
cmd = [command(:crm), 'configure', 'delete', @resource[:name]]
PuppetX::Voxpupuli::Corosync::Provider::Crmsh.run_command_in_cib(cmd, @resource[:cib])
self.class.run_command_in_cib(cmd, @resource[:cib])
@property_hash.clear
end

Expand Down Expand Up @@ -115,7 +115,7 @@ def flush
tmpfile.write(updated)
tmpfile.flush
cmd = [command(:crm), 'configure', 'load', 'update', tmpfile.path.to_s]
PuppetX::Voxpupuli::Corosync::Provider::Crmsh.run_command_in_cib(cmd, @resource.value(:cib))
self.class.run_command_in_cib(cmd, @resource.value(:cib))
end
end
end
12 changes: 6 additions & 6 deletions lib/puppet/provider/cs_clone/pcs.rb
Expand Up @@ -20,13 +20,13 @@
def change_clone_id(type, primitive, id, cib)
xpath = "/cib/configuration/resources/clone[descendant::#{type}[@id='#{primitive}']]"
cmd = [command(:cibadmin), '--query', '--xpath', xpath]
raw, = PuppetX::Voxpupuli::Corosync::Provider::Pcs.run_command_in_cib(cmd, cib)
raw, = self.class.run_command_in_cib(cmd, cib)
doc = REXML::Document.new(raw)
return unless doc.root.attributes['id'] != id

doc.root.attributes['id'] = id
cmd = [command(:cibadmin), '--replace', '--xpath', xpath, '--xml-text', doc.to_s.chop]
PuppetX::Voxpupuli::Corosync::Provider::Pcs.run_command_in_cib(cmd, cib)
self.class.run_command_in_cib(cmd, cib)
end

def self.instances
Expand All @@ -35,7 +35,7 @@ def self.instances
instances = []

cmd = [command(:pcs), 'cluster', 'cib']
raw, = PuppetX::Voxpupuli::Corosync::Provider::Pcs.run_command_in_cib(cmd)
raw, = self.class.run_command_in_cib(cmd)
doc = REXML::Document.new(raw)

REXML::XPath.each(doc, '//resources//clone') do |e|
Expand Down Expand Up @@ -89,7 +89,7 @@ def create
# Unlike create we actually immediately delete the item.
def destroy
debug 'Removing clone'
PuppetX::Voxpupuli::Corosync::Provider::Pcs.run_command_in_cib([command(:pcs), 'resource', 'unclone', @resource[:name]], @resource[:cib])
self.class.run_command_in_cib([command(:pcs), 'resource', 'unclone', @resource[:name]], @resource[:cib])
@property_hash.clear
end

Expand All @@ -116,7 +116,7 @@ def flush
# pcs versions earlier than 0.9.116 do not allow updating a cloned
# resource. Being conservative, we will unclone then create a new clone
# with the new parameters.
PuppetX::Voxpupuli::Corosync::Provider::Pcs.run_command_in_cib([command(:pcs), 'resource', 'unclone', @property_hash[:existing_clone_element]], @resource.value(:cib))
self.class.run_command_in_cib([command(:pcs), 'resource', 'unclone', @property_hash[:existing_clone_element]], @resource.value(:cib))
end
cmd = [command(:pcs), 'resource', 'clone', target.to_s]
{
Expand All @@ -129,7 +129,7 @@ def flush
}.each do |property, clone_property|
cmd << "#{clone_property}=#{@resource.should(property)}" unless @resource.should(property) == :absent
end
PuppetX::Voxpupuli::Corosync::Provider::Pcs.run_command_in_cib(cmd, @resource.value(:cib))
self.class.run_command_in_cib(cmd, @resource.value(:cib))
change_clone_id(target_type, target, @resource.value(:name), @resource.value(:cib))
end
end
4 changes: 2 additions & 2 deletions lib/puppet/provider/cs_colocation/crm.rb
Expand Up @@ -104,7 +104,7 @@ def create
def destroy
debug('Removing colocation')
cmd = [command(:crm), 'configure', 'delete', @resource[:name]]
PuppetX::Voxpupuli::Corosync::Provider::Crmsh.run_command_in_cib(cmd, @resource[:cib])
self.class.run_command_in_cib(cmd, @resource[:cib])
@property_hash.clear
end

Expand Down Expand Up @@ -153,7 +153,7 @@ def flush
Tempfile.open('puppet_crm_update') do |tmpfile|
tmpfile.write(updated)
tmpfile.flush
PuppetX::Voxpupuli::Corosync::Provider::Crmsh.run_command_in_cib(['crm', 'configure', 'load', 'update', tmpfile.path.to_s], @resource[:cib])
self.class.run_command_in_cib(['crm', 'configure', 'load', 'update', tmpfile.path.to_s], @resource[:cib])
end
end
end
8 changes: 4 additions & 4 deletions lib/puppet/provider/cs_colocation/pcs.rb
Expand Up @@ -23,7 +23,7 @@ def self.instances
instances = []

cmd = [command(:pcs), 'cluster', 'cib']
raw, = PuppetX::Voxpupuli::Corosync::Provider::Pcs.run_command_in_cib(cmd)
raw, = self.class.run_command_in_cib(cmd)
doc = REXML::Document.new(raw)
resource_set_options = ['sequential', 'require-all', 'action', 'role']

Expand Down Expand Up @@ -102,7 +102,7 @@ def create
def destroy
debug('Removing colocation')
cmd = [command(:pcs), 'constraint', 'remove', @resource[:name]]
PuppetX::Voxpupuli::Corosync::Provider::Pcs.run_command_in_cib(cmd, @resource[:cib])
self.class.run_command_in_cib(cmd, @resource[:cib])
@property_hash.clear
end

Expand Down Expand Up @@ -153,7 +153,7 @@ def flush
if @property_hash[:new] == false
debug('Removing colocation')
cmd = [command(:pcs), 'constraint', 'remove', @resource[:name]]
PuppetX::Voxpupuli::Corosync::Provider::Pcs.run_command_in_cib(cmd, @resource[:cib])
self.class.run_command_in_cib(cmd, @resource[:cib])
end
first_item = @property_hash[:primitives].shift
cmd = [command(:pcs), 'constraint', 'colocation']
Expand Down Expand Up @@ -196,6 +196,6 @@ def flush
cmd << @property_hash[:score]
cmd << "id=#{@property_hash[:name]}"
end
PuppetX::Voxpupuli::Corosync::Provider::Pcs.run_command_in_cib(cmd, @resource[:cib])
self.class.run_command_in_cib(cmd, @resource[:cib])
end
end
6 changes: 3 additions & 3 deletions lib/puppet/provider/cs_commit/crm.rb
Expand Up @@ -19,11 +19,11 @@ def self.instances
end

def commit
PuppetX::Voxpupuli::Corosync::Provider::Crmsh.run_command_in_cib(['crm_shadow', '--force', '--commit', @resource[:name]])
self.class.run_command_in_cib(['crm_shadow', '--force', '--commit', @resource[:name]])
# We run the next command in the CIB directly by purpose:
# We commit the shadow CIB with the admin_epoch it was created.
PuppetX::Voxpupuli::Corosync::Provider::Crmsh.run_command_in_cib(['cibadmin', '--modify', '--xml-text', '<cib admin_epoch="admin_epoch++"/>'])
self.class.run_command_in_cib(['cibadmin', '--modify', '--xml-text', '<cib admin_epoch="admin_epoch++"/>'])
# Next line is for indempotency
PuppetX::Voxpupuli::Corosync::Provider::Crmsh.sync_shadow_cib(@resource[:name], true)
self.class.sync_shadow_cib(@resource[:name], true)
end
end
6 changes: 3 additions & 3 deletions lib/puppet/provider/cs_commit/pcs.rb
Expand Up @@ -19,11 +19,11 @@ def self.instances

def commit
cib_path = File.join(Puppet[:vardir], 'shadow.' + @resource[:name])
PuppetX::Voxpupuli::Corosync::Provider::Pcs.run_command_in_cib([command(:pcs), 'cluster', 'cib-push', cib_path, 'diff-against=' + cib_path + '.ori'])
self.class.run_command_in_cib([command(:pcs), 'cluster', 'cib-push', cib_path, 'diff-against=' + cib_path + '.ori'])
# We run the next command in the CIB directly by purpose:
# We commit the shadow CIB with the admin_epoch it was created.
PuppetX::Voxpupuli::Corosync::Provider::Pcs.run_command_in_cib([command(:cibadmin), '--modify', '--xml-text', '<cib admin_epoch="admin_epoch++"/>'])
self.class.run_command_in_cib([command(:cibadmin), '--modify', '--xml-text', '<cib admin_epoch="admin_epoch++"/>'])
# Next line is for indempotency
PuppetX::Voxpupuli::Corosync::Provider::Pcs.sync_shadow_cib(@resource[:name], true)
self.class.sync_shadow_cib(@resource[:name], true)
end
end
8 changes: 4 additions & 4 deletions lib/puppet/provider/cs_group/crm.rb
Expand Up @@ -19,7 +19,7 @@ def self.instances
instances = []

cmd = [command(:crm), 'configure', 'show', 'xml']
raw, = PuppetX::Voxpupuli::Corosync::Provider::Crmsh.run_command_in_cib(cmd)
raw, = self.class.run_command_in_cib(cmd)
doc = REXML::Document.new(raw)

REXML::XPath.each(doc, '//group') do |e|
Expand Down Expand Up @@ -58,10 +58,10 @@ def create
def destroy
debug('Stopping group before removing it')
cmd = [command(:crm), '-w', 'resource', 'stop', @resource[:name]]
PuppetX::Voxpupuli::Corosync::Provider::Crmsh.run_command_in_cib(cmd, @resource[:cib], false)
self.class.run_command_in_cib(cmd, @resource[:cib], false)
debug('Removing group')
cmd = [command(:crm), 'configure', 'delete', @resource[:name]]
PuppetX::Voxpupuli::Corosync::Provider::Crmsh.run_command_in_cib(cmd, @resource[:cib])
self.class.run_command_in_cib(cmd, @resource[:cib])
@property_hash.clear
end

Expand Down Expand Up @@ -93,7 +93,7 @@ def flush
tmpfile.write(updated)
tmpfile.flush
cmd = [command(:crm), 'configure', 'load', 'update', tmpfile.path.to_s]
PuppetX::Voxpupuli::Corosync::Provider::Crmsh.run_command_in_cib(cmd, @resource[:cib])
self.class.run_command_in_cib(cmd, @resource[:cib])
end
end
end
8 changes: 4 additions & 4 deletions lib/puppet/provider/cs_group/pcs.rb
Expand Up @@ -21,7 +21,7 @@ def self.instances
instances = []

cmd = [command(:pcs), 'cluster', 'cib']
raw, = PuppetX::Voxpupuli::Corosync::Provider::Pcs.run_command_in_cib(cmd)
raw, = self.class.run_command_in_cib(cmd)
doc = REXML::Document.new(raw)

REXML::XPath.each(doc, '//group') do |e|
Expand Down Expand Up @@ -61,7 +61,7 @@ def create
# we need to stop the group.
def destroy
debug('Removing group')
PuppetX::Voxpupuli::Corosync::Provider::Pcs.run_command_in_cib([command(:pcs), 'resource', 'ungroup', @property_hash[:name]], @resource[:cib])
self.class.run_command_in_cib([command(:pcs), 'resource', 'ungroup', @property_hash[:name]], @resource[:cib])
@property_hash.clear
end

Expand All @@ -88,11 +88,11 @@ def flush

if @property_hash[:new] == false
debug('Removing group')
PuppetX::Voxpupuli::Corosync::Provider::Pcs.run_command_in_cib([command(:pcs), 'resource', 'ungroup', @property_hash[:name]], @resource[:cib])
self.class.run_command_in_cib([command(:pcs), 'resource', 'ungroup', @property_hash[:name]], @resource[:cib])
end

cmd = [command(:pcs), 'resource', 'group', 'add', (@property_hash[:name]).to_s]
cmd += @property_hash[:primitives]
PuppetX::Voxpupuli::Corosync::Provider::Pcs.run_command_in_cib(cmd, @resource[:cib])
self.class.run_command_in_cib(cmd, @resource[:cib])
end
end
6 changes: 3 additions & 3 deletions lib/puppet/provider/cs_location/crm.rb
Expand Up @@ -33,7 +33,7 @@ def self.instances
# The expression key is handled differently because the result must not
# contain the id of the XML node. The crm command can not set the
# expression id so Puppet would try to update the rule at every run.
id, items = PuppetX::Voxpupuli::Corosync::Provider::CibHelper.node2hash(e, ['expression']).first
id, items = self.class.node2hash(e, ['expression']).first

location_instance = {
name: id,
Expand Down Expand Up @@ -67,7 +67,7 @@ def create
# Unlike create we actually immediately delete the item.
def destroy
debug('Removing location')
PuppetX::Voxpupuli::Corosync::Provider::Crmsh.run_command_in_cib(['crm', 'configure', 'delete', @resource[:name]], @resource[:cib])
self.class.run_command_in_cib(['crm', 'configure', 'delete', @resource[:name]], @resource[:cib])
@property_hash.clear
end

Expand Down Expand Up @@ -108,7 +108,7 @@ def flush
Tempfile.open('puppet_crm_update') do |tmpfile|
tmpfile.write(updated)
tmpfile.flush
PuppetX::Voxpupuli::Corosync::Provider::Crmsh.run_command_in_cib(['crm', 'configure', 'load', 'update', tmpfile.path.to_s], @resource[:cib])
self.class.run_command_in_cib(['crm', 'configure', 'load', 'update', tmpfile.path.to_s], @resource[:cib])
end
end
end
12 changes: 6 additions & 6 deletions lib/puppet/provider/cs_location/pcs.rb
Expand Up @@ -26,7 +26,7 @@ def self.instances
instances = []

cmd = [command(:pcs), 'cluster', 'cib']
raw, = PuppetX::Voxpupuli::Corosync::Provider::Pcs.run_command_in_cib(cmd)
raw, = self.class.run_command_in_cib(cmd)
doc = REXML::Document.new(raw)

constraints = doc.root.elements['configuration'].elements['constraints']
Expand All @@ -36,7 +36,7 @@ def self.instances
# The expression key is handled differently because the result must
# not contain the id of the XML node. The crm command can not set the
# expression id so Puppet would try to update the rule at every run.
id, items = PuppetX::Voxpupuli::Corosync::Provider::CibHelper.node2hash(e, ['expression']).first
id, items = self.class.node2hash(e, ['expression']).first

location_instance = {
name: id,
Expand Down Expand Up @@ -72,7 +72,7 @@ def create
def destroy
debug('Removing location')
cmd = [command(:pcs), 'constraint', 'remove', @resource[:name]]
PuppetX::Voxpupuli::Corosync::Provider::Pcs.run_command_in_cib(cmd, @resource[:cib])
self.class.run_command_in_cib(cmd, @resource[:cib])
@property_hash.clear
end

Expand All @@ -85,11 +85,11 @@ def flush

# Remove existing location
cmd = [command(:pcs), 'constraint', 'remove', @resource[:name]]
PuppetX::Voxpupuli::Corosync::Provider::Pcs.run_command_in_cib(cmd, @resource[:cib], false)
self.class.run_command_in_cib(cmd, @resource[:cib], false)
unless @property_hash[:node_name].nil?
cmd = [command(:pcs), 'constraint', 'location', 'add', @property_hash[:name], @property_hash[:primitive], @property_hash[:node_name], @property_hash[:score]]
cmd << "resource-discovery=#{@property_hash[:resource_discovery]}" unless @property_hash[:resource_discovery].nil?
PuppetX::Voxpupuli::Corosync::Provider::Pcs.run_command_in_cib(cmd, @resource[:cib])
self.class.run_command_in_cib(cmd, @resource[:cib])
end

return if @property_hash[:rules].nil?
Expand All @@ -116,7 +116,7 @@ def flush
else
[command(:pcs), 'constraint', 'rule', 'add', @resource[:name]] + params
end
PuppetX::Voxpupuli::Corosync::Provider::Pcs.run_command_in_cib(cmd_rule, @resource[:cib])
self.class.run_command_in_cib(cmd_rule, @resource[:cib])
count += 1
end
end
Expand Down
6 changes: 3 additions & 3 deletions lib/puppet/provider/cs_order/crm.rb
Expand Up @@ -24,7 +24,7 @@ def self.instances
instances = []

cmd = [command(:crm), 'configure', 'show', 'xml']
raw, = PuppetX::Voxpupuli::Corosync::Provider::Crmsh.run_command_in_cib(cmd)
raw, = self.class.run_command_in_cib(cmd)
doc = REXML::Document.new(raw)

doc.root.elements['configuration'].elements['constraints'].each_element('rsc_order') do |e|
Expand Down Expand Up @@ -81,7 +81,7 @@ def create
# Unlike create we actually immediately delete the item.
def destroy
debug('Removing order directive')
PuppetX::Voxpupuli::Corosync::Provider::Crmsh.run_command_in_cib([command(:crm), 'configure', 'delete', @resource[:name]], @resource[:cib])
self.class.run_command_in_cib([command(:crm), 'configure', 'delete', @resource[:name]], @resource[:cib])
@property_hash.clear
end

Expand All @@ -100,7 +100,7 @@ def flush
Tempfile.open('puppet_crm_update') do |tmpfile|
tmpfile.write(updated)
tmpfile.flush
PuppetX::Voxpupuli::Corosync::Provider::Crmsh.run_command_in_cib([command(:crm), 'configure', 'load', 'update', tmpfile.path.to_s], @resource[:cib])
self.class.run_command_in_cib([command(:crm), 'configure', 'load', 'update', tmpfile.path.to_s], @resource[:cib])
end
end
end
8 changes: 4 additions & 4 deletions lib/puppet/provider/cs_order/pcs.rb
Expand Up @@ -28,7 +28,7 @@ def self.instances
instances = []

cmd = [command(:pcs), 'cluster', 'cib']
raw, = PuppetX::Voxpupuli::Corosync::Provider::Pcs.run_command_in_cib(cmd)
raw, = self.class.run_command_in_cib(cmd)
doc = REXML::Document.new(raw)

constraints = doc.root.elements['configuration'].elements['constraints']
Expand Down Expand Up @@ -101,7 +101,7 @@ def create
def destroy
debug('Removing order directive')
cmd = [command(:pcs), 'constraint', 'remove', @resource[:name]]
PuppetX::Voxpupuli::Corosync::Provider::Pcs.run_command_in_cib(cmd, @resource[:cib])
self.class.run_command_in_cib(cmd, @resource[:cib])
@property_hash.clear
end

Expand All @@ -115,7 +115,7 @@ def flush
if @property_hash[:new] == false
debug('Removing order directive')
cmd = [command(:pcs), 'constraint', 'remove', @resource[:name]]
PuppetX::Voxpupuli::Corosync::Provider::Pcs.run_command_in_cib(cmd, @resource[:cib])
self.class.run_command_in_cib(cmd, @resource[:cib])
end

cmd = [command(:pcs), 'constraint', 'order']
Expand All @@ -130,6 +130,6 @@ def flush
cmd << "kind=#{@property_hash[:kind]}"
cmd << "id=#{@property_hash[:name]}"
cmd << "symmetrical=#{@property_hash[:symmetrical]}"
PuppetX::Voxpupuli::Corosync::Provider::Pcs.run_command_in_cib(cmd, @resource[:cib])
self.class.run_command_in_cib(cmd, @resource[:cib])
end
end

0 comments on commit b1ed93b

Please sign in to comment.