예제 #1
0
    def invoke(self, api, *arg):
        """A convenience routine which wraps invoke_elem().
    It constructs an NaElement with name $api, and for
    each argument name/value pair, adds a child element
    to it.  It's an error to have an even number of
    arguments to this function.

    Example: myserver->invoke('snapshot-create',
                                    'snapshot', 'mysnapshot',
                                'volume', 'vol0');
    """

        num_parms = len(arg)

        if ((num_parms & 1) != 0):
            return self.fail_response(
                13001, "in Zapi::invoke, invalid number of parameters")

        xi = NaElement(api)
        i = 0

        while (i < num_parms):
            key = arg[i]
            i = i + 1
            value = arg[i]
            i = i + 1
            xi.child_add(NaElement(key, value))

        return self.invoke_elem(xi)
    def invoke(self, api, *arg):
        """A convenience routine which wraps invoke_elem().
    It constructs an NaElement with name $api, and for
    each argument name/value pair, adds a child element
    to it.  It's an error to have an even number of
    arguments to this function.

    Example: myserver->invoke('snapshot-create',
                                    'snapshot', 'mysnapshot',
                                'volume', 'vol0');
    """

        num_parms = len(arg)

        if ((num_parms & 1)!= 0):
            return self.fail_response(13001,"in Zapi::invoke, invalid number of parameters")

        xi = NaElement(api)
        i = 0

        while(i < num_parms):
            key = arg[i]
            i = i+1
            value = arg[i]
            i = i+1
            xi.child_add(NaElement(key, value))

        return self.invoke_elem(xi)