git://git.onelab.eu
/
nepi.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
dac2434
)
last modifications for OMF6 before test
author
Julien Tribino
<julien.tribino@inria.fr>
Wed, 14 May 2014 08:59:02 +0000
(10:59 +0200)
committer
Julien Tribino
<julien.tribino@inria.fr>
Wed, 14 May 2014 08:59:02 +0000
(10:59 +0200)
src/nepi/resources/omf/application.py
patch
|
blob
|
history
src/nepi/resources/omf/interface.py
patch
|
blob
|
history
src/nepi/resources/omf/node.py
patch
|
blob
|
history
src/nepi/resources/omf/omf6_parser.py
patch
|
blob
|
history
diff --git
a/src/nepi/resources/omf/application.py
b/src/nepi/resources/omf/application.py
index
1ec831f
..
b66d2a5
100644
(file)
--- a/
src/nepi/resources/omf/application.py
+++ b/
src/nepi/resources/omf/application.py
@@
-24,7
+24,7
@@
from nepi.execution.resource import ResourceManager, clsinit_copy, \
ResourceState, reschedule_delay
from nepi.execution.attribute import Attribute, Flags
from nepi.resources.omf.omf_resource import ResourceGateway, OMFResource
ResourceState, reschedule_delay
from nepi.execution.attribute import Attribute, Flags
from nepi.resources.omf.omf_resource import ResourceGateway, OMFResource
-from nepi.resources.omf.node import OMFNode
+from nepi.resources.omf.node import OMFNode
, confirmation_counter
from nepi.resources.omf.omf_api_factory import OMFAPIFactory
from nepi.util import sshfuncs
from nepi.resources.omf.omf_api_factory import OMFAPIFactory
from nepi.util import sshfuncs
@@
-92,7
+92,10
@@
class OMFApplication(OMFResource):
self._omf_api = None
self._topic_app = None
self.create_id = None
self._omf_api = None
self._topic_app = None
self.create_id = None
+ self._create_cnt = 0
+ self._start_cnt = 0
self.release_id = None
self.release_id = None
+ self._release_cnt = 0
self.add_set_hook()
self.add_set_hook()
@@
-213,12
+216,18
@@
class OMFApplication(OMFResource):
self.create_id = os.urandom(16).encode('hex')
self._omf_api.frcp_create( self.create_id, self.node.get('hostname'), "application", props = props)
self.create_id = os.urandom(16).encode('hex')
self._omf_api.frcp_create( self.create_id, self.node.get('hostname'), "application", props = props)
-
+
+ if self._create_cnt > confirmation_counter:
+ msg = "Couldn't retrieve the confirmation of the creation"
+ self.error(msg)
+ raise RuntimeError, msg
+
uid = self.check_deploy(self.create_id)
if not uid:
uid = self.check_deploy(self.create_id)
if not uid:
+ self._create_cnt +=1
self.ec.schedule(reschedule_delay, self.deploy)
return
self.ec.schedule(reschedule_delay, self.deploy)
return
-
+
self._topic_app = uid
self._omf_api.enroll_topic(self._topic_app)
self._topic_app = uid
self._omf_api.enroll_topic(self._topic_app)
@@
-255,18
+264,35
@@
class OMFApplication(OMFResource):
self.get('args'), self.get('path'), self.get('env'))
else:
#For OMF 6
self.get('args'), self.get('path'), self.get('env'))
else:
#For OMF 6
- props = {}
- props['state'] = "running"
+ if self._start_cnt == 0:
+ props = {}
+ props['state'] = "running"
- guards = {}
- guards['type'] = "application"
- guards['name'] = self.get('command')
+ guards = {}
+ guards['type'] = "application"
+ guards['name'] = self.get('command')
+
+ self._omf_api.frcp_configure(self._topic_app, props = props, guards = guards )
- self._omf_api.frcp_configure(self._topic_app, props = props, guards = guards )
+ if self._start_cnt > confirmation_counter:
+ msg = "Couldn't retrieve the confirmation that the application started"
+ self.error(msg)
+ raise RuntimeError, msg
+ res = self.check_start(self._topic_app)
+ if not res:
+ self._start_cnt +=1
+ self.ec.schedule(reschedule_delay, self.start)
+ return
super(OMFApplication, self).do_start()
super(OMFApplication, self).do_start()
+ def check_start(self, uid):
+ res = self._omf_api.check_mailbox("started", uid)
+ if res :
+ return True
+ return False
+
def do_stop(self):
""" Stop the RM. It means : Send Xmpp Message Using OMF protocol to
kill the application.
def do_stop(self):
""" Stop the RM. It means : Send Xmpp Message Using OMF protocol to
kill the application.
@@
-292,10
+318,15
@@
class OMFApplication(OMFResource):
self.release_id = os.urandom(16).encode('hex')
self._omf_api.frcp_release( self.release_id, self.node.get('hostname'),self._topic_app, res_id=self._topic_app)
self.release_id = os.urandom(16).encode('hex')
self._omf_api.frcp_release( self.release_id, self.node.get('hostname'),self._topic_app, res_id=self._topic_app)
- cid = self.check_release(self.release_id)
- if not cid:
- self.ec.schedule(reschedule_delay, self.release)
- return
+ if self._release_cnt < confirmation_counter:
+ cid = self.check_release(self.release_id)
+ if not cid:
+ self._release_cnt +=1
+ self.ec.schedule(reschedule_delay, self.release)
+ return
+ else:
+ msg = "Couldn't retrieve the confirmation of the release"
+ self.error(msg)
if self._omf_api:
OMFAPIFactory.release_api(self.get('version'),
if self._omf_api:
OMFAPIFactory.release_api(self.get('version'),
diff --git
a/src/nepi/resources/omf/interface.py
b/src/nepi/resources/omf/interface.py
index
7926fb6
..
c487327
100644
(file)
--- a/
src/nepi/resources/omf/interface.py
+++ b/
src/nepi/resources/omf/interface.py
@@
-23,7
+23,7
@@
from nepi.execution.resource import ResourceManager, clsinit_copy, \
ResourceState, reschedule_delay
from nepi.execution.attribute import Attribute, Flags
ResourceState, reschedule_delay
from nepi.execution.attribute import Attribute, Flags
-from nepi.resources.omf.node import OMFNode
+from nepi.resources.omf.node import OMFNode
, confirmation_counter
from nepi.resources.omf.omf_resource import ResourceGateway, OMFResource
from nepi.resources.omf.channel import OMFChannel
from nepi.resources.omf.omf_api_factory import OMFAPIFactory
from nepi.resources.omf.omf_resource import ResourceGateway, OMFResource
from nepi.resources.omf.channel import OMFChannel
from nepi.resources.omf.omf_api_factory import OMFAPIFactory
@@
-81,7
+81,9
@@
class OMFWifiInterface(OMFResource):
self._alias = self.get('alias')
self.create_id = None
self._alias = self.get('alias')
self.create_id = None
+ self._create_cnt = 0
self.release_id = None
self.release_id = None
+ self._release_cnt = 0
self._topic_iface = None
self._omf_api = None
self._type = ""
self._topic_iface = None
self._omf_api = None
self._type = ""
@@
-164,10
+166,16
@@
class OMFWifiInterface(OMFResource):
if self.state < ResourceState.PROVISIONED:
if self._conf == False:
self._conf = self.configure_iface()
if self.state < ResourceState.PROVISIONED:
if self._conf == False:
self._conf = self.configure_iface()
+ res = self._conf
if self._conf == True:
if self._conf == True:
- self.configure_ip()
-
+
res =
self.configure_ip()
+ return res
+ def check_deploy(self, cid):
+ uid = self._omf_api.check_mailbox("create", cid)
+ if uid :
+ return uid
+ return False
def do_deploy(self):
""" Deploy the RM. It means : Get the xmpp client and send messages
def do_deploy(self):
""" Deploy the RM. It means : Get the xmpp client and send messages
@@
-216,11
+224,12
@@
class OMFWifiInterface(OMFResource):
self.set('type',self.get('hw_mode'))
if self.get('version') == "5":
self.set('type',self.get('hw_mode'))
if self.get('version') == "5":
- self.configure_on_omf5()
+
res =
self.configure_on_omf5()
else :
else :
- self.configure_on_omf6()
+
res =
self.configure_on_omf6()
- super(OMFWifiInterface, self).do_deploy()
+ if res:
+ super(OMFWifiInterface, self).do_deploy()
def configure_on_omf6(self):
if not self.create_id :
def configure_on_omf6(self):
if not self.create_id :
@@
-241,24
+250,21
@@
class OMFWifiInterface(OMFResource):
self.create_id = os.urandom(16).encode('hex')
self._omf_api.frcp_create( self.create_id, self.node.get('hostname'), "wlan", props = props)
self.create_id = os.urandom(16).encode('hex')
self._omf_api.frcp_create( self.create_id, self.node.get('hostname'), "wlan", props = props)
- self.check_deploy(self.create_id)
- self._omf_api.enroll_topic(self._topic_iface)
-
- def check_deploy(self, cid):
- delay = 1.0
- for i in xrange(10):
- uid = self._omf_api.check_mailbox("create", cid)
- if uid:
- self._topic_iface = uid
- break
- else:
- time.sleep(delay)
- delay = delay * 1.5
- else:
+ if self._create_cnt > confirmation_counter:
msg = "Couldn't retrieve the confirmation of the creation"
self.error(msg)
raise RuntimeError, msg
msg = "Couldn't retrieve the confirmation of the creation"
self.error(msg)
raise RuntimeError, msg
+ uid = self.check_deploy(self.create_id)
+ if not uid:
+ self._create_cnt +=1
+ self.ec.schedule(reschedule_delay, self.deploy)
+ return False
+
+ self._topic_iface = uid
+ self._omf_api.enroll_topic(self._topic_iface)
+ return True
+
def check_release(self, cid):
res = self._omf_api.check_mailbox("release", cid)
if res :
def check_release(self, cid):
res = self._omf_api.check_mailbox("release", cid)
if res :
@@
-274,10
+280,15
@@
class OMFWifiInterface(OMFResource):
self.release_id = os.urandom(16).encode('hex')
self._omf_api.frcp_release( self.release_id, self.node.get('hostname'),self._topic_iface, res_id=self._topic_iface)
self.release_id = os.urandom(16).encode('hex')
self._omf_api.frcp_release( self.release_id, self.node.get('hostname'),self._topic_iface, res_id=self._topic_iface)
- cid = self.check_release(self.release_id)
- if not cid:
- self.ec.schedule(reschedule_delay, self.release)
- return
+ if self._release_cnt < confirmation_counter:
+ cid = self.check_release(self.release_id)
+ if not cid:
+ self._release_cnt +=1
+ self.ec.schedule(reschedule_delay, self.release)
+ return
+ else:
+ msg = "Couldn't retrieve the confirmation of the release"
+ self.error(msg)
if self._omf_api:
OMFAPIFactory.release_api(self.get('version'),
if self._omf_api:
OMFAPIFactory.release_api(self.get('version'),
diff --git
a/src/nepi/resources/omf/node.py
b/src/nepi/resources/omf/node.py
index
6658f62
..
166249b
100644
(file)
--- a/
src/nepi/resources/omf/node.py
+++ b/
src/nepi/resources/omf/node.py
@@
-26,6
+26,8
@@
from nepi.resources.omf.omf_api_factory import OMFAPIFactory
import time
import time
+confirmation_counter = 600
+
@clsinit_copy
class OMFNode(OMFResource):
"""
@clsinit_copy
class OMFNode(OMFResource):
"""
@@
-141,6
+143,14
@@
class OMFNode(OMFResource):
self.ec.schedule(reschedule_delay, self.release)
return
self.ec.schedule(reschedule_delay, self.release)
return
+ from nepi.resources.omf.interface import OMFWifiInterface
+ rm_list = self.get_connected(OMFWifiInterface.get_rtype())
+ if rm_list:
+ for rm in rm_list:
+ if rm.state < ResourceState.RELEASED:
+ self.ec.schedule(reschedule_delay, self.release)
+ return
+
if self._omf_api:
if self.get('version') == "5":
self._omf_api.release(self.get('hostname'))
if self._omf_api:
if self.get('version') == "5":
self._omf_api.release(self.get('hostname'))
diff --git
a/src/nepi/resources/omf/omf6_parser.py
b/src/nepi/resources/omf/omf6_parser.py
index
4142029
..
6039e63
100644
(file)
--- a/
src/nepi/resources/omf/omf6_parser.py
+++ b/
src/nepi/resources/omf/omf6_parser.py
@@
-56,10
+56,8
@@
class OMF6Parser(Logger):
def init_mailbox(self):
self.mailbox['create'] = []
def init_mailbox(self):
self.mailbox['create'] = []
- self.mailbox['configure'] = []
- self.mailbox['request'] = []
+ self.mailbox['started'] = []
self.mailbox['release'] = []
self.mailbox['release'] = []
- self.mailbox['inform'] = []
def _check_for_tag(self, root, namespaces, tag):
""" Check if an element markup is in the ElementTree
def _check_for_tag(self, root, namespaces, tag):
""" Check if an element markup is in the ElementTree
@@
-159,11
+157,15
@@
class OMF6Parser(Logger):
def _inform_status(self, root, namespaces):
props = self._check_for_props(root, namespaces)
def _inform_status(self, root, namespaces):
props = self._check_for_props(root, namespaces)
+ uid = self._check_for_tag(root, namespaces, "uid")
msg = "STATUS -- "
for elt in props.keys():
ns, tag = elt.split('}')
if tag == "it":
msg = msg + "membership : " + props[elt]+" -- "
msg = "STATUS -- "
for elt in props.keys():
ns, tag = elt.split('}')
if tag == "it":
msg = msg + "membership : " + props[elt]+" -- "
+ elif tag == "event":
+ self.mailbox['started'].append(uid)
+ msg = msg + "event : " + props[elt]+" -- "
else:
msg = msg + tag +" : " + props[elt]+" -- "
msg = msg + " STATUS "
else:
msg = msg + tag +" : " + props[elt]+" -- "
msg = msg + " STATUS "
@@
-218,12
+220,11
@@
class OMF6Parser(Logger):
if binary == attr:
self.mailbox[itype].remove(res)
return uid
if binary == attr:
self.mailbox[itype].remove(res)
return uid
- el
if itype == "release"
:
+ el
se
:
for res in self.mailbox[itype]:
if attr == res:
self.mailbox[itype].remove(res)
return res
for res in self.mailbox[itype]:
if attr == res:
self.mailbox[itype].remove(res)
return res
-
def handle(self, iq):
def handle(self, iq):