Пример #1
0
def vnet_config(minigraph_facts, vnet_test_params, scaled_vnet_params):
    """
    Fixture to generate vnet configuration from templates/vnet_config.j2

    Args:
        minigraph_facts: minigraph information/facts
        vnet_test_params: Dictionary holding vnet test parameters
        scaled_vnet_params: Dictionary holding scaled vnet testing parameters

    Returns:
        A dictionary containing the generated vnet configuration information
    """

    num_rifs = vnet_test_params[NUM_INTF_PER_VNET_KEY] * scaled_vnet_params[
        NUM_VNET_KEY]

    if num_rifs > 128:
        logger.warning(
            "Total number of configured interfaces will be greater than 128. This is not a supported test scenario"
        )

    combined_args = combine_dicts(minigraph_facts, vnet_test_params,
                                  scaled_vnet_params)
    return yaml.safe_load(
        safe_open_template(path.join(TEMPLATE_DIR,
                                     "vnet_config.j2")).render(combined_args))
Пример #2
0
def prepare_ptf(ptfhost, mg_facts, dut_facts, vnet_config):
    """
    Prepares the PTF container for testing

    Generates and copies PTF required config files to the PTF host

    Args:
        ptfhost: PTF host object
        mg_facts: Minigraph facts
        dut_facts: DUT host facts
        vnet_config: Configuration file generated from templates/vnet_config.j2
    """

    logger.info("Preparing PTF host")

    arp_responder_conf = safe_open_template("templates/arp_responder.conf.j2") \
                            .render(arp_responder_args="--conf /tmp/vnet_arpresponder.conf")

    ptfhost.copy(content=arp_responder_conf,
                 dest="/etc/supervisor/conf.d/arp_responder.conf")

    ptfhost.shell("supervisorctl reread")
    ptfhost.shell("supervisorctl update")

    logger.debug("VNet config is: " + str(vnet_config))
    vnet_json = {
        "minigraph_port_indices":
        mg_facts["minigraph_port_indices"],
        "minigraph_portchannel_interfaces":
        mg_facts["minigraph_portchannel_interfaces"],
        "minigraph_portchannels":
        mg_facts["minigraph_portchannels"],
        "minigraph_lo_interfaces":
        mg_facts["minigraph_lo_interfaces"],
        "minigraph_vlans":
        mg_facts["minigraph_vlans"],
        "minigraph_vlan_interfaces":
        mg_facts["minigraph_vlan_interfaces"],
        "dut_mac":
        dut_facts["router_mac"],
        "vnet_interfaces":
        vnet_config["vnet_intf_list"],
        "vnet_routes":
        vnet_config["vnet_route_list"] + vnet_config["vnet_subnet_routes"],
        "vnet_local_routes":
        vnet_config["vnet_local_routes"],
        "vnet_neighbors":
        vnet_config["vnet_nbr_list"],
        "vnet_peers":
        vnet_config["vnet_peer_list"]
    }
    ptfhost.copy(content=json.dumps(vnet_json, indent=2),
                 dest="/tmp/vnet.json")
Пример #3
0
def vnet_config(minigraph_facts, vnet_test_params, scaled_vnet_params):
    """
    Fixture to generate vnet configuration from templates/vnet_config.j2

    Args:
        minigraph_facts: minigraph information/facts
        vnet_test_params: Dictionary holding vnet test parameters
        scaled_vnet_params: Dictionary holding scaled vnet testing parameters

    Returns:
        A dictionary containing the generated vnet configuration information
    """

    combined_args = combine_dicts(minigraph_facts, vnet_test_params,
                                  scaled_vnet_params)
    return yaml.safe_load(
        safe_open_template(path.join(TEMPLATE_DIR,
                                     "vnet_config.j2")).render(combined_args))