Class: Bgp
- Inherits:
-
Object
- Object
- Bgp
- Defined in:
- lib/sonic-rbapi/bgp.rb
Overview
The Bgp class provides a class implementation and methods for managing BGP on the node. This class presents an abstraction
Class Method Summary collapse
-
.create_bgp_neighbor(conn, neighbor_ip, local_addr, admin_status = 'up', asn = 0, holdtime = 180, keepalive = 60) ⇒ RestClient::Request
This API creates a new BGP neighbor on the switch.
-
.delete_bgp_neighbor(conn, neighbor_ip) ⇒ RestClient::Request
This API delete BGP neighbor on the switch.
-
.get_all_bgp_neighbors(conn) ⇒ RestClient::Request
This API gets all BGP neighbors.
-
.get_bgp_info(conn, filter = nil) ⇒ RestClient::Request
This API gets BGP information from the switch.
-
.update_bgp_global_config(conn, bgp_status = 'up', bgp_asn) ⇒ RestClient::Request
This API updates the BGP global configuration on the switch.
Class Method Details
.create_bgp_neighbor(conn, neighbor_ip, local_addr, admin_status = 'up', asn = 0, holdtime = 180, keepalive = 60) ⇒ RestClient::Request
This API creates a new BGP neighbor on the switch.
Request URL: IP-ADDR:REST-PORT/api/bgps/neighbors/cfgs/10.10.10.10
payload format of key-value pairs
{
"local_addr": local_ip,
"neighbor_addr": neighbor_ip,
"admin_status": status,
"asn": asn,
"holdtime": 180,
"keepalive": 60
}
105 106 107 108 109 110 111 |
# File 'lib/sonic-rbapi/bgp.rb', line 105 def self.create_bgp_neighbor(conn, neighbor_ip, local_addr, admin_status='up', asn=0, holdtime=180, keepalive=60) url = form_url(conn, @bgp_cfg + '/' + neighbor_ip) hdr = form_hdr(conn) params = {"local_addr": local_addr, "neighbor_addr": neighbor_ip, "admin_status": admin_status, "asn": asn, "holdtime": holdtime, "keepalive": keepalive} params = params.to_json Rest.put(conn, url, hdr, params) end |
.delete_bgp_neighbor(conn, neighbor_ip) ⇒ RestClient::Request
This API delete BGP neighbor on the switch.
Request URL: IP-ADDR:REST-PORT/api/bgps/neighbors/cfgs/10.10.10.10
121 122 123 124 125 |
# File 'lib/sonic-rbapi/bgp.rb', line 121 def self.delete_bgp_neighbor(conn, neighbor_ip) url = form_url(conn, @bgp_cfg + '/' + neighbor_ip) hdr = form_hdr(conn) Rest.delete(conn, url, hdr) end |
.get_all_bgp_neighbors(conn) ⇒ RestClient::Request
This API gets all BGP neighbors
Request URL: IP-ADDR:REST-PORT/api/bgps/neighbors/cfgs
146 147 148 149 150 |
# File 'lib/sonic-rbapi/bgp.rb', line 146 def self.get_all_bgp_neighbors(conn) url = form_url(conn, @bgp_cfg) hdr = form_hdr(conn) Rest.get(conn, url, hdr) end |
.get_bgp_info(conn, filter = nil) ⇒ RestClient::Request
This API gets BGP information from the switch.
Request URL: IP-ADDR:REST-PORT/api/bgps/neighbors/info/summary
http://IP-ADDR:REST-PORT/api/bgps/neighbors/info
49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/sonic-rbapi/bgp.rb', line 49 def self.get_bgp_info(conn, filter=nil) summary_filter = "summary" if filter == summary_filter url = form_url(conn, @bgp_info + '/' + summary_filter) elsif filter == nil url = form_url(conn, @bgp_info) end hdr = form_hdr(conn) Rest.get(conn, url, hdr) end |
.update_bgp_global_config(conn, bgp_status = 'up', bgp_asn) ⇒ RestClient::Request
This API updates the BGP global configuration on the switch.
Request URL: IP-ADDR:REST-PORT/api/bgps/globals
payload format of key-value pairs
{
"default_bgp_status": "up",
"bgp_asn": 5000
}
75 76 77 78 79 80 81 |
# File 'lib/sonic-rbapi/bgp.rb', line 75 def self.update_bgp_global_config(conn, bgp_status='up', bgp_asn) url = form_url(conn, @bgp_global) hdr = form_hdr(conn) params = {"default_bgp_status": bgp_status, "bgp_asn": bgp_asn} params = params.to_json Rest.put(conn, url, hdr, params) end |