You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
the following function is huge, not very ruby-like, and can be split in at least two functions (between if and else) and multiple helpers.
defself.instancesblock_until_readyinstances=[]cmd=[command(:crm),'configure','show','xml']ifPuppet::PUPPETVERSION.to_f < 3.4raw,status=Puppet::Util::SUIDManager.run_and_capture(cmd)elseraw=Puppet::Util::Execution.execute(cmd)status=raw.exitstatusenddoc=REXML::Document.new(raw)doc.root.elements['configuration'].elements['constraints'].each_element('rsc_colocation')do |e|
rscs=[]items=e.attributesifitems['rsc']# The colocation is defined as a single rsc_colocation element. This means# the format is rsc and with-rsc. In the type we chose to always deal with# ordering in a sequential way, which is why we reverse their order.ifitems['rsc-role']rsc="#{items['rsc']}:#{items['rsc-role']}"elsersc=items['rsc']endifitems['with-rsc-role']with_rsc="#{items['with-rsc']}:#{items['with-rsc-role']}"elsewith_rsc=items['with-rsc']end# Put primitives in chronological order, first 'with-rsc', then 'rsc'.primitives=[with_rsc,rsc]else# The colocation is defined as a rsc_colocation element wrapped around a single resource_set.# This happens automatically when you configure a colocation between more than 2 primitives.# Notice, we can only interpret colocations of single sets, not multiple sets combined.# In Pacemaker speak, this means we can support "A B C" but not e.g. "A B (C D) E".# Feel free to contribute a patch for this.primitives=[]e.each_element('resource_set')do |rset|
rsetitems=rset.attributes# If the resource set has a role, it will apply to all referenced resources.ifrsetitems['role']rsetrole=rsetitems['role']elsersetrole=nilend# Add all referenced resources to the primitives array.rset.each_element('resource_ref')do |rref|
rrefitems=rref.attributesifrsetrole# Make sure the reference is stripped from a possible rolerrefprimitive=rrefitems['id'].split(':')[0]# Always reuse the resource set roleprimitives.push("#{rrefprimitive}:#{rsetrole}")else# No resource_set role was set: just push the complete reference.primitives.push(rrefitems['id'])endendendendcolocation_instance={:name=>items['id'],:ensure=>:present,:primitives=>primitives,:score=>items['score'],:provider=>self.name}instances << new(colocation_instance)endinstancesend
my perception is that those helpers could also be used in other cs_* providers.
The text was updated successfully, but these errors were encountered:
the following function is huge, not very ruby-like, and can be split in at least two functions (between if and else) and multiple helpers.
my perception is that those helpers could also be used in other cs_* providers.
The text was updated successfully, but these errors were encountered: