예제 #1
0
def getNativeWorkloads():
    # Get all available host interfaces
    lst_nodes = api.GetWorkloadNodeHostnames()
    lst_native_if = {}
    mgmt_intf = {}

    # Get host interfaces on all nodes
    for node in lst_nodes:
        lst_native_if[node] = list(api.GetWorkloadNodeHostInterfaces(node))
        # Exclude host side management interface from this test case on naples
        if api.IsNaplesNode(node):
            mgmt_intf[node] = list(
                naples_utils.GetHostInternalMgmtInterfaces(node))

    for node, infs in mgmt_intf.items():
        for inf in infs:
            if inf in lst_native_if[node]:
                lst_native_if[node].remove(inf)

    # Get workloads corresponding to host interfaces
    total_workloads = api.GetWorkloads()
    native_workloads = []
    for w1 in total_workloads:
        for node, infs in lst_native_if.items():
            if w1.interface in infs and w1.node_name == node:
                native_workloads.append(w1)

    return native_workloads
예제 #2
0
def GetNaplesHostInterfacesList(naples_node, device_name=None):
    #GetNaplesHostInterfaces API returns only ETH_HOST interfaces
    eth_host_intfs = list(api.GetNaplesHostInterfaces(naples_node,
                                                      device_name))
    #GetHostInternalMgmtInterfaces API returns only ETH_HOST_MGMT interfaces
    eth_host_mgmt_intfs = naples_host_utils.GetHostInternalMgmtInterfaces(
        naples_node, device_name)
    host_intf_list = eth_host_intfs + eth_host_mgmt_intfs
    return host_intf_list
예제 #3
0
def Trigger(tc):

    # move device.json
    cmd = "mv /device.json /nic/conf/"
    resp = api.RunNaplesConsoleCmd(tc.nodes[0], cmd)

    # load drivers
    cmd = "insmod /nic/bin/ionic_mnic.ko && insmod /nic/bin/mnet_uio_pdrv_genirq.ko && insmod /nic/bin/mnet.ko"
    resp = api.RunNaplesConsoleCmd(tc.nodes[0], cmd)

    # start athena app
    cmd = "/nic/tools/start-agent-skip-dpdk.sh"
    resp = api.RunNaplesConsoleCmd(tc.nodes[0], cmd)

    # wait for athena app to be up
    utils.Sleep(80)

    # configure int_mnic0
    cmd = "ifconfig int_mnic0 " + tc.int_mnic_ip + " netmask 255.255.255.0"
    resp = api.RunNaplesConsoleCmd(tc.nodes[0], cmd)

    # run plugctl to gracefully bring up the PCI device on host
    req = api.Trigger_CreateExecuteCommandsRequest(serial=True)
    cmd = "./plugctl.sh in"
    api.Trigger_AddHostCommand(req, tc.bitw_node_name, cmd)
    resp = api.Trigger(req)
    cmd = resp.commands[0]
    api.PrintCommandResults(cmd)

    if cmd.exit_code != 0:
        api.Logger.error("Failed to gracefully bring up the PCI device on host %s" % \
                          tc.bitw_node_name)
        return api.types.status.FAILURE

    # get host internal mgmt intf
    host_intfs = naples_host.GetHostInternalMgmtInterfaces(tc.bitw_node_name)
    # Assuming single nic per host
    if len(host_intfs) == 0:
        api.Logger.error('Failed to get host interfaces')
        return api.types.status.FAILURE

    intf = host_intfs[0]
    ip_addr = str(ip_address(tc.int_mnic_ip.rstrip()) + 1)

    req = api.Trigger_CreateExecuteCommandsRequest(serial=True)
    cmd = "ifconfig " + str(intf) + " " + ip_addr + "/24 up"
    api.Trigger_AddHostCommand(req, tc.bitw_node_name, cmd)
    resp = api.Trigger(req)
    cmd = resp.commands[0]
    api.PrintCommandResults(cmd)

    if cmd.exit_code != 0:
        api.Logger.error("Failed to gracefully bring up the internal mgmt intf on host %s" % \
                          tc.bitw_node_name)
        return api.types.status.FAILURE

    return api.types.status.SUCCESS
예제 #4
0
def GetHostInternalMgmtInterfaces(node, device=None):
    intfs = []
    devices = [device] if device else api.GetDeviceNames(node)
    for device_name in devices:
        for intf in naples_host.GetHostInternalMgmtInterfaces(
                node, device_name):
            intfObj = NaplesInterface(node, intf, InterfaceType.HOST_INTERNAL,
                                      api.GetNodeOs(node), device_name)
            intfs.append(intfObj)
    api.Logger.debug("HostInternalMgmtInterfaces for node: ", node, intfs)
    return intfs
예제 #5
0
def getNativeWorkloadIntfs(tc):
    tc.host_nodes = api.GetWorkloadNodeHostnames()
    tmp_native_intf_list = {}
    tc.native_intf_list = {}
    tc.mgmt_intf_list = {}

    # Get host interfaces on all nodes
    for node in tc.host_nodes:
        tmp_native_intf_list[node] = list(api.GetWorkloadNodeHostInterfaces(node))
        if api.IsNaplesNode(node):
            tc.mgmt_intf_list[node] = list(naples_host_utils.GetHostInternalMgmtInterfaces(node))

    for node in tc.mgmt_intf_list:
        tc.native_intf_list[node] = list(set(tmp_native_intf_list.get(node))-set(tc.mgmt_intf_list.get(node)))
    return api.types.status.SUCCESS
예제 #6
0
def Setup(tc):

    tc.skip = False
    node_names = api.GetWorkloadNodeHostnames()

    if api.IsNaplesNode(node_names[0]):
        tc.naples_node = node_names[0]
        tc.peer_node = node_names[1]
    elif api.IsNaplesNode(node_names[1]):
        tc.naples_node = node_names[1]
        tc.peer_node = node_names[0]
    else:
        api.Logger.verbose("Skipping as there are no Naples nodes")
        tc.skip = True
        return api.types.status.IGNORED

    tc.on_host = {}

    tc.host_intfs = list(api.GetNaplesHostInterfaces(tc.naples_node))
    for intf in tc.host_intfs:
        tc.on_host[intf] = True

    # Mgmt interface on host for network connection to Naples over PCIE
    tc.host_int_intfs = naples_host_utils.GetHostInternalMgmtInterfaces(
        tc.naples_node)
    for intf in tc.host_int_intfs:
        tc.on_host[intf] = True

    tc.inband_intfs = naples_host_utils.GetNaplesInbandInterfaces(
        tc.naples_node)
    for intf in tc.inband_intfs:
        tc.on_host[intf] = False

    tc.naples_int_mgmt_intfs = naples_host_utils.GetNaplesInternalMgmtInterfaces(
        tc.naples_node)
    for intf in tc.naples_int_mgmt_intfs:
        tc.on_host[intf] = False

    tc.naples_oob_mgmt_intfs = naples_host_utils.GetNaplesOobInterfaces(
        tc.naples_node)
    for intf in tc.naples_oob_mgmt_intfs:
        tc.on_host[intf] = False

    tc.all_intfs = tc.host_intfs + tc.host_int_intfs + tc.inband_intfs + tc.naples_int_mgmt_intfs + tc.naples_oob_mgmt_intfs
    api.Logger.debug("Promiscuous test interfaces: ", tc.all_intfs)

    return api.types.status.SUCCESS
예제 #7
0
def InitializeMacConfig(tc):
    nodes = api.GetNaplesHostnames()
    naples_node = nodes[0]

    # workload endpoints
    wload_intf_mac_dict = {}
    wload_intf_vlan_map = {}
    for wd in subif_utils.getNativeWorkloads():
        if wd.node_name == naples_node and wd.interface == wd.parent_interface:
            wload_intf_mac_dict[wd.interface] = util_host.GetMACAddress(naples_node, wd.interface)
            wload_intf_vlan_map[wd.interface] = [8192]
            for sub in subif_utils.GetSubifs(wd.interface, wd.node_name):
                sub_wd = subif_utils.getWorkloadForInf(sub, wd.node_name)
                wload_intf_mac_dict[sub_wd.interface] = util_host.GetMACAddress(naples_node, sub_wd.interface)
                lst = wload_intf_vlan_map.get(wd.interface, None)
                if lst:
                    (wload_intf_vlan_map[wd.interface]).append(sub_wd.encap_vlan)
                else:
                    (wload_intf_vlan_map[wd.interface]).append(sub_wd.encap_vlan)

    host_intf_mac_dict = {}
    for wl in api.GetWorkloads():
        if wl.node_name == naples_node and wl.interface == wl.parent_interface:
            if wl.interface not in wload_intf_mac_dict:
                host_intf_mac_dict[wl.interface] = util_host.GetMACAddress(naples_node, wl.interface)

    for inf in utils.GetHostInternalMgmtInterfaces(naples_node):
        if inf not in wload_intf_mac_dict:
            mac = util_host.GetMACAddress(naples_node, inf)
            host_intf_mac_dict[inf] = mac

    naples_intf_mac_dict = filters_utils.getNaplesIntfMacAddrDict(naples_node)

    #Store the following info for building endpoint view and also for rollback
    tc.naples_node = naples_node
    tc.naples_intf_mac_dict = naples_intf_mac_dict
    tc.host_intf_mac_dict = host_intf_mac_dict
    tc.wload_intf_mac_dict = wload_intf_mac_dict
    tc.wload_intf_vlan_map = wload_intf_vlan_map
예제 #8
0
def Setup(tc):
    api.Logger.info("Driver Watchdog")

    tc.nodes = api.GetNaplesHostnames()
    tc.os = api.GetNodeOs(tc.nodes[0])

    if tc.os != host.OS_TYPE_BSD:
        api.Logger.info("Not implemented")
        return api.types.status.IGNORED

    tc.stg1 = {}
    tc.stg2 = {}
    tc.stg3 = {}
    tc.stg4 = {}

    tc.host_intf = {}
    for node in tc.nodes:
        tc.host_intf[node] = []
        for intf in api.GetNaplesHostInterfaces(node):
            tc.host_intf[node].append(intf)
        for intf in host.GetHostInternalMgmtInterfaces(node):
            tc.host_intf[node].append(intf)

    return api.types.status.SUCCESS
예제 #9
0
def Setup(tc):

    tc.skip = False
    node_names = api.GetWorkloadNodeHostnames()

    if api.IsNaplesNode(node_names[0]):
        tc.naples_node = node_names[0]
        tc.peer_node = node_names[1]
    elif api.IsNaplesNode(node_names[1]):
        tc.naples_node = node_names[1]
        tc.peer_node = node_names[0]
    else:
        api.Logger.verbose("Skipping as there are no Naples nodes")
        tc.skip = True
        return api.types.status.IGNORED

    tc.expect_pkt = {}
    tc.on_host = {}

    tc.host_intfs = list(api.GetNaplesHostInterfaces(tc.naples_node))
    # UUC Packets from uplink will reach host interface while promiscuous
    for intf in tc.host_intfs:
        tc.expect_pkt[intf] = True
        tc.on_host[intf] = True

    # Mgmt interface on host for network connection to Naples over PCIE
    tc.host_int_intfs = naples_host_utils.GetHostInternalMgmtInterfaces(
        tc.naples_node)
    for intf in tc.host_int_intfs:
        # Host internal management should not receive packets from uplink regardless of its promiscuity state
        tc.expect_pkt[intf] = False
        tc.on_host[intf] = True

    tc.inband_intfs = naples_host_utils.GetNaplesInbandInterfaces(
        tc.naples_node)
    # UUC Packets from uplink will reach inabnd interface while promiscuous
    for intf in tc.inband_intfs:
        tc.expect_pkt[intf] = True
        tc.on_host[intf] = False

    tc.naples_int_mgmt_intfs = naples_host_utils.GetNaplesInternalMgmtInterfaces(
        tc.naples_node)
    # Packets from uplink should not reach naples internal managment interfaces [int_mnic0] regardless of its promiscuity state
    for intf in tc.naples_int_mgmt_intfs:
        tc.expect_pkt[intf] = False
        tc.on_host[intf] = False

    tc.naples_oob_mgmt_intfs = naples_host_utils.GetNaplesOobInterfaces(
        tc.naples_node)
    # Packets from uplink should not reach naples oob managment interfaces [oob_mnic0] regardless of its promiscuity state
    for intf in tc.naples_oob_mgmt_intfs:
        tc.expect_pkt[intf] = False
        tc.on_host[intf] = False

    tc.all_intfs = tc.host_intfs + tc.host_int_intfs + tc.inband_intfs + tc.naples_int_mgmt_intfs + tc.naples_oob_mgmt_intfs
    api.Logger.info("Promiscuous test interfaces: ", tc.all_intfs)

    workloads = api.GetWorkloads()
    tc.peer_workloads = []

    # List of 'default vlan' workloads on peer node
    for workload in workloads:
        if workload.encap_vlan == 0 and workload.node_name == tc.peer_node:
            tc.peer_workloads.append(workload)

    # Random IP address within workload[0] IP address domain
    tc.target_IP = (ipaddress.ip_address(tc.peer_workloads[0].ip_address) +
                    2).__str__()

    #TODO: Generate a random MAC instead
    tc.random_mac = "00:0f:b7:aa:bb:cc"

    api.Logger.info("Random_Ip = %s Random_MAC = %s " %
                    (tc.target_IP, tc.random_mac))

    host_utils.DeleteARP(tc.peer_node, tc.peer_workloads[0].interface,
                         tc.target_IP)
    if host_utils.AddStaticARP(tc.peer_node, tc.peer_workloads[0].interface,
                               tc.target_IP,
                               tc.random_mac) != api.types.status.SUCCESS:
        api.Logger.error("Failed to add Static ARP entry on %s" %
                         (tc.peer_node))
        return api.types.status.FAILURE
    return api.types.status.SUCCESS
예제 #10
0
def Setup(tc):

    tc.skip = False
    node_names = api.GetWorkloadNodeHostnames()

    if api.IsNaplesNode(node_names[0]):
        tc.naples_node = node_names[0]
        tc.peer_node = node_names[1]
    elif api.IsNaplesNode(node_names[1]):
        tc.naples_node = node_names[1]
        tc.peer_node = node_names[0]
    else:
        api.Logger.verbose("Skipping as there are no Naples nodes")
        tc.skip = True
        return api.types.status.IGNORED

    if tc.args.mode != "promiscuous" and tc.args.mode != "non-promiscuous":
        api.Logger.error("Unknown mode '%s'. Skipping testcase" %
                         (tc.args.mode))
        tc.skip = True
        return api.types.status.IGNORED

    tc.on_host = {}

    tc.host_intfs = list(api.GetNaplesHostInterfaces(tc.naples_node))
    for intf in tc.host_intfs:
        tc.on_host[intf] = True

    # Mgmt interface on host for network connection to Naples over PCIE (Subset of tc.host_intfs)
    tc.host_int_intfs = naples_host_utils.GetHostInternalMgmtInterfaces(
        tc.naples_node)
    for intf in tc.host_int_intfs:
        tc.on_host[intf] = True

    tc.inband_intfs = naples_host_utils.GetNaplesInbandInterfaces(
        tc.naples_node)
    for intf in tc.inband_intfs:
        tc.on_host[intf] = False

    tc.naples_int_mgmt_intfs = naples_host_utils.GetNaplesInternalMgmtInterfaces(
        tc.naples_node)
    for intf in tc.naples_int_mgmt_intfs:
        tc.on_host[intf] = False

    tc.naples_oob_mgmt_intfs = naples_host_utils.GetNaplesOobInterfaces(
        tc.naples_node)
    for intf in tc.naples_oob_mgmt_intfs:
        tc.on_host[intf] = False

    tc.all_intfs = tc.host_intfs + tc.host_int_intfs + tc.inband_intfs + tc.naples_int_mgmt_intfs + tc.naples_oob_mgmt_intfs

    workloads = api.GetWorkloads()
    tc.peer_workloads = []

    # List of 'default vlan' workloads on peer node
    for workload in workloads:
        if workload.encap_vlan == 0 and workload.node_name == tc.peer_node:
            tc.peer_workloads.append(workload)

    # Random IP address within workload[0] IP address domain
    tc.target_IP = (ipaddress.ip_address(tc.peer_workloads[0].ip_address) +
                    4).__str__()

    return api.types.status.SUCCESS
예제 #11
0
def GetNaplesMgmtIntf(node, device=None):
    naples_host_mgmt_if = naples_host_util.GetHostInternalMgmtInterfaces(node)
    return naples_host_mgmt_if[0]
예제 #12
0
def ValidateMacRegistration():
    nodes = api.GetNaplesHostnames()
    naples_node = nodes[0]

    # workload endpoints
    wload_intf_mac_dict = {}
    wload_intf_vlan_map = {}
    for wd in subif_utils.getNativeWorkloads():
        if wd.node_name == naples_node and wd.interface == wd.parent_interface:
            wload_intf_mac_dict[wd.interface] = util_host.GetMACAddress(
                naples_node, wd.interface)
            wload_intf_vlan_map[wd.interface] = [8192]
            for sub in subif_utils.GetSubifs(wd.interface, wd.node_name):
                sub_wd = subif_utils.getWorkloadForInf(sub, wd.node_name)
                wload_intf_mac_dict[
                    sub_wd.interface] = util_host.GetMACAddress(
                        naples_node, sub_wd.interface)
                lst = wload_intf_vlan_map.get(wd.interface, None)
                if lst:
                    (wload_intf_vlan_map[wd.interface]).append(
                        sub_wd.encap_vlan)
                else:
                    (wload_intf_vlan_map[wd.interface]).append(
                        sub_wd.encap_vlan)

    api.Logger.info("wload_intf_vlan_map: %s \n" % wload_intf_vlan_map)
    api.Logger.info("wload_intf_mac_dict: %s \n" % wload_intf_mac_dict)

    wload_ep_set = filters_utils.getWorkloadEndPoints(naples_node,
                                                      wload_intf_mac_dict,
                                                      wload_intf_vlan_map)

    host_intf_mac_dict = {}
    for wl in api.GetWorkloads():
        if wl.node_name == naples_node and wl.interface == wl.parent_interface:
            if wl.interface not in wload_intf_mac_dict:
                host_intf_mac_dict[wl.interface] = util_host.GetMACAddress(
                    naples_node, wl.interface)

    for inf in naples_host_utils.GetHostInternalMgmtInterfaces(naples_node):
        if inf not in wload_intf_mac_dict:
            mac = util_host.GetMACAddress(naples_node, inf)
            host_intf_mac_dict[inf] = mac

    # Other host interface endpoints (which aren't part of workloads)
    host_ep_set = filters_utils.getHostIntfEndPoints(naples_node,
                                                     host_intf_mac_dict)

    # Naples intf endpoints
    naples_intf_mac_dict = filters_utils.getNaplesIntfMacAddrDict(naples_node)
    naples_ep_set = filters_utils.getNaplesIntfEndPoints(
        naples_node, naples_intf_mac_dict)

    # HAL view of endpoints
    hal_ep_set = filters_utils.getNaplesHALEndPoints(naples_node)

    #Keeping them separate as it is useful for debugging in scale
    api.Logger.info("getAllEndPointsView: wload_ep_set ", len(wload_ep_set),
                    wload_ep_set)
    api.Logger.info("getAllEndPointsView: host_ep_set ", len(host_ep_set),
                    host_ep_set)
    api.Logger.info("getAllEndPointsView: naples_ep_set ", len(naples_ep_set),
                    naples_ep_set)
    api.Logger.info("getAllEndPointsView: hal_ep_set ", len(hal_ep_set),
                    hal_ep_set)

    return wload_ep_set, host_ep_set, naples_ep_set, hal_ep_set
예제 #13
0
def Setup(tc):

    result = api.types.status.SUCCESS
    tc.skip = False
    node_names = api.GetWorkloadNodeHostnames()

    if not api.RunningOnSameSwitch():
        tc.skip = True
        api.Logger.error(
            "Rx Mode MC : Setup -> Multi switch topology not supported yet - So skipping the TC"
        )
        return api.types.status.IGNORED

    if api.IsNaplesNode(node_names[0]):
        tc.naples_node = node_names[0]
        tc.peer_node = node_names[1]
    elif api.IsNaplesNode(node_names[1]):
        tc.naples_node = node_names[1]
        tc.peer_node = node_names[0]
    else:
        api.Logger.info("Skipping as there are no Naples nodes")
        tc.skip = True
        return api.types.status.IGNORED

    if tc.args.mode != "enable_allmulti" and tc.args.mode != "disable_allmulti":
        api.Logger.error("Unknown mode '%s'. Skipping testcase" %
                         (tc.args.mode))
        tc.skip = True
        return api.types.status.IGNORED

    if api.GetNodeOs(
            tc.naples_node) != "linux" and tc.args.mode == "enable_allmulti":
        api.Logger.info("Skipping testcase because allmulti cannot be set")
        tc.skip = True
        return api.types.status.IGNORED

    tc.expect_pkt = {}
    tc.on_host = {}

    tc.host_intfs = list(api.GetNaplesHostInterfaces(tc.naples_node))
    # Unknown Multicast Packets from uplink will reach host interface when allmulti is enabled
    for intf in tc.host_intfs:
        tc.expect_pkt[intf] = True
        tc.on_host[intf] = True

    # Mgmt interface on host for network connection to Naples over PCIE (Subset of tc.host_intfs)
    tc.host_int_intfs = naples_host_utils.GetHostInternalMgmtInterfaces(
        tc.naples_node)
    for intf in tc.host_int_intfs:
        # Host internal management should not receive unknown multicast packets from uplink regardless of its allmulti state
        tc.expect_pkt[intf] = False
        tc.on_host[intf] = True

    tc.inband_intfs = naples_host_utils.GetNaplesInbandInterfaces(
        tc.naples_node)
    # Unknwown multicast packets from uplink will reach inband interface when allmulti is enabled
    for intf in tc.inband_intfs:
        tc.expect_pkt[intf] = True
        tc.on_host[intf] = False

    tc.naples_int_mgmt_intfs = naples_host_utils.GetNaplesInternalMgmtInterfaces(
        tc.naples_node)
    # Packets from uplink should not reach naples internal managment interfaces [int_mnic0] regardless of its allmulti
    for intf in tc.naples_int_mgmt_intfs:
        tc.expect_pkt[intf] = False
        tc.on_host[intf] = False

    tc.naples_oob_mgmt_intfs = naples_host_utils.GetNaplesOobInterfaces(
        tc.naples_node)
    # Packets from uplink should not reach naples oob managment interfaces [oob_mnic0] regardless of its allmulti state
    for intf in tc.naples_oob_mgmt_intfs:
        tc.expect_pkt[intf] = False
        tc.on_host[intf] = False

    tc.all_intfs = tc.host_intfs + tc.host_int_intfs + tc.inband_intfs + tc.naples_int_mgmt_intfs + tc.naples_oob_mgmt_intfs

    # In non-promiscuous mode, unknown unicast traffic shouldn't reach any interface
    if tc.args.mode == "disable_allmulti":
        for intf in tc.all_intfs:
            tc.expect_pkt[intf] = False

    api.Logger.debug("Test interfaces: ", tc.all_intfs)

    workloads = api.GetWorkloads()
    tc.peer_workloads = []

    # List of 'default vlan' workloads on peer node
    for workload in workloads:
        if workload.encap_vlan == 0 and workload.node_name == tc.peer_node:
            tc.peer_workloads.append(workload)

    # Random Multicast IP address
    tc.target_multicast_IP = "226.1.2.3"
    api.Logger.debug("Random Multicast IP = %s " % (tc.target_multicast_IP))

    # Move all interfaces to allmulti mode if tc.args.mode == 'enable_allmulti'
    if tc.args.mode == "enable_allmulti":
        for intf in tc.all_intfs:
            result = __Toggle_AllMulti(tc, intf, True)
            if result != api.types.status.SUCCESS:
                api.Logger.Error("Skipping testcase")
                break

    return result