예제 #1
0
    def test_routeservers_excluded_from_clients(self):
        """External resources: route servers excluded from clients-from-euroix"""

        # The idea behind this check is to be sure that the most recent version of
        # the Euro-IX Member list JSON file will be always processed correctly, and
        # that the route server IPs will always be excluded from the output of the
        # clients-from-euroix command.
        #
        # Here, the INEX members list is retrieve from their member-export endpoint.
        # INEX is behind IXPManager, and hopefully they will always export their
        # member list using the most recent version of the Euro-IX Member JSON format.
        # Doing this, hopefully this test will catch any major issue that could affect
        # the integration with IXPManager and the processing of the latest version of
        # the Euro-IX schema.
        euro_ix = EuroIXMemberList(
            "https://www.inex.ie/ixp/api/v4/member-export/ixf", None, None)
        clients = euro_ix.get_clients(ixp_id=1, vlan_id=2)
        client_ips = [client["ip"] for client in clients]

        for rs_ip in (
                "185.6.36.8",
                "2001:7f8:18::8",
        ):
            self.assertTrue(rs_ip not in client_ips)

        for member_ip in (
                "185.6.36.60",
                "2001:7f8:18::60",
        ):
            self.assertTrue(member_ip in client_ips)
    def _test(self, clients_content, exp_res=None):
        cls = IXFMemberListFromClientsCommand

        dic = cls.build_json(self.write_file("clients.yml", clients_content),
                             1, "Test IX", 1)

        if exp_res:
            member_list = dic["member_list"]
            self.assertEqual(member_list, exp_res)

        # Test if the file generated can be read by ARouteServer itself
        with open(self.write_file("ixf.json", json.dumps(dic)), "rb") as f:
            clients_from_ixf_member_list = EuroIXMemberList(f, None, None)

        clients_from_ixf_member_list.get_clients(1, 1)

        return dic
 def _run(self, filename, *args, **kwargs):
     data = self._load(filename)
     euro_ix = EuroIXMemberList(data, None, None)
     self.clients = euro_ix.get_clients(*args, **kwargs)