Пример #1
0
        def _prefix_mgr_client():
            prefix_mgr_client_inst = prefix_mgr_client.PrefixMgrClient(
                zmq.Context(), "tcp://localhost:5000")

            resp = prefix_mgr_client_inst.add_prefix(
                '2620:0:1cff:dead:bef1:ffff:ffff:4/128')
            self.assertTrue(resp.success)

            resp = prefix_mgr_client_inst.view_prefix()
            prefix_entry4 = lsdb_types.PrefixEntry(
                prefix=ip_str_to_prefix(
                    '2620:0:1cff:dead:bef1:ffff:ffff:4/128'),
                type=lsdb_types.PrefixType.LOOPBACK)
            self.assertTrue(resp.success)
            self.assertTrue(prefix_entry4 in resp.prefixes)

            resp = prefix_mgr_client_inst.withdraw_prefix(
                '2620:0:1cff:dead:bef1:ffff:ffff:4/128')
            self.assertTrue(resp.success)

            resp = prefix_mgr_client_inst.view_prefix()
            self.assertTrue(resp.success)
            self.assertFalse(prefix_entry4 in resp.prefixes)

            resp = prefix_mgr_client_inst.withdraw_prefix(
                '2620:0:1cff:dead:bef1:ffff:ffff:5/128')
            self.assertFalse(resp.success)
Пример #2
0
        def _prefix_mgr_client():
            prefix_mgr_client_inst = prefix_mgr_client.PrefixMgrClient(
                bunch.Bunch({
                    "ctx": zmq.Context(),
                    "host": "localhost",
                    "prefix_mgr_cmd_port": 5000,
                }))

            resp = prefix_mgr_client_inst.add_prefix(
                ["2620:0:1cff:dead:bef1:ffff:ffff:4/128"], "LOOPBACK")
            self.assertTrue(resp.success)

            resp = prefix_mgr_client_inst.view_prefix()
            prefix_entry4 = lsdb_types.PrefixEntry(
                prefix=ip_str_to_prefix(
                    "2620:0:1cff:dead:bef1:ffff:ffff:4/128"),
                type=network_types.PrefixType.LOOPBACK,
            )
            self.assertTrue(resp.success)
            self.assertTrue(prefix_entry4 in resp.prefixes)

            resp = prefix_mgr_client_inst.withdraw_prefix(
                ["2620:0:1cff:dead:bef1:ffff:ffff:4/128"])
            self.assertTrue(resp.success)

            resp = prefix_mgr_client_inst.view_prefix()
            self.assertTrue(resp.success)
            self.assertFalse(prefix_entry4 in resp.prefixes)

            resp = prefix_mgr_client_inst.withdraw_prefix(
                ["2620:0:1cff:dead:bef1:ffff:ffff:5/128"])
            self.assertFalse(resp.success)
Пример #3
0
        def _prefix_mgr_client():
            prefix_mgr_client_inst = prefix_mgr_client.PrefixMgrClient(
                zmq.Context(), socket_url)

            resp = prefix_mgr_client_inst.add_prefix(
                ["2620:0:1cff:dead:bef1:ffff:ffff:4/128"], "LOOPBACK")
            self.assertTrue(resp.success)

            resp = prefix_mgr_client_inst.view_prefix()
            prefix_entry4 = lsdb_types.PrefixEntry(
                prefix=ip_str_to_prefix(
                    "2620:0:1cff:dead:bef1:ffff:ffff:4/128"),
                type=lsdb_types.PrefixType.LOOPBACK,
            )
            self.assertTrue(resp.success)
            self.assertTrue(prefix_entry4 in resp.prefixes)

            resp = prefix_mgr_client_inst.withdraw_prefix(
                ["2620:0:1cff:dead:bef1:ffff:ffff:4/128"])
            self.assertTrue(resp.success)

            resp = prefix_mgr_client_inst.view_prefix()
            self.assertTrue(resp.success)
            self.assertFalse(prefix_entry4 in resp.prefixes)

            resp = prefix_mgr_client_inst.withdraw_prefix(
                ["2620:0:1cff:dead:bef1:ffff:ffff:5/128"])
            self.assertFalse(resp.success)
Пример #4
0
    def __init__(self, cli_opts):
        ''' initialize the Prefix Manager client '''

        self.client = prefix_mgr_client.PrefixMgrClient(
            cli_opts.zmq_ctx,
            "tcp://[{}]:{}".format(cli_opts.host, cli_opts.prefix_mgr_cmd_port),
            cli_opts.timeout,
            cli_opts.proto_factory)
Пример #5
0
 def __init__(self, cli_opts):
     """ initialize the Prefix Manager client """
     self.client = prefix_mgr_client.PrefixMgrClient(cli_opts)