Class: Stp

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

Overview

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

Constant Summary collapse

@@cfg =
'/nos/api/cfg/stp/interface'

Class Method Summary collapse

Class Method Details

.get_all_stp(conn) ⇒ Object

parameters:

conn - connection object to the node

return: JSON response


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

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

.get_stp_intf(conn, intf) ⇒ Object

parameters:

conn - connection object to the node
intf - Interface name

return: JSON response


48
49
50
51
52
53
# File 'lib/cnos-rbapi/stp.rb', line 48

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

.update_stp(conn, intf, params) ⇒ Object

parameters:

conn - connection object to the node
intf - Interface name
params - dictionary that requires the following format of key-value pairs
    {
      

}

description -
if_name   :The IP interface name; a string.
     Note: The interface must exist.
edge_port   :Whether the interface is configured as an edge port, which allows
     the port to automatically transition to the STP forwarding state;
     one of yes, no. Default value: yes.
bpdu_guard   :(Optional) Whether BPDU guard is enabled on a port, which
     automatically shuts down the interface upon receipt of a BPDU;
     one of enable, disable. Default value: disable.
loop_guard  :(Optional) Whether look guard is enabled on a port for additional
     checks for preventing STP looping; one of enable, disable.

Default value: disable.

root_guard  :(Optional) Whether guard mode is set to root guard on interface

return: JSON response


85
86
87
88
89
90
91
# File 'lib/cnos-rbapi/stp.rb', line 85

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