Class: Lldp

Inherits:
Object
  • Object
show all
Defined in:
lib/cnos-rbapi/lldp.rb

Overview

The Lldp class provides a class implementation and methods for managing LLdp on the node. This class presents an abstraction

Constant Summary collapse

@@cfg =
'/nos/api/cfg/lldp'

Class Method Summary collapse

Class Method Details

.get_lldp_all_intf(conn) ⇒ Object

parameters:

conn - connection object to the node

return: JSON response


76
77
78
79
80
# File 'lib/cnos-rbapi/lldp.rb', line 76

def self.get_lldp_all_intf(conn)
        url = form_url(conn, @@cfg + '/lldp_interface')
        hdr = form_hdr(conn)
        Rest.get(conn, url, hdr)
end

.get_lldp_intf(conn, intf) ⇒ Object

parameters:

conn - connection object to the node
intf - Interface name

return: JSON response


90
91
92
93
94
95
# File 'lib/cnos-rbapi/lldp.rb', line 90

def self.get_lldp_intf(conn, intf)
		intf.sub! '/', '%2F'
        url = form_url(conn, @@cfg + '/lldp_interface/' + intf)
        hdr = form_hdr(conn)
        Rest.get(conn, url, hdr)
end

.get_lldp_intf_neighbor(conn, intf) ⇒ Object

parameters:

conn - connection object to the node
intf - Interface name

return: JSON response


150
151
152
153
154
155
# File 'lib/cnos-rbapi/lldp.rb', line 150

def self.get_lldp_intf_neighbor(conn, intf)
        intf.sub! '/', '%2F'
        url = form_url(conn, @@cfg + '/lldp_interface/neighbor/' + intf)
        hdr = form_hdr(conn)
        Rest.get(conn, url, hdr)
end

.get_lldp_intf_neighbor_all(conn) ⇒ Object

parameters:

conn - connection object to the node

return: JSON response


164
165
166
167
168
# File 'lib/cnos-rbapi/lldp.rb', line 164

def self.get_lldp_intf_neighbor_all(conn)
        url = form_url(conn, @@cfg + '/lldp_interface/neighbor')
        hdr = form_hdr(conn)
        Rest.get(conn, url, hdr)
end

.get_lldp_intf_stats(conn, intf) ⇒ Object

parameters:

conn - connection object to the node
intf - Interface name

return: JSON response


135
136
137
138
139
140
# File 'lib/cnos-rbapi/lldp.rb', line 135

def self.get_lldp_intf_stats(conn, intf)
        intf.sub! '/', '%2F'
        url = form_url(conn, @@cfg + '/lldp_interface/statistics/' + intf)
        hdr = form_hdr(conn)
        Rest.get(conn, url, hdr)
end

.get_lldp_prop(conn) ⇒ Object

parameters:

conn - connection object to the node

return: JSON response


35
36
37
38
39
# File 'lib/cnos-rbapi/lldp.rb', line 35

def self.get_lldp_prop(conn)
        url = form_url(conn, @@cfg)
        hdr = form_hdr(conn)
        Rest.get(conn, url, hdr)
end

.update_lldp_intf(conn, intf, params) ⇒ Object

parameters:

conn - connection object to the node
intf - Interface name
params - dictionary that requires the following format of key-value pairs
		{
			 "if_name": "<if_name>",
			 "ena_lldp_rx": "<ena_lldp_rx>",
			 "ena_lldp_tx": "<ena_lldp_tx>"	
		}

description -

if_name :Ethernet interface name (String).Note: The Ethernet interface must exist. ena_lldp_rx :Enables or disables LLDP frame reception on a physical interface; one of yes (default), no. ena_lldp_tx :Enables or disable sLLDP frame transmission on a physical interface; one of yes (default), no.

return: JSON response



119
120
121
122
123
124
125
# File 'lib/cnos-rbapi/lldp.rb', line 119

def self.update_lldp_intf(conn, intf, params)
        intf.sub! '/', '%2F'
        url = form_url(conn, @@cfg + '/lldp_interface/' + intf)
        hdr = form_hdr(conn)
		params = params.to_json
        Rest.put(conn, url, hdr, params)
end

.update_lldp_prop(conn, params) ⇒ Object

parameters:

conn - connection object to the node
params - dictionary that requires the following format of key-value pairs
		{
	  	  "reinit delay": "<reinit delay>",
	  	  "transit interval": "<transmit interval>",
	  	  "transmit delay": "<transmit delay>"
	  	}

description - reinit delay :The number of seconds until LLDP re‐initialization is attempted

on an interface; an integer from 1‐10. Default value: 2 seconds.

transmit interval :The time interval, in seconds, between transmissions of LLDP

messages; an integer from 5‐32768.. Default value: 30 seconds.

transmit delay :The number of seconds for transmission delay; an integer from

                  1‐8192. Default value: 2 seconds.

return: JSON response


61
62
63
64
65
66
67
# File 'lib/cnos-rbapi/lldp.rb', line 61

def self.update_lldp_prop(conn, params)
        url = form_url(conn, @@cfg)
        hdr = form_hdr(conn)
        params = params.to_json
		Rest.put(conn, url, hdr, params)

end