Esempio n. 1
0
    def test_managed_obj(self):
        # create console
        # find agents
        # synchronous query for a managed object
        # method call on each object
        self.notifier = _testNotifier()
        self.console = qmf2.console.Console(notifier=self.notifier,
                                            agent_timeout=3)
        self.conn = qpid.messaging.Connection(self.broker)
        self.conn.open()
        self.console.add_connection(self.conn)

        for aname in ["agent1", "agent2"]:
            agent = self.console.find_agent(aname, timeout=3)
            self.assertTrue(agent and agent.get_name() == aname)

            query = QmfQuery.create_id(QmfQuery.TARGET_OBJECT, "01545")
            obj_list = self.console.do_query(agent, query)

            self.assertTrue(isinstance(obj_list, type([])))
            self.assertTrue(len(obj_list) == 1)
            obj = obj_list[0]

            mr = obj.invoke_method("a_method", {
                "arg1": 1,
                "arg2": "Now set!",
                "arg3": 1966
            },
                                   _timeout=3)
            self.assertTrue(isinstance(mr, qmf2.console.MethodResult))
            self.assertTrue(mr.succeeded())
            self.assertTrue(mr.get_argument("code") == 0)
            # @todo refresh and verify changes

        self.console.destroy(10)
Esempio n. 2
0
    def test_managed_obj(self):
        # create console
        # find agents
        # synchronous query for a managed object
        # method call on each object
        self.notifier = _testNotifier()
        self.console = qmf2.console.Console(notifier=self.notifier, agent_timeout=3)
        self.conn = qpid.messaging.Connection(self.broker)
        self.conn.open()
        self.console.add_connection(self.conn)

        for aname in ["agent1", "agent2"]:
            agent = self.console.find_agent(aname, timeout=3)
            self.assertTrue(agent and agent.get_name() == aname)

            query = QmfQuery.create_id(QmfQuery.TARGET_OBJECT, "01545")
            obj_list = self.console.do_query(agent, query)

            self.assertTrue(isinstance(obj_list, type([])))
            self.assertTrue(len(obj_list) == 1)
            obj = obj_list[0]

            mr = obj.invoke_method("a_method", {"arg1": 1, "arg2": "Now set!", "arg3": 1966}, _timeout=3)
            self.assertTrue(isinstance(mr, qmf2.console.MethodResult))
            self.assertTrue(mr.succeeded())
            self.assertTrue(mr.get_argument("code") == 0)
            # @todo refresh and verify changes

        self.console.destroy(10)
Esempio n. 3
0
    def test_managed_obj(self):
        # create console
        # find agents
        # synchronous query for a managed object
        # method call on each object
        self.notifier = _testNotifier()
        self.console = qmf2.console.Console(notifier=self.notifier,
                                              agent_timeout=3)
        self.conn = qpid.messaging.Connection(self.broker)
        self.conn.open()
        self.console.add_connection(self.conn)

        i_count = 0
        for aname in ["agent1", "agent2"]:
            agent = self.console.find_agent(aname, timeout=3)
            self.assertTrue(agent and agent.get_name() == aname)

            query = QmfQuery.create_id(QmfQuery.TARGET_OBJECT, "01545")
            obj_list = self.console.do_query(agent, query)

            self.assertTrue(isinstance(obj_list, type([])))
            self.assertTrue(len(obj_list) == 1)
            obj = obj_list[0]

            cookie = "cookie-" + str(i_count)
            i_count += 1
            mr = obj.invoke_method("a_method",
                                   {"arg1": 1,
                                    "arg2": "Now set!",
                                    "arg3": 1966,
                                    "cookie": cookie},
                                   _reply_handle=cookie,
                                   _timeout=3)
            self.assertTrue(mr)

        # done, now wait for async responses

        r_count = 0
        while self.notifier.wait_for_work(3):
            wi = self.console.get_next_workitem(timeout=0)
            while wi is not None:
                r_count += 1
                self.assertTrue(wi.get_type() == WorkItem.METHOD_RESPONSE)
                reply = wi.get_params()
                self.assertTrue(isinstance(reply, qmf2.console.MethodResult))
                self.assertTrue(reply.succeeded())
                self.assertTrue(reply.get_argument("cookie") == wi.get_handle())

                wi = self.console.get_next_workitem(timeout=0)

        self.assertTrue(r_count == i_count)

        self.console.destroy(10)
Esempio n. 4
0
    while _wi:
        print("!!! work item received %d:%s" %
              (_wi.get_type(), str(_wi.get_params())))

        if _wi.get_type() == _wi.AGENT_ADDED:
            _agent = _wi.get_params().get("agent")
            if not _agent:
                print("!!!! AGENT IN REPLY IS NULL !!! ")

            _query = QmfQuery.create_wildcard(QmfQuery.TARGET_OBJECT_ID)
            oid_list = _myConsole.doQuery(_agent, _query)

            print("!!!************************** REPLY=%s" % oid_list)

            for oid in oid_list:
                _query = QmfQuery.create_id(QmfQuery.TARGET_OBJECT, oid)
                obj_list = _myConsole.doQuery(_agent, _query)

                print("!!!************************** REPLY=%s" % obj_list)

                if obj_list is None:
                    obj_list = {}

                for obj in obj_list:
                    resp = obj.invoke_method("set_meth", {
                        "arg_int": -11,
                        "arg_str": "are we not goons?"
                    }, None, 3)
                    if resp is None:
                        print("!!!*** NO RESPONSE FROM METHOD????")
                    else: