示例#1
0
 def _local_setup(self, mock_rpyc):
     _client = AxonClient(axon_host=self.axon_host,
                          axon_port=self.axon_port)
     self.traffic = _client.traffic
     self.stats = _client.stats
     self.interface = _client.interface
     self.namespace = _client.namespace
def register_traffic(register_param):
    workload_server = register_param[0]
    rule_list = register_param[1]
    proxy_host = register_param[2]
    with AxonClient(workload_server, proxy_host=proxy_host) as client:
        for rule in rule_list:
            client.traffic.register_traffic([rule.as_dict()])
示例#3
0
def stop_clients(server, proxy_host):
    try:
        with AxonClient(server, proxy_host=proxy_host) as client:
            client.traffic.stop_clients()
    except Exception:
        log.exception("Stopping clients on endpoint %s failed" % server)
        return False
    return True
示例#4
0
def unregister_traffic(server, rule, proxy_host):
    try:
        with AxonClient(server, proxy_host=proxy_host) as client:
            client.traffic.unregister_traffic([rule.as_dict()])
    except Exception:
        log.exception("Traffic push on endpoint %s failed" % server)
        return False
    return True
示例#5
0
def clear_traffic_rules(delete_param):
    server = delete_param[0]
    proxy_host = delete_param[1]
    with AxonClient(server,
                    proxy_host=proxy_host,
                    retry_count=30,
                    sleep_interval=1) as client:
        client.traffic.delete_traffic_rules()
示例#6
0
def stop_clients(stop_param):
    server = stop_param[0]
    proxy_host = stop_param[1]
    with AxonClient(server,
                    proxy_host=proxy_host,
                    retry_count=30,
                    sleep_interval=1) as client:
        client.traffic.stop_clients()
示例#7
0
def register_traffic(register_param):
    workload_server = register_param[0]
    rule_list = register_param[1]
    proxy_host = register_param[2]
    with AxonClient(workload_server,
                    proxy_host=proxy_host,
                    retry_count=30,
                    sleep_interval=1) as client:
        client.traffic.register_traffic(rule_list)
示例#8
0
 def test_axon_client_init_without_proxy(self, mock_rpyc):
     conn = mock_rpyc.return_value
     conn.root.return_value = None
     _client = AxonClient(axon_host=self.axon_host,
                          axon_port=self.axon_port)
     self.assertTrue(isinstance(_client.traffic, TrafficManger))
     self.assertTrue(isinstance(_client.interface, InterfaceManager))
     self.assertTrue(isinstance(_client.stats, StatsManager))
     self.assertTrue(isinstance(_client.namespace, NamespaceManager))
def rediscover_namespaces(discover_param):
    server = discover_param[0]
    proxy_host = discover_param[1]
    server_port = discover_param[2]
    with AxonClient(server,
                    proxy_host=proxy_host,
                    axon_port=server_port,
                    retry_count=30,
                    sleep_interval=1) as client:
        client.traffic.rediscover_namespaces()
def start_clients(start_param):
    server = start_param[0]
    proxy_host = start_param[1]
    server_port = start_param[2]
    with AxonClient(server,
                    proxy_host=proxy_host,
                    axon_port=server_port,
                    retry_count=30,
                    sleep_interval=1) as client:
        client.traffic.start_clients()
    def build_workloads_vifs_map(self, workload_ips=[]):
        """
        This function build workloads_vifs_map based on workload_ips and
        dumps this
        :param workload_ips:
        :return: workload_vif_map
        """
        if not workload_ips:
            return "No Workload IPs passed to build workloads vifs map"
        map_dict = {}
        for wip in workload_ips:
            with AxonClient(wip) as client:
                map_dict.update({
                    nm_ip: wip
                    for nm_ip in client.namespace.list_namespaces_ips()
                })

        self.dump_workloads_vifs_map(map_dict)
def stop_clients(stop_param):
    server = stop_param[0]
    proxy_host = stop_param[1]
    with AxonClient(server, proxy_host=proxy_host) as client:
        client.traffic.stop_clients()
示例#13
0
            rule_list.extend(allow_rules)
        return rule_list


if __name__ == "__main__":
    managed_hosts = sys.argv[1:]
    if not managed_hosts:
        print("\nHELP: python test.py <host1> <host2> . . <hostN>\n")
        sys.exit()
    basic_test_obj = BasicL2ConnectivityTest(managed_hosts)
    traffic_rules = basic_test_obj.create_rules_with_given_hosts()
    controller = BasicTrafficController()
    controller.register_traffic(traffic_rules)
    controller.restart_traffic()
    start_time = time.time()
    time.sleep(30)
    end_time = time.time()
    for host in managed_hosts:
        with AxonClient(host) as client:
            print("Checking failure count for host - %s" % host)
            failure_count = client.stats.get_failure_count(
                start_time=start_time, end_time=end_time)
            success_count = client.stats.get_success_count(
                start_time=start_time, end_time=end_time)
            print("Failure Count = %s " % failure_count)
            print("sucess Count = %s " % success_count)
            if failure_count != 0:
                raise RuntimeError("Traffic is failing."
                                   "Failure count for "
                                   "host %s is %s" % (host, failure_count))