'Restart the Docker daemon on the specified address.
Restarts by stopping, verifying the service has stopped, then
starting and finally verifying the service has started.
Verification is performed via the success of running "docker ps"
on the target node; an exit code of 0 indicates the daemon is
running, an exit code of 1 is expected if we try to run this
command when the daemon is stopped.
:param bytes address: The public IP of the node on which Docker will
be restarted.
:param bytes action: The action to perform on the service.'

def docker_service(self, address, action):

    distro = []
    get_distro = run_ssh(reactor, 'root', address, ['python2.7', '-m', 'platform'], handle_stdout=distro.append)
    get_distro.addCallback((lambda _: distro[0].lower()))
    def action_docker(distribution):
        if ('ubuntu-14.04' in distribution):
            command = ['service', 'docker', action]
        else:
            command = ['systemctl', action, 'docker']
        d = run_ssh(reactor, 'root', address, command)
        def handle_error(_, action):
            self.fail('Docker    {}    failed.    See    logs    for    process    output.'.format(action))
        d.addErrback(handle_error, action)
        return d
    acting = get_distro.addCallback(action_docker)
    return acting
