#NEWLINE# def docker_service( self , address , action ) : #NEWLINE# #INDENT# '\n        Restart the Docker daemon on the specified address.\n        Restarts by stopping, verifying the service has stopped, then\n        starting and finally verifying the service has started.\n        Verification is performed via the success of running "docker ps"\n        on the target node; an exit code of 0 indicates the daemon is\n        running, an exit code of 1 is expected if we try to run this\n        command when the daemon is stopped.\n\n        :param bytes address: The public IP of the node on which Docker will\n            be restarted.\n        :param bytes action: The action to perform on the service.\n        ' #NEWLINE# distro = [ ] #NEWLINE# get_distro = run_ssh ( reactor , b'root' , address , [ 'python' , '-m' , 'platform' ] , handle_stdout = distro . append ) #NEWLINE# get_distro . addCallback ( ( lambda _ : distro [ 0 ] . lower ( ) ) ) #NEWLINE# def action_docker( distribution ) : #NEWLINE# #INDENT# if ( 'ubuntu' in distribution ) : #NEWLINE# #INDENT# command = [ 'service' , 'docker' , action ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# command = [ 'systemctl' , action , 'docker' ] #NEWLINE# #UNINDENT# d = run_ssh ( reactor , b'root' , address , command ) #NEWLINE# def handle_error( _ , action ) : #NEWLINE# #INDENT# self . fail ( 'Docker {} failed. See logs for process output.' . format ( action ) ) #NEWLINE# #UNINDENT# d . addErrback ( handle_error , action ) #NEWLINE# return d #NEWLINE# #UNINDENT# acting = get_distro . addCallback ( action_docker ) #NEWLINE# return acting