#NEWLINE# def deploy_sensor_app( ) : #NEWLINE# #INDENT# ' Uploads the sensor app for registered deployments. ' #NEWLINE# deployment_id = helper . get_deployment_id ( ) #NEWLINE# if ( not deployment_id ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# uaserver = SOAPpy . SOAPProxy ( 'https://{0}:{1}' . format ( appscale_info . get_db_master_ip ( ) , hermes_constants . UA_SERVER_PORT ) ) #NEWLINE# is_app_enabled = uaserver . is_app_enabled ( hermes_constants . APPSCALE_SENSOR , appscale_info . get_secret ( ) ) #NEWLINE# if ( is_app_enabled == 'true' ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# pwd = appscale_utils . encrypt_password ( hermes_constants . USER_EMAIL , appscale_utils . random_password_generator ( ) ) #NEWLINE# if ( create_appscale_user ( pwd , uaserver ) and create_xmpp_user ( pwd , uaserver ) ) : #NEWLINE# #INDENT# logging . debug ( 'Created new user and now tarring app to be deployed.' ) #NEWLINE# file_path = os . path . join ( os . path . dirname ( __file__ ) , '../Apps/sensor' ) #NEWLINE# app_dir_location = os . path . join ( hermes_constants . APP_DIR_LOCATION , hermes_constants . APPSCALE_SENSOR ) #NEWLINE# archive = tarfile . open ( app_dir_location , 'w|gz' ) #NEWLINE# archive . add ( file_path , arcname = hermes_constants . APPSCALE_SENSOR ) #NEWLINE# archive . close ( ) #NEWLINE# try : #NEWLINE# #INDENT# logging . info ( 'Deploying the sensor app for registered deployments.' ) #NEWLINE# acc = appscale_info . get_appcontroller_client ( ) #NEWLINE# acc . upload_app ( uaserver , hermes_constants . FILE_SUFFIX , hermes_constants . USER_EMAIL ) #NEWLINE# #UNINDENT# except AppControllerException : #NEWLINE# #INDENT# logging . exception ( 'AppControllerException while trying to deploy appscalesensor app.' ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# logging . error ( 'Error while creating or accessing the user to deploy appscalesensor app.' )