Class: Interfaces
- Inherits:
-
Object
- Object
- Interfaces
- Defined in:
- lib/sonic-rbapi/interfaces.rb
Overview
The Interface class provides a class implementation and methods for managing the Interfaces on the node. This class presents an abstraction
Class Method Summary collapse
-
.get_interface_cfg(conn, interface = nil) ⇒ RestClient::Request
This API get the configuration of particular or all interface.
-
.get_interface_info(conn, interface = nil) ⇒ RestClient::Request
This API get the interface information.
-
.get_interface_stats(conn, interface = nil) ⇒ RestClient::Request
This API get the interface statistics.
-
.get_interface_transceivers(conn, interface = nil) ⇒ RestClient::Request
This API get the interface transceiver information.
-
.update_interface_cfg(conn, interface, fec = "none", mtu = 9100, speed = 100000, admin_status = "up") ⇒ RestClient::Request
This API updates properties of a interface.
Class Method Details
.get_interface_cfg(conn, interface = nil) ⇒ RestClient::Request
This API get the configuration of particular or all interface.
Request URL: IP-ADDR:REST-PORT/api/interfaces/cfgs/Ethernet0
165 166 167 168 169 170 171 172 173 |
# File 'lib/sonic-rbapi/interfaces.rb', line 165 def self.get_interface_cfg(conn, interface=nil) if (interface != nil) url = form_url(conn, @interface_cfg + '/' + interface.to_s) else url = form_url(conn, @interface_cfg) end hdr = form_hdr(conn) Rest.get(conn, url, hdr) end |
.get_interface_info(conn, interface = nil) ⇒ RestClient::Request
This API get the interface information.
Request URL: IP-ADDR:REST-PORT/api/interfaces/info/Ethernet0
http://IP-ADDR:REST-PORT/api/interfaces/info
47 48 49 50 51 52 53 54 55 |
# File 'lib/sonic-rbapi/interfaces.rb', line 47 def self.get_interface_info(conn, interface=nil) if interface == nil url = form_url(conn, @interface_info) else url = form_url(conn, @interface_info + '/' + interface.to_s) end hdr = form_hdr(conn) Rest.get(conn, url, hdr) end |
.get_interface_stats(conn, interface = nil) ⇒ RestClient::Request
This API get the interface statistics.
Request URL: IP-ADDR:REST-PORT/api/interfaces/info/stats/Ethernet0
http://IP-ADDR:REST-PORT/api/interfaces/info/stats
77 78 79 80 81 82 83 84 85 |
# File 'lib/sonic-rbapi/interfaces.rb', line 77 def self.get_interface_stats(conn, interface=nil) if interface == nil url = form_url(conn, @interface_stats) else url = form_url(conn, @interface_stats + '/' + interface.to_s) end hdr = form_hdr(conn) Rest.get(conn, url, hdr) end |
.get_interface_transceivers(conn, interface = nil) ⇒ RestClient::Request
This API get the interface transceiver information.
Request URL: IP-ADDR:REST-PORT/api/interfaces/transceivers/Ethernet0
http://IP-ADDR:REST-PORT/api/interfaces/transceivers
111 112 113 114 115 116 117 118 119 |
# File 'lib/sonic-rbapi/interfaces.rb', line 111 def self.get_interface_transceivers(conn, interface=nil) if interface == nil url = form_url(conn, @interface_transceiver) else url = form_url(conn, @interface_transceiver + '/' + interface.to_s) end hdr = form_hdr(conn) Rest.get(conn, url, hdr) end |
.update_interface_cfg(conn, interface, fec = "none", mtu = 9100, speed = 100000, admin_status = "up") ⇒ RestClient::Request
This API updates properties of a interface.
Request URL: IP-ADDR:REST-PORT/api/interfaces/cfgs/Ethernet0
payload format of key-value pairs
{
"fec": "none",
"mtu": "9100",
"speed": "100000",
"admin_status": "up",
}
140 141 142 143 144 145 146 |
# File 'lib/sonic-rbapi/interfaces.rb', line 140 def self.update_interface_cfg(conn, interface, fec="none", mtu=9100, speed=100000, admin_status="up") url = form_url(conn, @interface_cfg + '/' + interface.to_s) hdr = form_hdr(conn) params = {"fec": fec, "mtu": mtu, "speed": speed, "admin_status": admin_status} params = params.to_json Rest.post(conn, url, hdr, params) end |