#NEWLINE# def _stop_console( node_uuid ) : #NEWLINE# #INDENT# 'Close the serial console for a node\n\n    Kills the console process and deletes the PID file.\n\n    :param node_uuid: the UUID of the node\n    :raises: NoConsolePid if no console PID was found\n    :raises: ConsoleError if unable to stop the console process\n    ' #NEWLINE# try : #NEWLINE# #INDENT# console_pid = _get_console_pid ( node_uuid ) #NEWLINE# os . kill ( console_pid , signal . SIGTERM ) #NEWLINE# #UNINDENT# except OSError as exc : #NEWLINE# #INDENT# if ( exc . errno != errno . ESRCH ) : #NEWLINE# #INDENT# msg = ( _ ( "Could not stop the console for node '%(node)s'. Reason: %(err)s." ) % { #NEWLINE# #INDENT# 'node' : node_uuid , #NEWLINE# 'err' : exc , #NEWLINE# #UNINDENT# } ) #NEWLINE# raise exception . ConsoleError ( message = msg ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# LOG . warning ( _LW ( 'Console process for node %s is not running but pid file exists while trying to stop shellinabox console.' ) , node_uuid ) #NEWLINE# #UNINDENT# #UNINDENT# finally : #NEWLINE# #INDENT# ironic_utils . unlink_without_raise ( _get_console_pid_file ( node_uuid ) )