Class: Vlan
- Inherits:
-
Object
- Object
- Vlan
- Defined in:
- lib/cnos-rbapi/vlan.rb
Overview
The Vlan class provides a class implementation and methods for managing the VLANs on the node. This class presents an abstraction
Constant Summary collapse
- @@cfg =
'/nos/api/cfg/vlan'
Class Method Summary collapse
-
.create_vlan(conn, params) ⇒ Object
parameters: conn - connection object to the node params - dictionary that requires the following format of key-value pairs { “vlan_name”: “<vlan_name>”, “vlan_id”: “<vlan_id>”, “admin_state”: “<admin_state>”, } description - vlan_name :VLAN name; a string up to 32 characters long.
-
.delete_vlan(conn, vlan_id) ⇒ Object
parameters: conn - connection object to the node vlan_id - VLAN number Note: If the specified vlan_id is all, all user‐created VLANs will be deleted.
-
.get_all_vlan(conn) ⇒ Object
parameters: conn - connection object to the node.
-
.get_vlan_prop(conn, vlan_id) ⇒ Object
parameters: conn - connection object to the node vlan_id - VLAN number.
-
.update_vlan(conn, vlan_id, params) ⇒ Object
parameters: conn - connection object to the node vlan_id - VLAN number params - dictionary that requires the following format of key-value pairs { “vlan_name”: “<vlan_name>”, “admin_state”: “<admin_state>” } description - vlan_name :VLAN name; a string up to 32 characters long.
Class Method Details
.create_vlan(conn, params) ⇒ Object
parameters:
conn - connection object to the node
params - dictionary that requires the following format of key-value pairs
{
"vlan_name": "<vlan_name>",
"vlan_id": "<vlan_id>",
"admin_state": "<admin_state>",
}
description -
vlan_name :VLAN name; a string up to 32 characters long. To create a VLAN
with the default name, the vlan_name field must be null.
vlan_id :VLAN number.; an integer from 2‐3999.
admin_state :The admin status; one of up, down
return: JSON response
61 62 63 64 65 66 67 |
# File 'lib/cnos-rbapi/vlan.rb', line 61 def self.create_vlan(conn, params) url = form_url(conn, @@cfg) hdr = form_hdr(conn) params = params.to_json Rest.post(conn, url, hdr, params) end |
.delete_vlan(conn, vlan_id) ⇒ Object
parameters:
conn - connection object to the node
vlan_id - VLAN number
Note: If the specified vlan_id is all, all user‐created VLANs will be deleted.
return:
117 118 119 120 121 |
# File 'lib/cnos-rbapi/vlan.rb', line 117 def self.delete_vlan(conn, vlan_id) url = form_url(conn, @@cfg + '/' + vlan_id.to_s) hdr = form_hdr(conn) Rest.delete(conn, url, hdr) end |
.get_all_vlan(conn) ⇒ Object
parameters:
conn - connection object to the node
return: JSON response
37 38 39 40 41 |
# File 'lib/cnos-rbapi/vlan.rb', line 37 def self.get_all_vlan(conn) url = form_url(conn, @@cfg) hdr = form_hdr(conn) Rest.get(conn, url, hdr) end |
.get_vlan_prop(conn, vlan_id) ⇒ Object
parameters:
conn - connection object to the node
vlan_id - VLAN number
return: JSON response
77 78 79 80 81 |
# File 'lib/cnos-rbapi/vlan.rb', line 77 def self.get_vlan_prop(conn, vlan_id) url = form_url(conn, @@cfg + '/' + vlan_id.to_s) hdr = form_hdr(conn) Rest.get(conn, url, hdr) end |
.update_vlan(conn, vlan_id, params) ⇒ Object
parameters:
conn - connection object to the node
vlan_id - VLAN number
params - dictionary that requires the following format of key-value pairs
{
"vlan_name": "<vlan_name>",
"admin_state": "<admin_state>"
}
description -
vlan_name :VLAN name; a string up to 32 characters long. To change a VLAN
name with default name, the vlan_name field must be null.
admin_state :The admin status; one of up, down
return: JSON response
100 101 102 103 104 105 106 |
# File 'lib/cnos-rbapi/vlan.rb', line 100 def self.update_vlan(conn, vlan_id, params) url = form_url(conn, @@cfg + '/' + vlan_id.to_s) hdr = form_hdr(conn) params = params.to_json Rest.put(conn, url, hdr, params) end |