lenovo-rbapi 0.0.2 → 0.0.3

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.
@@ -1,16 +1,15 @@
1
1
  ##
2
- ## Copyright (c) 2017, Lenovo. All rights reserved.
2
+ ## Copyright (C) 2017 Lenovo, Inc.
3
+ ## Licensed under the Apache License, Version 2.0 (the "License");
4
+ ## you may not use this file except in compliance with the License.
5
+ ## You may obtain a copy of the License at
6
+ ## http://www.apache.org/licenses/LICENSE-2.0
3
7
  ##
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.
8
+ ## Unless required by applicable law or agreed to in writing, software
9
+ ## distributed under the License is distributed on an "AS IS" BASIS,
10
+ ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ ## See the License for the specific language governing permissions and
12
+ ## limitations under the License.
14
13
  ##
15
14
  require 'rest-client'
16
15
  require 'json'
@@ -27,7 +26,7 @@ require_relative 'rest_utils'
27
26
 
28
27
  class System
29
28
 
30
- @cfg = '/nos/api'
29
+ @@cfg = '/nos/api'
31
30
  # This API downloads a boot image to the switch
32
31
  #
33
32
  #
@@ -54,7 +53,7 @@ class System
54
53
  #
55
54
  # return: JSON response
56
55
  def self.download_boot_img(conn, params)
57
- temp = @cfg + '/download/image'
56
+ temp = @@cfg + '/download/image'
58
57
  url = form_url(conn, temp)
59
58
  hdr = form_hdr(conn)
60
59
  params = params.to_json
@@ -75,7 +74,7 @@ class System
75
74
  #
76
75
  # return: JSON response
77
76
  def self.put_startup_sw(conn, params)
78
- temp = @cfg + '/startup/software'
77
+ temp = @@cfg + '/startup/software'
79
78
  url = form_url(conn, temp)
80
79
  hdr = form_hdr(conn)
81
80
  params = params.to_json
@@ -90,7 +89,7 @@ class System
90
89
  #
91
90
  # return: JSON response
92
91
  def self.get_startup_sw(conn)
93
- temp = @cfg + '/startup/software'
92
+ temp = @@cfg + '/startup/software'
94
93
  url = form_url(conn, temp)
95
94
  hdr = form_hdr(conn)
96
95
  Rest.get(conn, url, hdr)
@@ -104,7 +103,7 @@ class System
104
103
  #
105
104
  # return: JSON response
106
105
  def self.reset_switch(conn)
107
- temp = @cfg + '/reset'
106
+ temp = @@cfg + '/reset'
108
107
  url = form_url(conn, temp)
109
108
  hdr = form_hdr(conn)
110
109
  Rest.get(conn, url, hdr)
@@ -137,7 +136,7 @@ class System
137
136
  #
138
137
  # return: JSON response
139
138
  def self.download_sw_config(conn, params)
140
- temp = @cfg + '/download/config'
139
+ temp = @@cfg + '/download/config'
141
140
  url = form_url(conn, temp)
142
141
  hdr = form_hdr(conn)
143
142
  params = params.to_json
@@ -152,7 +151,7 @@ class System
152
151
  #
153
152
  # return: JSON response
154
153
  def self.save_config(conn)
155
- temp = @cfg + '/save/config'
154
+ temp = @@cfg + '/save/config'
156
155
  url = form_url(conn, temp)
157
156
  hdr = form_hdr(conn)
158
157
  Rest.get(conn, url, hdr)
@@ -184,7 +183,7 @@ class System
184
183
  #
185
184
  # return: JSON response
186
185
  def self.upload_sw_config(conn, params)
187
- temp = @cfg + '/upload/config'
186
+ temp = @@cfg + '/upload/config'
188
187
  url = form_url(conn, temp)
189
188
  hdr = form_hdr(conn)
190
189
  params = params.to_json
@@ -215,7 +214,7 @@ class System
215
214
  #
216
215
  # return: JSON response
217
216
  def self.upload_tech_support(conn, params)
218
- temp = @cfg + '/upload/tech_support'
217
+ temp = @@cfg + '/upload/tech_support'
219
218
  url = form_url(conn, temp)
220
219
  hdr = form_hdr(conn)
221
220
  params = params.to_json
@@ -232,7 +231,7 @@ class System
232
231
  #
233
232
  # return: JSON response
234
233
  def self.get_transfer_status(conn, type, content)
235
- temp = @cfg + '/' + type + '/status/' + content
234
+ temp = @@cfg + '/' + type + '/status/' + content
236
235
  url = form_url(conn, temp)
237
236
  hdr = form_hdr(conn)
238
237
  Rest.get(conn, url, hdr)
@@ -246,7 +245,7 @@ class System
246
245
  #
247
246
  # return: JSON response
248
247
  def self.get_hostname(conn)
249
- temp = @cfg + '/cfg/hostname'
248
+ temp = @@cfg + '/cfg/hostname'
250
249
  url = form_url(conn, temp)
251
250
  hdr = form_hdr(conn)
252
251
  Rest.get(conn, url, hdr)
@@ -266,7 +265,7 @@ class System
266
265
  #
267
266
  # return: JSON response
268
267
  def self.set_hostname(conn, params)
269
- temp = @cfg + '/cfg/hostname'
268
+ temp = @@cfg + '/cfg/hostname'
270
269
  url = form_url(conn, temp)
271
270
  hdr = form_hdr(conn)
272
271
  params = params.to_json
@@ -281,7 +280,7 @@ class System
281
280
  #
282
281
  # return: JSON response
283
282
  def self.get_clock(conn)
284
- temp = @cfg + '/cfg/clock'
283
+ temp = @@cfg + '/cfg/clock'
285
284
  url = form_url(conn, temp)
286
285
  hdr = form_hdr(conn)
287
286
  Rest.get(conn, url, hdr)
@@ -319,7 +318,7 @@ class System
319
318
  #
320
319
  # return: JSON response
321
320
  def self.set_clock(conn, params)
322
- temp = @cfg + '/cfg/clock'
321
+ temp = @@cfg + '/cfg/clock'
323
322
  url = form_url(conn, temp)
324
323
  hdr = form_hdr(conn)
325
324
  params = params.to_json
@@ -342,7 +341,7 @@ class System
342
341
  #
343
342
  # return: JSON response
344
343
  def self.set_clock_format(conn, params)
345
- temp = @cfg + '/cfg/clock/format/'
344
+ temp = @@cfg + '/cfg/clock/format/'
346
345
  url = form_url(conn, temp)
347
346
  hdr = form_hdr(conn)
348
347
  params = params.to_json
@@ -366,7 +365,7 @@ class System
366
365
  #
367
366
  # return: JSON response
368
367
  def self.set_clock_protocol(conn, params)
369
- temp = @cfg + '/cfg/clock/protocol/'
368
+ temp = @@cfg + '/cfg/clock/protocol/'
370
369
  url = form_url(conn, temp)
371
370
  hdr = form_hdr(conn)
372
371
  params = params.to_json
@@ -391,7 +390,7 @@ class System
391
390
  #
392
391
  # return: JSON response
393
392
  def self.set_clock_timezone(conn, params)
394
- temp = @cfg + '/cfg/clock/timezone/'
393
+ temp = @@cfg + '/cfg/clock/timezone/'
395
394
  url = form_url(conn, temp)
396
395
  hdr = form_hdr(conn)
397
396
  params = params.to_json
@@ -406,7 +405,7 @@ class System
406
405
  #
407
406
  # return: JSON response
408
407
  def self.get_device_contact(conn)
409
- temp = @cfg + '/cfg/contact'
408
+ temp = @@cfg + '/cfg/contact'
410
409
  url = form_url(conn, temp)
411
410
  hdr = form_hdr(conn)
412
411
  Rest.get(conn, url, hdr)
@@ -426,7 +425,7 @@ class System
426
425
  #
427
426
  # return: JSON response
428
427
  def self.set_device_contact(conn, params)
429
- temp = @cfg + '/cfg/contact'
428
+ temp = @@cfg + '/cfg/contact'
430
429
  url = form_url(conn, temp)
431
430
  hdr = form_hdr(conn)
432
431
  params = params.to_json
@@ -441,7 +440,7 @@ class System
441
440
  #
442
441
  # return: JSON response
443
442
  def self.get_device_descr(conn)
444
- temp = @cfg + '/cfg/descr'
443
+ temp = @@cfg + '/cfg/descr'
445
444
  url = form_url(conn, temp)
446
445
  hdr = form_hdr(conn)
447
446
  Rest.get(conn, url, hdr)
@@ -461,7 +460,7 @@ class System
461
460
  #
462
461
  # return: JSON response
463
462
  def self.set_device_descr(conn, params)
464
- temp = @cfg + '/cfg/descr'
463
+ temp = @@cfg + '/cfg/descr'
465
464
  url = form_url(conn, temp)
466
465
  hdr = form_hdr(conn)
467
466
  params = params.to_json
@@ -512,7 +511,7 @@ class System
512
511
  #
513
512
  # return: JSON response
514
513
  def self.set_clock_summertime(conn, params)
515
- temp = @cfg + '/cfg/clock/summertime'
514
+ temp = @@cfg + '/cfg/clock/summertime'
516
515
  url = form_url(conn, temp)
517
516
  hdr = form_hdr(conn)
518
517
  params = params.to_json
@@ -1,16 +1,15 @@
1
1
  ##
2
- ## Copyright (c) 2017, Lenovo. All rights reserved.
2
+ ## Copyright (C) 2017 Lenovo, Inc.
3
+ ## Licensed under the Apache License, Version 2.0 (the "License");
4
+ ## you may not use this file except in compliance with the License.
5
+ ## You may obtain a copy of the License at
6
+ ## http://www.apache.org/licenses/LICENSE-2.0
3
7
  ##
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.
8
+ ## Unless required by applicable law or agreed to in writing, software
9
+ ## distributed under the License is distributed on an "AS IS" BASIS,
10
+ ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ ## See the License for the specific language governing permissions and
12
+ ## limitations under the License.
14
13
  ##
15
14
  require 'rest-client'
16
15
  require 'json'
@@ -25,7 +24,7 @@ require_relative 'rest_utils'
25
24
  ##
26
25
 
27
26
  class Telemetry
28
- @cfg = '/nos/api/cfg/telemetry'
27
+ @@cfg = '/nos/api/cfg/telemetry'
29
28
 
30
29
  # This API gets system switch properties.
31
30
  #
@@ -35,7 +34,7 @@ class Telemetry
35
34
  #
36
35
  # return: JSON response
37
36
  def self.get_sys_feature(conn)
38
- url = form_url(conn, @cfg + '/feature')
37
+ url = form_url(conn, @@cfg + '/feature')
39
38
  hdr = form_hdr(conn)
40
39
  Rest.get(conn, url, hdr)
41
40
  end
@@ -61,7 +60,7 @@ class Telemetry
61
60
  #
62
61
  # return: JSON response
63
62
  def self.set_sys_feature(conn, params)
64
- url = form_url(conn, @cfg + '/feature')
63
+ url = form_url(conn, @@cfg + '/feature')
65
64
  hdr = form_hdr(conn)
66
65
  params = params.to_json
67
66
  Rest.put(conn, url, hdr, params)
@@ -75,7 +74,7 @@ class Telemetry
75
74
  #
76
75
  # return: JSON response
77
76
  def self.get_bst_tracking(conn)
78
- url = form_url(conn, @cfg + '/bst/tracking')
77
+ url = form_url(conn, @@cfg + '/bst/tracking')
79
78
  hdr = form_hdr(conn)
80
79
  Rest.get(conn, url, hdr)
81
80
  end
@@ -116,7 +115,7 @@ class Telemetry
116
115
  #
117
116
  # return: JSON response
118
117
  def self.set_bst_tracking(conn, params)
119
- url = form_url(conn, @cfg + '/bst/tracking')
118
+ url = form_url(conn, @@cfg + '/bst/tracking')
120
119
  hdr = form_hdr(conn)
121
120
  params = params.to_json
122
121
  Rest.put(conn, url, hdr, params)
@@ -130,7 +129,7 @@ class Telemetry
130
129
  #
131
130
  # return: JSON response
132
131
  def self.get_bst_feature(conn)
133
- url = form_url(conn, @cfg + '/bst/feature')
132
+ url = form_url(conn, @@cfg + '/bst/feature')
134
133
  hdr = form_hdr(conn)
135
134
  Rest.get(conn, url, hdr)
136
135
  end
@@ -179,7 +178,7 @@ class Telemetry
179
178
  #
180
179
  # return: JSON response
181
180
  def self.set_bst_feature(conn, params)
182
- url = form_url(conn, @cfg + '/bst/feature')
181
+ url = form_url(conn, @@cfg + '/bst/feature')
183
182
  hdr = form_hdr(conn)
184
183
  params = params.to_json
185
184
  Rest.put(conn, url, hdr, params)
@@ -193,7 +192,7 @@ class Telemetry
193
192
  #
194
193
  # return: JSON response
195
194
  def self.get_bst_report(conn, params)
196
- temp = @cfg.dup
195
+ temp = @@cfg.dup
197
196
  temp.sub! 'cfg', 'info'
198
197
  url = form_url(conn, temp + '/bst/report')
199
198
  hdr = form_hdr(conn)
@@ -209,7 +208,7 @@ class Telemetry
209
208
  #
210
209
  # return: JSON response
211
210
  def self.get_bst_threshold(conn, params)
212
- url = form_url(conn, @cfg + '/bst/threshold')
211
+ url = form_url(conn, @@cfg + '/bst/threshold')
213
212
  hdr = form_hdr(conn)
214
213
  params = params.to_json
215
214
  Rest.post(conn, url, hdr, params)
@@ -231,7 +230,7 @@ class Telemetry
231
230
  #
232
231
  # return: JSON response
233
232
  def self.set_bst_threshold(conn, params)
234
- url = form_url(conn, @cfg + '/bst/threshold')
233
+ url = form_url(conn, @@cfg + '/bst/threshold')
235
234
  hdr = form_hdr(conn)
236
235
  params = params.to_json
237
236
  Rest.put(conn, url, hdr, params)
@@ -245,7 +244,7 @@ class Telemetry
245
244
  #
246
245
  # return: JSON response
247
246
  def self.clear_bst_threshold(conn)
248
- url = form_url(conn, @cfg + '/bst/clear/threshold')
247
+ url = form_url(conn, @@cfg + '/bst/clear/threshold')
249
248
  hdr = form_hdr(conn)
250
249
  Rest.get(conn, url, hdr)
251
250
  end
@@ -258,7 +257,7 @@ class Telemetry
258
257
  #
259
258
  # return: JSON response
260
259
  def self.clear_bst_stats(conn)
261
- url = form_url(conn, @cfg + '/bst/clear/statistics')
260
+ url = form_url(conn, @@cfg + '/bst/clear/statistics')
262
261
  hdr = form_hdr(conn)
263
262
  Rest.get(conn, url, hdr)
264
263
  end
@@ -271,7 +270,7 @@ class Telemetry
271
270
  #
272
271
  # return: JSON response
273
272
  def self.clear_bst_cgsn_ctrs(conn)
274
- url = form_url(conn, @cfg + '/clear-cgsn-drop-counters')
273
+ url = form_url(conn, @@cfg + '/clear-cgsn-drop-counters')
275
274
  hdr = form_hdr(conn)
276
275
  Rest.get(conn, url, hdr)
277
276
  end
@@ -1,16 +1,15 @@
1
1
  ##
2
- ## Copyright (c) 2017, Lenovo. All rights reserved.
2
+ ## Copyright (C) 2017 Lenovo, Inc.
3
+ ## Licensed under the Apache License, Version 2.0 (the "License");
4
+ ## you may not use this file except in compliance with the License.
5
+ ## You may obtain a copy of the License at
6
+ ## http://www.apache.org/licenses/LICENSE-2.0
3
7
  ##
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.
8
+ ## Unless required by applicable law or agreed to in writing, software
9
+ ## distributed under the License is distributed on an "AS IS" BASIS,
10
+ ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ ## See the License for the specific language governing permissions and
12
+ ## limitations under the License.
14
13
  ##
15
14
  require 'rest-client'
16
15
  require 'json'
@@ -25,7 +24,7 @@ require_relative 'rest_utils'
25
24
  ##
26
25
 
27
26
  class Vlag
28
- @cfg = '/nos/api/cfg/vlag'
27
+ @@cfg = '/nos/api/cfg/vlag'
29
28
 
30
29
  # This API gets VLAG global configuration.
31
30
  #
@@ -35,7 +34,7 @@ class Vlag
35
34
  #
36
35
  # return: JSON response
37
36
  def self.get_vlag_conf(conn)
38
- url = form_url(conn, @cfg)
37
+ url = form_url(conn, @@cfg)
39
38
  hdr = form_hdr(conn)
40
39
  Rest.get(conn, url, hdr)
41
40
  end
@@ -64,7 +63,7 @@ class Vlag
64
63
  #
65
64
  # return: JSON response
66
65
  def self.update_vlag_conf(conn, params)
67
- url = form_url(conn, @cfg)
66
+ url = form_url(conn, @@cfg)
68
67
  hdr = form_hdr(conn)
69
68
  params = params.to_json
70
69
  Rest.put(conn, url, hdr, params)
@@ -78,7 +77,7 @@ class Vlag
78
77
  #
79
78
  # return: JSON response
80
79
  def self.get_global_vlag(conn)
81
- temp = @cfg.dup
80
+ temp = @@cfg.dup
82
81
  temp.sub! 'cfg' , 'info'
83
82
  url = form_url(conn, temp)
84
83
  hdr = form_hdr(conn)
@@ -93,7 +92,7 @@ class Vlag
93
92
  #
94
93
  # return: JSON response
95
94
  def self.get_vlag_isl(conn)
96
- temp = @cfg.dup
95
+ temp = @@cfg.dup
97
96
  temp.sub! 'cfg' , 'info'
98
97
  url = form_url(conn, temp + '/isl')
99
98
  hdr = form_hdr(conn)
@@ -114,7 +113,7 @@ class Vlag
114
113
  #
115
114
  # return: JSON response
116
115
  def self.update_vlag_isl(conn, params)
117
- url = form_url(conn, @cfg + '/isl')
116
+ url = form_url(conn, @@cfg + '/isl')
118
117
  hdr = form_hdr(conn)
119
118
  params = params.to_json
120
119
  Rest.put(conn, url, hdr, params)
@@ -128,7 +127,7 @@ class Vlag
128
127
  #
129
128
  # return: JSON response
130
129
  def self.get_vlag_health(conn)
131
- temp = @cfg.dup
130
+ temp = @@cfg.dup
132
131
  temp.sub! 'cfg' , 'info'
133
132
  url = form_url(conn, temp + '/health_check')
134
133
  hdr = form_hdr(conn)
@@ -160,7 +159,7 @@ class Vlag
160
159
  #
161
160
  # return: JSON response
162
161
  def self.update_vlag_health(conn, params)
163
- url = form_url(conn, @cfg + '/health_check')
162
+ url = form_url(conn, @@cfg + '/health_check')
164
163
  hdr = form_hdr(conn)
165
164
  params = params.to_json
166
165
  Rest.put(conn, url, hdr, params)
@@ -184,7 +183,7 @@ class Vlag
184
183
  #
185
184
  # return: JSON response
186
185
  def self.create_vlag_inst(conn, params)
187
- url = form_url(conn, @cfg + '/instance')
186
+ url = form_url(conn, @@cfg + '/instance')
188
187
  hdr = form_hdr(conn)
189
188
  params = params.to_json
190
189
  Rest.post(conn, url, hdr, params)
@@ -208,7 +207,7 @@ class Vlag
208
207
  #
209
208
  # return: JSON response
210
209
  def self.update_vlag_inst(conn, inst_id, params)
211
- url = form_url(conn, @cfg + '/instance/' + inst_id.to_s)
210
+ url = form_url(conn, @@cfg + '/instance/' + inst_id.to_s)
212
211
  hdr = form_hdr(conn)
213
212
  params = params.to_json
214
213
  Rest.post(conn, url, hdr, params)
@@ -224,7 +223,7 @@ class Vlag
224
223
  #
225
224
  # return: JSON response
226
225
  def self.delete_vlag_inst(conn, inst_id)
227
- url = form_url(conn, @cfg + '/instance/' + inst_id.to_s)
226
+ url = form_url(conn, @@cfg + '/instance/' + inst_id.to_s)
228
227
  hdr = form_hdr(conn)
229
228
  Rest.delete(conn, url, hdr)
230
229
  end
@@ -238,7 +237,7 @@ class Vlag
238
237
  #
239
238
  # return: JSON response
240
239
  def self.get_vlag_inst_confg(conn, inst_id)
241
- url = form_url(conn, @cfg + '/instance/' + inst_id.to_s)
240
+ url = form_url(conn, @@cfg + '/instance/' + inst_id.to_s)
242
241
  hdr = form_hdr(conn)
243
242
  Rest.get(conn, url, hdr)
244
243
  end
@@ -251,7 +250,7 @@ class Vlag
251
250
  #
252
251
  # return: JSON response
253
252
  def self.get_all_vlag(conn)
254
- url = form_url(conn, @cfg + '/instance')
253
+ url = form_url(conn, @@cfg + '/instance')
255
254
  hdr = form_hdr(conn)
256
255
  Rest.get(conn, url, hdr)
257
256
  end
@@ -265,7 +264,7 @@ class Vlag
265
264
  #
266
265
  # return: JSON response
267
266
  def self.get_vlag_inst_info(conn, inst_id)
268
- temp = @cfg.dup
267
+ temp = @@cfg.dup
269
268
  temp.sub! 'cfg' , 'info'
270
269
  url = form_url(conn, temp + '/instance/' + inst_id.to_s)
271
270
  hdr = form_hdr(conn)