Ejemplo n.º 1
0
    def generate_ping_configurations(self, config):
        """Base ping test configuration generator

        The generator loops over all endpoint pairs to test ping between
        (generated by the :any:`generate_ping_endpoints` method) then over all
        the selected :any:`ip_versions` and finally over all the IP addresses
        that fit those criteria.

        :return: list of Ping configurations to test in parallel
        :rtype: List[:any:`PingConf`]
        """
        for endpoints in self.generate_ping_endpoints(config):
            for ipv in self.params.ip_versions:
                if ipv == "ipv6" and not endpoints.reachable:
                    continue

                ip_filter = {}
                if ipv == "ipv4":
                    ip_filter.update(family=AF_INET)
                elif ipv == "ipv6":
                    ip_filter.update(family=AF_INET6)
                    ip_filter.update(is_link_local=False)

                endpoint1, endpoint2 = endpoints.endpoints
                endpoint1_ips = endpoint1.ips_filter(**ip_filter)
                endpoint2_ips = endpoint2.ips_filter(**ip_filter)

                if len(endpoint1_ips) != len(endpoint2_ips):
                    raise LnstError(
                        "Source/destination ip lists are of different size.")

                ping_conf_list = []
                for src_addr, dst_addr in zip(endpoint1_ips, endpoint2_ips):
                    pconf = PingConf(
                        client=endpoint1.netns,
                        client_bind=src_addr,
                        destination=endpoint2.netns,
                        destination_address=dst_addr,
                        count=self.params.ping_count,
                        interval=self.params.ping_interval,
                        size=self.params.ping_psize,
                    )

                    ping_evaluators = self.generate_ping_evaluators(
                        pconf, endpoints)
                    pconf.register_evaluators(ping_evaluators)

                    ping_conf_list.append(pconf)

                    if self.params.ping_bidirect:
                        ping_conf_list.append(self._create_reverse_ping(pconf))

                    if not self.params.ping_parallel:
                        break

                yield ping_conf_list
Ejemplo n.º 2
0
    def test(self):
        host1, host2 = self.matched.host1, self.matched.host2

        host1.eth0.ip_add(ipaddress(self.params.src_addr))
        host2.eth0.ip_add(ipaddress(self.params.dst_addr))

        if "mtu" in self.params:
            host1.eth0.mtu = self.params.mtu
            host2.eth0.mtu = self.params.mtu

        host1.eth0.up()
        host2.eth0.up()

        ip1 = host1.eth0.ips[0]
        ip2 = host2.eth0.ips[0]
        cn = self.params.count
        iv = self.params.interval
        if "size" in self.params:
            sz = self.params.size
        else:
            sz = None

        pcfg = PingConf(host1, ip1, host2, ip2, count=cn, interval=iv, size=sz)
        result = self.ping_test([pcfg])
        self.ping_report_and_evaluate(result)
Ejemplo n.º 3
0
 def _create_reverse_ping(self, pconf):
     return PingConf(
         client=pconf.destination,
         client_bind=pconf.destination_address,
         destination=pconf.client,
         destination_address=pconf.client_bind,
         count=pconf.ping_count,
         interval=pconf.ping_interval,
         size=pconf.ping_psize,
     )
Ejemplo n.º 4
0
 def generate_ping_configurations(self, config):
     ns1, ns2 = config.endpoint1.netns, config.endpoint2.netns
     ip1, ip2 = config.ips
     count = self.params.ping_count
     interval = self.params.ping_interval
     size = self.params.ping_psize
     common_args = {'count': count, 'interval': interval, 'size': size}
     ping_conf = PingConf(client=ns1,
                          client_bind=ip1,
                          destination=ns2,
                          destination_address=ip2,
                          **common_args)
     yield [ping_conf]
Ejemplo n.º 5
0
 def generate_ping_configurations(self, config):
     """
     The ping endpoints for this recipe are the configured endpoints of
     the IPsec tunnel on both hosts.
     """
     ns1, ns2 = config.endpoint1.netns, config.endpoint2.netns
     ip1, ip2 = config.ips
     count = self.params.ping_count
     interval = self.params.ping_interval
     size = self.params.ping_psize
     common_args = {'count': count, 'interval': interval, 'size': size}
     ping_conf = PingConf(client=ns1,
                          client_bind=ip1,
                          destination=ns2,
                          destination_address=ip2,
                          **common_args)
     yield [ping_conf]
Ejemplo n.º 6
0
    def generate_ping_configurations(self, config):
        if not config.encrypt:
            client_nic = config.endpoint1
            server_nic = config.endpoint2
            ip_vers = ('ipv4',)
        else:
            client_nic = config.host1.msec0
            server_nic = config.host2.msec0
            ip_vers = self.params.ip_versions

        count = self.params.ping_count
        interval = self.params.ping_interval
        size = self.params.ping_psize
        common_args = {'count' : count, 'interval' : interval,
            'size' : size}

        for ipv in ip_vers:
            kwargs = {}
            if ipv == "ipv4":
                kwargs.update(family = AF_INET)
            elif ipv == "ipv6":
                kwargs.update(family = AF_INET6)
                kwargs.update(is_link_local = False)

            client_ips = client_nic.ips_filter(**kwargs)
            server_ips = server_nic.ips_filter(**kwargs)
            if ipv == "ipv6":
                client_ips = client_ips[::-1]
                server_ips = server_ips[::-1]

            if len(client_ips) != len(server_ips) or (len(client_ips) *
                len(server_ips) == 0):
                raise LnstError("Source/destination ip lists are of "
                    "different size or empty.")

            for src_addr, dst_addr in zip(client_ips, server_ips):
                pconf = PingConf(client = client_nic.netns,
                                 client_bind = src_addr,
                                 destination = server_nic.netns,
                                 destination_address = dst_addr,
                                 **common_args)

                yield [pconf]