def check_nodes(ip): """ Checks if the local machine can reach a given IP returns :param ip: :return True/False: """ log.info("\nChecking {} is reachable from host node. - ".format(ip)) str=api.local("nc -z -w1 {} 22 && echo $?".format(ip)) if str == "0": log.info("Success") return True else: log.info("\nFailed to reach {}".format(ip)) return False
def test(): # run("mkdir yarntesting") # put(__file__, "yarntesting/testfile.py") # with cd("yarntesting"): # print(run("ls -1 *py")) # run("echo $HOSTNAME >> {}".format(run("ls -1 *.py"))) # get("yarntesting/testfile.py", "{}.testfile".format(env.host_string)) # print("SUDO ENV") # print(sudo("env")) # print("SUDO IFCONFIG") # print(sudo("uname -r")) # print("ENV") # print(run("env")) print(local("en"))
#!/usr/bin/env python import os import getpass import unittest from yarn.api import env, run, local env.host_string = local('ifconfig eth0 | grep "inet addr" | cut -d":" -f2 | awk \'{print $1}\'') env.host_port = 2222 env.password = "******" class TestConnection(unittest.TestCase): def test_simple_connection(self): print(env.__dict__) run("uptime")