Package enomalism2 :: Module model
[hide private]

Module model

The central location of all Enomalism SQLObject abstractions.


Requires:
Classes [hide private]
  UUIDSearch
UUIDSearch provides utility methods that are available to some Enomalism SQLObject classes.
  PermSelect
A query select utility class that will only return the objects with the specified permissions, as well as the specified filter if provided.
Functions [hide private]
None
register_hvtype(name, value)
Register a hypervisor type using the specified name-value pair.
Function
hook(theclass, themethod)
This hook re-wraps ANY method of any class to overload it.
 
hook_invoke(*args, **kw)
This function is deprecated.
Boolean
admin_user_exists(installer=None)
Check if the admin user exists while logging the actions taken if the log parameter is provided.
Boolean
admin_group_exists(installer=None)
Check if the admin group exists while logging the actions taken if the log parameter is provided.
Boolean
local_machine_exists(installer=None)
Check if the local machine exists while logging the actions taken if the log parameter is provided.
enomalism2.machine.Machine
get_local_machine()
Return the local machine on which Enomalism is running.
enomalism2.identity.EnomalismUser
create_default_users(installer)
Create the admin user while logging the actions taken if the log parameter is provided.
enomalism2.identity.EnomalismGroup
create_admin_group(installer=None)
Create the admin group while logging the actions taken if the log parameter is provided.
enomalism2.machine.Machine
create_local_machine(installer=None)
Create the local machine and create the hypervisors while logging the actions taken if the log parameter is provided.
List
get_hypervisors_by_name(name)
Return the a list of hypervisors that have the specified name.
List
get_hypervisors(machine, installer=None)
Determine the vertulization capabilities of the host.
Integer
default_cluster_exists(installer=None)
Return true if the default cluster exists.
enomalism2.cluster.Cluster
create_default_cluster(installer=None)
Create the default cluster.
 
restore_machines_state()
Tuple
guess_parent(m)
Guess the parent of the specified machine.
Variables [hide private]
turbogears.database.PackageHub hub = PackageHub('enomalism2')
The Enomalism database connection hub.
turbogears.database.PackageHub __connection__ = PackageHub('enomalism2')
The actual database connection.
Dictionary hooks = {}
A dictionary containing hooks.
Dictionary actions = {}
A dictionary containing actions.
Function Details [hide private]

register_hvtype(name, value)

 

Register a hypervisor type using the specified name-value pair.

Example usage:

>>> from enomalism2 import model
>>> model.register_hvtype('qemu',qemu_hvm())
Parameters:
  • name (String) - The name of the hypervisor.
  • value (Object) - The hypervisor object.
Returns: None
None
Raises:
  • None - No exceptions are raised by this method.

Status: Stable

hook(theclass, themethod)

 

This hook re-wraps ANY method of any class to overload it.

The hook is used rather than just a simple function replacement so that we can build function graphs and stuff later on.

What we do is take a "decorator" function and replace the current call with one that replaces the original with a new one that passes the original function, and THEN the *arg,**kw parameters. This way, the new "decorator" can decide how to use the results from the previous call (whatever it might be). What is really neat is this gives us the ability to hook on the "pre" and "post" positions, to use the old enomalism vernacular. This means you can both post process, and pre-process the results from the original call! It also means you can fit any triggers into the same call as well.

Example usage:

>>> from enomalism2 import model
>>> @model.hook(model.machine, model.machine.set_machine_name)
>>> def hook_set_machine_name(fn,self,name):
...     print 'hook_set_machine_name'
...     return fn(self,name)
Parameters:
  • theclass (Class) - The class that you want to hook into
  • themethod (Method) - The method you are modifying.
Returns: Function
The decorator.
Raises:
  • None - No exceptions are raised by this method.

Status: Stable

hook_invoke(*args, **kw)

 

This function is deprecated.

Status: Deprecated

admin_user_exists(installer=None)

 

Check if the admin user exists while logging the actions taken if the log parameter is provided.

Parameters:
  • log (List) - A reference to a log list.
  • err (List) - A reference to a error log list.
Returns: Boolean
True if the administrator user exists.

admin_group_exists(installer=None)

 

Check if the admin group exists while logging the actions taken if the log parameter is provided.

Parameters:
  • log (List) - A reference to a log list.
  • err (List) - A reference to an error log list.
Returns: Boolean
True if the administrator group exists.

local_machine_exists(installer=None)

 

Check if the local machine exists while logging the actions taken if the log parameter is provided.

Parameters:
  • log (List) - A reference to a log list.
  • err (List) - A reference to an error log list.
Returns: Boolean
True if the local machine exists.

get_local_machine()

 

Return the local machine on which Enomalism is running.

Returns: enomalism2.machine.Machine
The local machine.

create_default_users(installer)

 

Create the admin user while logging the actions taken if the log parameter is provided.

Parameters:
  • log (List) - A reference to a log list.
  • err (List) - A reference to an error log list.
Returns: enomalism2.identity.EnomalismUser
The newly created user.

create_admin_group(installer=None)

 

Create the admin group while logging the actions taken if the log parameter is provided.

Parameters:
  • log (List) - A reference to a log list.
  • err (List) - A reference to an error log list.
Returns: enomalism2.identity.EnomalismGroup
The newly created group.

create_local_machine(installer=None)

 

Create the local machine and create the hypervisors while logging the actions taken if the log parameter is provided.

Parameters:
  • log (List) - A reference to a log list.
  • err (List) - A reference to an error log list.
Returns: enomalism2.machine.Machine
The newly created machine instance.

get_hypervisors_by_name(name)

 

Return the a list of hypervisors that have the specified name.

Parameters:
  • name (String) - The name of the hypervisors to find.
Returns: List
A list of enomalism2.hypervisor.Hypervisor instances.

get_hypervisors(machine, installer=None)

 

Determine the vertulization capabilities of the host. This is done by calling enomalism2.utilities.find_libvirt_services. For each libvert service that is found, a new hypervisor instance is created while logging the actions taken if the log parameter is provided.

Parameters:
  • log (List) - A reference to a log list.
  • err (List) - A reference to an error log list.
Returns: List
A list of newly created hypervisor instances.

default_cluster_exists(installer=None)

 

Return true if the default cluster exists.

Parameters:
  • log (List) - The installation log.
  • err (List) - The installation error log.
Returns: Integer
True if the default cluster exists.

create_default_cluster(installer=None)

 

Create the default cluster.

Parameters:
  • log (List) - The installation log.
  • err (List) - The installation error log.
Returns: enomalism2.cluster.Cluster
The default cluster.

guess_parent(m)

 

Guess the parent of the specified machine. First, we fetch the specified machine from the database. If the specified machine has a parent, we return a tuple containing the parent uuid and REST URL. If the machine has no parent, a tuple containing it's uuid and REST URL is returned.

Example usage:

>>> enomalism2.REST.guess_parent(enomalism2.machine.machine())
Parameters:
Returns: Tuple
A tuple containing the uuid and REST URL of the parent.
Raises:
  • None - No exceptions are raised by this function.

Status: Stable