libraries/patch_mgmt.rb
def compute_filter_ml(targets, rq_name, niminfo)
      # build machine-oslevel hash
      levels = Hash.new { |h, k| h[k] = k == 'master' ? niminfo['nim']['master'].fetch('oslevel', nil) : niminfo['nim']['clients'].fetch(k, {}).fetch('oslevel', nil) }
      targets.each { |k| levels[k] }
      levels.delete_if { |_k, v| v.nil? || v.empty? || v.to_i != rq_name.to_i }
      log_debug("Hash table (machine/oslevel) built #{levels}")

      unless levels.empty?
        # discover FilterML level
        ary = levels.values.collect { |v| v.match(/^([0-9]{4}-[0-9]{2})(|-[0-9]{2}|-[0-9]{2}-[0-9]{4})$/)[1].delete('-') }
        # find lowest ML
        filter_ml = ary.min
      end

      raise InvalidTargetsProperty, 'Error: cannot discover filter ml based on the list of targets' if filter_ml.nil?
      filter_ml.insert(4, '-')
      filter_ml
    end
# -----------------------------------------------------------------
# Compute FilterML suma parameter
#
#    raise InvalidTargetsProperty in case of error
# -----------------------------------------------------------------
Compute FilterML suma parameter
raise InvalidTargetsProperty in case of error
Compute FilterML suma parameter raise InvalidTargetsProperty in case of error
def compute_filter_ml(targets, rq_name, niminfo)
      levels = Hash.new { |h, k| h[k] = k == 'master' ? niminfo['nim']['master'].fetch('oslevel', nil) : niminfo['nim']['clients'].fetch(k, {}).fetch('oslevel', nil) }
      targets.each { |k| levels[k] }
      levels.delete_if { |_k, v| v.nil? || v.empty? || v.to_i != rq_name.to_i }
      log_debug("Hash table (machine/oslevel) built #{levels}")
      unless levels.empty?
        ary = levels.values.collect { |v| v.match(/^([0-9]{4}-[0-9]{2})(|-[0-9]{2}|-[0-9]{2}-[0-9]{4})$/)[1].delete('-') }
        filter_ml = ary.min
      end
      raise InvalidTargetsProperty, 'Error: cannot discover filter ml based on the list of targets' if filter_ml.nil?
      filter_ml.insert(4, '-')
      filter_ml
    end
def compute_filter_ml ( targets , rq_name , niminfo ) levels = Hash . new { | h , k | h [ k ] = k == 'master' ? niminfo [ 'nim' ] [ 'master' ] . fetch ( 'oslevel' , nil ) : niminfo [ 'nim' ] [ 'clients' ] . fetch ( k , { } ) . fetch ( 'oslevel' , nil ) } targets . each { | k | levels [ k ] } levels . delete_if { | _k , v | v . nil? || v . empty? || v . to_i != rq_name . to_i } log_debug ( "Hash table (machine/oslevel) built #{levels}" ) unless levels . empty? ary = levels . values . collect { | v | v . match ( / ^([0-9]{4}-[0-9]{2})(|-[0-9]{2}|-[0-9]{2}-[0-9]{4})$ / ) [ 1 ] . delete ( '-' ) } filter_ml = ary . min end raise InvalidTargetsProperty , 'Error: cannot discover filter ml based on the list of targets' if filter_ml . nil? filter_ml . insert ( 4 , '-' ) filter_ml end
Compute FilterML suma parameter
raise InvalidTargetsProperty in case of error
Compute FilterML suma parameter raise InvalidTargetsProperty in case of error
# build machine-oslevel hash # discover FilterML level # find lowest ML
targets
rq_name
niminfo