libraries/patch_mgmt.rb
def find_resource_by_client(type, time, oslevel, niminfo)
      log_debug("nim: finding #{time} #{type}")
      lppsource = ''
      case type
      when 'tl'
        # reading output until I have found the good tl
        niminfo['nim']['lpp_sources'].keys.each do |key|
          a_key = key.split('-')
          next unless a_key[0] == oslevel[0] && a_key[1] > oslevel[1]
          lppsource = key
          break if time == 'next'
        end
      when 'sp'
        # reading output until I have found the good sp
        niminfo['nim']['lpp_sources'].keys.each do |key|
          a_key = key.split('-')
          next unless a_key[0] == oslevel[0] && a_key[1] == oslevel[1] && a_key[2] > oslevel[2]
          lppsource = key
          break if time == 'next'
        end
      end
      if lppsource.empty?
        # setting lpp_source to current oslevel if not found
        lppsource = oslevel[0] + '-' + oslevel[1] + '-' + oslevel[2] + '-' + oslevel[3] + '-lpp_source'
        log_debug("nim: server already to the #{time} #{type}, or no lpp_source were found, #{lppsource} will be utilized")
      else
        log_debug("nim: we found the #{time} lpp_source, #{lppsource} will be utilized")
      end
      lppsource
    end
# -----------------------------------------------------------------
# Search for a lpp_source resource into available nim resources
#
#    "type" : 'sp' or 'tl'
#    "time" : 'latest' or 'next'
#    "oslevel" : the oslevel of the machine for example 7100-01-01-1210
#    "niminfo" : the hash to look lpp_source into
#
#    returns the corresponding lpp source if found
#    or else the current oslevel
# -----------------------------------------------------------------


returns the corresponding lpp source if found
or else the current oslevel
returns the corresponding lpp source if found or else the current oslevel
def find_resource_by_client(type, time, oslevel, niminfo)
      log_debug("nim: finding #{time} #{type}")
      lppsource = ''
      case type
      when 'tl'
        niminfo['nim']['lpp_sources'].keys.each do |key|
          a_key = key.split('-')
          next unless a_key[0] == oslevel[0] && a_key[1] > oslevel[1]
          lppsource = key
          break if time == 'next'
        end
      when 'sp'
        niminfo['nim']['lpp_sources'].keys.each do |key|
          a_key = key.split('-')
          next unless a_key[0] == oslevel[0] && a_key[1] == oslevel[1] && a_key[2] > oslevel[2]
          lppsource = key
          break if time == 'next'
        end
      end
      if lppsource.empty?
        lppsource = oslevel[0] + '-' + oslevel[1] + '-' + oslevel[2] + '-' + oslevel[3] + '-lpp_source'
        log_debug("nim: server already to the #{time} #{type}, or no lpp_source were found, #{lppsource} will be utilized")
      else
        log_debug("nim: we found the #{time} lpp_source, #{lppsource} will be utilized")
      end
      lppsource
    end
def find_resource_by_client ( type , time , oslevel , niminfo ) log_debug ( "nim: finding #{time} #{type}" ) lppsource = '' case type when 'tl' niminfo [ 'nim' ] [ 'lpp_sources' ] . keys . each do | key | a_key = key . split ( '-' ) next unless a_key [ 0 ] == oslevel [ 0 ] && a_key [ 1 ] > oslevel [ 1 ] lppsource = key break if time == 'next' end when 'sp' niminfo [ 'nim' ] [ 'lpp_sources' ] . keys . each do | key | a_key = key . split ( '-' ) next unless a_key [ 0 ] == oslevel [ 0 ] && a_key [ 1 ] == oslevel [ 1 ] && a_key [ 2 ] > oslevel [ 2 ] lppsource = key break if time == 'next' end end if lppsource . empty? lppsource = oslevel [ 0 ] + '-' + oslevel [ 1 ] + '-' + oslevel [ 2 ] + '-' + oslevel [ 3 ] + '-lpp_source' log_debug ( "nim: server already to the #{time} #{type}, or no lpp_source were found, #{lppsource} will be utilized" ) else log_debug ( "nim: we found the #{time} lpp_source, #{lppsource} will be utilized" ) end lppsource end
Search for a lpp_source resource into available nim resources
"type" : 'sp' or 'tl'
"time" : 'latest' or 'next'
"oslevel" : the oslevel of the machine for example 7100-01-01-1210
"niminfo" : the hash to look lpp_source into
Search for a lpp_source resource into available nim resources " type " : ' sp ' or ' tl ' " time " : ' latest ' or ' next ' " oslevel " : the oslevel of the machine for example 7100 - 01 - 01 - 1210 " niminfo " : the hash to look lpp_source into
# reading output until I have found the good tl # reading output until I have found the good sp # setting lpp_source to current oslevel if not found
type
time
oslevel
niminfo