Esempio n. 1
0
    hosts = hosts[1:]

# Create an AuthManager to do login with password only
login = AuthManager('root', default_password=password)

# Create a Console for streaming the results of running command output
# This can be suppressed via the console.quiet() call
console = RadSSHConsole()

# Create a list of tuples for the connections
# Leave the 2nd element as None to let RadSSH do the socket connections
connections = [(x, None) for x in hosts]

print('\nConnecting...')
C = Cluster(connections, login, console=console)
for host, status in C.status():
    print('%14s : %s' % (str(host), status))

# Cluster connections and authentications established
# Use the run_command to execute just about any command line
print('\nRunning a command')
C.run_command('hostname')

# All hosts have finished (or were skipped)
# We can access the cluster last_result to post-process the results

print('\nCommand post-processing')
for host, job in C.last_result.items():
    if job.completed and job.result.return_code == 0:
        print(job.result.stdout)
    else:
Esempio n. 2
0
    hosts = hosts[1:]

# Create an AuthManager to do login with password only
login = AuthManager('root', default_password=password)

# Create a Console for streaming the results of running command output
# This can be suppressed via the console.quiet() call
console = RadSSHConsole()

# Create a list of tuples for the connections
# Leave the 2nd element as None to let RadSSH do the socket connections
connections = [(x, None) for x in hosts]

print('\nConnecting...')
C = Cluster(connections, login, console=console)
for host, status in C.status():
    print('%14s : %s' % (str(host), status))

# Cluster connections and authentications established
# Use the run_command to execute just about any command line
print('\nRunning a command')
C.run_command('hostname')

# All hosts have finished (or were skipped)
# We can access the cluster last_result to post-process the results

print('\nCommand post-processing')
for host, job in C.last_result.items():
    if job.completed and job.result.return_code == 0:
        print(job.result.stdout)
    else: