Module: Junos::Ez

Defined in:
lib/junos-ez/facts.rb,
lib/junos-ez/provider.rb,
lib/junos-ez/provider.rb,
lib/junos-ez/exceptions.rb,
lib/junos-ez/version.rb

Overview


Junos::Ez module devices the toplevel Provider and associated Facts class & methods


Defined Under Namespace

Modules: Config, FS, Facts, IPports, L1ports, L2ports, Provider, RE, StaticHosts, StaticRoutes, SysConfig, UserAuths, Users, Vlans Classes: NoProviderError

Constant Summary collapse

VERSION =
"0.1.2"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#factsObject

Returns the value of attribute facts.



10
11
12
# File 'lib/junos-ez/facts.rb', line 10

def facts
  @facts
end

#providersObject

Returns the value of attribute providers.



10
11
12
# File 'lib/junos-ez/facts.rb', line 10

def providers
  @providers
end

Class Method Details

.Provider(ndev) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/junos-ez/facts.rb', line 12

def self.Provider( ndev )       
  ndev.extend Junos::Ez
  ndev.providers = []
  ndev.facts = Junos::Ez::Facts::Keeper.new( ndev )     
  ndev.facts.read!
  true
end

.rpc_errors(as_xml) ⇒ Object


rpc_errors - decodes the XML into an array of error/Hash @@@ TBD: this should be moved into the ‘netconf’ gem




23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/junos-ez/provider.rb', line 23

def self.rpc_errors( as_xml )
  errs = as_xml.xpath('//rpc-error')
  return nil if errs.count == 0         # safety check    
  
  retval = []
  errs.each do |err|
     err_h = {}       
     # every error has a severity and message
     err_h[:severity] = err.xpath('error-severity').text.strip
     err_h[:message] = err.xpath('error-message').text.strip
     
     # some have an edit path error
     unless ( err_path = err.xpath('error-path')).empty?
       err_h[:edit_path] = err_path.text.strip 
     end
       
     # some have addition error-info/bad-element ...
     unless ( bad_i = err.xpath('error-info/bad-element')).empty?
       err_h[:bad_identifier] = bad_i.text.strip
     end
     
     retval << err_h
  end
  retval    
end

Instance Method Details

#fact(name) ⇒ Object



20
# File 'lib/junos-ez/facts.rb', line 20

def fact( name ); facts[name] end