Class: Cisco::NodeUtil

Inherits:
Object
  • Object
show all
Defined in:
lib/cisco_node_utils/node_util.rb

Overview

NodeUtil - generic functionality for node utility subclasses to use

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.clientObject


31
32
33
# File 'lib/cisco_node_utils/node_util.rb', line 31

def self.client
  node.client
end

.config_get(*args) ⇒ Object


39
40
41
42
43
44
45
# File 'lib/cisco_node_utils/node_util.rb', line 39

def self.config_get(*args)
  node.config_get(*args)
rescue Cisco::RequestFailed => e
  e2 = e.class.new("[#{self}] #{e}", **e.kwargs)
  e2.set_backtrace(e.backtrace)
  raise e2
end

.config_get_default(*args) ⇒ Object


55
56
57
# File 'lib/cisco_node_utils/node_util.rb', line 55

def self.config_get_default(*args)
  node.config_get_default(*args)
end

.config_set(*args) ⇒ Object


63
64
65
66
67
68
69
# File 'lib/cisco_node_utils/node_util.rb', line 63

def self.config_set(*args)
  node.config_set(*args)
rescue Cisco::RequestFailed => e
  e2 = e.class.new("[#{self}] #{e}", **e.kwargs)
  e2.set_backtrace(e.backtrace)
  raise e2
end

.nodeObject


23
24
25
# File 'lib/cisco_node_utils/node_util.rb', line 23

def self.node
  Cisco::Node.instance
end

.platformObject


87
88
89
# File 'lib/cisco_node_utils/node_util.rb', line 87

def self.platform
  client.platform
end

.supports?(api) ⇒ Boolean


79
80
81
# File 'lib/cisco_node_utils/node_util.rb', line 79

def self.supports?(api)
  client.supports?(api)
end

Instance Method Details

#clientObject


35
36
37
# File 'lib/cisco_node_utils/node_util.rb', line 35

def client
  node.client
end

#config_get(*args) ⇒ Object


47
48
49
50
51
52
53
# File 'lib/cisco_node_utils/node_util.rb', line 47

def config_get(*args)
  node.config_get(*args)
rescue Cisco::RequestFailed => e
  e2 = e.class.new("[#{self}] #{e}", **e.kwargs)
  e2.set_backtrace(e.backtrace)
  raise e2
end

#config_get_default(*args) ⇒ Object


59
60
61
# File 'lib/cisco_node_utils/node_util.rb', line 59

def config_get_default(*args)
  node.config_get_default(*args)
end

#config_set(*args) ⇒ Object


71
72
73
74
75
76
77
# File 'lib/cisco_node_utils/node_util.rb', line 71

def config_set(*args)
  node.config_set(*args)
rescue Cisco::RequestFailed => e
  e2 = e.class.new("[#{self}] #{e}", **e.kwargs)
  e2.set_backtrace(e.backtrace)
  raise e2
end

#get(**kwargs) ⇒ Object


95
96
97
98
99
100
101
# File 'lib/cisco_node_utils/node_util.rb', line 95

def get(**kwargs)
  node.get(**kwargs)
rescue Cisco::RequestFailed => e
  e2 = e.class.new("[#{self}] #{e}", **e.kwargs)
  e2.set_backtrace(e.backtrace)
  raise e2
end

#ios_xr?Boolean


103
104
105
# File 'lib/cisco_node_utils/node_util.rb', line 103

def ios_xr?
  platform == :ios_xr
end

#nexus?Boolean


107
108
109
# File 'lib/cisco_node_utils/node_util.rb', line 107

def nexus?
  platform == :nexus
end

#nodeObject


27
28
29
# File 'lib/cisco_node_utils/node_util.rb', line 27

def node
  self.class.node
end

#platformObject


91
92
93
# File 'lib/cisco_node_utils/node_util.rb', line 91

def platform
  client.platform
end

#supports?(api) ⇒ Boolean


83
84
85
# File 'lib/cisco_node_utils/node_util.rb', line 83

def supports?(api)
  client.supports?(api)
end