Package archipelcore :: Module scriptutils
[hide private]
[frames] | no frames]

Module scriptutils

source code

Functions [hide private]
 
success(msg)
Print a standardized success message
source code
 
error(msg, exit=True, code=1)
Print a standardized success message
source code
 
msg(msg, exit=True)
Print a standardized neutral message
source code
 
warn(msg)
Print a standardized warning message
source code
xmpp.Client
connect(jid, password)
Perform an XMPP connection/auth.
source code
xmpp.Client
initialize(options, fill_pubsubserver=True)
Lazy initialization according to OptionParser options.
source code
 
check_valid_jid(jid, bare=True)
Check if given JID is a valid JID Exit on any error
source code
archipelcore.TNPubSubNode
get_pubsub(xmppclient, pubsubserver, nodename, wait=True)
Returns a ready to use pubsub for further operations
source code
Boolean
publish_item(xmppclient, pubsubserver, nodename, item, wait=True)
Publish a new item to the pubsub node
source code
Boolean
retract_item(xmppclient, pubsubserver, nodename, refID, wait=True)
Retract an item from the pubsub node
source code
 
create_pubsub(xmppclient, pubsubserver, nodename, configuration)
Create a pubsub node
source code
 
configure_pubsub(xmppclient, pubsubserver, nodename, key, value)
Configure a specific token for the pubsub
source code
 
delete_pubsub(xmppclient, pubsubserver, nodename)
Delete a pubsub node
source code
xmpp.Node
send_acp(xmppclient, dest_jid, iq_type, query_ns, action, acp_parameters={}, acp_payload=[], debug=False)
Simplify the generation of an ACP.
source code
xmpp.Node
send_raw_acp(xmppclient, dest_jid, raw_acp_string, debug=False)
Take a string, convert it to a valid IQ, and send it.
source code
String
xml_print(xml_node)
This function will prettify an XML node
source code
Variables [hide private]
  __package__ = 'archipelcore'
Function Details [hide private]

success(msg)

source code 

Print a standardized success message

Parameters:
  • msg (String) - the message to print

error(msg, exit=True, code=1)

source code 

Print a standardized success message

Parameters:
  • msg (String) - the message to print
  • exit (Boolean) - if True, exit after print
  • code (int) - the error code

msg(msg, exit=True)

source code 

Print a standardized neutral message

Parameters:
  • msg (String) - the message to print
  • exit (Boolean) - if True, exit after print

warn(msg)

source code 

Print a standardized warning message

Parameters:
  • msg (String) - the message to print

connect(jid, password)

source code 

Perform an XMPP connection/auth. Exit on any error

Parameters:
  • jid (xmpp.JID) - the JID to use to connect
  • password (string) - the password
Returns: xmpp.Client
a ready to use client

initialize(options, fill_pubsubserver=True)

source code 

Lazy initialization according to OptionParser options. must contains options.jid, options.password and options.pubsubserver

Parameters:
  • options (parsed arguments) - options from OptionParser.
Returns: xmpp.Client
ready to use XMPP client

check_valid_jid(jid, bare=True)

source code 

Check if given JID is a valid JID Exit on any error

Parameters:
  • jid (xmpp.JID) - the JID to check
  • bare (Boolean) - if True, JID is considered as valid only if it's bare JID

get_pubsub(xmppclient, pubsubserver, nodename, wait=True)

source code 

Returns a ready to use pubsub for further operations

Parameters:
  • xmppclient (xmpp.Client) - a connected/authenticated xmpp client
  • pubsubserver (String) - pubsub server.
  • nodename (String) - the name of the node to create
Returns: archipelcore.TNPubSubNode
the pubsub

publish_item(xmppclient, pubsubserver, nodename, item, wait=True)

source code 

Publish a new item to the pubsub node

Parameters:
  • xmppclient (xmpp.Client) - a connected/authenticated xmpp client
  • pubsubserver (String) - pubsub server.
  • nodename (String) - the target node name
  • item (xmpp.Node) - the item to add
Returns: Boolean
True in case of success

retract_item(xmppclient, pubsubserver, nodename, refID, wait=True)

source code 

Retract an item from the pubsub node

Parameters:
  • xmppclient (xmpp.Client) - a connected/authenticated xmpp client
  • pubsubserver (String) - pubsub server.
  • nodename (String) - the target node name
  • refID (String) - the item ID
Returns: Boolean
True in case of success

create_pubsub(xmppclient, pubsubserver, nodename, configuration)

source code 

Create a pubsub node

Parameters:
  • xmppclient (xmpp.Client) - a connected/authenticated xmpp client
  • pubsub (String) - pubsub server.
  • nodename (String) - the name of the node to create
  • configuration (dict) - pubsub configuration

configure_pubsub(xmppclient, pubsubserver, nodename, key, value)

source code 

Configure a specific token for the pubsub

Parameters:
  • xmppclient (xmpp.Client) - a connected/authenticated xmpp client
  • pubsub (String) - pubsub server.
  • nodename (String) - the name of the node to create
  • key (string) - the config token name
  • value (string) - the value

delete_pubsub(xmppclient, pubsubserver, nodename)

source code 

Delete a pubsub node

Parameters:
  • xmppclient (xmpp.Client) - a connected/authenticated xmpp client
  • pubsub (String) - pubsub server.
  • nodename (String) - the name of the node to delete

send_acp(xmppclient, dest_jid, iq_type, query_ns, action, acp_parameters={}, acp_payload=[], debug=False)

source code 

Simplify the generation of an ACP.

Parameters:
  • xmppclient (xmpp.Client) - a connected/authenticated xmpp client
  • dest_jid (xmpp.JID) - the target entity
  • iq_type (String) - the IQ type (get or set)
  • query_ns (String) - the namespace of the query (i.e. archipel:hypervisor:control)
  • action (String) - the Archipel action (i.e. alloc)
  • acp_parameters (Dict) - any additional acp parameters (i.e. {"name": "my new VM"})
  • acp_payload (xmpp.Node) - any additional information that should be appended to the <archipel/> tag
Returns: xmpp.Node
the answer stanza

send_raw_acp(xmppclient, dest_jid, raw_acp_string, debug=False)

source code 

Take a string, convert it to a valid IQ, and send it.

Parameters:
  • xmppclient (xmpp.Client) - a connected/authenticated xmpp client
  • dest_jid (xmpp.JID) - the target entity
  • raw_acp_string (String) - the IQ to send
Returns: xmpp.Node
the answer stanza

xml_print(xml_node)

source code 

This function will prettify an XML node

Parameters:
  • xml_node (xmpp.Node) - the node to format
Returns: String
a pretiffied XML string