Package archipel :: Module archipelHypervisor :: Class TNArchipelHypervisor
[hide private]
[frames] | no frames]

Class TNArchipelHypervisor

source code

                                                              object --+    
                                                                       |    
                            archipelcore.archipelEntity.TNArchipelEntity --+
                                                                           |
                                                              object --+   |
                                                                       |   |
                           archipelLibvirtEntity.TNArchipelLibvirtEntity --+
                                                                           |
                                                              object --+   |
                                                                       |   |
                    archipelcore.archipelHookableEntity.TNHookableEntity --+
                                                                           |
                                                              object --+   |
                                                                       |   |
archipelcore.archipelAvatarControllableEntity.TNAvatarControllableEntity --+
                                                                           |
                                                              object --+   |
                                                                       |   |
                    archipelcore.archipelTaggableEntity.TNTaggableEntity --+
                                                                           |
                                                                          TNArchipelHypervisor

This class represents a Hypervisor XMPP Capable. This is a XMPP client that allows to alloc threaded instance of XMPP Virtual Machine, destroy already active XMPP VM, and remember which have been created.

Instance Methods [hide private]
 
__init__(self, jid, password, configuration, name, database_file="./database.sqlite3")
This is the constructor of the class.
source code
 
set_custom_vcard_information(self, vCard)
Put custom information in vCard
source code
 
get_custom_vcard_information(self, vCard)
Read custom info from vCard
source code
 
update_presence(self, origin=None, user_info=None, parameters=None, presence_msg=None)
Set the presence of the hypervisor.
source code
 
wake_up_virtual_machines_hook(self, origin=None, user_info=None, parameters=None)
Wake up virtual machines
source code
 
register_handlers(self)
This method overrides the defaut register_handler of the super class.
source code
 
unregister_handlers(self)
Unregister the handlers.
source code
 
init_vocabulary(self)
Initialize the base vocabulary.
source code
 
init_permissions(self)
Initialize the permissions.
source code
 
get_vms_from_local_db(self)
Get vms from local database
source code
 
manage_persistence(self, vms=[], existing_vms_entities=[])
After getting the status of local vms from central db (were they exist else where or not ?), we proceed to instanciate vms
source code
TNThreadedVirtualMachine
create_threaded_vm(self, jid, password, name, organizationInfo=None)
This method creates a threaded TNArchipelVirtualMachine, starts it and returns the Thread instance.
source code
string
generate_name(self)
Get a random name from the names file.
source code
TNArchipelVirtualMachine
get_vm_by_name(self, name)
Return the vm object by name.
source code
TNArchipelVirtualMachine
get_vm_by_uuid(self, uuid)
Return the vm object by uuid.
source code
TNArchipelVirtualMachine
get_vm_by_identifier(self, identifier)
Return the vm object by identifier.
source code
 
get_raw_libvirt_domains(self, only_persistant=True)
Returns a list of defined domain managed by libvirt that are not managed by Archipel.
source code
Boolean
libvirt_contains_domain_with_name(self, name, raise_error=False, name_check_level=ARCHIPEL_VM_NAME_CHECK_ALL)
Check if there is already a domain with the same name, managed, or not.
source code
 
hypervisor_on_domain_event(self, conn, dom, event, detail, opaque)
Trigger when a domain trigger vbent.
source code
 
process_iq(self, conn, iq)
This method is invoked when a ARCHIPEL_NS_HYPERVISOR_CONTROL IQ is received.
source code
TNArchipelVirtualMachine or TNThreadedVirtualMachine
alloc(self, requester=None, requested_name=None, start_thread=True, requested_uuid=None, definition=None, organization_info=None, name_check_level=ARCHIPEL_VM_NAME_CHECK_ALL)
Alloc a new XMPP entity.
source code
 
soft_alloc(self, jid, name, password, start=True, organization_info=None)
Perform light allocation (no registration, no subscription).
source code
 
free(self, jid)
Remove the XMPP container of VM with given jid.
source code
 
soft_free(self, identifier)
Perform light free (no removing of account, no unsubscription).
source code
 
clone(self, uuid, requester, wanted_name=None)
Clone a existing virtual machine.
source code
 
get_capabilities(self)
Return hypervisor's capabilities.
source code
 
get_nodeinfo(self)
Retur hypervisor's node informations
source code
 
migration_info(self)
Return the migration information
source code
xmpp.Protocol.Iq
iq_alloc(self, iq)
This method creates a threaded TNArchipelVirtualMachine with UUID given as payload in IQ and registers the hypervisor and the iq sender in the VM's roster.
source code
xmpp.Protocol.Message
message_alloc(self, msg)
Handle the allocation request message.
source code
xmpp.Protocol.Iq
iq_soft_alloc(self, iq)
Perform light allocation for handler migrating vm.
source code
xmpp.Protocol.Iq
iq_free(self, iq)
This method destroy a threaded TNArchipelVirtualMachine with UUID given as payload in IQ and remove it from the hypervisor roster.
source code
xmpp.Protocol.Message
message_free(self, msg)
Handle the free request message.
source code
 
iq_soft_free(self, iq)
Perform light free.
source code
xmpp.Protocol.Iq
iq_clone(self, iq)
Alloc a virtual as a clone of another.
source code
xmpp.Protocol.Message
message_clone(self, msg)
Handle the clone request message.
source code
xmpp.Protocol.Iq
iq_roster(self, iq)
Send the hypervisor roster content.
source code
xmpp.Protocol.Message
message_roster(self, msg)
Process the roster message request.
source code
xmpp.Protocol.Iq
iq_ip(self, iq)
Send the hypervisor IP address.
source code
xmpp.Protocol.Message
message_ip(self, msg)
Process the IP message request.
source code
xmpp.Protocol.Iq
iq_migration_info(self, iq)
Send the hypervisor IP address.
source code
xmpp.Protocol.Message
message_migration_info(self, msg)
Process the libvirt URI message request.
source code
xmpp.Protocol.Iq
iq_capabilities(self, iq)
Send the hypervisor capabilities.
source code
xmpp.Protocol.Message
message_capabilities(self, msg)
Process the capabilities message request.
source code
xmpp.Protocol.Iq
iq_nodeinfo(self, iq)
Send the hypervisor node informations.
source code
xmpp.Protocol.Message
message_nodeinfo(self, msg)
Process the node info message request.
source code
xmpp.Protocol.Iq
iq_manage(self, iq)
Manage an existing libvirt virtual machine
source code
xmpp.Protocol.Iq
iq_unmanage(self, iq)
Unanage an managed virtual machine
source code
 
iq_set_organization_info(self, iq)
Updates the VM organization info
source code
 
on_xmpp_loop_tick(self) source code
 
exit_proc(self)
Called when Archipel exits gracefully (by init script or system shutdown)
source code

Inherited from archipelcore.archipelEntity.TNArchipelEntity: add_jid, add_message_registrar_item, add_message_registrar_items, auth_xmpp, authorize, build_help, build_reply, change_presence, change_status, check_acp, check_perm, connect, connect_xmpp, did_receive_vcard, disconnect, filter_message, get_plugin, inband_registration, inband_unregistration, initialize_modules, iq_add_subscription, iq_get_permission, iq_list_permission, iq_remove_subscription, iq_set_permission, is_subscribed, loop, manage_vcard, on_new_admin_account_publication, process_inband_unregistration, process_message, process_permission_iq, process_presence, process_subscription_iq, push_change, recover_pubsubs, remove_jid, remove_pubsubs, send_update_vcard, set_vcard, shout, subscribe, unauthorize, unsubscribe

Inherited from archipelLibvirtEntity.TNArchipelLibvirtEntity: connect_libvirt, current_hypervisor, driver_version, is_hypervisor, libvirt_credential_callback, libvirt_version, manage_vcard_hook

Inherited from archipelcore.archipelHookableEntity.TNHookableEntity: create_hook, perform_hooks, register_hook, remove_hook, unregister_hook

Inherited from archipelcore.archipelAvatarControllableEntity.TNAvatarControllableEntity: b64avatar_from_filename, get_available_avatars, iq_get_available_avatars, iq_set_available_avatars, process_avatar_iq, set_avatar

Inherited from archipelcore.archipelTaggableEntity.TNTaggableEntity: did_clean_old_tags, iq_set_tags, process_tags_iq, set_tags

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, jid, password, configuration, name, database_file="./database.sqlite3")
(Constructor)

source code 

This is the constructor of the class.

Parameters:
  • jid (string) - the jid of the hypervisor
  • password (string) - the password associated to the JID
  • name (string) - the name of the hypervisor
  • database_file (string) - the sqlite3 file to store existing VM for persistance
Overrides: object.__init__

update_presence(self, origin=None, user_info=None, parameters=None, presence_msg=None)

source code 

Set the presence of the hypervisor.

Parameters:
  • origin (TNArchipelEntity) - the origin of the hook
  • user_info (object) - random user info
  • parameters (object) - runtime arguments

wake_up_virtual_machines_hook(self, origin=None, user_info=None, parameters=None)

source code 

Wake up virtual machines

Parameters:
  • origin (TNArchipelEntity) - the origin of the hook
  • user_info (object) - random user info
  • parameters (object) - runtime arguments

register_handlers(self)

source code 

This method overrides the defaut register_handler of the super class.

Overrides: archipelcore.archipelTaggableEntity.TNTaggableEntity.register_handlers

unregister_handlers(self)

source code 

Unregister the handlers.

Overrides: archipelcore.archipelTaggableEntity.TNTaggableEntity.unregister_handlers

init_vocabulary(self)

source code 

Initialize the base vocabulary.

Overrides: archipelcore.archipelEntity.TNArchipelEntity.init_vocabulary

init_permissions(self)

source code 

Initialize the permissions.

Overrides: archipelcore.archipelTaggableEntity.TNTaggableEntity.init_permissions

create_threaded_vm(self, jid, password, name, organizationInfo=None)

source code 

This method creates a threaded TNArchipelVirtualMachine, starts it and returns the Thread instance.

Parameters:
  • jid (xmpp.JID) - the JID of the TNArchipelVirtualMachine
  • password (string) - the password associated to the JID
  • name (String) - the Name of the VM
  • organizationInfo (Dict) - Dict containing locality, company name, company unit and owner
Returns: TNThreadedVirtualMachine
a TNThreadedVirtualMachine instance of the virtual machine

generate_name(self)

source code 

Get a random name from the names file.

Returns: string
a generated name

get_vm_by_name(self, name)

source code 

Return the vm object by name.

Parameters:
  • name (string) - the name of the vm
Returns: TNArchipelVirtualMachine
the virtual machine or None

get_vm_by_uuid(self, uuid)

source code 

Return the vm object by uuid.

Parameters:
  • uuid (string) - the uuid of the vm
Returns: TNArchipelVirtualMachine
the virtual machine or None

get_vm_by_identifier(self, identifier)

source code 

Return the vm object by identifier. Identifier can be the UUID of the name.

Parameters:
  • identifier (string) - the identifier of the vm
Returns: TNArchipelVirtualMachine
the virtual machine or None

libvirt_contains_domain_with_name(self, name, raise_error=False, name_check_level=ARCHIPEL_VM_NAME_CHECK_ALL)

source code 

Check if there is already a domain with the same name, managed, or not.

Parameters:
  • name (String) - the name to check
  • raise_error (bool) - If set to True, raise an error instead of returning a boolean
  • name_check_level (int) - Check all existing VM (including libvirt domain) or just internal VMs
Returns: Boolean
True if a domain has been found

hypervisor_on_domain_event(self, conn, dom, event, detail, opaque)

source code 

Trigger when a domain trigger vbent. We care only about RESUMED and SHUTDOWNED from MIGRATED.

process_iq(self, conn, iq)

source code 

This method is invoked when a ARCHIPEL_NS_HYPERVISOR_CONTROL IQ is received. It understands IQ of type:

  • alloc
  • free
  • rostervm
  • clone
  • ip
  • uri
  • capabilities
  • nodeinfo
  • manage
  • unmanage
  • setorginfo
  • soft_alloc
Parameters:
  • conn (xmpp.Dispatcher) - ths instance of the current connection that send the stanza
  • iq (xmpp.Protocol.Iq) - the received IQ

alloc(self, requester=None, requested_name=None, start_thread=True, requested_uuid=None, definition=None, organization_info=None, name_check_level=ARCHIPEL_VM_NAME_CHECK_ALL)

source code 

Alloc a new XMPP entity.

Parameters:
  • requester (xmpp.JID) - the JID of the migrated VM to alloc
  • requested_name (string) - the requested name for the VM if None, will be generated
  • start_thread (bool) - if True, start the thread for VM immediately (not the VM itself)
  • requested_uuid (string) - if set, the UUID to use as libvirt UUID and JID's node
  • definition (xmpp.Node) - Optional VM's definition (domain XML)
  • organization_info (dict) - Dict containing locality, company name, company unit and owner
  • name_check_level (integer) - Level of name checking when allocating the VM
Returns: TNArchipelVirtualMachine or TNThreadedVirtualMachine
TNArchipelVirtualMachine if start==True or TNThreadedVirtualMachine if start==False

soft_alloc(self, jid, name, password, start=True, organization_info=None)

source code 

Perform light allocation (no registration, no subscription).

Parameters:
  • jid (xmpp.JID) - the JID of the migrated VM to alloc
  • name (string) - the name of the migrated VM to alloc
  • password (string) - the password of the migrated VM to alloc

free(self, jid)

source code 

Remove the XMPP container of VM with given jid.

Parameters:
  • jid (xmpp.JID) - the JID of the VM to free

soft_free(self, identifier)

source code 

Perform light free (no removing of account, no unsubscription).

Parameters:
  • jid - the JID or the UUID of the migrated VM to free
  • identifier (xmpp.JID or UUID)

clone(self, uuid, requester, wanted_name=None)

source code 

Clone a existing virtual machine.

Parameters:
  • uuid (string) - the uuid of the VM to clone
  • requester (xmpp.JID) - JID of the requester

iq_alloc(self, iq)

source code 

This method creates a threaded TNArchipelVirtualMachine with UUID given as payload in IQ and registers the hypervisor and the iq sender in the VM's roster.

Parameters:
  • iq (xmpp.Protocol.Iq) - the sender request IQ
Returns: xmpp.Protocol.Iq
a ready-to-send IQ containing the results

message_alloc(self, msg)

source code 

Handle the allocation request message.

Parameters:
  • msg (xmpp.Protocol.Message) - the received message
Returns: xmpp.Protocol.Message
a ready to send Message containing the result of the action

iq_soft_alloc(self, iq)

source code 

Perform light allocation for handler migrating vm.

Parameters:
  • iq (xmpp.Protocol.Iq) - the sender request IQ
Returns: xmpp.Protocol.Iq
a ready-to-send IQ containing the results

iq_free(self, iq)

source code 

This method destroy a threaded TNArchipelVirtualMachine with UUID given as payload in IQ and remove it from the hypervisor roster.

Parameters:
  • iq (xmpp.Protocol.Iq) - the sender request IQ
Returns: xmpp.Protocol.Iq
a ready-to-send IQ containing the results

message_free(self, msg)

source code 

Handle the free request message.

Parameters:
  • msg (xmpp.Protocol.Message) - the received message
Returns: xmpp.Protocol.Message
a ready to send Message containing the result of the action

iq_clone(self, iq)

source code 

Alloc a virtual as a clone of another.

Parameters:
  • iq (xmpp.Protocol.Iq) - the received IQ
Returns: xmpp.Protocol.Iq
a ready to send IQ containing the result of the action

message_clone(self, msg)

source code 

Handle the clone request message.

Parameters:
  • msg (xmpp.Protocol.Message) - the received message
Returns: xmpp.Protocol.Message
a ready to send Message containing the result of the action

iq_roster(self, iq)

source code 

Send the hypervisor roster content.

Parameters:
  • iq (xmpp.Protocol.Iq) - the sender request IQ
Returns: xmpp.Protocol.Iq
a ready-to-send IQ containing the results

message_roster(self, msg)

source code 

Process the roster message request.

Parameters:
  • msg (xmpp.Protocol.Message) - the received message
Returns: xmpp.Protocol.Message
a ready to send Message containing the result of the action

iq_ip(self, iq)

source code 

Send the hypervisor IP address.

Parameters:
  • iq (xmpp.Protocol.Iq) - the sender request IQ
Returns: xmpp.Protocol.Iq
a ready-to-send IQ containing the results

message_ip(self, msg)

source code 

Process the IP message request.

Parameters:
  • msg (xmpp.Protocol.Message) - the received message
Returns: xmpp.Protocol.Message
a ready to send Message containing the result of the action

iq_migration_info(self, iq)

source code 

Send the hypervisor IP address.

Parameters:
  • iq (xmpp.Protocol.Iq) - the sender request IQ
Returns: xmpp.Protocol.Iq
a ready-to-send IQ containing the results

message_migration_info(self, msg)

source code 

Process the libvirt URI message request.

Parameters:
  • msg (xmpp.Protocol.Message) - the received message
Returns: xmpp.Protocol.Message
a ready to send Message containing the result of the action

iq_capabilities(self, iq)

source code 

Send the hypervisor capabilities.

Parameters:
  • iq (xmpp.Protocol.Iq) - the sender request IQ
Returns: xmpp.Protocol.Iq
a ready-to-send IQ containing the results

message_capabilities(self, msg)

source code 

Process the capabilities message request.

Parameters:
  • msg (xmpp.Protocol.Message) - the received message
Returns: xmpp.Protocol.Message
a ready to send Message containing the result of the action

iq_nodeinfo(self, iq)

source code 

Send the hypervisor node informations.

Parameters:
  • iq (xmpp.Protocol.Iq) - the sender request IQ
Returns: xmpp.Protocol.Iq
a ready-to-send IQ containing the results

message_nodeinfo(self, msg)

source code 

Process the node info message request.

Parameters:
  • msg (xmpp.Protocol.Message) - the received message
Returns: xmpp.Protocol.Message
a ready to send Message containing the result of the action

iq_manage(self, iq)

source code 

Manage an existing libvirt virtual machine

Parameters:
  • iq (xmpp.Protocol.Iq) - the sender request IQ
Returns: xmpp.Protocol.Iq
a ready-to-send IQ containing the results

iq_unmanage(self, iq)

source code 

Unanage an managed virtual machine

Parameters:
  • iq (xmpp.Protocol.Iq) - the sender request IQ
Returns: xmpp.Protocol.Iq
a ready-to-send IQ containing the results