def _validate_credentials_file(module, credentials_file, require_valid_json=True, check_libcloud=False):
 try:
  with open(credentials_file) as credentials:
   json.loads(credentials.read())
   if (check_libcloud and (LooseVersion(libcloud.__version__) < '0.17.0')):
    module.fail_json(msg='Using JSON credentials but libcloud minimum version not met. Upgrade to libcloud>=0.17.0.')
   return True
 except IOError as e:
  module.fail_json(msg=('GCP Credentials File %s not found.' % credentials_file), changed=False)
  return False
 except ValueError as e:
  if require_valid_json:
   module.fail_json(msg=('GCP Credentials File %s invalid.  Must be valid JSON.' % credentials_file), changed=False)
  else:
   display.deprecated(msg='Non-JSON credentials file provided. This format is deprecated.  Please generate a new JSON key from the Google Cloud console', version=2.5)
   return True

def _validate_credentials_file ( module , credentials_file , require_valid_json = True , check_libcloud = False ) : try : with open ( credentials_file ) as credentials : json . loads ( credentials . read ( ) ) if ( check_libcloud and ( LooseVersion ( libcloud . __version__ ) < '0.17.0' ) ) : module . fail_json ( msg = 'Using JSON credentials but libcloud minimum version not met. Upgrade to libcloud>=0.17.0.' ) return True except IOError as e : module . fail_json ( msg = ( 'GCP Credentials File %s not found.' % credentials_file ) , changed = False ) return False except ValueError as e : if require_valid_json : module . fail_json ( msg = ( 'GCP Credentials File %s invalid.  Must be valid JSON.' % credentials_file ) , changed = False ) else : display . deprecated ( msg = 'Non-JSON credentials file provided. This format is deprecated.  Please generate a new JSON key from the Google Cloud console' , version = 2.5 ) return True
check for valid credentials file .