コード例 #1
0
    def test_pbreq_ec_container(self):
        ec_rpc = RwMgmtagtDtsYang.YangInput_RwMgmtagtDts_MgmtAgentDts()
        ec_rpc.pb_request.xpath = "C,/dns:dns/dns:options"
        op_pb = DnsYang.DnsOptions()
        op_pb.ndots = 10
        op_pb.timeout = 5
        op_pb.attempts = 10
        ec_rpc.pb_request.data = op_pb.to_pbuf()
        ec_rpc.pb_request.request_type = "edit_config"
        ec_rpc.pb_request.edit_type = "merge"

        query_iter = yield from self._dtsh.query_rpc(
            xpath="I,/rw-mgmtagt-dts:mgmt-agent-dts", flags=0, msg=ec_rpc)

        for fut_resp in query_iter:
            query_resp = yield from fut_resp
            result = query_resp.result
            if result.pb_request.error is not None:
                return False
            #Verify the config in agent dom
            agent_dom_pb = yield from self.get_agent_dom()
            if agent_dom_pb is not None:
                dop_pb = DnsYang.DnsOptions()
                dop_pb.from_xml_v2(self._nc_proxy.model,
                                   agent_dom_pb.agent_dom)
                my_pb = DnsYang.DnsOptions()
                my_pb.from_pbuf(ec_rpc.pb_request.data)
                if ProtobufC.Message.is_equal_deep(None, my_pb.to_pbcm(),
                                                   dop_pb.to_pbcm()) is not 0:
                    return True
            break  # the uAgent sends only a single response

        return False
コード例 #2
0
 def test_dts_rpcs_edit_cfg(self):
     # Send an edit-config via agent rpc.
     ec_rpc = RwMgmtagtYang.YangInput_RwMgmtagt_MgmtAgent()
     ec_rpc.pb_request.xpath = "C,/dns:dns"
     dnspb = DnsYang.Dns()
     s1 = dnspb.search.add()
     s1.name = 100
     s1.domain = "abc.com"
     serv1 = dnspb.server.add()
     serv1.address = "10.0.1.9"
     dnspb.options.ndots = 2
     dnspb.options.timeout = 30
     dnspb.options.attempts = 5
     serv2 = dnspb.server.add()
     serv2.address = "10.0.1.10"
     dnspb.options.ndots = 3
     dnspb.options.timeout = 40
     dnspb.options.attempts = 5
     ec_rpc.pb_request.data = dnspb.to_pbuf()
     ec_rpc.pb_request.request_type = "edit_config"
     ec_rpc.pb_request.edit_type = "merge"
     mgmt_proxy = self.mgmt_session.proxy(RwMgmtagtYang)
     ret_obj = mgmt_proxy.rpc(ec_rpc)
     self.assertTrue(ret_obj)
     print(ret_obj)
コード例 #3
0
    def test_pbreq_ec_del(self):
        dc_rpc = RwMgmtagtDtsYang.YangInput_RwMgmtagtDts_MgmtAgentDts()
        dc_rpc.pb_request.xpath = "C,/dns:dns/dns:server[dns:address='10.0.1.10']"
        dc_rpc.pb_request.request_type = "edit_config"
        dc_rpc.pb_request.edit_type = "delete"

        query_iter = yield from self._dtsh.query_rpc(
            xpath="I,/rw-mgmtagt-dts:mgmt-agent-dts", flags=0, msg=dc_rpc)

        for fut_resp in query_iter:
            query_resp = yield from fut_resp
            result = query_resp.result
            if result.pb_request.error is not None:
                return False
            #Verify the deletion in agent dom
            agent_dom_pb = yield from self.get_agent_dom()
            if agent_dom_pb is not None:
                dns_pb = DnsYang.Dns()
                dns_pb.from_xml_v2(self._nc_proxy.model,
                                   agent_dom_pb.agent_dom)
                if len(dns_pb.server) is 10:
                    return True
            break  # the uAgent sends only a single response

        return False
コード例 #4
0
    def test_pbreq_ec_merge(self):
        def create_ec_pb_req():
            ec_rpc = RwMgmtagtDtsYang.YangInput_RwMgmtagtDts_MgmtAgentDts()
            ec_rpc.pb_request.xpath = "C,/dns:dns"
            dnspb = DnsYang.Dns()
            for i in range(10):
                s1 = dnspb.search.add()
                s1.name = 100
                s1.domain = "abc.com"

            for i in range(11):
                serv1 = dnspb.server.add()
                serv1.address = "10.0.1." + str(i)
                serv1.ttl = 254

            ec_rpc.pb_request.data = dnspb.to_pbuf()
            ec_rpc.pb_request.request_type = "edit_config"
            ec_rpc.pb_request.edit_type = "merge"

            return ec_rpc

        ec_rpc = create_ec_pb_req()
        query_iter = yield from self._dtsh.query_rpc(
            xpath="I,/rw-mgmtagt-dts:mgmt-agent-dts", flags=0, msg=ec_rpc)

        for fut_resp in query_iter:
            query_resp = yield from fut_resp
            result = query_resp.result
            if result.pb_request.error is not None:
                return False
            #Verify the config in agent dom
            agent_dom_pb = yield from self.get_agent_dom()
            if agent_dom_pb is not None:
                dns_pb = DnsYang.Dns()
                dns_pb.from_xml_v2(self._nc_proxy.model,
                                   agent_dom_pb.agent_dom)
                my_pb = DnsYang.Dns()
                my_pb.from_pbuf(ec_rpc.pb_request.data)
                if ProtobufC.Message.is_equal_deep(None, my_pb.to_pbcm(),
                                                   dns_pb.to_pbcm()) is not 0:
                    return True
            break  # the uAgent sends only a single response

        return False
コード例 #5
0
 def test_dts_rpcs_del_cfg(self):
     self.test_dts_rpcs_edit_cfg()
     # Send a delete cfg rpc
     dc_rpc = RwMgmtagtYang.YangInput_RwMgmtagt_MgmtAgent()
     dc_rpc.pb_request.xpath = "C,/dns:dns/dns:server[dns:address='10.0.1.10']"
     dnspb = DnsYang.Dns()
     serv1 = dnspb.server.add()
     serv1.address = "10.0.1.10"
     dc_rpc.pb_request.data = dnspb.to_pbuf()
     dc_rpc.pb_request.request_type = "edit_config"
     dc_rpc.pb_request.edit_type = "delete"
     mgmt_proxy = self.mgmt_session.proxy(RwMgmtagtYang)
     ret_obj = mgmt_proxy.rpc(dc_rpc)
     self.assertTrue(ret_obj)
     print(ret_obj)
コード例 #6
0
        def create_ec_pb_req():
            ec_rpc = RwMgmtagtDtsYang.YangInput_RwMgmtagtDts_MgmtAgentDts()
            ec_rpc.pb_request.xpath = "C,/dns:dns"
            dnspb = DnsYang.Dns()
            for i in range(10):
                s1 = dnspb.search.add()
                s1.name = 100
                s1.domain = "abc.com"

            for i in range(11):
                serv1 = dnspb.server.add()
                serv1.address = "10.0.1." + str(i)
                serv1.ttl = 254

            ec_rpc.pb_request.data = dnspb.to_pbuf()
            ec_rpc.pb_request.request_type = "edit_config"
            ec_rpc.pb_request.edit_type = "merge"

            return ec_rpc