self._port = port
self._password = password
self._hostnames = []
- self._xmpp_root = xmpp_root or "OMF"
+ self._xmpp_root = xmpp_root or "OMF_5.4"
self._logger = logging.getLogger("nepi.testbeds.omf")
def _enroll_experiment(self):
xmpp_node = self._exp_session_id
self._client.create(xmpp_node)
+ #print "Create experiment sesion id topics !!"
self._client.subscribe(xmpp_node)
+ #print "Subscribe to experiment sesion id topics !!"
+
address = "/%s/%s/%s/%s" % (self._host, self._xmpp_root, self._slice, self._user)
+ print address
payload = self._message.newexpfunction(self._user, address)
slice_sid = "/%s/%s" % (self._xmpp_root, self._slice)
self._client.publish(payload, slice_sid)
import sleekxmpp
from sleekxmpp.exceptions import IqError, IqTimeout
import traceback
+import xml.etree.ElementTree as ET
class OMFClient(sleekxmpp.ClientXMPP):
def __init__(self, jid, password):
self._logger.error('Could not unsubscribe %s from node %s\ntraceback:\n%s' \
% (self.boundjid.bare, node, error))
+ def _check_for_tag(self, treeroot, namespaces, tag):
+ for element in treeroot.iter(namespaces+tag):
+ if element.text:
+ return element
+ else :
+ return None
+
+ def _check_app_event(self, treeroot, namespaces):
+ message = self._check_for_tag(treeroot, namespaces, 'MESSAGE')
+ if message is not None :
+ target = self._check_for_tag(treeroot, namespaces, 'TARGET')
+ if target is not None :
+ self._logger.info(target.text + ": APP_EVENT: " + message.text)
+
+ def _check_configure(self, treeroot, namespaces, status):
+ for message in treeroot.iter(namespaces + status):
+ reason = self._check_for_tag(treeroot, namespaces, 'REASON')
+ if reason is not None and reason.text!="ENROLLED" :
+ target = self._check_for_tag(treeroot, namespaces, 'TARGET')
+ if target is not None :
+ path = self._check_for_tag(treeroot, namespaces, 'PATH')
+ if path is not None :
+ self._logger.debug(target.text+ ": " +reason.text+ ": " +path.text)
+ else :
+ self._logger.debug(target.text+ ": " +reason.text )
+
def handle_omf_message(self, iq):
+ namespaces = "{http://jabber.org/protocol/pubsub}"
for i in iq['pubsub_event']['items']:
+ root = ET.fromstring(str(i))
+ self._check_app_event(root, namespaces)
+ self._check_configure(root, namespaces, "OK")
+ self._check_configure(root, namespaces, "ERROR")
#self._logger.debug(i)
- print ""
+
+
+#<item xmlns="http://jabber.org/protocol/pubsub#event" id="WlO9GaRXpy6ayRB"><omf-message xmlns="http://jabber.org/protocol/pubsub"><OK id="omf-payload"><EXPID>default_slice-2012-12-20t12.07.02+02.00</EXPID><MESSAGE /><REASON>CONFIGURED</REASON><TARGET>omf.plexus.wlab17</TARGET><SLICEID>default_slice</SLICEID><VALUE>cvlcmode</VALUE><PATH>net/w0/essid</PATH></OK></omf-message></item>
+
+#<item xmlns="http://jabber.org/protocol/pubsub#event" id="nL1uzyXRMe86jEV"><omf-message xmlns="http://jabber.org/protocol/pubsub"><ERROR id="omf-payload"><EXPID>default_slice-2012-12-20t12.07.02+02.00</EXPID><MESSAGE /><REASON>FAILED_CONFIGURE</REASON><TARGET>omf.plexus.wlab17</TARGET><SLICEID>default_slice</SLICEID><VALUE>g</VALUE><PATH>net/w0/type</PATH></ERROR></omf-message></item>
#<item xmlns="http://jabber.org/protocol/pubsub#event" id="dFbv6WRlMuKghJ0"><omf-message xmlns="http://jabber.org/protocol/pubsub"><LOGGING id="'omf-payload'"><LEVEL>2</LEVEL><SLICEID>default_slice</SLICEID><LOGGER>nodeHandler::NodeHandler</LOGGER><EXPID>default_slice-2012-09-28t16.22.17+02.00</EXPID><LEVEL_NAME>INFO</LEVEL_NAME><DATA>OMF Experiment Controller 5.4 (git 529a626)</DATA></LOGGING></omf-message></item>