def gcp_connect(module, provider, get_driver, user_agent_product, user_agent_version):
 if (not HAS_LIBCLOUD_BASE):
  module.fail_json(msg='libcloud must be installed to use this module')
 creds = _get_gcp_credentials(module, require_valid_json=False, check_libcloud=True)
 try:
  gcp = get_driver(provider)(creds['service_account_email'], creds['credentials_file'], datacenter=module.params.get('zone', None), project=creds['project_id'])
  gcp.connection.user_agent_append(('%s/%s' % (user_agent_product, user_agent_version)))
 except (RuntimeError, ValueError) as e:
  module.fail_json(msg=str(e), changed=False)
 except Exception as e:
  module.fail_json(msg=unexpected_error_msg(e), changed=False)
 return gcp

def gcp_connect ( module , provider , get_driver , user_agent_product , user_agent_version ) : if ( not HAS_LIBCLOUD_BASE ) : module . fail_json ( msg = 'libcloud must be installed to use this module' ) creds = _get_gcp_credentials ( module , require_valid_json = False , check_libcloud = True ) try : gcp = get_driver ( provider ) ( creds [ 'service_account_email' ] , creds [ 'credentials_file' ] , datacenter = module . params . get ( 'zone' , None ) , project = creds [ 'project_id' ] ) gcp . connection . user_agent_append ( ( '%s/%s' % ( user_agent_product , user_agent_version ) ) ) except ( RuntimeError , ValueError ) as e : module . fail_json ( msg = str ( e ) , changed = False ) except Exception as e : module . fail_json ( msg = unexpected_error_msg ( e ) , changed = False ) return gcp
return a google libcloud driver connection .