Class: Mstp

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

Overview

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

Constant Summary collapse

@@cfg =
'/nos/api/cfg/mstp'

Class Method Summary collapse

Class Method Details

.create_mstp_inst(conn, params) ⇒ Object

parameters:

conn - connection object to the node
params - dictionary that requires the following format of key-value pairs
		{
		 "instance_id": "<instance_id>",
		  "instance_prio": "<instance_prio>",
		  "vlans": [
		    {
		      "vlan_id": "<vlan_id>"
		    }
		  ]
		}
description -
instance_id   :MST instance ID; an integer from 0‐64. Instance 0 refers to the
		  CIST.
instance_prio :Sets the instance bridge priority; an integer from 0‐61440. Default
		  value: 32768.
vlans         :Maps a range of VLANs to a multiple spanning tree instance
		  (MSTI); an integer from 1‐4094.

return: JSON response


101
102
103
104
105
106
# File 'lib/cnos-rbapi/mstp.rb', line 101

def self.create_mstp_inst(conn, params)
        url = form_url(conn, @@cfg + '_instance')
        hdr = form_hdr(conn)
		params = params.to_json
        Rest.post(conn, url, hdr, params)
end

.del_mstp_inst(conn, inst_id) ⇒ Object

parameters:

conn - connection object to the node

return: JSON response


160
161
162
163
164
# File 'lib/cnos-rbapi/mstp.rb', line 160

def self.del_mstp_inst(conn, inst_id)
        url = form_url(conn, @@cfg + '_instance/' + inst_id.to_s)
        hdr = form_hdr(conn)
        Rest.delete(conn, url, hdr)
end

.get_mstp_inst(conn, inst_id) ⇒ Object

parameters:

conn - connection object to the node

return: JSON response


115
116
117
118
119
# File 'lib/cnos-rbapi/mstp.rb', line 115

def self.get_mstp_inst(conn, inst_id)
        url = form_url(conn, @@cfg + '_instance/' + inst_id.to_s)
        hdr = form_hdr(conn)
        Rest.get(conn, url, hdr)
end

.get_mstp_inst_all(conn) ⇒ Object

parameters:

conn - connection object to the node

return: JSON response


71
72
73
74
75
# File 'lib/cnos-rbapi/mstp.rb', line 71

def self.get_mstp_inst_all(conn)
        url = form_url(conn, @@cfg + '_instance')
        hdr = form_hdr(conn)
        Rest.get(conn, url, hdr)
end

.get_mstp_inst_intf(conn, inst_id, intf) ⇒ Object

parameters:

conn - connection object to the node
inst_id - instance id
intf - interface in the MSTP instance 

return: JSON response


175
176
177
178
179
180
# File 'lib/cnos-rbapi/mstp.rb', line 175

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

.get_mstp_sys_prop(conn) ⇒ Object

parameters:

conn - connection object to the node

return: JSON response


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

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

.update_mstp_inst(conn, inst_id, params) ⇒ Object

return : JSON response



145
146
147
148
149
150
151
# File 'lib/cnos-rbapi/mstp.rb', line 145

def self.update_mstp_inst(conn, inst_id, params)
        url = form_url(conn, @@cfg + '_instance/' + inst_id.to_s)
        hdr = form_hdr(conn)
        params = params.to_json
        Rest.post(conn, url, hdr, params)

end

.update_mstp_inst_intf(conn, inst_id, intf, params) ⇒ Object

parameters:

conn - connection object to the node
inst_id - instance id
intf - interface in the MSTP instance 
params - dictionary that requires the following format of key-value pairs
		{
		  "if_name": "<if_name>",
		  "path_cost": "<path_cost>",
		  "port_prio": "<port_prio>"
		}
description -
if_name    :Interface name.Note: The interface must exist.
path_cost  :The port path‐cost value on the specified MST instance; either an
		integer from 1‐200000000 or auto (default) to base the path‐cost
		on port speed.
port_prio  :The port priority, in increments of 32, on the specified MST
		instance; a multiple of 32 from 0‐224. Default value: 128.
return: JSON response


203
204
205
206
207
208
209
210
# File 'lib/cnos-rbapi/mstp.rb', line 203

def self.update_mstp_inst_intf(conn, inst_id, intf, params)
        intf.sub! '/', '%2F'
        url = form_url(conn, @@cfg + '_instance/' + inst_id.to_s + '/' + intf )
        hdr = form_hdr(conn)
		params = params.to_json
        Rest.put(conn, url, hdr, params)

end

.update_mstp_sys_prop(conn, params) ⇒ Object

parameters:

conn - connection object to the node
params - dictionary that requires the following format of key-value pairs
		{
		  "region_name": "<region_name>"
		  "revision": "<revision>"
		}
description - 
region_name  :Region name; a string up to 32 characters long.
revision     :Revision number; an integer from 0‐65535.

return: JSON response


56
57
58
59
60
61
62
# File 'lib/cnos-rbapi/mstp.rb', line 56

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

end