class System

The System class provides a class implementation and methods for managing and setting up images and config files on the node. This class presents an abstraction

Public Class Methods

download_boot_img(conn, params) click to toggle source

This API downloads a boot image to the switch

parameters:
conn - connection object to the node
params - dictionary that requires the following format of key-value pairs
             {
               "protocol":"<protocol>",
               "serverip":"<serverip>",
               "srcfile":"<srcfile>",
               "imgtype":"<imgtype>",
               "username":"<username>",
               "passwd":"<passwd>",
               "vrf_name":"<vrf_name>"
             } 
description -
protocol :Protocol name; one of ʺtftpʺ, ʺsftpʺ.
serverip :Server IP address.
srcfile  :Source file; up to 256 characters long.
imgtype  :System image type; one of ʺallʺ, ʺbootʺ, ʺonieʺ, ʺosʺ.
username :Username for the server. Not required for TFTP.
passwd   :Password for the server username. Not required for TFTP.
vrf_name :(Optional) VRF name; an alphabetic string up to 64 characters long

return: JSON response
# File lib/cnos-rbapi/system.rb, line 55
def self.download_boot_img(conn, params)
        temp = @@cfg + '/download/image'
        url = form_url(conn, temp)
        hdr = form_hdr(conn)
        params = params.to_json
        Rest.post(conn, url, hdr, params)
end
download_sw_config(conn, params) click to toggle source

This API downloads a configuration to the switch

parameters:
conn - connection object to the node
params - dictionary that requires the following format of key-value pairs
             {
               "protocol":"<protocol>",
               "serverip":"<serverip>",
               "srcfile":"<srcfile>",
               "dstfile":"<dstfile>",
               "username":"<username>",
               "passwd":"<passwd>",
               "vrf_name":"<vrf_name>"
             }
description -
protocol :Protocol name; one of ʺtftpʺ, ʺsftpʺ.
serverip :Server IP address.
srcfile  :Source file; up to 256 characters long.
dstfile  :Destination file; one of 'running_config', 'startup_config'.
username :(Optional) Username for the server.
passwd   :(Optional) Password for the server username.
vrf_name :(Optional) VRF name; an alphabetic string up to 64 characters long

return: JSON response
# File lib/cnos-rbapi/system.rb, line 138
def self.download_sw_config(conn, params)
        temp = @@cfg + '/download/config'
        url = form_url(conn, temp)
        hdr = form_hdr(conn)
        params = params.to_json
        Rest.post(conn, url, hdr, params)
end
get_clock(conn) click to toggle source

This API gets the date of the system

parameters:
conn - connection object to the node

return: JSON response
# File lib/cnos-rbapi/system.rb, line 282
def self.get_clock(conn)
        temp = @@cfg + '/cfg/clock'
        url = form_url(conn, temp)
        hdr = form_hdr(conn)
        Rest.get(conn, url, hdr)
end
get_device_contact(conn) click to toggle source

This API gets the device contact.

parameters:
conn - connection object to the node

return: JSON response
# File lib/cnos-rbapi/system.rb, line 407
def self.get_device_contact(conn)
        temp = @@cfg + '/cfg/contact'
        url = form_url(conn, temp)
        hdr = form_hdr(conn)
        Rest.get(conn, url, hdr)
end
get_device_descr(conn) click to toggle source

This API gets the device descr.

parameters:
conn - connection object to the node

return: JSON response
# File lib/cnos-rbapi/system.rb, line 442
def self.get_device_descr(conn)
        temp = @@cfg + '/cfg/descr'
        url = form_url(conn, temp)
        hdr = form_hdr(conn)
        Rest.get(conn, url, hdr)
end
get_hostname(conn) click to toggle source

This API gets the hostname of the system

parameters:
conn - connection object to the node

return: JSON response
# File lib/cnos-rbapi/system.rb, line 247
def self.get_hostname(conn)
        temp = @@cfg + '/cfg/hostname'
        url = form_url(conn, temp)
        hdr = form_hdr(conn)
        Rest.get(conn, url, hdr)
end
get_startup_sw(conn) click to toggle source

This API gets the system startup image.

parameters:
conn - connection object to the node

return: JSON response
# File lib/cnos-rbapi/system.rb, line 91
def self.get_startup_sw(conn)
        temp = @@cfg + '/startup/software'
        url = form_url(conn, temp)
        hdr = form_hdr(conn)
        Rest.get(conn, url, hdr)
end
get_transfer_status(conn, type, content) click to toggle source

This API gets the status of a downloading transfer.

parameters:
conn - connection object to the node
content - One of 'image', 'running_config', 'startup_config'
type - 'upload' or 'download'

return: JSON response
# File lib/cnos-rbapi/system.rb, line 233
def self.get_transfer_status(conn, type, content)
        temp = @@cfg + '/' + type + '/status/' + content
        url = form_url(conn, temp)
        hdr = form_hdr(conn)
        Rest.get(conn, url, hdr)
end
put_startup_sw(conn, params) click to toggle source

This API updates the system startup image

parameters:
conn - connection object to the node
params - dictionary that requires the following format of key-value pairs
             {
               “boot software” : “<setting>”
             }
description -
setting :Next startup image setting; one of “active” or “standby”

return: JSON response
# File lib/cnos-rbapi/system.rb, line 76
def self.put_startup_sw(conn, params)
        temp = @@cfg + '/startup/software'
        url = form_url(conn, temp)
        hdr = form_hdr(conn)
        params = params.to_json
        Rest.put(conn, url, hdr, params)
end
reset_switch(conn) click to toggle source

This API resets the switch

parameters:
conn - connection object to the node

return: JSON response
# File lib/cnos-rbapi/system.rb, line 105
def self.reset_switch(conn)
        temp = @@cfg + '/reset'
        url = form_url(conn, temp)
        hdr = form_hdr(conn)
        Rest.get(conn, url, hdr)
end
save_config(conn) click to toggle source

This API saves the running configuration to the flash memory

parameters:
conn - connection object to the node

return: JSON response
# File lib/cnos-rbapi/system.rb, line 153
def self.save_config(conn)
        temp = @@cfg + '/save/config'
        url = form_url(conn, temp)
        hdr = form_hdr(conn)
        Rest.get(conn, url, hdr)
end
set_clock(conn, params) click to toggle source

This API sets the system date.

parameters:
conn - connection object to the node
params - dictionary that requires the following format of key-value pairs
                {
                     "time": "<HH:MM:SS>" ,
                     "day": <day>,
                     "month": <month> ,
                     "year": <year>
                }
description - 
time  :System time in the format ʺHH:MM:SSʺ.
day   :The day of the month; an integer from 1‐31.
month :The month; one of the following case‐insensitive strings:
 January
 February
 March
 April
 May
 June
 July
 August
 September
 October
 November
 December
year  :The year; an integer from 2000‐2030.

return: JSON response
# File lib/cnos-rbapi/system.rb, line 320
def self.set_clock(conn, params)
        temp = @@cfg + '/cfg/clock'
        url = form_url(conn, temp)
        hdr = form_hdr(conn)
        params = params.to_json
        Rest.put(conn, url, hdr, params)
end
set_clock_format(conn, params) click to toggle source

This API sets the clock format to 12 hour or 24 hour format.

parameters:
conn - connection object to the node
params - dictionary that requires the following format of key-value pairs
                {
                      "format": <format>
                }
description - 
format :System clock format; one of:
             12 (12 hour format)
             24 (24 hour format)

 return: JSON response
# File lib/cnos-rbapi/system.rb, line 343
def self.set_clock_format(conn, params)
        temp = @@cfg + '/cfg/clock/format/'
        url = form_url(conn, temp)
        hdr = form_hdr(conn)
        params = params.to_json
        Rest.put(conn, url, hdr, params)
end
set_clock_protocol(conn, params) click to toggle source

This API sets the protocol to either manual or Network Time Protocol.

parameters:
conn - connection object to the node
params - dictionary that requires the following format of key-value pairs
                {
                      "protocol": "<protocol>"
                }

description - protocol :System clock protocol; one of:

none ‐ the clock is manually configured
ntp ‐ the clock is configured through NTP
Default value: “ntp”.

return: JSON response

# File lib/cnos-rbapi/system.rb, line 367
def self.set_clock_protocol(conn, params)
        temp = @@cfg + '/cfg/clock/protocol/'
        url = form_url(conn, temp)
        hdr = form_hdr(conn)
        params = params.to_json
        Rest.put(conn, url, hdr, params)
end
set_clock_summertime(conn, params) click to toggle source

This API set the transition to and from a summer time zone adjustment.

parameters:
conn - connection object to the node
params - dictionary that requires the following format of key-value pairs
                {
                       "timezone": <time_zone>,
                       "startweek": <start_week>,
                       "startweekday": <start_weekday>,
                       "startmonth": <start_month>,
                       "starttime" :  "<HH:MM>",
                       "endweek"   : <end_week>,
                       "endweekday": <end_weekday>,
                       "endmonth"  : <end_month>,
                       "endtime"   :  “<HH:MM>”,
                       "offsetmin" : <minutes>
                }
description -
timezone     :Local time zone of the system; a three to five character
              string such as ʺPSTʺ, ʺMSTʺ, ʺCSTʺ, or ʺESTʺ.
startweek    :Week number in the month in which to start Daylight
              Saving time; an integer from 1‐5 (first week=1, last
              week=5).
startweekday :Weekday on which to start DST; one of the following
              case‐insensitive strings:
              monday - sunday
startmonth   :Month to start DST; one of the following
              case‐insensitive strings:
              january - december
starttime    :Time to start DST; a string in the format ʺHH:MMʺ.
              endweek Week number in which to end DST; an integer from
              1‐5 (first week=1, last week=5).
endweekday   :Weekday on which to end DST; one of the following
              case‐insensitive strings:
              monday - sunday
endmonth     :Month in which DST ends; one of the following
              case‐insensitive strings:
              january - december
endtime      :Time to end DST; a string in the format ʺHH:MMʺ
offsetmin    :Offset to add, in minutes; an integer from 1‐1440.

return: JSON response
# File lib/cnos-rbapi/system.rb, line 513
def self.set_clock_summertime(conn, params)
        temp = @@cfg + '/cfg/clock/summertime'
        url = form_url(conn, temp)
        hdr = form_hdr(conn)
        params = params.to_json
        Rest.put(conn, url, hdr, params)
end
set_clock_timezone(conn, params) click to toggle source

This API sets the clock time zone for the switch

parameters:
conn - connection object to the node
params - dictionary that requires the following format of key-value pairs
                {
                      ""timezone": "<timezone>",
                       "offsethour": "<offsethour>",
                       "offsetmin": "<lag_mode>",
                }

description - timezone :One to five letter string denoting the local system time zone. offsethour :Hours offset from UTC; an integer from ‐23 through 23. offsetmin :Minutes offset from UTC; an integer from 0‐59.

return: JSON response

# File lib/cnos-rbapi/system.rb, line 392
def self.set_clock_timezone(conn, params)
        temp = @@cfg + '/cfg/clock/timezone/'
        url = form_url(conn, temp)
        hdr = form_hdr(conn)
        params = params.to_json
        Rest.put(conn, url, hdr, params)
end
set_device_contact(conn, params) click to toggle source

This API updates the device contact.

parameters:
conn - connection object to the node
params - dictionary that requires the following format of key-value pairs
                {
                       "contact": <contact>
                }
description - 
contact   :Device contact; a string up to 256 characters long

return: JSON response
# File lib/cnos-rbapi/system.rb, line 427
def self.set_device_contact(conn, params)
        temp = @@cfg + '/cfg/contact'
        url = form_url(conn, temp)
        hdr = form_hdr(conn)
        params = params.to_json
        Rest.put(conn, url, hdr, params)
end
set_device_descr(conn, params) click to toggle source

This API updates the device description.

parameters:
conn - connection object to the node
params - dictionary that requires the following format of key-value pairs
                {
                       "descr": <descr>
                }
description - 
descr   :Device description; a string up to 256 characters long.

return: JSON response
# File lib/cnos-rbapi/system.rb, line 462
def self.set_device_descr(conn, params)
        temp = @@cfg + '/cfg/descr'
        url = form_url(conn, temp)
        hdr = form_hdr(conn)
        params = params.to_json
        Rest.put(conn, url, hdr, params)
end
set_hostname(conn, params) click to toggle source

This API sets the system boot image.

parameters:
conn - connection object to the node
params - dictionary that requires the following format of key-value pairs
                {
                    "hostname":"<hostname>"
                }
description - 
hostname :The hostname of the system; a string from 1‐64 characters long                    

return: JSON response
# File lib/cnos-rbapi/system.rb, line 267
def self.set_hostname(conn, params)
        temp = @@cfg + '/cfg/hostname'
        url = form_url(conn, temp)
        hdr = form_hdr(conn)
        params = params.to_json
        Rest.put(conn, url, hdr, params)
end
upload_sw_config(conn, params) click to toggle source

This API uploads a configuration file from the switch to the server

parameters:
conn - connection object to the node
params - dictionary that requires the following format of key-value pairs
             {
               "protocol":"<protocol>",
               "serverip":"<serverip>",
               "srcfile":"<srcfile>",
               "dstfile":"<dstfile>",
               "username":"<username>",
               "passwd":"<passwd>",
               "vrf_name":"<vrf_name>"
             }
description -
protocol :Protocol name; one of ʺtftpʺ, ʺsftpʺ.
serverip :Server IP address.
srcfile  :Source file; up to 256 characters long.
dstfile  :Destination file; one of 'running_config', 'startup_config'.
username :(Optional) Username for the server.
passwd   :(Optional) Password for the server username.
vrf_name :(Optional) VRF name; an alphabetic string up to 64 characters long

return: JSON response
# File lib/cnos-rbapi/system.rb, line 185
def self.upload_sw_config(conn, params)
        temp = @@cfg + '/upload/config'
        url = form_url(conn, temp)
        hdr = form_hdr(conn)
        params = params.to_json
        Rest.post(conn, url, hdr, params)
end
upload_tech_support(conn, params) click to toggle source

This API uploads technical support information from the switch to the server

parameters:
conn - connection object to the node
params - dictionary that requires the following format of key-value pairs
             {
               "protocol":"<protocol>",
               "serverip":"<serverip>",
               "dstfile":"<dstfile>",
               "username":"<username>",
               "passwd":"<passwd>",
               "vrf_name":"<vrf_name>"
             }
description -
protocol :Protocol name; one of ʺtftpʺ, ʺsftpʺ.
serverip :Server IP address.
dstfile  :Destination file; one of 'running_config', 'startup_config'.
username :(Optional) Username for the server.
passwd   :(Optional) Password for the server username.
vrf_name :(Optional) VRF name; an alphabetic string up to 64 characters long

return: JSON response
# File lib/cnos-rbapi/system.rb, line 216
def self.upload_tech_support(conn, params)
        temp = @@cfg + '/upload/tech_support'
        url = form_url(conn, temp)
        hdr = form_hdr(conn)
        params = params.to_json
        Rest.post(conn, url, hdr, params)
end