Hi people,<br>I&#39;m luigi and I&#39;m a student at Politecnico di Milano, Italy. I&#39;m working for a graduate thesis on a framework called usher. It provides an API to do connect e command operations. It manages all those calls with a defferred object (i think). In fact when I call the connect it returns me a defferred object. All that i want to know is how to call the other operations with this object and how to know when an operation is completely done.<br>
The procedure I call is simple: connect method, start method many times, stop method, disconnect method. I want to call these methods sequentially because I have to fallow a list of commands so I have to be sure the previous methods are already been invoked. I&#39;ll post the main methods hoping someone could help me in how to add the method in the deferred and how to know when it is completely invoked.<br>
# Connect<br>def connect(self, ctrl_host, ctrl_port, user, passwd):<br>        &quot;&quot;&quot;Connect to an Usher control server.<br><br>        @param ctrl_host: fqdn where Usher controller is running<br>        @type ctrl_host: string<br>
        @param ctrl_port: port number Usher controller is listening on<br>        @type ctrl_port: int<br>        @param user: username of user connecting to Usher controller<br>        @type user: string<br>        @param passwd: password of user connecting to Usher controller<br>
        @type passwd: string<br><br>        return: Deferred which returns and L{UsherResult}<br>        rtype: twisted.internet.defer.Deferred<br>        &quot;&quot;&quot;<br>        # serialize access to connect<br>        if not self.connect_lock.acquire(False):<br>
            raise UsherEx, &quot;Connection Pending&quot;<br><br>        if self.factory:<br>            self.disconnect()<br><br>        # reset vms<br>        self.vms = {}<br>        # reset passwd to None until we&#39;re connected<br>
        self.passwd = None<br>        self.factory = APIFactory()<br>        self.factory.api = self<br>        # connect to server<br>        reactor.connectSSL(ctrl_host, ctrl_port, self.factory,<br>            ssl.ClientContextFactory())<br>
        d = self.factory.login(credentials.UsernamePassword(user, passwd),<br>            client=self)<br>        d.addErrback(self._handle_err, misc.whoami())<br>        d.addCallback(self._connected_to_ctrl, ctrl_host, ctrl_port, user,<br>
            passwd)<br>        return d<br><br># start<br>def start(self,<br>              cluster=None,<br>              prefix=&#39;&#39;,<br>              vmlist=None,<br>              count=None,<br>              first=None,<br>
              last=None,<br>              dregex=None,<br>              dlist=None,<br>              dryrun=False,<br>              eid=None,<br>              **kw):<br>        &quot;&quot;&quot;Start a VM or set of VMs<br>
<br>        @param cluster: Name of cluster to which VMs should belong<br>        @type cluster: string<br>        @param prefix: prefix to prepend to VM names<br>        @type prefix: string<br>        @param vmlist: list of strings of VMs to start<br>
        @type vmlist: list of strings<br>        @param count: Number of consecutive VMs to start<br>        @type count: int<br>        @param first: Lowest number of VM to start <br>        @type first: int<br>        @param last: Highest number of VM to start<br>
        @type last: int<br>        @param dregex: regular expression to match against destination LNM<br>            names<br>        @type dregex: list of strings<br>        @param dlist: list of strings to match against destination LNM names<br>
        @type dlist: list of strings<br>        @param dryrun: Show what would have happened if the command had been<br>                run without the dryrun command (at the instant that the dryrun<br>                command was run of course)<br>
        @type dryrun: bool<br>        @param eid: mechanism for admin user to be able to specify an alternate<br>                username for forming suffix for regex<br>        @type eid: string<br>        @param kw: Extra arguments passed to controller for use by plugins or<br>
            LNM.  Any keywords starting with &#39;vm_&#39; are added to VM&#39;s uargs<br>            parameter.  Note, the controller actually checks for two kw<br>            arguments: ram and ip_addrs.  Though these are, strictly speaking,<br>
            VM parameters, they&#39;re considered important enough that the<br>            controller checks for them.<br>        @type kw: dict<br><br>        @return: Deferred which returns an L{UsherResult}<br>        @rtype: twisted.internet.defer.Deferred<br>
<br>        @raise UsherNotConnected: Raised when not connected to Usher<br>            Controller<br>        @raise UsherPBDeadRefEx: Raised when capability for Usher<br>            Controller goes stale.  Must reconnect when this happens<br>
        @raise UsherInvalidInputEx: Raised when an invalid input or<br>            combination of parameters is received.<br><br>        @attention: The following conditions must hold:<br>                1. first, last, and count must be non-negative<br>
                2. specifying first requires last or count<br>                3. cannot use count with vmlist<br>                4. cannot use count with both first and last<br> <br>       &quot;&quot;&quot;<br>        # make sure we&#39;re connected<br>
        if not self.aref:<br>            raise UsherNotConnectedEx<br><br>        # combine these to reduce params<br>        if ((first and first &lt; 0) or (last and last &lt; 0) or (count and count &lt;<br>            0)):<br>
            raise UsherInvalidInputEx(<br>                    &quot;first, last, and count must be non-negative&quot;)<br>        vmrange = (first,last,count)<br>        # arg check<br>        self._arg_check(vmlist, vmrange)<br>
<br>        # get final destination list<br>        dlist = self._namecomplete(dlist, suffix=self.suffix)<br>        self._check_lnmlist(dlist)<br>        dregex = self._regex_append(dregex, dlist)<br>        dlist = self._regex_filter(dregex, self.lnms.keys()) <br>
<br>        # complete names (if necessary) in the vmlist<br>        vmlist = self._namecomplete(vmlist, cluster, eid)<br>        # check that the vms specified don&#39;t already exist<br>        self._check_vmlist(vmlist, isin=True)<br>
        vmlist = self._get_vm_names_to_start(vmlist, cluster, prefix, vmrange,<br>            eid)<br><br>        # controller handles eid from kw, so add it<br>        if eid:<br>            kw[&#39;eid&#39;] = eid<br><br>
        if dryrun:<br>            d = UsherResult(&#39;dryrun&#39;, msg = &#39;started:&#39; + linesep +<br>                    linesep.join(vmlist))<br>            return d<br><br>        try:<br>            if vmlist:<br>
                d = self.aref.callRemote(&quot;start&quot;, vmlist, dlist,<br>                    **kw)<br>                d.addErrback(self._handle_err, misc.whoami())<br>            else:<br>                raise UsherInvalidInputEx( <br>
                        &quot;No VMs started.  No unique VMs specified in command&quot;)<br>            return d<br>        except pb.DeadReferenceError, ex:<br>            raise UsherPBDeadRefEx<br><br>If you want, all the package is at <a href="http://usher.ucsd.edu/downloads/snapshots/usher/latest/usher-latest.tgz">http://usher.ucsd.edu/downloads/snapshots/usher/latest/usher-latest.tgz</a><br>
in the client folder you&#39;ll find the api.py<br><br>Thank you very much hoping someone will help this totally inexpert user,<br>Luigi.<br>