5. Management

5.1. Configuration

class cloudmesh.management.configuration.counter.Counter(counter_file_path='~/.cloudmesh/counter.yaml')[source]

A counter is used to keep track of some value that can be increased and is associated with a user. Typically it is used to increment the vm id or the job id.

decr(name='counter')[source]

increments the counter by one :return:

get(name='counter')[source]

returns the value of the counter :param name: name of the counter :return: the value of the counter

incr(name='counter')[source]

increments the counter by one :return:

set(name='counter', value=None)[source]

sets a counter associated with a particular user :param name: name of the counter :param value: the value :return:

We use a uniform naming convention method. The name is defined by different kinds of objects. The name is a string its syntax is defined in a yaml file located at ~/.cloudmesh/name.yaml

order:
- experiment
- group
- user
- kind
- counter
schema: '{experiment}-{group}-{user}-{kind}-{counter}'
experiment: exp
group: grp
user: gregor
kind: container
counter: 2

This file is automatically generated if it does not exists by a simple Name object that can include an ordered number of dictionary keys such as

Experiment:is an experiment that all cloud objects can be placed under.
Group:A group formulates a number of objects that logically build an entity, such as a number of virtual machines building a cluster
User:A user name that may control the group
Kind:A kind that identifies which kind of resource this is

The last is a counter which is always increased and written into this file in order to assure that the latest value is safely included in it.

A typical use is

n = Name(experiment="exp",
         group="grp",
         user="gregor",
         kind="vm",
         counter=1)

n.incr()
counter = n.get()

Which will return

exp-grp-gregor-vm-1
class cloudmesh.management.configuration.name.Name(order=None, **kwargs)[source]
class cloudmesh.management.configuration.SSHkey.SSHkey[source]
get_from_git(user, keyname=None)[source]

gets the key from github

Parameters:
  • keyname – the keyname
  • user – the github username
Returns:

an array of public keys

Return type:

list

set_permissions(path)[source]

Sets the permissions of the path assuming the path is a public or private key :param path: :return:

5.2. Printer

5.3. Names

We use a uniform naming convention method. The name is defined by different kinds of objects. The name is a string its syntax is defined in a yaml file located at ~/.cloudmesh/name.yaml

order:
- experiment
- group
- user
- kind
- counter
schema: '{experiment}-{group}-{user}-{kind}-{counter}'
experiment: exp
group: grp
user: gregor
kind: container
counter: 2

This file is automatically generated if it does not exists by a simple Name object that can include an ordered number of dictionary keys such as

Experiment:is an experiment that all cloud objects can be placed under.
Group:A group formulates a number of objects that logically build an entity, such as a number of virtual machines building a cluster
User:A user name that may control the group
Kind:A kind that identifies which kind of resource this is

The last is a counter which is always increased and written into this file in order to assure that the latest value is safely included in it.

A typical use is

n = Name(experiment="exp",
         group="grp",
         user="gregor",
         kind="vm",
         counter=1)

n.incr()
counter = n.get()

Which will return

exp-grp-gregor-vm-1
class cloudmesh.management.configuration.name.Name(order=None, **kwargs)[source]

5.4. Script

A convenient method to execute shell commands and return their output. Note: that this method requires that the command be completely executed before the output is returned. For many activities in cloudmesh this is sufficient.

class cloudmesh.management.script.Script[source]

Executing a script defined by a simple text parameter

static run(script, live=False, debug=False)[source]

run the specified script line by line.

TODO: at one point this should be moved to cloudmesh.common

Parameters:
  • script – The script
  • debug – If true the output of the script is printed
Returns:

class cloudmesh.management.script.SystemPath[source]

Managing the System path in the .bashrc or .bash_profile files

static add(path)[source]

Adds a path to the ~/.bashrc or ~/.bash_profile files.

TODO: Windows is not implemented yet.

Parameters:path – The path to be added
Returns:
cloudmesh.management.script.find_process(name)[source]

find a process by name

Parameters:name – the name of the process
Returns:A list of dicts in which the attributes pid, command, and created are available and the name matches the specified name argument.

TODO: at one point this should be moved to cloudmesh.common

Return a list of processes matching ‘name’.

5.5. Debug