+ def do_deploy(self):
+ """ Deploy the RM. It means nothing special for an application
+ for now (later it will be upload sources, ...)
+ It becomes DEPLOYED after the topic for the application has been created
+
+ """
+ if not self.node or self.node.state < ResourceState.READY:
+ self.debug("---- RESCHEDULING DEPLOY ---- node state %s "
+ % self.node.state )
+ self.ec.schedule(reschedule_delay, self.deploy)
+ return
+
+ self._init_command()
+
+ self.set('xmppUser',self.node.get('xmppUser'))
+ self.set('xmppServer',self.node.get('xmppServer'))
+ self.set('xmppPort',self.node.get('xmppPort'))
+ self.set('xmppPassword',self.node.get('xmppPassword'))
+ self.set('version',self.node.get('version'))
+
+ if not self.get('xmppServer'):
+ msg = "XmppServer is not initialzed. XMPP Connections impossible"
+ self.error(msg)
+ raise RuntimeError, msg
+
+ if not (self.get('xmppUser') or self.get('xmppPort')
+ or self.get('xmppPassword')):
+ msg = "Credentials are not all initialzed. Default values will be used"
+ self.warn(msg)
+
+ if not self.get('command') :
+ msg = "Application's Command is not initialized"
+ self.error(msg)
+ raise RuntimeError, msg
+
+ if not self._omf_api :
+ self._omf_api = OMFAPIFactory.get_api(self.get('version'),
+ self.get('xmppServer'), self.get('xmppUser'), self.get('xmppPort'),
+ self.get('xmppPassword'), exp_id = self.exp_id)
+
+ if self.get('version') == "5":
+ if self.get('sources'):
+ gateway = ResourceGateway.AMtoGateway[self.get('xmppServer')]
+ user = self.get('sshUser') or self.get('xmppUser')
+ dst = user + "@"+ gateway + ":"
+ (out, err), proc = sshfuncs.rcopy(self.get('sources'), dst)
+ else :
+ # For OMF 6 :
+ if not self.create_id:
+ props = {}
+ if self.get('command'):
+ props['application:binary_path'] = self.get('command')
+ props['application:hrn'] = self.get('command')
+ props['application:membership'] = self._topic_app
+ props['application:type'] = "application"
+
+ 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:
+ self._create_cnt +=1
+ self.ec.schedule(reschedule_check, self.deploy)
+ return
+
+ self._topic_app = uid
+ self._omf_api.enroll_topic(self._topic_app)
+
+ super(OMFApplication, self).do_deploy()
+
+ def check_deploy(self, cid):
+ """ Check, through the mail box in the parser,
+ if the confirmation of the creation has been received
+
+ :param cid: the id of the original message
+ :type guid: string