Skip to content

Commit

Permalink
implement --search to limit the report
Browse files Browse the repository at this point in the history
  • Loading branch information
evgeni committed Jul 18, 2016
1 parent a4dfd32 commit 3a1efbb
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion sat6Inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import json
import getpass
import urllib2
import urllib
import base64
import sys
import ssl
Expand Down Expand Up @@ -140,6 +141,7 @@
parser.add_option("-d", "--debug", dest="debug", action="store_true", help="Debugging output (debug output enables verbose)")
parser.add_option("-c", "--columns", dest="columns", help="coma separated list of columns to add to the output")
parser.add_option("-f", "--format", dest="format", help="use an predefined output format", choices=_format_columns_mapping.keys())
parser.add_option("-S", "--search", dest="search", help="limit report to machines matching this search")
(options, args) = parser.parse_args()


Expand Down Expand Up @@ -201,7 +203,10 @@ class error_colors:
per_page = 100
while (page == 0 or int(jsonresult['per_page']) == len(jsonresult['results'])):
page += 1
url = "https://" + satellite + "/katello/api/v2/systems?page=" + str(page) + "&per_page=" + str(per_page)
q = [('page', page), ('per_page', per_page)]
if options.search:
q.append(('search', options.search))
url = "https://" + satellite + "/katello/api/v2/systems?" + urllib.urlencode(q)
request = urllib2.Request(url)
if VERBOSE:
print "=" * 80
Expand Down

0 comments on commit 3a1efbb

Please sign in to comment.