示例#1
0
def create_vswitch(deployment_scenario, vswitch_class, traffic,
                   tunnel_operation=None):
    """Return a new IVSwitchController for the deployment_scenario.

    The returned controller is configured with the given vSwitch class.

    Deployment scenarios: e.g. 'p2p', 'pvp', 'pvpv12', etc.

    :param deployment_scenario: The deployment scenario name
    :param vswitch_class: Reference to vSwitch class to be used.
    :param traffic: Dictionary with traffic specific details
    :param tunnel_operation encapsulation/decapsulation or None
    :return: IVSwitchController for the deployment_scenario
    """
    # pylint: disable=too-many-return-statements
    deployment = deployment_scenario.lower()
    if deployment.startswith("p2p"):
        return VswitchControllerP2P(deployment, vswitch_class, traffic)
    elif deployment.startswith("pvp"):
        return VswitchControllerPXP(deployment, vswitch_class, traffic)
    elif deployment.startswith("pvvp"):
        return VswitchControllerPXP(deployment, vswitch_class, traffic)
    elif deployment.startswith("pvpv"):
        return VswitchControllerPXP(deployment, vswitch_class, traffic)
    elif deployment.startswith("op2p"):
        return VswitchControllerOP2P(deployment, vswitch_class, traffic, tunnel_operation)
    elif deployment.startswith("ptunp"):
        return VswitchControllerPtunP(deployment, vswitch_class, traffic)
    elif deployment.startswith("clean"):
        return VswitchControllerClean(deployment, vswitch_class, traffic)
    elif deployment.startswith("pc"):
        return VswitchControllerP2P(deployment, vswitch_class, traffic)
    else:
        raise RuntimeError("Unknown deployment scenario '{}'.".format(deployment))
示例#2
0
def create_vswitch(deployment_scenario, vswitch_class, traffic):
    """Return a new IVSwitchController for the deployment_scenario.

    The returned controller is configured with the given vSwitch class.

    Deployment scenarios: 'p2p', 'pvp'

    :param deployment_scenario: The deployment scenario name
    :param vswitch_class: Reference to vSwitch class to be used.
    :param traffic: Dictionary with traffic specific details
    :return: IVSwitchController for the deployment_scenario
    """
    deployment_scenario = deployment_scenario.lower()
    if deployment_scenario.find("p2p") >= 0:
        return VswitchControllerP2P(vswitch_class, traffic)
    elif deployment_scenario.find("pvp") >= 0:
        return VswitchControllerPVP(vswitch_class, traffic)
    elif deployment_scenario.find("pvvp") >= 0:
        return VswitchControllerPVVP(vswitch_class, traffic)