def run(TopologyConfig):
    logger = _get_logger()
    cmd = _get_this_cmd()
    if cmd:
        cmd.Set('ErrorOnFailure', True)

    try:
        topology_nodes = json_util.loads(TopologyConfig)
        device_handle_list = []
        for topology_node in topology_nodes:
            subnet_configs = topology_node["subnet_configs"]
            for subnet_config in subnet_configs:
                subnet = subnet_config["subnet"]
                if subnet["dhcp_enabled"]:
                    devices = get_devices(subnet)
                    device_handle_list += devices
        device_handle_list = list(set(device_handle_list))
        if len(device_handle_list) > 0:
            run_dhcp(device_handle_list)
    except RuntimeError as e:
        logger.LogError(str(e))
        if cmd:
            cmd.Set("Status", str(e))
        return False
    except:
        logger.LogError("unhandled exception:" + traceback.format_exc())
        return False

    return True
示例#2
0
def run(TopologyConfig):
    topology_nodes = json_util.loads(TopologyConfig)
    streamblocks_to_arp = []
    for topology_node in topology_nodes:
        subnet_configs = topology_node["subnet_configs"]
        for subnet_config in subnet_configs:
            subnet = subnet_config["subnet"]
            gateway_config = subnet["gateway_config"]
            gateway_config_type = gateway_config["_type"]
            if gateway_config_type == "Profile::GatewayArpConfig":
                streamblocks = get_streamblocks(subnet)
                streamblocks_to_arp += streamblocks
    streamblocks_to_arp = list(set(streamblocks_to_arp))
    if len(streamblocks_to_arp) > 0:
        run_arp(streamblocks_to_arp)
    return True
示例#3
0
def run(TopologyConfig):
    topology_nodes = json_util.loads(TopologyConfig)
    for topology_node in topology_nodes:
        subnet_configs = topology_node["subnet_configs"]
        for subnet_config in subnet_configs:
            subnet = subnet_config["subnet"]
            mac_config = subnet["mac_config"]
            mac_config_type = mac_config["_type"]
            if mac_config_type == "Profile::UniqueMacConfig":
                if subnet["device_count_per_port"] == 1:
                    handle_physical_interface(subnet_config)
                elif subnet["device_count_per_port"] > 1:
                    handle_randomize_mac(subnet_config)
                else:
                    raise Exception("invalid device_count_per_port")
    return True
def run(TrafficFilters, Ports, Drvs, DrvPorts, CallbackInfo):
    cb = json_util.loads(CallbackInfo)
    clear_sequencer()
    cmd = create_command_hnd(TrafficFilters, Ports, Drvs, DrvPorts)
    with AutoCommand("SequencerInsertCommand") as seq_insert_cmd:
        seq_insert_cmd.SetCollection("CommandList", [cmd])
        seq_insert_cmd.Execute()
    with AutoCommand("SubscribePropertyChangeCommand") as sub_cmd:
        sub_cmd.Set("PropertyClassId", "sequencer")
        sub_cmd.SetCollection("PropertyIdList", [
            "sequencer.state",
            "sequencer.teststate"
            ])
        sub_cmd.Set("PublishUrl", cb["url"])
        sub_cmd.Set("Context", cb["context"])
        sub_cmd.Execute()
    CommandUtils.set_attribute("StartedCommand", cmd, _get_this_cmd())
    return True