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,285 @@
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 Telemetry class provides a class implementation and methods for managing Telemetry features
24
+ ## on the node. This class presents an abstraction
25
+ ##
26
+
27
+ class Telemetry
28
+ @cfg = '/nos/api/cfg/telemetry'
29
+
30
+ # This API gets system switch properties.
31
+ #
32
+ #
33
+ # parameters:
34
+ # conn - connection object to the node
35
+ #
36
+ # return: JSON response
37
+ def self.get_sys_feature(conn)
38
+ url = form_url(conn, @cfg + '/feature')
39
+ hdr = form_hdr(conn)
40
+ Rest.get(conn, url, hdr)
41
+ end
42
+
43
+ # This API sets system feature.
44
+ #
45
+ #
46
+ # parameters:
47
+ # conn - connection object to the node
48
+ # params - dictionary that requires the following format of key-value pairs
49
+ # {
50
+ #  "heartbeat­enable" :  1,        
51
+ #     "msg­interval" :  10   
52
+ # }
53
+ # description -
54
+ # heartbeat-enable :When enabled, the Agent asynchronously sends the registration
55
+ # and heartbeat message to the collector. One of:
56
+ # 0: disable heartbeat
57
+ # 1: enable heartbeat (default value)
58
+ # msg-interval :Determines the interval with which the registration and heartbeat
59
+ # messages are sent to the collector; units of seconds from 1‐600.
60
+ # Default value: 5 seconds.
61
+ #
62
+ # return: JSON response
63
+ def self.set_sys_feature(conn, params)
64
+ url = form_url(conn, @cfg + '/feature')
65
+ hdr = form_hdr(conn)
66
+ params = params.to_json
67
+ Rest.put(conn, url, hdr, params)
68
+ end
69
+
70
+ # This API gets BST trackers and the tracking mode on the ASIC.
71
+ #
72
+ #
73
+ # parameters:
74
+ # conn - connection object to the node
75
+ #
76
+ # return: JSON response
77
+ def self.get_bst_tracking(conn)
78
+ url = form_url(conn, @cfg + '/bst/tracking')
79
+ hdr = form_hdr(conn)
80
+ Rest.get(conn, url, hdr)
81
+ end
82
+
83
+ # This API sets BST trackers and the tracking mode on the ASIC.
84
+ #
85
+ #
86
+ # parameters:
87
+ # conn - connection object to the node
88
+ # params - dictionary that requires the following format of key-value pairs
89
+ # {
90
+ # "track­peak­stats" : 1,
91
+ # "track­ingress­port­priority­group" : 1,
92
+ # "track­ingress­port­service­pool" : 1,
93
+ # "track­ingress­service­pool" : 1,
94
+ # "track­egress­port­service­pool" : 1,
95
+ # "track­egress­service­pool" : 1,
96
+ # "track­egress­rqe­queue" : 1,
97
+ # "track­device" : 1
98
+ # }
99
+ # description -
100
+ # track­peak­stats :Set to 1 to peak statistics tracking, 0 to disable
101
+ # this feature
102
+ # track­ingress­portpriority­group:Set to 1 to enable ingress port priority group
103
+ # tracking, 0 to disable this feature
104
+ # track­ingress­portservice­pool :Set to 1 to enable ingress port service pool
105
+ # tracking, 0 to disable this feature
106
+ # track­ingress­servicepool :Set to 1 to enable ingress service pool tracking,
107
+ # 0 to disable this feature
108
+ # track­egress­portservice­pool :Set to 1 to enable egress port service pool
109
+ # tracking, 0 to disable this feature
110
+ # track­egress­servicepool :Set to 1 to enable egress service pool tracking, 0
111
+ # to disable this feature
112
+ # track­egress­rqe­queue :Set to 1 to enable egress RQE queue tracking, 0
113
+ # to disable this feature
114
+ # track­device :Set to 1 to enable tracking of this device, 0 to
115
+ # disable this feature
116
+ #
117
+ # return: JSON response
118
+ def self.set_bst_tracking(conn, params)
119
+ url = form_url(conn, @cfg + '/bst/tracking')
120
+ hdr = form_hdr(conn)
121
+ params = params.to_json
122
+ Rest.put(conn, url, hdr, params)
123
+ end
124
+
125
+ # This API gets BST information.
126
+ #
127
+ #
128
+ # parameters:
129
+ # conn - connection object to the node
130
+ #
131
+ # return: JSON response
132
+ def self.get_bst_feature(conn)
133
+ url = form_url(conn, @cfg + '/bst/feature')
134
+ hdr = form_hdr(conn)
135
+ Rest.get(conn, url, hdr)
136
+ end
137
+
138
+ # This API sets BST feature.
139
+ #
140
+ #
141
+ # parameters:
142
+ # conn - connection object to the node
143
+ # params - dictionary that requires the following format of key-value pairs
144
+ # {
145
+ # "bst­enable": 1,
146
+ # "send­async­reports": 1,
147
+ # "collection­interval": 300,
148
+ # "trigger­rate­limit": 5,
149
+ # "trigger­rate­limit­interval": 2,
150
+ # "send­snapshot­on­trigger": 1,
151
+ # "async­full­reports": 1,
152
+ # }
153
+ # description -
154
+ # bst­enable :Set to 1 to enable BST, 0 to disable it. Enabling BST
155
+ # allows the switch to track buffer utilization
156
+ # statistics.
157
+ # send­async­reports :Set to 1 to enable the transmission of periodic
158
+ # asynchronous reports, 0 to disable this feature.
159
+ # collection­interval :The collection interval, in seconds. This defines how
160
+ # frequently periodic reports will be sent to the
161
+ # configured controller.
162
+ # trigger­rate­limit :The trigger rate limit, which defines the maximum
163
+ # number of threshold‐driven triggered reports that
164
+ # the agent is allowed to send to the controller per
165
+ # trigger­rate­limit­interval; an integer
166
+ # from 1‐5.
167
+ # trigger­rate­limit-interval :The trigger rate limit interval, in seconds; an integer
168
+ # from 10‐60.
169
+ # send­snapshot­ontrigger :Set to 1 to enable sending a complete snapshot of all
170
+ # buffer statistics counters when a trigger happens, 0
171
+ # to disable this feature.
172
+ # async­full­report :Set to 1 to enable the async full report feature, 0 to
173
+ # disable it.
174
+ # When this feature is enabled, the agent sends full
175
+ # reports containing data related to all counters.
176
+ # When the feature is disabled, the agent sends
177
+ # incremental reports containing only the counters
178
+ # that have changed since the last report.
179
+ #
180
+ # return: JSON response
181
+ def self.set_bst_feature(conn, params)
182
+ url = form_url(conn, @cfg + '/bst/feature')
183
+ hdr = form_hdr(conn)
184
+ params = params.to_json
185
+ Rest.put(conn, url, hdr, params)
186
+ end
187
+
188
+ # This API gets BST report information.
189
+ #
190
+ #
191
+ # parameters:
192
+ # conn - connection object to the node
193
+ #
194
+ # return: JSON response
195
+ def self.get_bst_report(conn, params)
196
+ temp = @cfg.dup
197
+ temp.sub! 'cfg', 'info'
198
+ url = form_url(conn, temp + '/bst/report')
199
+ hdr = form_hdr(conn)
200
+ params = params.to_json
201
+ Rest.post(conn, url, hdr, params)
202
+ end
203
+
204
+ # This API gets BST threshold.
205
+ #
206
+ #
207
+ # parameters:
208
+ # conn - connection object to the node
209
+ #
210
+ # return: JSON response
211
+ def self.get_bst_threshold(conn, params)
212
+ url = form_url(conn, @cfg + '/bst/threshold')
213
+ hdr = form_hdr(conn)
214
+ params = params.to_json
215
+ Rest.post(conn, url, hdr, params)
216
+ end
217
+
218
+ # This API sets BST threshold to trigger BST reports.
219
+ #
220
+ #
221
+ # parameters:
222
+ # conn - connection object to the node
223
+ # params - dictionary that requires the following format of key-value pairs for the realms
224
+ # given in description
225
+ # {
226
+ # "realm": "ingress­service­pool",       
227
+ # "service­pool" : 0,
228
+ # "um­share­threshold" : 70
229
+ # }
230
+ # description -
231
+ #
232
+ # return: JSON response
233
+ def self.set_bst_threshold(conn, params)
234
+ url = form_url(conn, @cfg + '/bst/threshold')
235
+ hdr = form_hdr(conn)
236
+ params = params.to_json
237
+ Rest.put(conn, url, hdr, params)
238
+ end
239
+
240
+ # This API clears BST threshold.
241
+ #
242
+ #
243
+ # parameters:
244
+ # conn - connection object to the node
245
+ #
246
+ # return: JSON response
247
+ def self.clear_bst_threshold(conn)
248
+ url = form_url(conn, @cfg + '/bst/clear/threshold')
249
+ hdr = form_hdr(conn)
250
+ Rest.get(conn, url, hdr)
251
+ end
252
+
253
+ # This API clear BST statistics.
254
+ #
255
+ #
256
+ # parameters:
257
+ # conn - connection object to the node
258
+ #
259
+ # return: JSON response
260
+ def self.clear_bst_stats(conn)
261
+ url = form_url(conn, @cfg + '/bst/clear/statistics')
262
+ hdr = form_hdr(conn)
263
+ Rest.get(conn, url, hdr)
264
+ end
265
+
266
+ # This API clears BST congestion drops.
267
+ #
268
+ #
269
+ # parameters:
270
+ # conn - connection object to the node
271
+ #
272
+ # return: JSON response
273
+ def self.clear_bst_cgsn_ctrs(conn)
274
+ url = form_url(conn, @cfg + '/clear-cgsn-drop-counters')
275
+ hdr = form_hdr(conn)
276
+ Rest.get(conn, url, hdr)
277
+ end
278
+
279
+
280
+ end
281
+
282
+
283
+
284
+
285
+
File without changes
@@ -0,0 +1,275 @@
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 Vlag class provides a class implementation and methods for managing the Vlags
24
+ ## on the node. This class presents an abstraction
25
+ ##
26
+
27
+ class Vlag
28
+ @cfg = '/nos/api/cfg/vlag'
29
+
30
+ # This API gets VLAG global configuration.
31
+ #
32
+ #
33
+ # parameters:
34
+ # conn - connection object to the node
35
+ #
36
+ # return: JSON response
37
+ def self.get_vlag_conf(conn)
38
+ url = form_url(conn, @cfg)
39
+ hdr = form_hdr(conn)
40
+ Rest.get(conn, url, hdr)
41
+ end
42
+
43
+ # This API updates VLAG global configuration.
44
+ #
45
+ #
46
+ # parameters:
47
+ # conn - connection object to the node
48
+ # params - dictionary that requires the following format of key-value pairs
49
+ # {
50
+ # "status": "<status>",
51
+ #    "tier_id": "<tier_id>",
52
+ #    "priority": "<priority>",
53
+ #    "auto_recover" : "<auto_recover>",
54
+ #    "startup_delay": "<startup_delay>",
55
+ # }
56
+ # description -
57
+ # status :Whether the vLAG is enabled or disabled; one of enable, disable.
58
+ # Default value; disable
59
+ # tier_id :vLAG tier ID value; an intger from 1‐512. Default value: 0.
60
+ # priority :vLAG priority value; an integer from 0‐65535. Default value: 0.
61
+ # auto_recover :Time interval, in seconds; an integer from 240‐3600. Default
62
+ # value: 300.
63
+ # startup_delay :Delay time, in seconds; an integer from 0‐3600. Default value: 120
64
+ #
65
+ # return: JSON response
66
+ def self.update_vlag_conf(conn, params)
67
+ url = form_url(conn, @cfg)
68
+ hdr = form_hdr(conn)
69
+ params = params.to_json
70
+ Rest.put(conn, url, hdr, params)
71
+ end
72
+
73
+ # This API gets global VLAG information.
74
+ #
75
+ #
76
+ # parameters:
77
+ # conn - connection object to the node
78
+ #
79
+ # return: JSON response
80
+ def self.get_global_vlag(conn)
81
+ temp = @cfg.dup
82
+ temp.sub! 'cfg' , 'info'
83
+ url = form_url(conn, temp)
84
+ hdr = form_hdr(conn)
85
+ Rest.get(conn, url, hdr)
86
+ end
87
+
88
+ # This API gets VLAG Inter Switch Link Information.
89
+ #
90
+ #
91
+ # parameters:
92
+ # conn - connection object to the node
93
+ #
94
+ # return: JSON response
95
+ def self.get_vlag_isl(conn)
96
+ temp = @cfg.dup
97
+ temp.sub! 'cfg' , 'info'
98
+ url = form_url(conn, temp + '/isl')
99
+ hdr = form_hdr(conn)
100
+ Rest.get(conn, url, hdr)
101
+ end
102
+
103
+ # This API configures the port aggregator for the VLAG ISL.
104
+ #
105
+ #
106
+ # parameters:
107
+ # conn - connection object to the node
108
+ # params - dictionary that requires the following format of key-value pairs
109
+ # {
110
+ #  "port_aggregator": ʺ<port_aggregator>ʺ
111
+ # }
112
+ # description -
113
+ # port_aggregator :Port aggregator for the vLAG ISL.
114
+ #
115
+ # return: JSON response
116
+ def self.update_vlag_isl(conn, params)
117
+ url = form_url(conn, @cfg + '/isl')
118
+ hdr = form_hdr(conn)
119
+ params = params.to_json
120
+ Rest.put(conn, url, hdr, params)
121
+ end
122
+
123
+ # This API gets VLAG health check information.
124
+ #
125
+ #
126
+ # parameters:
127
+ # conn - connection object to the node
128
+ #
129
+ # return: JSON response
130
+ def self.get_vlag_health(conn)
131
+ temp = @cfg.dup
132
+ temp.sub! 'cfg' , 'info'
133
+ url = form_url(conn, temp + '/health_check')
134
+ hdr = form_hdr(conn)
135
+ Rest.get(conn, url, hdr)
136
+ end
137
+
138
+ # This API configures the VLAG health check parameters
139
+ #
140
+ #
141
+ # parameters:
142
+ # conn - connection object to the node
143
+ # params - dictionary that requires the following format of key-value pairs
144
+ # {
145
+ #   "peer_ip": "<peer_ip>",
146
+ #   "vrf": "<vrf>",
147
+ #   “retry_interval": "<retry_interval>",
148
+ #   "keepalive_attempts" : "<keepalive_attempts>",
149
+ #   "keepalive_interval" : "<keepalive_interval>",ʺ
150
+ # }
151
+ # description -
152
+ # peer_ip :IP address of peer switch. This can be the management IP address
153
+ # of the peer switch.
154
+ # vrf :VRF context string.
155
+ # retry_interval :Time interval, in seconds; an integer from 1‐300. Default value:
156
+ # 30.
157
+ # keepalive_attempts :Number of keepalive attempts made before declaring the peer is
158
+ # down; an integer from 1‐24. Default value: 3.
159
+ # keepalive_interval :Time interval, in seconds; an integer from 2‐300. Default value: 5
160
+ #
161
+ # return: JSON response
162
+ def self.update_vlag_health(conn, params)
163
+ url = form_url(conn, @cfg + '/health_check')
164
+ hdr = form_hdr(conn)
165
+ params = params.to_json
166
+ Rest.put(conn, url, hdr, params)
167
+ end
168
+
169
+ # This API creates a VLAG instance.
170
+ #
171
+ #
172
+ # parameters:
173
+ # conn - connection object to the node
174
+ # params - dictionary that requires the following format of key-value pairs
175
+ # {
176
+ #   "inst_id": "<inst_id>",
177
+ #   "port_aggregator": "<port_aggregator>",
178
+ #   "status": "<status>",
179
+ # }
180
+ # description -
181
+ # inst_id :vLAG instance ID number; an integer from 1‐64.
182
+ # port_ aggregator :LAG identifier; an integer from 1‐4096.
183
+ # status : vLAG status; one of enable, disable. Default value: disable.
184
+ #
185
+ # return: JSON response
186
+ def self.create_vlag_inst(conn, params)
187
+ url = form_url(conn, @cfg + '/instance')
188
+ hdr = form_hdr(conn)
189
+ params = params.to_json
190
+ Rest.post(conn, url, hdr, params)
191
+
192
+ end
193
+
194
+ # This API updates VLAG instance.
195
+ #
196
+ #
197
+ # parameters:
198
+ # conn - connection object to the node
199
+ # inst_id - Vlan instance ID number
200
+ # params - dictionary that requires the following format of key-value pairs
201
+ # {
202
+ #   "port_aggregator": "<port_aggregator>",
203
+ #   "status": "<status>",
204
+ # }
205
+ # description -
206
+ # port_ aggregator :LAG identifier; an integer from 1‐4096.
207
+ # status : vLAG status; one of enable, disable. Default value: disable.
208
+ #
209
+ # return: JSON response
210
+ def self.update_vlag_inst(conn, inst_id, params)
211
+ url = form_url(conn, @cfg + '/instance/' + inst_id.to_s)
212
+ hdr = form_hdr(conn)
213
+ params = params.to_json
214
+ Rest.post(conn, url, hdr, params)
215
+
216
+ end
217
+
218
+ # This API deletes a Vlag Instance.
219
+ #
220
+ #
221
+ # parameters:
222
+ # conn - connection object to the node
223
+ # inst_id - Vlag instance ID number
224
+ #
225
+ # return: JSON response
226
+ def self.delete_vlag_inst(conn, inst_id)
227
+ url = form_url(conn, @cfg + '/instance/' + inst_id.to_s)
228
+ hdr = form_hdr(conn)
229
+ Rest.delete(conn, url, hdr)
230
+ end
231
+
232
+ # This API gets configuration paramteres for the specified VLAG instance.
233
+ #
234
+ #
235
+ # parameters:
236
+ # conn - connection object to the node
237
+ # inst_id - Vlag instance ID number
238
+ #
239
+ # return: JSON response
240
+ def self.get_vlag_inst_confg(conn, inst_id)
241
+ url = form_url(conn, @cfg + '/instance/' + inst_id.to_s)
242
+ hdr = form_hdr(conn)
243
+ Rest.get(conn, url, hdr)
244
+ end
245
+
246
+ # This API gets configuration paramteres for all VLAG instance.
247
+ #
248
+ #
249
+ # parameters:
250
+ # conn - connection object to the node
251
+ #
252
+ # return: JSON response
253
+ def self.get_all_vlag(conn)
254
+ url = form_url(conn, @cfg + '/instance')
255
+ hdr = form_hdr(conn)
256
+ Rest.get(conn, url, hdr)
257
+ end
258
+
259
+ # This API get information about a VLAG instance.
260
+ #
261
+ #
262
+ # parameters:
263
+ # conn - connection object to the node
264
+ # inst_id - Vlag instance ID number
265
+ #
266
+ # return: JSON response
267
+ def self.get_vlag_inst_info(conn, inst_id)
268
+ temp = @cfg.dup
269
+ temp.sub! 'cfg' , 'info'
270
+ url = form_url(conn, temp + '/instance/' + inst_id.to_s)
271
+ hdr = form_hdr(conn)
272
+ Rest.get(conn, url, hdr)
273
+ end
274
+
275
+ end