@@ -56,7 +56,8 @@ def inventory_list():
56
56
This def will collect the first 50 HBI entries
57
57
"""
58
58
59
- url = "https://console.redhat.com/api/inventory/v1/hosts"
59
+ url = "https://console.redhat.com/api/inventory/v1/hosts?per_page=10"
60
+ # url = "https://console.redhat.com/api/inventory/v1/hosts"
60
61
response = connection_request (url )
61
62
check_authentication (response )
62
63
@@ -103,7 +104,9 @@ def inventory_list_all():
103
104
104
105
# Here we are checking the total number of objects and setting the correct
105
106
# number of pages based on that.
106
- check_response = divmod (response .json ()['total' ], 50 )
107
+ # check_response = divmod(response.json()['total'], 50)
108
+ # ITEMS_PER_PAGE = 10
109
+ check_response = divmod (response .json ()['total' ], conf .ITEMS_PER_PAGE )
107
110
108
111
if check_response [1 ] == 0 :
109
112
num_of_pages = check_response [0 ] + 1
@@ -121,7 +124,7 @@ def inventory_list_all():
121
124
# num_of_pages = 2
122
125
123
126
for page in range (1 , num_of_pages ):
124
- url = "https://console.redhat.com/api/inventory/v1/hosts?per_page=50 &page=" + str (page )
127
+ url = "https://console.redhat.com/api/inventory/v1/hosts?per_page=" + str ( conf . ITEMS_PER_PAGE ) + " &page=" + str (page )
125
128
response = connection_request (url )
126
129
127
130
for server in response .json ()['results' ]:
@@ -191,7 +194,10 @@ def swatch_list():
191
194
This def will collect the first 100 entries from Subscription Watch
192
195
"""
193
196
194
- url = "https://console.redhat.com/api/rhsm-subscriptions/v1/hosts/products/RHEL?limit=100&offset=0&sort=display_name"
197
+ # ITEMS_PER_PAGE = 10
198
+
199
+ url = "https://console.redhat.com/api/rhsm-subscriptions/v1/hosts/products/RHEL?limit=" + str (conf .ITEMS_PER_PAGE ) + "&offset=0&sort=display_name"
200
+ # url = "https://console.redhat.com/api/rhsm-subscriptions/v1/hosts/products/RHEL?limit=100&offset=0&sort=display_name"
195
201
response = connection_request (url )
196
202
check_authentication (response )
197
203
@@ -203,20 +209,26 @@ def swatch_list_all():
203
209
This def will collect all the entries from Subscription Watch
204
210
"""
205
211
206
- url = "https://console.redhat.com/api/rhsm-subscriptions/v1/hosts/products/RHEL?limit=100&offset=0&sort=display_name"
212
+ # ITEMS_PER_PAGE = 10
213
+
214
+ url = "https://console.redhat.com/api/rhsm-subscriptions/v1/hosts/products/RHEL?limit=" + str (conf .ITEMS_PER_PAGE ) + "&offset=0&sort=display_name"
215
+ # url = "https://console.redhat.com/api/rhsm-subscriptions/v1/hosts/products/RHEL?limit=100&offset=0&sort=display_name"
207
216
response = connection_request (url )
208
217
check_authentication (response )
209
218
210
- num_of_pages = round (response .json ()['meta' ]['count' ] / 100 + 1 )
219
+ num_of_pages = round (response .json ()['meta' ]['count' ] / conf .ITEMS_PER_PAGE + 1 )
220
+ # num_of_pages = round(response.json()['meta']['count'] / 100 + 1)
211
221
212
222
dic_full_list = {'data' : '' , 'meta' : {'count' : response .json ()['meta' ]['count' ]}}
213
223
full_list = []
214
224
215
225
count = 0
216
226
for page in range (0 , num_of_pages ):
217
- url = "https://console.redhat.com/api/rhsm-subscriptions/v1/hosts/products/RHEL?limit=100&offset=" + str (count ) + "&sort=display_name"
227
+ url = "https://console.redhat.com/api/rhsm-subscriptions/v1/hosts/products/RHEL?limit=" + str (conf .ITEMS_PER_PAGE ) + "&offset=" + str (count ) + "&sort=display_name"
228
+ # url = "https://console.redhat.com/api/rhsm-subscriptions/v1/hosts/products/RHEL?limit=100&offset=" + str(count) + "&sort=display_name"
218
229
response = connection_request (url )
219
- count = count + 100
230
+ count = count + conf .ITEMS_PER_PAGE
231
+ # count = count + 100
220
232
221
233
for entry in response .json ()['data' ]:
222
234
full_list .append (entry )
@@ -378,15 +390,20 @@ def patch_systems():
378
390
response = connection_request (url )
379
391
check_authentication (response )
380
392
381
- num_of_pages = int (response .json ()['meta' ]['total_items' ] / 20 + 1 )
393
+ # ITEMS_PER_PAGE = 10
394
+
395
+ num_of_pages = int (response .json ()['meta' ]['total_items' ] / conf .ITEMS_PER_PAGE + 1 )
396
+ # num_of_pages = int(response.json()['meta']['total_items'] / 20 + 1)
382
397
383
398
dic_full_list = {'data' : '' , 'total' : response .json ()['meta' ]['total_items' ]}
384
399
full_list = []
385
400
386
401
count = 0
387
402
for page in range (0 , num_of_pages ):
388
- url = "https://console.redhat.com/api/patch/v1/systems?limit=20&offset=" + str (count ) + "&sort=-last_upload"
389
- count = count + 20
403
+ url = "https://console.redhat.com/api/patch/v1/systems?limit=" + str (conf .ITEMS_PER_PAGE ) + "&offset=" + str (count ) + "&sort=-last_upload"
404
+ # url = "https://console.redhat.com/api/patch/v1/systems?limit=20&offset=" + str(count) + "&sort=-last_upload"
405
+ count = count + conf .ITEMS_PER_PAGE
406
+ # count = count + 20
390
407
response = connection_request (url )
391
408
392
409
for entry in response .json ()['data' ]:
@@ -406,9 +423,12 @@ def vulnerability_systems():
406
423
response = connection_request (url )
407
424
check_authentication (response )
408
425
426
+ # ITEMS_PER_PAGE = 10
427
+
409
428
# Here we are checking the total number of objects and setting the correct
410
429
# number of pages based on that.
411
- check_response = divmod (response .json ()['meta' ]['total_items' ], 20 )
430
+ check_response = divmod (response .json ()['meta' ]['total_items' ], conf .ITEMS_PER_PAGE )
431
+ # check_response = divmod(response.json()['meta']['total_items'], 20)
412
432
413
433
if check_response [1 ] == 0 :
414
434
num_of_pages = check_response [0 ]
@@ -422,8 +442,10 @@ def vulnerability_systems():
422
442
423
443
count = 0
424
444
for page in range (0 , num_of_pages ):
425
- url = "https://console.redhat.com/api/vulnerability/v1/systems?limit=20&offset=" + str (count ) + "&sort=-last_upload"
426
- count = count + 20
445
+ url = "https://console.redhat.com/api/vulnerability/v1/systems?limit=" + str (conf .ITEMS_PER_PAGE ) + "&offset=" + str (count ) + "&sort=-last_upload"
446
+ # url = "https://console.redhat.com/api/vulnerability/v1/systems?limit=20&offset=" + str(count) + "&sort=-last_upload"
447
+ count = count + conf .ITEMS_PER_PAGE
448
+ # count = count + 20
427
449
response = connection_request (url )
428
450
429
451
for entry in response .json ()['data' ]:
@@ -438,21 +460,21 @@ def advisor_systems():
438
460
This def will collect all the entries from advisor/insights systems
439
461
"""
440
462
441
- ITEMS_PER_PAGE = 10
463
+ # ITEMS_PER_PAGE = 10
442
464
443
465
url = "https://console.redhat.com/api/insights/v1/system"
444
466
response = connection_request (url )
445
467
check_authentication (response )
446
468
447
- num_of_pages = int (response .json ()['meta' ]['count' ] / ITEMS_PER_PAGE + 1 )
469
+ num_of_pages = int (response .json ()['meta' ]['count' ] / conf . ITEMS_PER_PAGE + 1 )
448
470
449
471
dic_full_list = {'data' : '' , 'total' : response .json ()['meta' ]['count' ]}
450
472
full_list = []
451
473
452
474
count = 0
453
475
for page in range (0 , num_of_pages ):
454
- url = "https://console.redhat.com/api/insights/v1/system?limit=ITEMS_PER_PAGE&offset=" + str (count )
455
- count = count + ITEMS_PER_PAGE
476
+ url = "https://console.redhat.com/api/insights/v1/system?limit=" + str ( conf . ITEMS_PER_PAGE ) + " &offset=" + str (count )
477
+ count = count + conf . ITEMS_PER_PAGE
456
478
response = connection_request (url )
457
479
458
480
for entry in response .json ()['data' ]:
0 commit comments