cloudmesh_client.db package¶
Subpackages¶
Submodules¶
cloudmesh_client.db.CloudmeshDatabase module¶
-
class
cloudmesh_client.db.CloudmeshDatabase.
CloudmeshDatabase
[source]¶ Bases:
object
- def __init__(self, user=None):
self.__dict__ = self.__shared_state
- if self.initialized is None:
self.user = ConfigDict(“cloudmesh.yaml”)[“cloudmesh.profile.user”] self.filename = Config.path_expand(os.path.join(“~”, “.cloudmesh”, “cloudmesh.db”)) self.engine = create_engine(‘sqlite:///{}’.format(self.filename), echo=False) self.data = {“filename”: self.filename}
- if user is None:
- self.user = ConfigDict(“cloudmesh.yaml”)[“cloudmesh.profile.user”]
- else:
- self.user = user
CloudmeshDatabase.create() CloudmeshDatabase.create_tables() CloudmeshDatabase.start()
# # MODEL # @classmethod def create(cls):
# cls.clean() filename = Config.path_expand(os.path.join(“~”, “.cloudmesh”, “cloudmesh.db”)) if not os.path.isfile(filename):
cls.create_model()-
classmethod
add
(d, replace=True)[source]¶ o dotdict
if o is a dict an object of that type is created. It is checked if another object in the db already exists, if so the attributes of the object will be overwritten with the once in the database
provider, kind, category, name must be set to identify the object
o is in CloudmeshDatabase.Base
this is an object of a table has been created and is to be added. It is checked if another object in the db already exists. If so the attributes of the existing object will be updated.
-
classmethod
add_new
(d, replace=True)[source]¶ o dotdict
if o is a dict an object of that type is created. It is checked if another object in the db already exists, if so the attributes of the object will be overwritten with the once in the database
provider, kind, category, name must be set to identify the object
o is in CloudmeshDatabase.Base
this is an object of a table has been created and is to be added. It is checked if another object in the db already exists. If so the attributes of the existing object will be updated.
-
classmethod
clear
(kind, category, user=None)[source]¶ This method deletes all ‘kind’ entries from the cloudmesh database :param category: the category name
-
data
= {'filename': '/Users/fuwang/.cloudmesh/cloudmesh.db'}¶
-
classmethod
delete_
(table, **filter_args)[source]¶ Delete rows in the table matching
filter_args
Parameters: table (type) – the model class
-
engine
= Engine(sqlite:////Users/fuwang/.cloudmesh/cloudmesh.db)¶
-
classmethod
filter_by
(**kwargs)[source]¶ This method returns either a) an array of objects from the database in dict format, that match a particular kind.
If the kind is not specified vm is used. one of the arguments must be scope=”all”- a single entry that matches the first occurance of the query specified by kwargs, such as name=”vm_001”
Parameters: kwargs – the arguments to be matched, scope defines if all or just the first value is returned. first is default. Returns: a list of objects, if scope is first a single object in dotdict format is returned
-
classmethod
find
(**kwargs)[source]¶ This method returns either a) an array of objects from the database in dict format, that match a particular kind.
If the kind is not specified vm is used. one of the arguments must be scope=”all”- a single entry that matches the first occurance of the query specified by kwargs, such as name=”vm_001”
To select a value from a specific table: 1) identify the table of interest with
table()
>>> t = db.table(name='default')
- specify the ‘table’ keywork: >>> db.find(table=t, cm_id=42)
Parameters: kwargs – the arguments to be matched, scope defines if all or just the first value is returned. first is default. Returns: a list of objects, if scope is first a single object in dotdict format is returned
-
find_new
(**kwargs)[source]¶ This method returns either a) an array of objects from the database in dict format, that match a particular kind.
If the kind is not specified vm is used. one of the arguments must be scope=”all”- a single entry that matches the first occurance of the query specified by kwargs, such as name=”vm_001”
Parameters: kwargs – the arguments to be matched, scope defines if all or just the first value is returned. first is default. Returns: a list of objects, if scope is first a single object in dotdict format is returned
-
initialized
= None¶
-
classmethod
insert
(obj)[source]¶ Insert a row into the database
Parameters: obj – the object model to insert Returns: Return type:
-
classmethod
refresh
(kind, name, **kwargs)[source]¶ This method refreshes the local database with the live cloud details :param kind: :param name: :param kwargs: :return:
-
classmethod
refresh_new
(kind, name, **kwargs)[source]¶ This method refreshes the local database with the live cloud details :param kind: :param name: :param kwargs: :return:
-
classmethod
select
(table, **filter_args)[source]¶ Return rows of the table matching filter args.
This is a proxy for sqlalchemy’s
session.query(table).filter(**kwargs)
Parameters: table (type) – the model class Returns: all rows in the table matching **filter_args
-
session
= <sqlalchemy.orm.session.Session object>¶
-
classmethod
table
(provider=None, kind=None, name=None)[source]¶ Parameters: - category –
- kind –
Returns: the table class based on a given table name. In case the table does not exist an exception is thrown
-
tables
= [<class 'cloudmesh_client.db.general.model.SPECIFICATION'>, <class 'cloudmesh_client.db.general.model.WORKFLOW'>, <class 'cloudmesh_client.db.general.model.DEFAULT'>, <class 'cloudmesh_client.db.general.model.VAR'>, <class 'cloudmesh_client.db.general.model.LAUNCHER'>, <class 'cloudmesh_client.db.general.model.KEY'>, <class 'cloudmesh_client.db.general.model.GROUP'>, <class 'cloudmesh_client.db.general.model.RESERVATION'>, <class 'cloudmesh_client.db.general.model.SECGROUPRULE'>, <class 'cloudmesh_client.db.general.model.BATCHJOB'>, <class 'cloudmesh_client.db.general.model.CLUSTER'>, <class 'cloudmesh_client.db.openstack.model.IMAGE_OPENSTACK'>, <class 'cloudmesh_client.db.openstack.model.FLAVOR_OPENSTACK'>, <class 'cloudmesh_client.db.openstack.model.VM_OPENSTACK'>, <class 'cloudmesh_client.db.azure.model.IMAGE_AZURE'>, <class 'cloudmesh_client.db.azure.model.FLAVOR_AZURE'>, <class 'cloudmesh_client.db.azure.model.VM_AZURE'>, <class 'cloudmesh_client.db.azure.model.KEY_AZURE'>, <class 'cloudmesh_client.db.libcloud.model.IMAGE_LIBCLOUD'>, <class 'cloudmesh_client.db.libcloud.model.FLAVOR_LIBCLOUD'>, <class 'cloudmesh_client.db.libcloud.model.VM_LIBCLOUD'>]¶
-
classmethod
update_
(table, where=None, values=None)[source]¶ Updates a subset of rows in the table, filtered by
where
, setting tovalues
.Parameters:
-
user
= None¶
-
class
cloudmesh_client.db.CloudmeshDatabase.
CloudmeshMixin
[source]¶ Bases:
object
-
category
= Column(None, String(), table=None)¶
-
cm_id
= Column(None, Integer(), table=None, primary_key=True, nullable=False)¶
-
created_at
= Column(None, String(), table=None, default=ColumnDefault('2017-07-09 14:07:50'))¶
-
kind
= Column(None, String(), table=None)¶
-
label
= Column(None, String(), table=None)¶
-
name
= Column(None, String(), table=None)¶
-
project
= Column(None, String(), table=None)¶
-
provider
= Column(None, String(), table=None)¶
-
type
= Column(None, String(), table=None)¶
-
updated_at
= Column(None, String(), table=None, onupdate=ColumnDefault('2017-07-09 14:07:50'), default=ColumnDefault('2017-07-09 14:07:50'))¶
-
user
= Column(None, String(), table=None)¶
-