lenovo-rbapi 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,214 @@
1
+ ##
2
+ ## Copyright (c) 2017, Lenovo. All rights reserved.
3
+ ##
4
+ ## This program and the accompanying materials are licensed and made available
5
+ ## under the terms and conditions of the 3-clause BSD License that accompanies
6
+ ## this distribution.
7
+ ##
8
+ ## The full text of the license may be found at
9
+ ##
10
+ ## https://opensource.org/licenses/BSD-3-Clause
11
+ ##
12
+ ## THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13
+ ## WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14
+ ##
15
+ require 'rest-client'
16
+ require 'json'
17
+ require_relative 'connect'
18
+ require_relative 'rest_utils'
19
+
20
+
21
+
22
+ ##
23
+ ## The Mstp class provides a class implementation and methods for managing Mstp
24
+ ## on the node. This class presents an abstraction
25
+ ##
26
+
27
+ class Mstp
28
+ @cfg = '/nos/api/cfg/mstp'
29
+ # This API gets global MSTP properties of the system
30
+ #
31
+ #
32
+ # parameters:
33
+ # conn - connection object to the node
34
+ #
35
+ # return: JSON response
36
+ def self.get_mstp_sys_prop(conn)
37
+ url = form_url(conn, @cfg)
38
+ hdr = form_hdr(conn)
39
+ Rest.get(conn, url, hdr)
40
+ end
41
+
42
+ # This API updates MSTP properties of the system
43
+ #
44
+ #
45
+ # parameters:
46
+ # conn - connection object to the node
47
+ # params - dictionary that requires the following format of key-value pairs
48
+ # {
49
+ #   "region_name": "<region_name>"
50
+ #   "revision": "<revision>"
51
+ # }
52
+ # description -
53
+ # region_name :Region name; a string up to 32 characters long.
54
+ # revision :Revision number; an integer from 0‐65535.
55
+ #
56
+ # return: JSON response
57
+ def self.update_mstp_sys_prop(conn, params)
58
+ url = form_url(conn, @cfg)
59
+ hdr = form_hdr(conn)
60
+ params = params.to_json
61
+ Rest.put(conn, url, hdr, params)
62
+
63
+ end
64
+
65
+ # This API gets properties of all MSTP instances
66
+ #
67
+ #
68
+ # parameters:
69
+ # conn - connection object to the node
70
+ #
71
+ # return: JSON response
72
+ def self.get_mstp_inst_all(conn)
73
+ url = form_url(conn, @cfg + '_instance')
74
+ hdr = form_hdr(conn)
75
+ Rest.get(conn, url, hdr)
76
+ end
77
+
78
+ # This API creates an MSTP instance
79
+ #
80
+ #
81
+ # parameters:
82
+ # conn - connection object to the node
83
+ # params - dictionary that requires the following format of key-value pairs
84
+ # {
85
+ #  "instance_id": "<instance_id>",
86
+ #   "instance_prio": "<instance_prio>",
87
+ #   "vlans": [
88
+ #     {
89
+ #       "vlan_id": "<vlan_id>"
90
+ #     }
91
+ #   ]
92
+ # }
93
+ # description -
94
+ # instance_id :MST instance ID; an integer from 0‐64. Instance 0 refers to the
95
+ # CIST.
96
+ # instance_prio :Sets the instance bridge priority; an integer from 0‐61440. Default
97
+ # value: 32768.
98
+ # vlans :Maps a range of VLANs to a multiple spanning tree instance
99
+ # (MSTI); an integer from 1‐4094.
100
+ #
101
+ # return: JSON response
102
+ def self.create_mstp_inst(conn, params)
103
+ url = form_url(conn, @cfg + '_instance')
104
+ hdr = form_hdr(conn)
105
+ params = params.to_json
106
+ Rest.post(conn, url, hdr, params)
107
+ end
108
+
109
+ # This API gets properties of an MSTP instance
110
+ #
111
+ #
112
+ # parameters:
113
+ # conn - connection object to the node
114
+ #
115
+ # return: JSON response
116
+ def self.get_mstp_inst(conn, inst_id)
117
+ url = form_url(conn, @cfg + '_instance/' + inst_id.to_s)
118
+ hdr = form_hdr(conn)
119
+ Rest.get(conn, url, hdr)
120
+ end
121
+
122
+ # This API updates the properties of an MSTP instance
123
+ #
124
+ #
125
+ # parameters:
126
+ # conn - connection object to the node
127
+ # params - dictionary that requires the following format of key-value pairs
128
+ # {
129
+ #  "instance_id": "<instance_id>",
130
+ #   "instance_prio": "<instance_prio>",
131
+ #   "vlans": [
132
+ #     {
133
+ #       "vlan_id": "<vlan_id>"
134
+ #     }
135
+ #   ]
136
+ # }
137
+ # description -
138
+ # instance_id :MST instance ID; an integer from 0‐64. Instance 0 refers to the
139
+ # CIST.
140
+ # instance_prio :Sets the instance bridge priority; an integer from 0‐61440. Default
141
+ # value: 32768.
142
+ # vlans :Maps a range of VLANs to a multiple spanning tree instance
143
+ # (MSTI); an integer from 1‐4094.
144
+ #
145
+ # return : JSON response
146
+ def self.update_mstp_inst(conn, inst_id, params)
147
+ url = form_url(conn, @cfg + '_instance/' + inst_id.to_s)
148
+ hdr = form_hdr(conn)
149
+ params = params.to_json
150
+ Rest.post(conn, url, hdr, params)
151
+
152
+ end
153
+
154
+ # This API deletes an MSTP instance
155
+ #
156
+ #
157
+ # parameters:
158
+ # conn - connection object to the node
159
+ #
160
+ # return: JSON response
161
+ def self.del_mstp_inst(conn, inst_id)
162
+ url = form_url(conn, @cfg + '_instance/' + inst_id.to_s)
163
+ hdr = form_hdr(conn)
164
+ Rest.delete(conn, url, hdr)
165
+ end
166
+
167
+ # This API gets interface properties of an MSTP instance
168
+ #
169
+ #
170
+ # parameters:
171
+ # conn - connection object to the node
172
+ # inst_id - instance id
173
+ # intf - interface in the MSTP instance
174
+ #
175
+ # return: JSON response
176
+ def self.get_mstp_inst_intf(conn, inst_id, intf)
177
+ intf.sub! '/', '%2F'
178
+ url = form_url(conn, @cfg + '_instance/' + inst_id.to_s + '/' + intf )
179
+ hdr = form_hdr(conn)
180
+ Rest.get(conn, url, hdr)
181
+ end
182
+
183
+ # This API updates interface properties of an MSTP instance
184
+ #
185
+ #
186
+ # parameters:
187
+ # conn - connection object to the node
188
+ # inst_id - instance id
189
+ # intf - interface in the MSTP instance
190
+ # params - dictionary that requires the following format of key-value pairs
191
+ # {
192
+ #   "if_name": "<if_name>",
193
+ #   "path_cost": "<path_cost>",
194
+ #   "port_prio": "<port_prio>"
195
+ # }
196
+ # description -
197
+ # if_name :Interface name.Note: The interface must exist.
198
+ # path_cost :The port path‐cost value on the specified MST instance; either an
199
+ # integer from 1‐200000000 or auto (default) to base the path‐cost
200
+ # on port speed.
201
+ # port_prio :The port priority, in increments of 32, on the specified MST
202
+ # instance; a multiple of 32 from 0‐224. Default value: 128.
203
+ # return: JSON response
204
+ def self.update_mstp_inst_intf(conn, inst_id, intf, params)
205
+ intf.sub! '/', '%2F'
206
+ url = form_url(conn, @cfg + '_instance/' + inst_id.to_s + '/' + intf )
207
+ hdr = form_hdr(conn)
208
+ params = params.to_json
209
+ Rest.put(conn, url, hdr, params)
210
+
211
+ end
212
+
213
+ end
214
+
@@ -0,0 +1,111 @@
1
+ ##
2
+ ## Copyright (c) 2017, Lenovo. All rights reserved.
3
+ ##
4
+ ## This program and the accompanying materials are licensed and made available
5
+ ## under the terms and conditions of the 3-clause BSD License that accompanies
6
+ ## this distribution.
7
+ ##
8
+ ## The full text of the license may be found at
9
+ ##
10
+ ## https://opensource.org/licenses/BSD-3-Clause
11
+ ##
12
+ ## THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13
+ ## WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14
+ ##
15
+ require 'rest-client'
16
+ require 'json'
17
+
18
+ ##
19
+ ## The Rest class provides a class implementation and methods for executing REST methods such as GET, POST, PUT and DELETE
20
+ ## on the node. This class presents an abstraction
21
+ ##
22
+
23
+ class Rest
24
+ # This API performs GET request for the given url and switch connection.
25
+ #
26
+ #
27
+ # parameters:
28
+ # conn - connection object to the node
29
+ # url - URL for the GET request
30
+ # hdr - header paramters for the GET request
31
+ #
32
+ # return: JSON response
33
+ def self.get(conn, url, hdr)
34
+ begin
35
+ resp = RestClient::Request.execute method: :get, url: url, headers: hdr, user: conn.getUser, password: conn.getPassword, timeout: 20 ,:verify_ssl => false
36
+ response = JSON.parse(resp)
37
+ response
38
+ rescue RestClient::ExceptionWithResponse => err
39
+ puts err
40
+ puts err.response.match(/<p>(.+)<\/p>/)[1]
41
+
42
+ end
43
+
44
+ end
45
+
46
+ # This API performs PUT request for the given url and switch connection.
47
+ #
48
+ #
49
+ # parameters:
50
+ # conn - connection object to the node
51
+ # url - URL for the PUT request
52
+ # hdr - header paramters for the PUT request
53
+ # params - JSON body for POST request
54
+ #
55
+ # return: JSON response
56
+ def self.put(conn, url, hdr, params)
57
+ begin
58
+ resp = RestClient::Request.execute method: :put, url: url, headers: hdr, payload: params, user: conn.getUser, password: conn.getPassword, timeout: 20 ,:verify_ssl => false
59
+ response = JSON.parse(resp)
60
+ response
61
+ rescue RestClient::ExceptionWithResponse => err
62
+ puts err
63
+ puts err.response.match(/<p>(.+)<\/p>/)[1]
64
+ end
65
+
66
+ end
67
+
68
+ # This API performs POST request for the given url and switch connection.
69
+ #
70
+ #
71
+ # parameters:
72
+ # conn - connection object to the node
73
+ # url - URL for the POST request
74
+ # hdr - header paramters for the POST request
75
+ # params - JSON body for POST request
76
+ #
77
+ # return: JSON response
78
+ def self.post(conn, url, hdr, params)
79
+ begin
80
+ resp = RestClient::Request.execute method: :post, url: url, headers: hdr, payload: params, user: conn.getUser, password: conn.getPassword, timeout: 20 ,:verify_ssl => false
81
+ response = JSON.parse(resp)
82
+ response
83
+ rescue RestClient::ExceptionWithResponse => err
84
+ puts err
85
+ puts err.response.match(/<p>(.+)<\/p>/)[1]
86
+
87
+
88
+ end
89
+ end
90
+
91
+ # This API performs DELETE request for the given url and switch connection.
92
+ #
93
+ #
94
+ # parameters:
95
+ # conn - connection object to the node
96
+ # url - URL for the DELETE request
97
+ # hdr - header paramters for the DELETE request
98
+ #
99
+ # return: JSON response
100
+ def self.delete(conn, url, hdr)
101
+ begin
102
+ resp = RestClient::Request.execute method: :delete, url: url, headers: hdr, user: conn.getUser, password: conn.getPassword, timeout: 20 ,:verify_ssl => false
103
+ rescue RestClient::ExceptionWithResponse => err
104
+ puts err
105
+ puts err.response.match(/<p>(.+)<\/p>/)[1]
106
+
107
+ end
108
+
109
+ end
110
+
111
+ end
@@ -0,0 +1,93 @@
1
+ ##
2
+ ## Copyright (c) 2017, Lenovo. All rights reserved.
3
+ ##
4
+ ## This program and the accompanying materials are licensed and made available
5
+ ## under the terms and conditions of the 3-clause BSD License that accompanies
6
+ ## this distribution.
7
+ ##
8
+ ## The full text of the license may be found at
9
+ ##
10
+ ## https://opensource.org/licenses/BSD-3-Clause
11
+ ##
12
+ ## THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13
+ ## WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14
+ ##
15
+ require 'rest-client'
16
+ require 'json'
17
+ require_relative 'connect'
18
+ require_relative 'rest_utils'
19
+
20
+
21
+ ##
22
+ ## The Stp class provides a class implementation and methods for managing the STP
23
+ ## on the node. This class presents an abstraction
24
+ ##
25
+
26
+ class Stp
27
+ @cfg = '/nos/api/cfg/stp/interface'
28
+ # This API gets STP properties of all interfaces.
29
+ #
30
+ #
31
+ # parameters:
32
+ # conn - connection object to the node
33
+ #
34
+ # return: JSON response
35
+ def self.get_all_stp(conn)
36
+ url = form_url(conn, @cfg)
37
+ hdr = form_hdr(conn)
38
+ Rest.get(conn, url, hdr)
39
+ end
40
+
41
+ # This API gets STP properties of one interface.
42
+ #
43
+ #
44
+ # parameters:
45
+ # conn - connection object to the node
46
+ # intf - Interface name
47
+ #
48
+ # return: JSON response
49
+ def self.get_stp_intf(conn, intf)
50
+ intf.sub! '/', '%2F'
51
+ url = form_url(conn, @cfg + '/' + intf)
52
+ hdr = form_hdr(conn)
53
+ Rest.get(conn, url, hdr)
54
+ end
55
+
56
+
57
+ # This API updates STP properties of one interface.
58
+ #
59
+ #
60
+ # parameters:
61
+ # conn - connection object to the node
62
+ # intf - Interface name
63
+ # params - dictionary that requires the following format of key-value pairs
64
+ # {
65
+ #  "if_name":  "<if_name>",
66
+ #   "edge_port":  "<edge_port>",
67
+ #   "bpdu_guard":  "<bpdu_guard>",
68
+ #   "loop_guard":  "<loop_guard>",
69
+ #   "root_guard":  "<root_guard>"
70
+ # }
71
+ # description -
72
+ # if_name :The IP interface name; a string.
73
+ # Note: The interface must exist.
74
+ # edge_port :Whether the interface is configured as an edge port, which allows
75
+ # the port to automatically transition to the STP forwarding state;
76
+ # one of yes, no. Default value: yes.
77
+ # bpdu_guard :(Optional) Whether BPDU guard is enabled on a port, which
78
+ # automatically shuts down the interface upon receipt of a BPDU;
79
+ # one of enable, disable. Default value: disable.
80
+ # loop_guard :(Optional) Whether look guard is enabled on a port for additional
81
+ # checks for preventing STP looping; one of enable, disable.
82
+ # Default value: disable.
83
+ # root_guard :(Optional) Whether guard mode is set to root guard on interface
84
+ #
85
+ # return: JSON response
86
+ def self.update_stp(conn, intf, params)
87
+ intf.sub! '/', '%2F'
88
+ url = form_url(conn, @cfg + '/' + intf)
89
+ hdr = form_hdr(conn)
90
+ params = params.to_json
91
+ Rest.put(conn, url, hdr, params)
92
+ end
93
+ end
@@ -0,0 +1,523 @@
1
+ ##
2
+ ## Copyright (c) 2017, Lenovo. All rights reserved.
3
+ ##
4
+ ## This program and the accompanying materials are licensed and made available
5
+ ## under the terms and conditions of the 3-clause BSD License that accompanies
6
+ ## this distribution.
7
+ ##
8
+ ## The full text of the license may be found at
9
+ ##
10
+ ## https://opensource.org/licenses/BSD-3-Clause
11
+ ##
12
+ ## THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13
+ ## WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14
+ ##
15
+ require 'rest-client'
16
+ require 'json'
17
+ require_relative 'connect'
18
+ require_relative 'rest_utils'
19
+
20
+
21
+
22
+ ##
23
+ ## The System class provides a class implementation and methods for managing and setting up
24
+ ## images and config files on the node. This class presents an abstraction
25
+ ##
26
+
27
+
28
+ class System
29
+
30
+ @cfg = '/nos/api'
31
+ # This API downloads a boot image to the switch
32
+ #
33
+ #
34
+ # parameters:
35
+ # conn - connection object to the node
36
+ # params - dictionary that requires the following format of key-value pairs
37
+ # {
38
+ #   "protocol":"<protocol>",
39
+ #   "serverip":"<serverip>",
40
+ #   "srcfile":"<srcfile>",
41
+ #   "imgtype":"<imgtype>",
42
+ #   "username":"<username>",
43
+ #   "passwd":"<passwd>",
44
+ #   "vrf_name":"<vrf_name>"
45
+ # }
46
+ # description -
47
+ # protocol :Protocol name; one of ʺtftpʺ, ʺsftpʺ.
48
+ # serverip :Server IP address.
49
+ # srcfile :Source file; up to 256 characters long.
50
+ # imgtype :System image type; one of ʺallʺ, ʺbootʺ, ʺonieʺ, ʺosʺ.
51
+ # username :Username for the server. Not required for TFTP.
52
+ # passwd :Password for the server username. Not required for TFTP.
53
+ # vrf_name :(Optional) VRF name; an alphabetic string up to 64 characters long
54
+ #
55
+ # return: JSON response
56
+ def self.download_boot_img(conn, params)
57
+ temp = @cfg + '/download/image'
58
+ url = form_url(conn, temp)
59
+ hdr = form_hdr(conn)
60
+ params = params.to_json
61
+ Rest.post(conn, url, hdr, params)
62
+ end
63
+
64
+ # This API updates the system startup image
65
+ #
66
+ #
67
+ # parameters:
68
+ # conn - connection object to the node
69
+ # params - dictionary that requires the following format of key-value pairs
70
+ # {
71
+ #    “boot software” : “<setting>”
72
+ # }
73
+ # description -
74
+ # setting :Next startup image setting; one of “active” or “standby”
75
+ #
76
+ # return: JSON response
77
+ def self.put_startup_sw(conn, params)
78
+ temp = @cfg + '/startup/software'
79
+ url = form_url(conn, temp)
80
+ hdr = form_hdr(conn)
81
+ params = params.to_json
82
+ Rest.put(conn, url, hdr, params)
83
+ end
84
+
85
+ # This API gets the system startup image.
86
+ #
87
+ #
88
+ # parameters:
89
+ # conn - connection object to the node
90
+ #
91
+ # return: JSON response
92
+ def self.get_startup_sw(conn)
93
+ temp = @cfg + '/startup/software'
94
+ url = form_url(conn, temp)
95
+ hdr = form_hdr(conn)
96
+ Rest.get(conn, url, hdr)
97
+ end
98
+
99
+ # This API resets the switch
100
+ #
101
+ #
102
+ # parameters:
103
+ # conn - connection object to the node
104
+ #
105
+ # return: JSON response
106
+ def self.reset_switch(conn)
107
+ temp = @cfg + '/reset'
108
+ url = form_url(conn, temp)
109
+ hdr = form_hdr(conn)
110
+ Rest.get(conn, url, hdr)
111
+ end
112
+
113
+
114
+ # This API downloads a configuration to the switch
115
+ #
116
+ #
117
+ # parameters:
118
+ # conn - connection object to the node
119
+ # params - dictionary that requires the following format of key-value pairs
120
+ # {
121
+ #   "protocol":"<protocol>",
122
+ #   "serverip":"<serverip>",
123
+ #   "srcfile":"<srcfile>",
124
+ #   "dstfile":"<dstfile>",
125
+ #   "username":"<username>",
126
+ #   "passwd":"<passwd>",
127
+ #   "vrf_name":"<vrf_name>"
128
+ # }
129
+ # description -
130
+ # protocol :Protocol name; one of ʺtftpʺ, ʺsftpʺ.
131
+ # serverip :Server IP address.
132
+ # srcfile :Source file; up to 256 characters long.
133
+ # dstfile :Destination file; one of 'running_config', 'startup_config'.
134
+ # username :(Optional) Username for the server.
135
+ # passwd :(Optional) Password for the server username.
136
+ # vrf_name :(Optional) VRF name; an alphabetic string up to 64 characters long
137
+ #
138
+ # return: JSON response
139
+ def self.download_sw_config(conn, params)
140
+ temp = @cfg + '/download/config'
141
+ url = form_url(conn, temp)
142
+ hdr = form_hdr(conn)
143
+ params = params.to_json
144
+ Rest.post(conn, url, hdr, params)
145
+ end
146
+
147
+ # This API saves the running configuration to the flash memory
148
+ #
149
+ #
150
+ # parameters:
151
+ # conn - connection object to the node
152
+ #
153
+ # return: JSON response
154
+ def self.save_config(conn)
155
+ temp = @cfg + '/save/config'
156
+ url = form_url(conn, temp)
157
+ hdr = form_hdr(conn)
158
+ Rest.get(conn, url, hdr)
159
+ end
160
+
161
+ # This API uploads a configuration file from the switch to the server
162
+ #
163
+ #
164
+ # parameters:
165
+ # conn - connection object to the node
166
+ # params - dictionary that requires the following format of key-value pairs
167
+ # {
168
+ #   "protocol":"<protocol>",
169
+ #   "serverip":"<serverip>",
170
+ #   "srcfile":"<srcfile>",
171
+ #   "dstfile":"<dstfile>",
172
+ #   "username":"<username>",
173
+ #   "passwd":"<passwd>",
174
+ #   "vrf_name":"<vrf_name>"
175
+ # }
176
+ # description -
177
+ # protocol :Protocol name; one of ʺtftpʺ, ʺsftpʺ.
178
+ # serverip :Server IP address.
179
+ # srcfile :Source file; up to 256 characters long.
180
+ # dstfile :Destination file; one of 'running_config', 'startup_config'.
181
+ # username :(Optional) Username for the server.
182
+ # passwd :(Optional) Password for the server username.
183
+ # vrf_name :(Optional) VRF name; an alphabetic string up to 64 characters long
184
+ #
185
+ # return: JSON response
186
+ def self.upload_sw_config(conn, params)
187
+ temp = @cfg + '/upload/config'
188
+ url = form_url(conn, temp)
189
+ hdr = form_hdr(conn)
190
+ params = params.to_json
191
+ Rest.post(conn, url, hdr, params)
192
+ end
193
+
194
+ # This API uploads technical support information from the switch to the server
195
+ #
196
+ #
197
+ # parameters:
198
+ # conn - connection object to the node
199
+ # params - dictionary that requires the following format of key-value pairs
200
+ # {
201
+ #   "protocol":"<protocol>",
202
+ #   "serverip":"<serverip>",
203
+ #   "dstfile":"<dstfile>",
204
+ #   "username":"<username>",
205
+ #   "passwd":"<passwd>",
206
+ #   "vrf_name":"<vrf_name>"
207
+ # }
208
+ # description -
209
+ # protocol :Protocol name; one of ʺtftpʺ, ʺsftpʺ.
210
+ # serverip :Server IP address.
211
+ # dstfile :Destination file; one of 'running_config', 'startup_config'.
212
+ # username :(Optional) Username for the server.
213
+ # passwd :(Optional) Password for the server username.
214
+ # vrf_name :(Optional) VRF name; an alphabetic string up to 64 characters long
215
+ #
216
+ # return: JSON response
217
+ def self.upload_tech_support(conn, params)
218
+ temp = @cfg + '/upload/tech_support'
219
+ url = form_url(conn, temp)
220
+ hdr = form_hdr(conn)
221
+ params = params.to_json
222
+ Rest.post(conn, url, hdr, params)
223
+ end
224
+
225
+ # This API gets the status of a downloading transfer.
226
+ #
227
+ #
228
+ # parameters:
229
+ # conn - connection object to the node
230
+ # content - One of 'image', 'running_config', 'startup_config'
231
+ # type - 'upload' or 'download'
232
+ #
233
+ # return: JSON response
234
+ def self.get_transfer_status(conn, type, content)
235
+ temp = @cfg + '/' + type + '/status/' + content
236
+ url = form_url(conn, temp)
237
+ hdr = form_hdr(conn)
238
+ Rest.get(conn, url, hdr)
239
+ end
240
+
241
+ # This API gets the hostname of the system
242
+ #
243
+ #
244
+ # parameters:
245
+ # conn - connection object to the node
246
+ #
247
+ # return: JSON response
248
+ def self.get_hostname(conn)
249
+ temp = @cfg + '/cfg/hostname'
250
+ url = form_url(conn, temp)
251
+ hdr = form_hdr(conn)
252
+ Rest.get(conn, url, hdr)
253
+ end
254
+
255
+ # This API sets the system boot image.
256
+ #
257
+ #
258
+ # parameters:
259
+ # conn - connection object to the node
260
+ # params - dictionary that requires the following format of key-value pairs
261
+ # {
262
+ # "hostname":"<hostname>"
263
+ # }
264
+ # description -
265
+ # hostname :The hostname of the system; a string from 1‐64 characters long
266
+ #
267
+ # return: JSON response
268
+ def self.set_hostname(conn, params)
269
+ temp = @cfg + '/cfg/hostname'
270
+ url = form_url(conn, temp)
271
+ hdr = form_hdr(conn)
272
+ params = params.to_json
273
+ Rest.put(conn, url, hdr, params)
274
+ end
275
+
276
+ # This API gets the date of the system
277
+ #
278
+ #
279
+ # parameters:
280
+ # conn - connection object to the node
281
+ #
282
+ # return: JSON response
283
+ def self.get_clock(conn)
284
+ temp = @cfg + '/cfg/clock'
285
+ url = form_url(conn, temp)
286
+ hdr = form_hdr(conn)
287
+ Rest.get(conn, url, hdr)
288
+ end
289
+
290
+ # This API sets the system date.
291
+ #
292
+ #
293
+ # parameters:
294
+ # conn - connection object to the node
295
+ # params - dictionary that requires the following format of key-value pairs
296
+ # {
297
+ #   "time": "<HH:MM:SS>" ,
298
+ #    "day": <day>,
299
+ #    "month": <month> ,
300
+ #    "year": <year>
301
+ # }
302
+ # description -
303
+ # time :System time in the format ʺHH:MM:SSʺ.
304
+ # day :The day of the month; an integer from 1‐31.
305
+ # month :The month; one of the following case‐insensitive strings:
306
+ # January
307
+ # February
308
+ # March
309
+ # April
310
+ # May
311
+ # June
312
+ # July
313
+ # August
314
+ # September
315
+ # October
316
+ # November
317
+ # December
318
+ # year :The year; an integer from 2000‐2030.
319
+ #
320
+ # return: JSON response
321
+ def self.set_clock(conn, params)
322
+ temp = @cfg + '/cfg/clock'
323
+ url = form_url(conn, temp)
324
+ hdr = form_hdr(conn)
325
+ params = params.to_json
326
+ Rest.put(conn, url, hdr, params)
327
+ end
328
+
329
+ # This API sets the clock format to 12 hour or 24 hour format.
330
+ #
331
+ #
332
+ # parameters:
333
+ # conn - connection object to the node
334
+ # params - dictionary that requires the following format of key-value pairs
335
+ # {
336
+ #  "format": <format>
337
+ # }
338
+ # description -
339
+ # format :System clock format; one of:
340
+ # 12 (12 hour format)
341
+ # 24 (24 hour format)
342
+ #
343
+ # return: JSON response
344
+ def self.set_clock_format(conn, params)
345
+ temp = @cfg + '/cfg/clock/format/'
346
+ url = form_url(conn, temp)
347
+ hdr = form_hdr(conn)
348
+ params = params.to_json
349
+ Rest.put(conn, url, hdr, params)
350
+ end
351
+
352
+ # This API sets the protocol to either manual or Network Time Protocol.
353
+ #
354
+ #
355
+ # parameters:
356
+ # conn - connection object to the node
357
+ # params - dictionary that requires the following format of key-value pairs
358
+ # {
359
+ #  "protocol": "<protocol>"
360
+ # }
361
+ # description -
362
+ # protocol :System clock protocol; one of:
363
+ # none ‐ the clock is manually configured
364
+ # ntp ‐ the clock is configured through NTP
365
+ # Default value: “ntp”.
366
+ #
367
+ # return: JSON response
368
+ def self.set_clock_protocol(conn, params)
369
+ temp = @cfg + '/cfg/clock/protocol/'
370
+ url = form_url(conn, temp)
371
+ hdr = form_hdr(conn)
372
+ params = params.to_json
373
+ Rest.put(conn, url, hdr, params)
374
+ end
375
+
376
+ # This API sets the clock time zone for the switch
377
+ #
378
+ #
379
+ # parameters:
380
+ # conn - connection object to the node
381
+ # params - dictionary that requires the following format of key-value pairs
382
+ # {
383
+ #  ""timezone": "<timezone>",
384
+ #   "offsethour": "<offsethour>",
385
+ #   "offsetmin": "<lag_mode>",
386
+ # }
387
+ # description -
388
+ # timezone :One to five letter string denoting the local system time zone.
389
+ # offsethour :Hours offset from UTC; an integer from ‐23 through 23.
390
+ # offsetmin :Minutes offset from UTC; an integer from 0‐59.
391
+ #
392
+ # return: JSON response
393
+ def self.set_clock_timezone(conn, params)
394
+ temp = @cfg + '/cfg/clock/timezone/'
395
+ url = form_url(conn, temp)
396
+ hdr = form_hdr(conn)
397
+ params = params.to_json
398
+ Rest.put(conn, url, hdr, params)
399
+ end
400
+
401
+ # This API gets the device contact.
402
+ #
403
+ #
404
+ # parameters:
405
+ # conn - connection object to the node
406
+ #
407
+ # return: JSON response
408
+ def self.get_device_contact(conn)
409
+ temp = @cfg + '/cfg/contact'
410
+ url = form_url(conn, temp)
411
+ hdr = form_hdr(conn)
412
+ Rest.get(conn, url, hdr)
413
+ end
414
+
415
+ # This API updates the device contact.
416
+ #
417
+ #
418
+ # parameters:
419
+ # conn - connection object to the node
420
+ # params - dictionary that requires the following format of key-value pairs
421
+ # {
422
+ #   "contact": <contact>
423
+ # }
424
+ # description -
425
+ # contact :Device contact; a string up to 256 characters long
426
+ #
427
+ # return: JSON response
428
+ def self.set_device_contact(conn, params)
429
+ temp = @cfg + '/cfg/contact'
430
+ url = form_url(conn, temp)
431
+ hdr = form_hdr(conn)
432
+ params = params.to_json
433
+ Rest.put(conn, url, hdr, params)
434
+ end
435
+
436
+ # This API gets the device descr.
437
+ #
438
+ #
439
+ # parameters:
440
+ # conn - connection object to the node
441
+ #
442
+ # return: JSON response
443
+ def self.get_device_descr(conn)
444
+ temp = @cfg + '/cfg/descr'
445
+ url = form_url(conn, temp)
446
+ hdr = form_hdr(conn)
447
+ Rest.get(conn, url, hdr)
448
+ end
449
+
450
+ # This API updates the device description.
451
+ #
452
+ #
453
+ # parameters:
454
+ # conn - connection object to the node
455
+ # params - dictionary that requires the following format of key-value pairs
456
+ # {
457
+ #   "descr": <descr>
458
+ # }
459
+ # description -
460
+ # descr :Device description; a string up to 256 characters long.
461
+ #
462
+ # return: JSON response
463
+ def self.set_device_descr(conn, params)
464
+ temp = @cfg + '/cfg/descr'
465
+ url = form_url(conn, temp)
466
+ hdr = form_hdr(conn)
467
+ params = params.to_json
468
+ Rest.put(conn, url, hdr, params)
469
+ end
470
+
471
+ # This API set the transition to and from a summer time zone adjustment.
472
+ #
473
+ #
474
+ # parameters:
475
+ # conn - connection object to the node
476
+ # params - dictionary that requires the following format of key-value pairs
477
+ # {
478
+ #   "timezone": <time_zone>,
479
+ #   "startweek": <start_week>,
480
+ #   "startweekday": <start_weekday>,
481
+ #   "startmonth": <start_month>,
482
+ #   "starttime" :  "<HH:MM>",
483
+ #   "endweek"   : <end_week>,
484
+ #   "endweekday": <end_weekday>,
485
+ #   "endmonth"  : <end_month>,
486
+ #   "endtime"   :  “<HH:MM>”,
487
+ #   "offsetmin" : <minutes>
488
+ # }
489
+ # description -
490
+ # timezone :Local time zone of the system; a three to five character
491
+ # string such as ʺPSTʺ, ʺMSTʺ, ʺCSTʺ, or ʺESTʺ.
492
+ # startweek :Week number in the month in which to start Daylight
493
+ # Saving time; an integer from 1‐5 (first week=1, last
494
+ # week=5).
495
+ # startweekday :Weekday on which to start DST; one of the following
496
+ # case‐insensitive strings:
497
+ # monday - sunday
498
+ # startmonth :Month to start DST; one of the following
499
+ # case‐insensitive strings:
500
+ # january - december
501
+ # starttime :Time to start DST; a string in the format ʺHH:MMʺ.
502
+ # endweek Week number in which to end DST; an integer from
503
+ # 1‐5 (first week=1, last week=5).
504
+ # endweekday :Weekday on which to end DST; one of the following
505
+ # case‐insensitive strings:
506
+ # monday - sunday
507
+ # endmonth :Month in which DST ends; one of the following
508
+ # case‐insensitive strings:
509
+ # january - december
510
+ # endtime :Time to end DST; a string in the format ʺHH:MMʺ
511
+ # offsetmin :Offset to add, in minutes; an integer from 1‐1440.
512
+ #
513
+ # return: JSON response
514
+ def self.set_clock_summertime(conn, params)
515
+ temp = @cfg + '/cfg/clock/summertime'
516
+ url = form_url(conn, temp)
517
+ hdr = form_hdr(conn)
518
+ params = params.to_json
519
+ Rest.put(conn, url, hdr, params)
520
+ end
521
+
522
+
523
+ end