cloudmesh-common.cloudmesh.common.Host

Module Contents

Classes

Host

class cloudmesh-common.cloudmesh.common.Host.Host

Bases: object

static get_hostnames(names)

Given a list of host names it identifies if they have numbers in them. If so, they are assumed workers. If not, it is a manager. There can only be one manager.

@param names: list of names @type names: str @return: manager, worker as list @rtype: tuple

static config(hosts=None, ips=None, username=None, key='~/.ssh/id_rsa.pub')
static _run(args)

An internal command that executes as part of a process map a given command. args is a dict and must include

  • command

  • shell

It returns a dict of the form

  • command

  • stdout

& stderr * returncode * success

Parameters

args – command dict

Returns

static run(hosts=None, command=None, execute=None, processors=3, shell=False, **kwargs)

Executes the command on all hosts. The key values specified in **kwargs will be replaced prior to the execution. Furthermore, {host} will be replaced with the specific hostname.

Parameters
  • hosts – The hosts given in parameter notation Example: red[01-10]

  • command – The command to be executed for each host Example: ssh {host} uname

  • username – Specify the username on the host

  • processors – The number of parallel processes used

  • shell – Set to Tue if the current context of the shell is to be used. It is by default True

  • kwargs – The key value pairs to be replaced in the command

Returns

static ssh(hosts=None, command=None, username=None, key='~/.ssh/id_rsa', processors=3, dryrun=False, executor=None, verbose=False, **kwargs)
Parameters
  • command – the command to be executed

  • hosts – a list of hosts to be checked

  • username – the usernames for the hosts

  • key – the key for logging in

  • processors – the number of parallel checks

Returns

list of dicts representing the ping result

static put(hosts=None, source=None, destination=None, username=None, key='~/.ssh/id_rsa', shell=False, processors=3, dryrun=False, verbose=False)
Parameters
  • command – the command to be executed

  • hosts – a list of hosts to be checked

  • username – the usernames for the hosts

  • key – the key for logging in

  • processors – the number of parallel checks

Returns

list of dicts representing the ping result

static check(hosts=None, username=None, key='~/.ssh/id_rsa', processors=3)
Parameters
  • hosts – a list of hosts to be checked

  • username – the usernames for the hosts

  • key – the key for logging in

  • processors – the number of parallel checks

Returns

list of dicts representing the ping result

static _ping(args)

ping a vm

Parameters

args – dict of {ip address, count}

Returns

a dict representing the result, if returncode=0 ping is successfully

static ping(hosts=None, count=1, processors=3)

ping a list of given ip addresses

Parameters
  • hosts – a list of ip addresses

  • count – number of pings to run per ip

  • processors – number of processors to Pool

Returns

list of dicts representing the ping result

static ssh_keygen(hosts=None, filename='~/.ssh/id_rsa', username=None, processors=3, dryrun=False, verbose=True)

generates the keys on the specified hosts. this fonction does not work well as it still will aski if we overwrite.

Parameters
  • hosts

  • filename

  • username

  • output

  • dryrun

  • verbose

Returns

static gather_keys(username=None, hosts=None, filename='~/.ssh/id_rsa.pub', key='~/.ssh/id_rsa', processors=3, dryrun=False)

returns in a list the keys of the specified hosts

Parameters
  • username

  • hosts

  • filename

  • key

  • dryrun

Returns