Skip to content

Commit

Permalink
cleanup testing, checking for api creds
Browse files Browse the repository at this point in the history
  • Loading branch information
alemsh committed Oct 30, 2024
1 parent 50721aa commit e85c1e2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 20 deletions.
22 changes: 10 additions & 12 deletions condor_history_to_es.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
help="query jobs, but do not ingest into ES",)
parser.add_argument('--collectors', default=False, action='store_true',
help='Args are collector addresses, not files')
parser.add_argument('--client_id',help='oauth2 client id')
parser.add_argument('--client_secret',help='oauth2 client secret')
parser.add_argument('--token_url',help='oauth2 realm token url')
parser.add_argument('--client_id',help='oauth2 client id',default=None)
parser.add_argument('--client_secret',help='oauth2 client secret',default=None)
parser.add_argument('--token_url',help='oauth2 realm token url',default=None)
parser.add_argument("positionals", nargs='+')

options = parser.parse_args()
Expand Down Expand Up @@ -55,22 +55,21 @@ def es_generator(entries):
if '://' in address:
prefix,address = address.split('://')

api = ClientCredentialsAuth(address='https://elasticsearch.icecube.aq',
token_url=options.token_url,
client_secret=options.client_secret,
client_id=options.client_id)
token = api.make_access_token()
token = None

print(token)
if None not in (options.token_url, options.client_secret, options.client_id):
api = ClientCredentialsAuth(address='https://elasticsearch.icecube.aq',
token_url=options.token_url,
client_secret=options.client_secret,
client_id=options.client_id)
token = api.make_access_token()

url = '{}://{}'.format(prefix, address)
logging.info('connecting to ES at %s',url)
es = Elasticsearch(hosts=[url],
request_timeout=5000,
bearer_auth=token)

print('made it here')

def es_import(document_generator):
if options.dry_run:
import json
Expand All @@ -94,7 +93,6 @@ def es_import(document_generator):
else:
print(options.positionals)
for path in options.positionals:
print(path)
for filename in glob.glob(path):
gen = es_generator(read_from_file(filename))
success = es_import(gen)
Expand Down
19 changes: 11 additions & 8 deletions condor_queue_to_es.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
help="query jobs, but do not ingest into ES",)
parser.add_argument('--collectors', default=False, action='store_true',
help='Args are collector addresses, not files')
parser.add_argument('--client_id',help='oauth2 client id')
parser.add_argument('--client_secret',help='oauth2 client secret')
parser.add_argument('--token_url',help='oauth2 realm token url')
parser.add_argument('--client_id',help='oauth2 client id',default=None)
parser.add_argument('--client_secret',help='oauth2 client secret',default=None)
parser.add_argument('--token_url',help='oauth2 realm token url',default=None)
parser.add_argument("positionals", nargs='+')

options = parser.parse_args()
Expand Down Expand Up @@ -68,11 +68,14 @@ def es_generator(entries):

url = '{}://{}'.format(prefix, address)

api = ClientCredentialsAuth(address='https://elasticsearch.icecube.aq',
token_url=options.token_url,
client_secret=options.client_secret,
client_id=options.client_id)
token = api.make_access_token()
token = None

if None not in (options.token_url, options.client_secret, options.client_id):
api = ClientCredentialsAuth(address='https://elasticsearch.icecube.aq',
token_url=options.token_url,
client_secret=options.client_secret,
client_id=options.client_id)
token = api.make_access_token()

logging.info('connecting to ES at %s',url)
es = Elasticsearch(hosts=[url],
Expand Down

0 comments on commit e85c1e2

Please sign in to comment.