Class: System

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

Constant Summary collapse

@@cfg =
'/nos/api'

Class Method Summary collapse

Class Method Details

.download_boot_img(conn, params) ⇒ Object

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


55
56
57
58
59
60
61
# 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) ⇒ Object

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


138
139
140
141
142
143
144
# 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) ⇒ Object

parameters:

conn - connection object to the node

return: JSON response


282
283
284
285
286
287
# 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) ⇒ Object

parameters:

conn - connection object to the node

return: JSON response


407
408
409
410
411
412
# 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) ⇒ Object

parameters:

conn - connection object to the node

return: JSON response


442
443
444
445
446
447
# 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) ⇒ Object

parameters:

conn - connection object to the node

return: JSON response


247
248
249
250
251
252
# 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) ⇒ Object

parameters:

conn - connection object to the node

return: JSON response


91
92
93
94
95
96
# 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) ⇒ Object

parameters:

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

return: JSON response


233
234
235
236
237
238
# 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) ⇒ Object

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


76
77
78
79
80
81
82
# 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) ⇒ Object

parameters:

conn - connection object to the node

return: JSON response


105
106
107
108
109
110
# 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) ⇒ Object

parameters:

conn - connection object to the node

return: JSON response


153
154
155
156
157
158
# 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) ⇒ Object

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


320
321
322
323
324
325
326
# 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) ⇒ Object

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


343
344
345
346
347
348
349
# 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) ⇒ Object

return: JSON response



367
368
369
370
371
372
373
# 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) ⇒ Object

return: JSON response



513
514
515
516
517
518
519
# 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) ⇒ Object

return: JSON response



392
393
394
395
396
397
398
# 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) ⇒ Object

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


427
428
429
430
431
432
433
# 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) ⇒ Object

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


462
463
464
465
466
467
468
# 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) ⇒ Object

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


267
268
269
270
271
272
273
# 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) ⇒ Object

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


185
186
187
188
189
190
191
# 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) ⇒ Object

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


216
217
218
219
220
221
222
# 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