#NEWLINE# def get_params_from_args( self , args ) : #NEWLINE# #INDENT# " Constructs a dict with only the parameters necessary to interact with\n    Google Compute Engine (here, the client_secrets file and the image name).\n\n    Args:\n      args: A Namespace or dict that maps all of the arguments the user has\n        invoked an AppScale command with their associated value.\n    Returns:\n      A dict containing the location of the client_secrets file and that name\n      of the image to use in GCE.\n    Raises:\n      AgentConfigurationException: If the caller fails to specify a\n        client_secrets file, or if it doesn't exist on the local filesystem.\n    " #NEWLINE# if ( not isinstance ( args , dict ) ) : #NEWLINE# #INDENT# args = vars ( args ) #NEWLINE# #UNINDENT# if ( ( not args . get ( 'client_secrets' ) ) and ( not args . get ( 'oauth2_storage' ) ) ) : #NEWLINE# #INDENT# raise AgentConfigurationException ( ( ( 'Please specify a client_secrets ' + 'file or a oauth2_storage file in your AppScalefile when running ' ) + 'over Google Compute Engine.' ) ) #NEWLINE# #UNINDENT# credentials_file = ( args . get ( 'client_secrets' ) or args . get ( 'oauth2_storage' ) ) #NEWLINE# full_credentials = os . path . expanduser ( credentials_file ) #NEWLINE# if ( not os . path . exists ( full_credentials ) ) : #NEWLINE# #INDENT# raise AgentConfigurationException ( ( "Couldn't find your credentials " + 'at {0}' . format ( full_credentials ) ) ) #NEWLINE# #UNINDENT# if args . get ( 'client_secrets' ) : #NEWLINE# #INDENT# destination = LocalState . get_client_secrets_location ( args [ 'keyname' ] ) #NEWLINE# destination_par = os . path . abspath ( os . path . join ( destination , os . pardir ) ) #NEWLINE# if ( not os . path . exists ( destination_par ) ) : #NEWLINE# #INDENT# os . makedirs ( destination_par ) #NEWLINE# #UNINDENT# shutil . copy ( full_credentials , destination ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if args . get ( 'oauth2_storage' ) : #NEWLINE# #INDENT# destination = LocalState . get_oauth2_storage_location ( args [ 'keyname' ] ) #NEWLINE# destination_par = os . path . abspath ( os . path . join ( destination , os . pardir ) ) #NEWLINE# if ( not os . path . exists ( destination_par ) ) : #NEWLINE# #INDENT# os . makedirs ( destination_par ) #NEWLINE# #UNINDENT# shutil . copy ( full_credentials , destination ) #NEWLINE# #UNINDENT# #UNINDENT# params = { #NEWLINE# #INDENT# self . PARAM_GROUP : args [ 'group' ] , #NEWLINE# self . PARAM_IMAGE_ID : args [ 'machine' ] , #NEWLINE# self . PARAM_INSTANCE_TYPE : args [ 'gce_instance_type' ] , #NEWLINE# self . PARAM_KEYNAME : args [ 'keyname' ] , #NEWLINE# self . PARAM_PROJECT : args [ 'project' ] , #NEWLINE# self . PARAM_STATIC_IP : args . get ( self . PARAM_STATIC_IP ) , #NEWLINE# self . PARAM_ZONE : args [ 'zone' ] , #NEWLINE# self . PARAM_TEST : args [ 'test' ] , #NEWLINE# #UNINDENT# } #NEWLINE# if params [ self . PARAM_ZONE ] : #NEWLINE# #INDENT# params [ self . PARAM_REGION ] = params [ self . PARAM_ZONE ] [ : ( - 2 ) ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# params [ self . PARAM_REGION ] = self . DEFAULT_REGION #NEWLINE# #UNINDENT# if args . get ( self . PARAM_SECRETS ) : #NEWLINE# #INDENT# params [ self . PARAM_SECRETS ] = args . get ( self . PARAM_SECRETS ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if args . get ( self . PARAM_STORAGE ) : #NEWLINE# #INDENT# params [ self . PARAM_STORAGE ] = args . get ( self . PARAM_STORAGE ) #NEWLINE# #UNINDENT# #UNINDENT# params [ self . PARAM_VERBOSE ] = args . get ( 'verbose' , False ) #NEWLINE# self . assert_credentials_are_valid ( params ) #NEWLINE# return params