11. cloudmesh-cloud

class cloudmesh.security.encrypt.EncryptFile(filename, secret)[source]

keys must be generated with

ssh-keygen -t rsa -m pem openssl rsa -in id_rsa -out id_rsa.pem
check_passphrase()[source]

this does not work with pem

cecks if the ssh key has a password :return:

pem_verify()[source]

this does not work :return:

Managing ~/.ssh/config

class cloudmesh.security.ssh_config.ssh_config(filename=None)[source]

Managing the config in .ssh

execute(name, command)[source]

execute the command on the named host :param name: the name of the host in config :param command: the command to be executed :return:

generate(key='india', host='india.futuresystems.org', username=None, force=False, verbose=False)[source]

adds a host to the config file with given parameters. #TODO: make sure this is better documented :param key: the key :param host: the host :param username: the username :param force: not used :param verbose: prints debug messages :return:

list()[source]

list the hosts in the config file :return:

load()[source]

list the hosts defined in the ssh config file

local(command)[source]

execute the command on the localhost :param command: the command to execute :return:

login(name)[source]

login to the host defines in .ssh/config by name :param name: the name of the host as defined in the config file :return:

names()[source]

The names defined in ~/.ssh/config :return: the names

status()[source]
executes a test with the given ssh config if a login is possible.
TODO: not yet implemented
username(host)[source]

returns the username for a given host in the config file :param host: the hostname :return: the username

authorized key management.

class cloudmesh.security.authorized_keys.AuthorizedKeys[source]

Class to manage authorized keys.

add(pubkey)[source]

add a public key. :param pubkey: the filename to the public key :return:

classmethod load(path)[source]

load the keys from a path

Parameters:path – the filename (path) in which we find the keys
Returns:
remove(pubkey)[source]

Removes the public key TODO: this method is not implemented :param pubkey: the filename of the public key :return:

cloudmesh.security.authorized_keys.get_fingerprint_from_public_key(pubkey)[source]

Generate the fingerprint of a public key

Parameters:pubkey (str) – the value of the public key
Returns:fingerprint
Return type:str
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:

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.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:

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’.

cloudmesh.vbox.command.vbox.defaults()[source]

default values :return: a number of default values for memory, image, and script :rtype: dotdict

class cloudmesh.display.Display[source]
class cloudmesh.compute.azure.AzProvider.Provider(name=None, configuration='~/.cloudmesh/cloudmesh4.yaml')[source]

az commands

https://docs.microsoft.com/en-us/cli/azure/reference-index?view=azure-cli-latest

create the

https://docs.microsoft.com/en-us/azure/active-directory/develop/howto-create-service-principal-portal

create(name=None, image=None, size=None, timeout=360, **kwargs)[source]

creates a named node

Parameters:
  • name – the name of the node
  • image – the image used
  • size – the size of the image
  • timeout – a timeout in seconds that is invoked in case the image does not boot. The default is set to 3 minutes.
  • kwargs – additional arguments passed along at time of boot
Returns:

destroy(name=None)[source]

Destroys the node :param name: the name of the node :return: the dict of the node

info(name=None)[source]

gets the information of a node with a given name

Parameters:name
Returns:The dict representing the node including updated status
list()[source]

list all nodes id

Returns:an array of dicts representing the nodes
rename(name=None, destination=None)[source]

rename a node

Parameters:
  • destination
  • name – the current name
Returns:

the dict with the new name

resume(name=None)[source]

resume the named node

Parameters:name – the name of the node
Returns:the dict of the node
start(name=None)[source]

start a node

Parameters:name – the unique node name
Returns:The dict representing the node
stop(name=None)[source]

stops the node with the given name

Parameters:name
Returns:The dict representing the node including updated status
suspend(name=None)[source]

suspends the node with the given name

Parameters:name – the name of the node
Returns:The dict representing the node
class cloudmesh.abstractclass.State.State(name=None)[source]
class cloudmesh.mongo.DataBaseDecorator.DatabaseAlter(**kwargs)[source]

The data base decorator utomatically replaces an entry in the database with the dictionary returned by a function.

It is added to a MongoDB collection. The location is determined from the values in the dictionary.

The name of the collection is determined from cloud and kind:

cloud-kind

In addition each entry in the collection has a name that must be unique in that collection.

IN most examples it is pest to separate the updload from the actual return class. This way we essentially provide two functions one that provide the dict and another that is responsible for the upload to the database.

Example:

cloudmesh.example.foo contains:

class Provider(object)

def entries(self):
return {
“cm”: {
“cloud”: “foo”, “kind”“: “entries”, “name”: “test01” “test”: “hello”}

} “cloud”: “foo”, “kind”“: “entries”, “name”: “test01” “test”: “hello”}

cloudmesh.example.bar contains:

class Provider(object)

def entries(self):
return {
“cloud”: “bar”, “kind”“: “entries”, “name”: “test01” “test”: “hello”}

cloudmesh.example.provider.foo:

from cloudmesh.example.foo import Provider as FooProvider from cloudmesh.example.foo import Provider as BarProvider

class Provider(object)

def __init__(self, provider):
if provider == “foo”:
provider = FooProvider()
elif provider == “bar”:
provider = BarProvider()

@DatabaseUpdate def entries(self):

provider.entries()

Separating the database and the dictionary creation allows the developer to implement different providers but only use one class with the same methods to interact for all providers with the database.

In the combined provider a find function to for example search for entries by name across collections could be implemented.

class cloudmesh.mongo.DataBaseDecorator.DatabaseUpdate(**kwargs)[source]

The data base decorator utomatically replaces an entry in the database with the dictionary returned by a function.

It is added to a MongoDB collection. The location is determined from the values in the dictionary.

The name of the collection is determined from cloud and kind:

cloud-kind

In addition each entry in the collection has a name that must be unique in that collection.

IN most examples it is pest to separate the updload from the actual return class. This way we essentially provide two functions one that provide the dict and another that is responsible for the upload to the database.

Example:

cloudmesh.example.foo contains:

class Provider(object)

def entries(self):
return {
“cm”: {
“cloud”: “foo”, “kind”“: “entries”, “name”: “test01” “test”: “hello”}

} “cloud”: “foo”, “kind”“: “entries”, “name”: “test01” “test”: “hello”}

cloudmesh.example.bar contains:

class Provider(object)

def entries(self):
return {
“cloud”: “bar”, “kind”“: “entries”, “name”: “test01” “test”: “hello”}

cloudmesh.example.provider.foo:

from cloudmesh.example.foo import Provider as FooProvider from cloudmesh.example.foo import Provider as BarProvider

class Provider(object)

def __init__(self, provider):
if provider == “foo”:
provider = FooProvider()
elif provider == “bar”:
provider = BarProvider()

@DatabaseUpdate def entries(self):

provider.entries()

Separating the database and the dictionary creation allows the developer to implement different providers but only use one class with the same methods to interact for all providers with the database.

In the combined provider a find function to for example search for entries by name across collections could be implemented.

class cloudmesh.data.api.storage.StorageProviderABC.StorageProviderABC[source]

Abstract Base Class for supported cloud providers.

delete(name)[source]

delete a file from the provider

Parameters:name – the cloud file entry being deleted
exists(name)[source]

if a file exists in the remote storage provider

Parameters:name – a file name to check
get(source, destination)[source]

get a file stored with this provider

Parameters:
  • source – the cloud file entry being retrieved
  • destination – download destination
Returns:

the downloaded cloud file binary

put(source)[source]

upload a file

Parameters:source – a CloudFile. todo
Returns:a CloudFile with resource information filled in
class cloudmesh.data.api.db.DBProviderABC.DBProviderABC[source]

Abstract Base Class for supported database providers.

add(cloud_file)[source]

add a new CloudFile to the database

Parameters:cloud_file – a CloudFile. todo
Returns:a CloudFile with resource information filled in
delete(cloud_file)[source]

delete a file from the database

Parameters:cloud_file – the cloud file entry being deleted
list_files()[source]

get a list of stored files

Returns:a list of CloudFiles
update(cloud_file)[source]

update a file

Parameters:cloud_file – the cloud file entry being updated
Returns:the updated CloudFile