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
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:
-
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:
-
authorized key management.
Class to manage authorized keys.
add a public key. :param pubkey: the filename to the public key :return:
load the keys from a path
Parameters: path – the filename (path) in which we find the keys Returns:
Removes the public key TODO: this method is not implemented :param pubkey: the filename of the public key :return:
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]¶
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.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.
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
-
class
cloudmesh.management.script.
SystemPath
[source]¶ Managing the System path in the .bashrc or .bash_profile files
-
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.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
-
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
-
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
-
-
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-kindIn 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-kindIn 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
-
-
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
-