Ejemplo n.º 1
0
def ping_test(sender_name, receiver_name, packet_count):
    sender = lxc.Container(sender_name)
    receiver = lxc.Container(receiver_name)

    r_ipop_ip = get_ipop_ip(receiver)

    ping_command = ["ping", "-c", str(packet_count), r_ipop_ip]
    ping_output = run(sender, ping_command)
    return ping_output
Ejemplo n.º 2
0
def iperf_test(client_name, server_name):
    client = lxc.Container(client_name)
    server = lxc.Container(server_name)

    server_ip = get_ipop_ip(server)

    iperf_client_command = ["iperf3", "-J", "-t", "5", "-c", server_ip]
    iperf_server_command = ["iperf3", "-s", "-1", "-B", server_ip, "-D"]
    run(server, iperf_server_command)
    iperf_output = run(client, iperf_client_command)
    return iperf_output
Ejemplo n.º 3
0
def configure_container(name):
    container = lxc.Container(name)
    data = request.get_json(force=True)
    if data is None:
        return jsonify({'status':"error", 'error':"Bad request"}), 400
    container_config = ConfigObj(container.config_file_name, stringify=True, list_values=False)
    for option, value in data.items():
        if len(value) > 0:
            if option.startswith('lxc.') is False:
                option = 'lxc.{}'.format(option)
            container_config[option] = value
            container_config.write()
    result = ContainerSchema().dump(lxc.Container(name))
    return jsonify(result[0])