Example #1
0
def setDataPortStatePerUplink(naples_nodes, oper, id):
    uplink_list = []
    if id == 'Uplink0':
        uplink_list.append(UPLINK_PREFIX1)
    elif id == 'Uplink1':
        uplink_list.append(UPLINK_PREFIX2)
    else:
        uplink_list.append(UPLINK_PREFIX1)
        uplink_list.append(UPLINK_PREFIX2)

    if GlobalOptions.dryrun:
        return api.types.status.SUCCESS

    for node in naples_nodes:
        node_uuid = EzAccessStoreClient[node].GetNodeUuid(node)
        #node_uuid = 750763714960
        for uplink in uplink_list:
            intf_uuid = uplink % node_uuid
            cmd = ("debug update port --admin-state %s --port " +
                   intf_uuid) % oper
            ret, resp = pdsctl.ExecutePdsctlCommand(node, cmd, yaml=False)
            if ret != True:
                api.Logger.error("oper:%s uplink failed at node %s : %s" %
                                 (oper, node, resp))
                return api.types.status.FAILURE
        misc_utils.Sleep(1)  #give a short gap before printing status
        pdsctl.ExecutePdsctlShowCommand(node, "port status", yaml=False)
    return api.types.status.SUCCESS
Example #2
0
def ClearLearnStatistics(nodes=[]):
    nodes = nodes if nodes else api.GetNaplesHostnames()
    for node in nodes:
        ret, resp = pdsctl.ExecutePdsctlCommand(node,
                                                "clear learn statistics",
                                                yaml=False)
        if ret != True:
            api.Logger.error(
                "Failed to execute clear learn statistics at node %s : %s" %
                (node, resp))
            return ret
    return True
Example #3
0
def Fetch():
    global __store
    global __stdout
    global __dirty
    __store = learn_utils.GetLearnStatistics(__nodes)
    __normalize_stats()
    for node in __nodes:
        _, resp = pdsctl.ExecutePdsctlCommand(node,
                                              "show learn statistics",
                                              yaml=False,
                                              print_op=False)
        __stdout[node] = resp
    __dirty = False
Example #4
0
def SetDeviceLearnTimeout(val):
    # Enabling Max age for all endpoints
    nodes = api.GetNaplesHostnames()
    for node in nodes:
        ret, resp = pdsctl.ExecutePdsctlCommand(node,
                                                "debug update device",
                                                "--learn-age-timeout %d" % val,
                                                yaml=False)
        if ret != True:
            api.Logger.error("Failed to execute debug device at node %s : %s" %
                             (node, resp))
            return ret
    return True
Example #5
0
def ClearLearnData(node=None):
    # Clearing all learnt MAC/IP info
    if node is None:
        nodes = api.GetNaplesHostnames()
    else:
        nodes = [node]
    for n in nodes:
        ret, resp = pdsctl.ExecutePdsctlCommand(n,
                                                "clear learn mac",
                                                yaml=False)
        if ret != True:
            api.Logger.error(
                "Failed to execute clear learn mac at node %s : %s" %
                (n, resp))
            return ret
    return True
Example #6
0
def UpdatePolicer(tc, workload):
    if not workload.IsNaples():
        return 0
    PolicerClient = EzAccessStore.GetConfigClient(
        agent_api.ObjectTypes.POLICER)
    policer = PolicerClient.GetMatchingPolicerObject(workload.node_name,\
            tc.iterators.direction, tc.iterators.policertype)
    if policer:
        spec = PolicerUpdateSpec(policer)
        workload.vnic.Update(spec)
        tokens = ((policer.rate * tc.duration) + policer.burst)
        vnic_id = workload.vnic.UUID.String()
        pdsctl.ExecutePdsctlCommand(workload.node_name,\
                f"clear vnic statistics -i {vnic_id}", None, yaml=False)
    else:
        tokens = 0
    return tokens
Example #7
0
def clearFlowTable(workload_pairs):
    if api.IsDryrun():
        return api.types.status.SUCCESS

    nodes = api.GetNaplesHostnames()
    for node in nodes:
        ret, resp = pdsctl.ExecutePdsctlCommand(node, "clear flow", yaml=False)
        if ret != True:
            api.Logger.error("Failed to execute clear flows at node %s : %s" %
                             (node, resp))
            return api.types.status.FAILURE

        if "Clearing flows succeeded" not in resp:
            api.Logger.error("Failed to clear flows at node %s : %s" %
                             (node, resp))
            return api.types.status.FAILURE

    return api.types.status.SUCCESS