lib/junos-ez/utils/re.rb
## ----------------------------------------------------------------
## - retrieve Hash of license information.  
##
## By default this will provide the license installed
## information.  
## 
## --- returns ---
## - Hash of data if there are licenses
## - nil if no licenses
##
## --- options ---
## :keys => true
##    Will include the key-text for the license
##
## ----------------------------------------------------------------

retrieve Hash of license information.

By default this will provide the license installed
information.

returns
Hash of data if there are licenses
nil if no licenses

options
:keys => true
Will include the key-text for the license
retrieve Hash of license information . By default this will provide the license installed information . returns Hash of data if there are licenses nil if no licenses options : keys = > true Will include the key - text for the license
def licenses( opts = {} )
    got = @ndev.rpc.get_license_summary_information
    licenses = got.xpath('license-information/license')
    return nil if licenses.empty?
    ret_h = {}
    licenses.each do |lic|
      lic_h = {}
      ret_h[lic.xpath('name').text.strip] = lic_h
      lic_h[:state] = lic.xpath('license-state').text.strip
      lic_h[:version] = lic.xpath('license-version').text.strip
      lic_h[:serialnumber] = lic.xpath('software-sn').text.strip
      lic_h[:customer] = lic.xpath('customer-reference').text.strip
      features = lic.xpath('feature-block/feature')
      unless features.empty?
        feats_h = {}
        lic_h[:features] = feats_h
        features.each do |feat|
          feat_h = {}
          feats_h[feat.xpath('name').text.strip] = feat_h
          feat_h[:description] = feat.xpath('description').text.strip
          v_info = feat.xpath('validity-information')[0]
          case v_info.xpath('validity-type').text.strip
          when 'date-based'
            feat_h[:date_start] = v_info.xpath('start-date').text.strip
            feat_h[:date_end] = v_info.xpath('end-date').text.strip
          end
        end 
      end 
    end 
    if opts[:keys]
      got = @ndev.rpc.get_license_key_information
      got.xpath('license-key').each do |key|
        name = key.xpath('name').text.strip
        ret_h[name][:key] = key.xpath('key-data').text
      end
    end    
    ret_h
  end
def licenses ( opts = { } ) got = @ndev . rpc . get_license_summary_information licenses = got . xpath ( 'license-information/license' ) return nil if licenses . empty? ret_h = { } licenses . each do | lic | lic_h = { } ret_h [ lic . xpath ( 'name' ) . text . strip ] = lic_h lic_h [ :state ] = lic . xpath ( 'license-state' ) . text . strip lic_h [ :version ] = lic . xpath ( 'license-version' ) . text . strip lic_h [ :serialnumber ] = lic . xpath ( 'software-sn' ) . text . strip lic_h [ :customer ] = lic . xpath ( 'customer-reference' ) . text . strip features = lic . xpath ( 'feature-block/feature' ) unless features . empty? feats_h = { } lic_h [ :features ] = feats_h features . each do | feat | feat_h = { } feats_h [ feat . xpath ( 'name' ) . text . strip ] = feat_h feat_h [ :description ] = feat . xpath ( 'description' ) . text . strip v_info = feat . xpath ( 'validity-information' ) [ 0 ] case v_info . xpath ( 'validity-type' ) . text . strip when 'date-based' feat_h [ :date_start ] = v_info . xpath ( 'start-date' ) . text . strip feat_h [ :date_end ] = v_info . xpath ( 'end-date' ) . text . strip end end end end if opts [ :keys ] got = @ndev . rpc . get_license_key_information got . xpath ( 'license-key' ) . each do | key | name = key . xpath ( 'name' ) . text . strip ret_h [ name ] [ :key ] = key . xpath ( 'key-data' ) . text end end ret_h end
retrieve Hash of license information.
retrieve Hash of license information .
# each features
 # if features
 # each license
 ## now check to see if the :keys have been requested.  if so
 ## then get that data, and store back into the return Hash.

opts
<not_specific>