libraries/patch_mgmt.rb
def expand_targets(targets, clients)
      return ['master'] if targets.nil? || targets.empty?

      selected_machines = []
      targets.split(/[,\s]/).each do |machine|
        selected_machines.push(machine) if machine == 'master'
        # expand wildcard
        machine.gsub!(/\*/, '.*?')
        clients.each do |m|
          selected_machines.concat(m.split) if m =~ /^#{machine}$/
        end
      end
      raise InvalidTargetsProperty, "Error: cannot contact any machines in '#{targets}'" if selected_machines.empty?
      selected_machines = selected_machines.sort.uniq
      log_info("List of targets expanded to #{selected_machines}")
      selected_machines
    end
# -----------------------------------------------------------------
# Expand the target machine list parameter
#
#    "*" should be specified as target to apply an operation on all
#        the machines
#    If target parameter is empty or not present operation is
#        performed locally
#
#    raise InvalidTargetsProperty in case of error
#    - cannot contact the target machines
# -----------------------------------------------------------------
Expand the target machine list parameter
"*" should be specified as target to apply an operation on all
the machines
If target parameter is empty or not present operation is
performed locally

raise InvalidTargetsProperty in case of error
cannot contact the target machines
Expand the target machine list parameter " * " should be specified as target to apply an operation on all the machines If target parameter is empty or not present operation is performed locally raise InvalidTargetsProperty in case of error cannot contact the target machines
def expand_targets(targets, clients)
      return ['master'] if targets.nil? || targets.empty?
      selected_machines = []
      targets.split(/[,\s]/).each do |machine|
        selected_machines.push(machine) if machine == 'master'
        machine.gsub!(/\*/, '.*?')
        clients.each do |m|
          selected_machines.concat(m.split) if m =~ /^#{machine}$/
        end
      end
      raise InvalidTargetsProperty, "Error: cannot contact any machines in '#{targets}'" if selected_machines.empty?
      selected_machines = selected_machines.sort.uniq
      log_info("List of targets expanded to #{selected_machines}")
      selected_machines
    end
def expand_targets ( targets , clients ) return [ 'master' ] if targets . nil? || targets . empty? selected_machines = [ ] targets . split ( / [, \s ] / ) . each do | machine | selected_machines . push ( machine ) if machine == 'master' machine . gsub! ( / \* / , '.*?' ) clients . each do | m | selected_machines . concat ( m . split ) if m =~ / ^ #{ machine } $ / end end raise InvalidTargetsProperty , "Error: cannot contact any machines in '#{targets}'" if selected_machines . empty? selected_machines = selected_machines . sort . uniq log_info ( "List of targets expanded to #{selected_machines}" ) selected_machines end
Expand the target machine list parameter
"*" should be specified as target to apply an operation on all
the machines
If target parameter is empty or not present operation is
performed locally
Expand the target machine list parameter " * " should be specified as target to apply an operation on all the machines If target parameter is empty or not present operation is performed locally
# expand wildcard
targets
clients