def check_arvados_token(requested_username, token):
auth_log("%s %s" % (requested_username, token))
- ARVADOS_API_HOST='4xphq.arvadosapi.com' ## FIXME replace with puppet
- # BUG: hostname stored on the API is just "foo.shell", not "foo.shell.zzzzz.arvadosapi.com"!
- my_hostname='shell' ## FIXME replace with puppet
try:
- arv = arvados.api('v1',host=ARVADOS_API_HOST, token=token, cache=None)
+ f=file('/etc/default/arvados_pam')
+ config=dict([l.split('=') for l in f.readlines() if not l.startswith('#') or l.strip()==""])
+ arvados_api_host=config['ARVADOS_API_HOST'].strip()
+ hostname=config['HOSTNAME'].strip()
except Exception as e:
- auth_log(str(e))
- return False
+ auth_log("problem getting default values %s" % e)
+ return False
+
+ try:
+ arv = arvados.api('v1',host=arvados_api_host, token=token, cache=None)
+ except Exception as e:
+ auth_log(str(e))
+ return False
try:
- matches = arv.virtual_machines().list(filters=[['hostname','=',my_hostname]]).execute()['items']
+ matches = arv.virtual_machines().list(filters=[['hostname','=',hostname]]).execute()['items']
except Exception as e:
- auth_log(str(e))
- return False
+ auth_log(str(e))
+ return False
if len(matches) != 1:
- auth_log("libpam_arvados could not dertermine vm uuid for '%s'" % my_hostname)
+ auth_log("libpam_arvados could not determine vm uuid for '%s'" % hostname)
return False
this_vm_uuid = matches[0]['uuid']