Class: Lag
- Inherits:
-
Object
- Object
- Lag
- Defined in:
- lib/cnos-rbapi/lag.rb
Overview
The Lag class provides a class implementation and methods for managing Lag on the node. This class presents an abstraction
Constant Summary collapse
- @@cfg =
'/nos/api/cfg/lag'
Class Method Summary collapse
-
.create_lag(conn, lag_id, interfaces = []) ⇒ Object
parameters: conn - connection object to the node params - dictionary that requires the following format of key-value pairs { “lag_id”: “<lag_id>”, “interfaces”: [ { “if_name”: “<if_name>”, “lag_mode”: “<lag_mode>”, “lacp_prio”: “<lacp_prio>”, “lacp_timeout”: “<lacp_timeout>” } ] } description - lag_id :LAG identifier; a positive integer from 1‐4096.
-
.delete_lag(conn, lag_id) ⇒ Object
parameters: conn - connection object to the node.
-
.get_all_lag(conn) ⇒ Object
parameters: conn - connection object to the node.
-
.get_lag_prop(conn, lag_id) ⇒ Object
parameters: conn - connection object to the node.
-
.get_load_balance(conn) ⇒ Object
parameters: conn - connection object to the node.
-
.update_lag(conn, lag_id, params) ⇒ Object
parameters: conn - connection object to the node params - dictionary that requires the following format of key-value pairs { { “lag_name”: “<lag_name>”, “lag_id”: “<lag_id>”, “interfaces”: [ { “if_name”: “<if_name>”, “lag_mode”: “<lag_mode>”, “lacp_prio”: “<lacp_prio>”, “lacp_timeout”: “<lacp_timeout>” } ], “suspend_individual”: “<status>”, “min_links”: “<min_links>”, } } description - lag_name :The name of the LAG; a string.
-
.update_lag_load_balance(conn, params) ⇒ Object
parameters: conn - connection object to the node params - dictionary that requires the following format of key-value pairs { “destinationip” : “<destination‐ip>” “destinationmac” : “<destination‐mac>” “destinationport” : “<destination‐port>” “sourcedestip” : “<source‐dest‐ip>” “sourcedestmac” : “<source‐dest‐mac>” “sourcedestport” : “<source‐dest‐port>” “sourceinterface” : “<source‐interface>” “sourceip” : “<source‐ip>” “sourcemac” : “<source‐mac>” “sourceport” : ”<source‐port>“ } description - destination‐ip :Load distribution on the destination IP address.
Class Method Details
.create_lag(conn, lag_id, interfaces = []) ⇒ Object
parameters:
conn - connection object to the node
params - dictionary that requires the following format of key-value pairs
{
"lag_id": "<lag_id>",
"interfaces": [
{
"if_name": "<if_name>",
"lag_mode": "<lag_mode>",
"lacp_prio": "<lacp_prio>",
"lacp_timeout": "<lacp_timeout>"
}
]
}
description -
lag_id :LAG identifier; a positive integer from 1‐4096.
interfaces :Physical interface members of the LAG. Up to 32 interfaces can be
added.
if_name :Ethernet interface name (String).Note: The interface must exist.
lag_mode :LAG mode; one of lacp_active, lacp_passive, no_lacp.
lacp_prio :(Optional) LACP priority for the physical port; a positive integer
from 1‐65535. Default value: 32768.
lacp_timeout :(Optional) LACP timeout for the physical port; one of short,
long. Default value: long.
return: JSON response
70 71 72 73 74 75 |
# File 'lib/cnos-rbapi/lag.rb', line 70 def self.create_lag(conn, lag_id, interfaces = []) url = form_url(conn, @@cfg) hdr = form_hdr(conn) params = {"lag_id" => lag_id, "interfaces" => interfaces}.to_json Rest.post(conn, url, hdr, params) end |
.delete_lag(conn, lag_id) ⇒ Object
parameters:
conn - connection object to the node
return:
200 201 202 203 204 |
# File 'lib/cnos-rbapi/lag.rb', line 200 def self.delete_lag(conn, lag_id) url = form_url(conn, @@cfg + '/' + lag_id.to_s) hdr = form_hdr(conn) Rest.delete(conn, url, hdr) end |
.get_all_lag(conn) ⇒ Object
parameters:
conn - connection object to the node
return: JSON response
35 36 37 38 39 |
# File 'lib/cnos-rbapi/lag.rb', line 35 def self.get_all_lag(conn) url = form_url(conn, @@cfg) hdr = form_hdr(conn) Rest.get(conn, url, hdr) end |
.get_lag_prop(conn, lag_id) ⇒ Object
parameters:
conn - connection object to the node
return: JSON response
84 85 86 87 88 |
# File 'lib/cnos-rbapi/lag.rb', line 84 def self.get_lag_prop(conn, lag_id) url = form_url(conn, @@cfg + '/' + lag_id.to_s) hdr = form_hdr(conn) Rest.get(conn, url, hdr) end |
.get_load_balance(conn) ⇒ Object
parameters:
conn - connection object to the node
return: JSON response
149 150 151 152 153 |
# File 'lib/cnos-rbapi/lag.rb', line 149 def self.get_load_balance(conn) url = form_url(conn, @@cfg + '/load_balance') hdr = form_hdr(conn) Rest.get(conn, url, hdr) end |
.update_lag(conn, lag_id, params) ⇒ Object
parameters:
conn - connection object to the node
params - dictionary that requires the following format of key-value pairs
{
{
"lag_name": "<lag_name>",
"lag_id": "<lag_id>",
"interfaces": [
{
"if_name": "<if_name>",
"lag_mode": "<lag_mode>",
"lacp_prio": "<lacp_prio>",
"lacp_timeout": "<lacp_timeout>"
}
],
"suspend_individual": "<status>",
"min_links": "<min_links>",
}
}
description -
lag_name :The name of the LAG; a string.
lag_id :LAG identifier; an integer from 1‐65535
interfaces :Physical interface members of the LAG; an integer from 1‐32.
if_name :Ethernet interface name.
Note: The interface must exist.
lag_mode :LAG mode; one of lacp_active, lacp_passive, no_lacp.
lacp_prio :LACP priority for the physical port; an integer from 1‐65535.
Default value : 32768.
lacp_timeout :LACP timeout for the physical port; one of short, long. Default
value: long.
suspend_individual :If the LAG does not get the LACP BPUD from peer ports the port
aggregation, the result is one of the following:
Yes ‐ LACP on the the ports is suspended rather than put into
individual state.
No - LAG on the ports is put into individual state.
Default value :No.
min_links :LACP minimum links number; an integer from 1‐65535.
Default value: 1.
return: JSON response
135 136 137 138 139 140 |
# File 'lib/cnos-rbapi/lag.rb', line 135 def self.update_lag(conn, lag_id, params) url = form_url(conn, @@cfg + '/' + lag_id.to_s) hdr = form_hdr(conn) params = params.to_json Rest.put(conn, url, hdr, params) end |
.update_lag_load_balance(conn, params) ⇒ Object
parameters:
conn - connection object to the node
params - dictionary that requires the following format of key-value pairs
{
"destinationip" : "<destination‐ip>"
"destinationmac" : "<destination‐mac>"
"destinationport" : "<destination‐port>"
"sourcedestip" : "<source‐dest‐ip>"
"sourcedestmac" : "<source‐dest‐mac>"
"sourcedestport" : "<source‐dest‐port>"
"sourceinterface" : "<source‐interface>"
"sourceip" : "<source‐ip>"
"sourcemac" : "<source‐mac>"
"sourceport” : "<source‐port>"
}
description -
destination‐ip :Load distribution on the destination IP address.
destination‐mac :Load distribution on the destination MAC address.
destination‐port :Load distribution on the destination TCP/UDP port.
source‐dest‐ip :Load distribution on the source and destination IP address.
source‐dest‐mac :Load distribution on the source and destination MAC address.
source‐dest‐ port :Load distribution on the source and destination TCP/UDP port.
source‐ interface :Load distribution on the source ethernet interface.
source‐ip :Load distribution on the source IP address.
source‐mac :Load distribution on the source MAC address.
source‐port :Load distribution on the source TCP/UDP port.
return: JSON response
186 187 188 189 190 191 |
# File 'lib/cnos-rbapi/lag.rb', line 186 def self.update_lag_load_balance(conn, params) url = form_url(conn, @@cfg + '/load_balance') hdr = form_hdr(conn) params = params.to_json Rest.put(conn, url, hdr, params) end |