@api_wrapper
def get_system(module):
 box = module.params['system']
 user = module.params.get('user', None)
 password = module.params.get('password', None)
 if (user and password):
  system = InfiniBox(box, auth=(user, password))
 elif (environ.get('INFINIBOX_USER') and environ.get('INFINIBOX_PASSWORD')):
  system = InfiniBox(box, auth=(environ.get('INFINIBOX_USER'), environ.get('INFINIBOX_PASSWORD')))
 elif path.isfile((path.expanduser('~') + '/.infinidat/infinisdk.ini')):
  system = InfiniBox(box)
 else:
  module.fail_json(msg='You must set INFINIBOX_USER and INFINIBOX_PASSWORD environment variables or set username/password module arguments')
 try:
  system.login()
 except Exception:
  module.fail_json(msg='Infinibox authentication failed. Check your credentials')
 return system

@ api_wrapper def get_system ( module ) : box = module . params [ 'system' ] user = module . params . get ( 'user' , None ) password = module . params . get ( 'password' , None ) if ( user and password ) : system = InfiniBox ( box , auth = ( user , password ) ) elif ( environ . get ( 'INFINIBOX_USER' ) and environ . get ( 'INFINIBOX_PASSWORD' ) ) : system = InfiniBox ( box , auth = ( environ . get ( 'INFINIBOX_USER' ) , environ . get ( 'INFINIBOX_PASSWORD' ) ) ) elif path . isfile ( ( path . expanduser ( '~' ) + '/.infinidat/infinisdk.ini' ) ) : system = InfiniBox ( box ) else : module . fail_json ( msg = 'You must set INFINIBOX_USER and INFINIBOX_PASSWORD environment variables or set username/password module arguments' ) try : system . login ( ) except Exception : module . fail_json ( msg = 'Infinibox authentication failed. Check your credentials' ) return system
return system object or fail .