Beispiel #1
0
def setupWorkloadDict(tc, kind=None):
    workload_pairs = []
    if kind != None:
        if kind == 'remote':
            workload_pairs = api.GetRemoteWorkloadPairs()
        elif kind == 'local':
            workload_pairs.extend(api.GetLocalWorkloadPairs())
    else:
        workload_pairs = api.GetRemoteWorkloadPairs()
        workload_pairs.extend(api.GetLocalWorkloadPairs())

    naples_node_name_list = api.GetNaplesHostnames()
    w_list = []

    for w1,w2 in workload_pairs:
        if w1.node_name in naples_node_name_list or \
           w2.node_name in naples_node_name_list:
            w_list.append((w1,w2))
            api.Logger.info("Adding Naples workload w1: %s and w2: %s to list"%
                            (w1.workload_name, w2.workload_name))
        else:
            api.Logger.debug("Skipping non Naples workload w1: %s and w2: %s"%
                             (w1.workload_name, w2.workload_name))
    tc.workload_dict = workload_dict = {}
    for w1,w2 in w_list:
        l = workload_dict.get(w1, [])
        l.append(w2)
        workload_dict[w1] = l

    for w1, dst_workload_list in tc.workload_dict.items():
        l = [w2.workload_name for w2 in dst_workload_list]
        api.Logger.info("%s => %s"%(w1.workload_name, ",".join(l)))
Beispiel #2
0
def ArPing(tc):
    if tc.args.type == 'local_only':
        api.Logger.info("local_only test")
        tc.workload_pairs = api.GetLocalWorkloadPairs()
    elif tc.args.type == 'both':
        api.Logger.info(" both local and remote test")
        tc.workload_pairs = api.GetLocalWorkloadPairs()
        tc.workload_pairs.extend(api.GetRemoteWorkloadPairs())
    else:
        api.Logger.info("remote_only test")
        tc.workload_pairs = api.GetRemoteWorkloadPairs()

    if len(tc.workload_pairs) == 0:
        api.Logger.info("Skipping Testcase due to no workload pairs.")
        tc.skip = True

    req = None
    interval = "0.2"
    if not api.IsSimulation():
        req = api.Trigger_CreateAllParallelCommandsRequest()
    else:
        req = api.Trigger_CreateExecuteCommandsRequest(serial=False)
        interval = "3"
    tc.cmd_cookies = []

    for pair in tc.workload_pairs:
        w1 = pair[0]
        w2 = pair[1]
        cmd_cookie = "%s %s %s %s" % (w1.node_name, w1.workload_name,
                                      w1.interface, w1.ip_address)
        api.Trigger_AddCommand(req, w1.node_name, w1.workload_name,
                               "arping -c  5 -U %s -I eth1" % (w1.ip_address))
        api.Logger.info("ArPing from %s" % (cmd_cookie))
        tc.cmd_cookies.append(cmd_cookie)

        cmd_cookie = "%s %s %s %s" % (w2.node_name, w2.workload_name,
                                      w2.interface, w2.ip_address)
        api.Trigger_AddCommand(req, w2.node_name, w2.workload_name,
                               "arping -c  5 -U %s -I eth1" % (w2.ip_address))
        api.Logger.info("ArPing from %s" % (cmd_cookie))
        tc.cmd_cookies.append(cmd_cookie)

    tc.resp = api.Trigger(req)

    if tc.resp is None:
        return api.types.status.FAILURE

    result = api.types.status.SUCCESS
    cookie_idx = 0

    for cmd in tc.resp.commands:
        api.Logger.info("ArPing Results for %s" % (tc.cmd_cookies[cookie_idx]))
        api.PrintCommandResults(cmd)
        if cmd.exit_code != 0:
            result = api.types.status.FAILURE
        cookie_idx += 1
    return result
Beispiel #3
0
def Trigger(tc):
    if tc.os == naples_host.OS_TYPE_ESX:
        api.Logger.info("Not implemented for %s" % tc.os)
        return api.types.status.IGNORED
    
    fail = 0   
    pairs = api.GetLocalWorkloadPairs()
    hosts = pairs[0]

    for host in hosts:
        if not host.IsNaples():
            continue

        api.Logger.info("Checking host %s" % host.node_name)
        lif_info = __getLifInfo(host.node_name)

        intfs = api.GetNaplesHostInterfaces(host.node_name)
        for intf in intfs:
            # Windows HAL interface name is translated two times.
            if tc.os == naples_host.OS_TYPE_WINDOWS:
                intf = ionic_utils.winHalIntfName(host.node_name, intf)
                # HAL yaml o/p is Pen..Adapter, halctl cli op/ is pen..adap.
                intf = intf.lower()

            if lif_info.find(intf) == -1:
                api.Logger.error("interface %s not found" % intf)
                fail += 1

    if fail != 0:
        return api.types.status.FAILURE

    return api.types.status.SUCCESS
Beispiel #4
0
def Setup(tc):
    tc.loop_count = 0
    tc.policy_db = {}
    api.Logger.info("Loop count set to ", tc.loop_count)

    tc.nodes = api.GetNaplesHostnames()
    #netagent_cfg_api.ReadJsons()
    tc.sgpolicy = sgpolicy_obj.gl_sg_json_template
    #get rules list - it is list of dictionary
    policy_rules = tc.sgpolicy['sgpolicies'][0]['spec']['policy-rules']
    meta = tc.sgpolicy['sgpolicies'][0]['meta']
    meta['name'] = 'default_policies'
    meta['namespace'] = 'default'
    meta['tenant'] = 'default'
    print('Initial policy rules {}'.format(policy_rules))
    print(api.GetWorkloads())
    tc.workload_pairs = api.GetLocalWorkloadPairs()
    print(tc.workload_pairs)
    for pair in tc.workload_pairs:
        w1 = pair[0]
        w2 = pair[1]
        rule = get_rule(w1.ip_address, w2.ip_address, "udp", "59379", "PERMIT")
        tc.policy_db[(w1, w2, "udp", "59379")] = "PERMIT"
        policy_rules.append(rule)
    return api.types.status.SUCCESS
Beispiel #5
0
def Trigger(tc):
    if tc.os != naples_host.OS_TYPE_BSD and tc.os != naples_host.OS_TYPE_LINUX:
        api.Logger.info("Not implemented for %s" % tc.os)
        return api.types.status.IGNORED

    fail = 0
    pairs = api.GetLocalWorkloadPairs()
    hosts = pairs[0]

    for host in hosts:
        if not host.IsNaples():
            continue

        api.Logger.info("Checking host %s" % host.node_name)
        lif_info = __getLifInfo(host.node_name)

        intfs = api.GetNaplesHostInterfaces(host.node_name)
        for intf in intfs:
            api.Logger.info("Checking interface %s" % intf)

            if lif_info.find(intf) == -1:
                api.Logger.info("interface %s not found" % intf)
                fail += 1

    if fail != 0:
        return api.types.status.FAILURE

    return api.types.status.SUCCESS
Beispiel #6
0
def Setup(tc):
    tc.Nodes    = api.GetNaplesHostnames()
    tc.uuidMap  = api.GetNaplesNodeUuidMap()
    tc.old_node = None
    tc.new_node = None
    tc.skip_security_prof = getattr(tc.args, "skip_security_prof", False)

    tc.client, tc.server, tc.naples = None, None, None

    if tc.args.type == 'local_only':
        tc.workload_pairs = api.GetLocalWorkloadPairs(naples=True)
    else:
        tc.workload_pairs = api.GetRemoteWorkloadPairs()

    if len(tc.workload_pairs) == 0:
        api.Logger.error("Failed to get client server pair")
        return api.types.status.FAIL

    # pick a node to run traffic test
    ret = chooseNaples(tc, tc.workload_pairs[0])
    if ret != api.types.status.SUCCESS:
        return ret

    # pick a new node to move one of the vms to
    ret = vm_utils.pick_new_node(tc)
    if ret != api.types.status.SUCCESS:
        return ret

    if not addPktFltrRuleOnEp(tc):
        api.Logger.error("Failed to add packet filter on EP")
        return api.types.status.FAIL

    return api.types.status.SUCCESS
Beispiel #7
0
def Setup(tc):
    tc.skip = False

    if tc.args.type == 'local_only':
        tc.workload_pairs = api.GetLocalWorkloadPairs()
    else:
        tc.workload_pairs = api.GetRemoteWorkloadPairs()

    if len(tc.workload_pairs) == 0:
        api.Logger.info("Skipping Testcase due to no workload pairs.")
        tc.skip = True

    if api.GetConfigNicMode() == 'hostpin' and tc.iterators.ipaf == 'ipv6':
        api.Logger.info("Skipping Testcase: IPv6 not supported in hostpin mode.")
        tc.skip = True

    if getattr(tc.args, 'vmotion_enable', False):
        wloads = []
        for idx, pair in enumerate(tc.workload_pairs):
            if idx % 2:
                continue
            w2 = pair[1]
            wloads.append(w2)
        vmotion_utils.PrepareWorkloadVMotion(tc, wloads)

    return api.types.status.SUCCESS
Beispiel #8
0
def Setup(tc):
    if tc.iterators.eptype == 'local':
        tc.workload_pairs = api.GetLocalWorkloadPairs()
    else:
        tc.workload_pairs = api.GetRemoteWorkloadPairs()

    return api.types.status.SUCCESS
Beispiel #9
0
def Setup(tc):
    api.Logger.info ("Driver compat test")
    if api.IsDryrun(): return api.types.status.SUCCESS

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

    tc.skip = False
    tc.driver_changed = False
    if tc.os == compat.OS_TYPE_BSD: # Not supportig BSD right now
        tc.skip = True
        return api.types.status.SUCCESS

    # Intention to test locally built FW with target-version driver
    tc.target_version = getattr(tc.iterators, 'release', 'latest')

    if compat.LoadDriver(tc.nodes, node_os, tc.target_version):
        tc.driver_changed = True

    if getattr(tc.args, 'type', 'local_only') == 'local_only': 
        tc.workload_pairs = api.GetLocalWorkloadPairs()
    else: 
        tc.workload_pairs = api.GetRemoteWorkloadPairs() 

    if len(tc.workload_pairs) == 0: 
        api.Logger.info("Skipping ping part of testcase due to no workload pairs.") 
        tc.skip = True

    return api.types.status.SUCCESS
Beispiel #10
0
def Setup(tc):

    tc.skip = False
    if tc.selected:
        tc.workload_pairs = tc.selected
    else:
        if tc.args.type == 'local_only':
            tc.workload_pairs = api.GetLocalWorkloadPairs()
        else:
            tc.workload_pairs = api.GetRemoteWorkloadPairs()

        tc.workload_pairs = tc.workload_pairs[:1]

    if len(tc.workload_pairs) == 0:
        api.Logger.info("Skipping Testcase due to no workload pairs.")
        tc.skip = True

    if getattr(tc.args, 'vmotion_enable', False):
        wloads = []
        # collecting all server
        for wl_pair in tc.workload_pairs:
            wloads.append(wl_pair[1])

        vmotion_utils.PrepareWorkloadVMotion(tc, wloads)

    #Have to fix it later.
    return api.types.status.SUCCESS
Beispiel #11
0
def Trigger(tc):
    pairs = api.GetLocalWorkloadPairs()
    tc.cmd_cookies = []
    server, client = pairs[0]
    naples = server
    if not server.IsNaples():
        naples = client
        if not client.IsNaples():
            return api.types.status.SUCCESS
        else:
            client, server = pairs[0]

    cmd_cookie = "%s(%s) --> %s(%s)" %\
                (server.workload_name, server.ip_address, client.workload_name, client.ip_address)
    api.Logger.info("Starting clear & show stress test from %s" % (cmd_cookie))

    basecmd = 'iperf -p %d ' % api.AllocateTcpPort()
    proto = 6
    timeout = 250
    #tc.secprof = sec_profile_obj.gl_securityprofile_json_template
    #timeout = int(tc.secprof['security-profiles'][0]['spec']['timeouts']['tcp']) + \
    #          int(tc.secprof['security-profiles'][0]['spec']['timeouts']['tcp-close'])
    if tc.iterators.proto == 'udp':
        basecmd = 'iperf -u -p %d ' % api.AllocateUdpPort()
        proto = 17
        timeout = 150
        #timeout = tc.security_profile['security-profiles'][0]['spec']['timeouts']['udp']

    req = api.Trigger_CreateExecuteCommandsRequest(serial=True)

    for cnt in range(tc.args.count):
        cmd_cookie = "iperf -s"
        api.Trigger_AddCommand(req,
                               server.node_name,
                               server.workload_name,
                               "%s-s -t 300" % basecmd,
                               background=True)
        tc.cmd_cookies.append(cmd_cookie)

        cmd_cookie = "iperf -c "
        api.Trigger_AddCommand(
            req, client.node_name, client.workload_name,
            "%s -c %s -P 100" % (basecmd, server.ip_address))
        tc.cmd_cookies.append(cmd_cookie)

        cmd_cookie = "Show session"
        api.Trigger_AddNaplesCommand(req, naples.node_name,
                                     "/nic/bin/halctl show session")
        tc.cmd_cookies.append(cmd_cookie)

        cmd_cookie = "Clear session"
        api.Trigger_AddNaplesCommand(req, naples.node_name,
                                     "/nic/bin/halctl clear session")
        tc.cmd_cookies.append(cmd_cookie)

    trig_resp = api.Trigger(req)
    term_resp = api.Trigger_TerminateAllCommands(trig_resp)

    tc.resp = api.Trigger_AggregateCommandsResponse(trig_resp, term_resp)
    return api.types.status.SUCCESS
Beispiel #12
0
def Setup(tc):
    tc.Nodes = api.GetNaplesHostnames()
    tc.uuidMap = api.GetNaplesNodeUuidMap()
    tc.old_node = None
    tc.new_node = None
    tc.skip_security_prof = getattr(tc.args, "skip_security_prof", False)

    if tc.args.type == 'local_only':
        tc.workload_pairs = api.GetLocalWorkloadPairs()
    else:
        tc.workload_pairs = api.GetRemoteWorkloadPairs()
    w1, w2 = tc.workload_pairs[0]
    tc.old_node = w1.node_name if w1.IsNaples() else w2.node_name
    tc.wl = w1

    # remove the node being used to pick wl for traffic
    # pick the next node in the naples nodes
    naples_nodes = tc.Nodes[:]
    naples_nodes.remove(w1.node_name)
    assert (len(naples_nodes) >= 1)
    new_node = naples_nodes[0]
    tc.new_node = new_node
    move_info = vm_utils.MoveInfo()
    move_info.new_node = new_node
    move_info.wl = w1
    move_info.old_node = w1.node_name
    tc.move_info.append(move_info)
    return api.types.status.SUCCESS
Beispiel #13
0
def Setup(tc):
    if tc.args.type == 'local_only':
        tc.workload_pairs = api.GetLocalWorkloadPairs()
    else:
        tc.workload_pairs = api.GetRemoteWorkloadPairs()
    w1, w2 = tc.workload_pairs[0]
    tc.naples = w1 if w1.IsNaples() else w2
    return api.types.status.SUCCESS
Beispiel #14
0
def Setup(tc):

    tc.workload_pairs = api.GetLocalWorkloadPairs()

    if len(tc.workload_pairs) == 0:
        api.Logger.info("Skipping Testcase due to no workload pairs.")
        tc.skip = True

    return api.types.status.SUCCESS
Beispiel #15
0
def Setup(tc):
    api.Logger.info("Setup.")
    tc.pcap_file_name = None
    tc.dir_path = os.path.dirname(os.path.realpath(__file__))
    tc.test_mss = 900
    if tc.iterators.kind == "remote":
        pairs = api.GetRemoteWorkloadPairs()
        if not pairs:
            api.Logger.info("no remtote eps")
            return api.types.status.SUCCESS
    else:
        pairs = api.GetLocalWorkloadPairs()

    tc.resp_flow = getattr(tc.args, "resp_flow", 0)
    tc.cmd_cookies = {}
    req = api.Trigger_CreateExecuteCommandsRequest(serial=True)

    if pairs[0][0].IsNaples():
        tc.client, tc.server = pairs[0]
    else:
        tc.server, tc.client = pairs[0]

    fullpath = tc.dir_path + '/' + "scapy_3way.py"
    resp = api.CopyToWorkload(tc.server.node_name, tc.server.workload_name,
                              [fullpath])
    resp = api.CopyToWorkload(tc.client.node_name, tc.client.workload_name,
                              [fullpath])

    cmd_cookie = start_nc_server(tc.server, "1237")
    add_command(req, tc, 'server', tc.server, cmd_cookie, True)

    ret = __add_remove_tcp_drop_rule(tc.client)
    if ret != api.types.status.SUCCESS:
        api.Logger.error(
            f"Failed to drop the drop rule on {tc.client.workload_name}")
        return ret

    #start session
    cmd_cookie = "sudo -E python3 ./scapy_3way.py {} {}".format(
        tc.client.ip_address, tc.server.ip_address)
    api.Trigger_AddCommand(req, tc.client.node_name, tc.client.workload_name,
                           cmd_cookie, False)

    cmd_cookie = "/nic/bin/halctl show session --dstport 1237 --dstip {} --yaml".format(
        tc.server.ip_address)
    add_command(req, tc, 'show before', tc.client, cmd_cookie, naples=True)
    tc.first_resp = api.Trigger(req)
    cmd = tc.first_resp.commands[-1]
    api.PrintCommandResults(cmd)

    tc.pre_ctrckinf = get_conntrackinfo(cmd)

    if getattr(tc.args, 'vmotion_enable', False):
        vmotion_utils.PrepareWorkloadVMotion(tc, [tc.client])

    return api.types.status.SUCCESS
Beispiel #16
0
def Setup(tc):
    tc.skip = False
    if tc.args.type == 'local_only':
        tc.workload_pairs = api.GetLocalWorkloadPairs()
    else:
        tc.workload_pairs = api.GetRemoteWorkloadPairs()
    if len(tc.workload_pairs) == 0:
        api.Logger.info("Skipping Testcase due to no workload pairs.")
        tc.skip = True
    return api.types.status.SUCCESS
Beispiel #17
0
def Trigger(tc):
    pairs = api.GetLocalWorkloadPairs()
    server = pairs[0][0]
    client = pairs[0][1]
    tc.cmd_cookies = []

    naples = server
    if not server.IsNaples():
       naples = client
       if not client.IsNaples():
          return api.types.status.SUCCESS

    req = api.Trigger_CreateExecuteCommandsRequest(serial = True)
    tc.cmd_descr = "Server: %s(%s) <--> Client: %s(%s)" %\
                   (server.workload_name, server.ip_address, client.workload_name, client.ip_address)
    api.Logger.info("Starting RTSP test from %s" % (tc.cmd_descr))

    dir_path = os.path.dirname(os.path.realpath(__file__))
    fullpath = dir_path + '/' + "small.vob"
    api.Logger.info("fullpath %s" % (fullpath))
    resp = api.CopyToWorkload(server.node_name, server.workload_name, [fullpath], 'rtspdir')
    if resp is None:
       return api.types.status.FAILURE

    api.Trigger_AddCommand(req, client.node_name, client.workload_name,
                           "ls -al | grep video")
    tc.cmd_cookies.append("Before RTSP")

    server_cmd = "cd rtspdir && live555MediaServer"
    api.Trigger_AddCommand(req, server.node_name, server.workload_name,
                           server_cmd, background = True)
    tc.cmd_cookies.append("Run RTSP server")
    
    api.Trigger_AddCommand(req, client.node_name, client.workload_name,
                           "openRTSP rtsp://%s/small.vob" % server.ip_address)
    tc.cmd_cookies.append("Run RTSP client")

    ## Add Naples command validation
    api.Trigger_AddNaplesCommand(req, naples.node_name,
                                "/nic/bin/halctl show session --alg rtsp --yaml")
    tc.cmd_cookies.append("show session RTSP established")

    api.Trigger_AddNaplesCommand(req, naples.node_name,
                            "/nic/bin/halctl show nwsec flow-gate | grep RTSP")
    tc.cmd_cookies.append("show flow-gate") 

    api.Trigger_AddCommand(req, client.node_name, client.workload_name,
                           "ls -al | grep video")
    tc.cmd_cookies.append("After RTSP")

    trig_resp = api.Trigger(req)
    term_resp = api.Trigger_TerminateAllCommands(trig_resp)

    tc.resp = api.Trigger_AggregateCommandsResponse(trig_resp, term_resp)
    return api.types.status.SUCCESS
Beispiel #18
0
def Main(step):
    res = api.types.status.SUCCESS
    workloads = api.GetLocalWorkloadPairs(True)
    naples_inband_ip = {}
    ip_offset = 100
    new_controller_ip = None
    for wl in workloads:
        w1 = wl[0]
        w2 = wl[1]

        if (w1.uplink_vlan != 0):
            continue

        if naples_inband_ip.get(w1.node_name) != None:
            continue

        ip_mask = w1.ip_prefix.split('/')[1]
        ip_addr = ip.IPv4Interface(w1.ip_prefix)

        w1_ip_intf = ip.IPv4Interface(str(w1.ip_prefix))
        #For inband collector config, agent always resolves thru first ip addr on the inband mgmt i/f.
        #so forcing to use 10.x.x.x network as inband mgmt ip for baremetal workloads
        if api.IsBareMetalWorkloadType(w1.node_name):
            if (str(w1_ip_intf.network).split('/')[0]) != "10.255.0.0":
                continue

        #chose ip_offset as the IP address for host in-band mgmt ip
        new_naples_inband_ip = ip.IPv4Interface(ip_addr.ip + ip_offset)
        ip_offset += 1
        if new_controller_ip == None:
            new_controller_ip = ip.IPv4Interface(ip_addr.ip + ip_offset)
            ip_offset += 1

        new_naples_inband_ip_str = str(
            new_naples_inband_ip.ip) + "/" + str(ip_mask)

        node = w1.node_name
        api.Logger.info(
            "Configuring Naples Inband IP {}".format(new_naples_inband_ip_str))
        ret = common.SetNaplesModeInband_Static(node,
                                                str(new_controller_ip.ip),
                                                new_naples_inband_ip_str)
        if ret == None:
            api.Logger.info("Failed to set Naples Inband mode IP: {}".format(
                new_naples_inband_ip_str))
            res = api.types.status.FAILURE
        #api.Logger.info("Naples {}".format(common.PenctlGetNaplesMgtmIp(node)))

        naples_inband_ip.update({w1.node_name: new_naples_inband_ip_str})
        #break

    return res
Beispiel #19
0
def Trigger(tc):
    pairs = api.GetLocalWorkloadPairs()
    server = pairs[0][0]
    client = pairs[0][1]
    tc.cmd_cookies = []

    naples = server
    if not server.IsNaples():
       naples = client
       if not client.IsNaples():
          return api.types.status.SUCCESS

    req = api.Trigger_CreateExecuteCommandsRequest(serial = True)
    tc.cmd_descr = "Server: %s(%s) <--> Client: %s(%s)" %\
                   (server.workload_name, server.ip_address, client.workload_name, client.ip_address)
    api.Logger.info("Starting SUNRPC test from %s" % (tc.cmd_descr))

    api.Trigger_AddNaplesCommand(req, naples.node_name,
                           "/nic/bin/halctl clear session")
    tc.cmd_cookies.append("clear session")

    api.Trigger_AddCommand(req, server.node_name, server.workload_name, 
                           "sudo service rpcbind start")
    tc.cmd_cookies.append("Start RPC")

    api.Trigger_AddCommand(req, client.node_name, client.workload_name,
                           "rpcinfo -T udp %s 100000 4"%(server.ip_address))
    tc.cmd_cookies.append("RPC Getport")

    api.Trigger_AddNaplesCommand(req, naples.node_name,
                           "/nic/bin/halctl show session --alg sun_rpc")
    tc.cmd_cookies.append("show session")
    api.Trigger_AddNaplesCommand(req, naples.node_name,
                           "/nic/bin/halctl show nwsec flow-gate")
    tc.cmd_cookies.append("show security flow-gate")

    # Add Naples command validation
    api.Trigger_AddNaplesCommand(req, naples.node_name,
                           "sleep 100", timeout=120)
    tc.cmd_cookies.append("sleep")
    api.Trigger_AddNaplesCommand(req, naples.node_name,
                           "/nic/bin/halctl show session --alg sun_rpc")
    tc.cmd_cookies.append("After timeout session")
    api.Trigger_AddNaplesCommand(req, naples.node_name,
                           "/nic/bin/halctl show nwsec flow-gate")
    tc.cmd_cookies.append("After timeout flow-gate")
  
    trig_resp = api.Trigger(req)
    term_resp = api.Trigger_TerminateAllCommands(trig_resp)
    tc.resp = api.Trigger_AggregateCommandsResponse(trig_resp, term_resp)
    return api.types.status.SUCCESS
Beispiel #20
0
def GetServerClientSinglePair(kind, naples=True):
    if kind == 'remote':
        pairs = api.GetRemoteWorkloadPairs()
    else:
        pairs = api.GetLocalWorkloadPairs(naples=naples)
    if len(pairs) == 0:
        api.Logger.info("No workloads found")
        return (None, None)
    server, client = pairs[0]
    if not server.IsNaples():
        if not client.IsNaples():
            api.Logger.info("Naples workloads not found")
            return (None, None)
    return (server, client)
Beispiel #21
0
def Setup(tc):
    api.Logger.info("Interface Names")
    tc.nodes = api.GetNaplesHostnames()
    tc.os = api.GetNodeOs(tc.nodes[0])

    if tc.os != naples_host.OS_TYPE_BSD and tc.os != naples_host.OS_TYPE_LINUX:
        api.Logger.info("Not implemented for %s" % tc.os)
        return api.types.status.IGNORED

    pairs = api.GetLocalWorkloadPairs()
    if not pairs:
        api.Logger.error("No workloads found")
        return api.types.status.FAILURE

    return api.types.status.SUCCESS
Beispiel #22
0
def chooseWorkload(tc):
    tc.skip = False
    if tc.selected:
        tc.workload_pairs = tc.selected
    else:
        if tc.args.type == 'local_only':
            tc.workload_pairs = api.GetLocalWorkloadPairs()
        else:
            tc.workload_pairs = api.GetRemoteWorkloadPairs()

    naples_node_name_list = api.GetNaplesHostnames()

    w1, w2 = tc.workload_pairs[0]
    tc.workload_pair = (w1, w2)
    return
Beispiel #23
0
def Setup(tc):
    if tc.args.type == 'local_only':
        tc.workload_pairs = api.GetLocalWorkloadPairs()
    else:
        tc.workload_pairs = api.GetRemoteWorkloadPairs()

    for pair in tc.workload_pairs:
        w1 = pair[0]
        w2 = pair[1]
        # check if BM type
        if api.IsBareMetalWorkloadType(w1.node_name):
            api.Logger.info("For BM type, this test is not supported yet")
            tc.skip = True
            break

    return api.types.status.SUCCESS
Beispiel #24
0
def Setup(tc):
    api.Logger.info("Setup.")
    if tc.iterators.kind == "remote":
        pairs = api.GetRemoteWorkloadPairs()
        if not pairs:
            api.Logger.info("no remtote eps")
            return api.types.status.SUCCESS
    else:
        pairs = api.GetLocalWorkloadPairs()
    tc.cmd_cookies = {}
    req = api.Trigger_CreateExecuteCommandsRequest(serial=True)

    #for w1,w2 in pairs:
    if pairs[0][0].IsNaples():
        tc.client, tc.server = pairs[0]
    else:
        tc.server, tc.client = pairs[0]
    cmd_cookie = "nc -l 1234"
    api.Trigger_AddCommand(req,
                           tc.server.node_name,
                           tc.server.workload_name,
                           cmd_cookie,
                           background=True)
    tc.cmd_cookies['server'] = cmd_cookie

    cmd_cookie = "nc {} 1234 -p 52252".format(tc.server.ip_address)
    api.Trigger_AddCommand(req,
                           tc.client.node_name,
                           tc.client.workload_name,
                           cmd_cookie,
                           background=True)
    tc.cmd_cookies['client'] = cmd_cookie

    cmd_cookie = "/nic/bin/halctl show session --dstport 1234 --dstip {} --yaml".format(
        tc.server.ip_address)
    api.Trigger_AddNaplesCommand(req, tc.client.node_name, cmd_cookie)
    tc.setup_cmd_resp = api.Trigger(req)

    cmd = tc.setup_cmd_resp.commands[-1]
    api.PrintCommandResults(cmd)
    tc.pre_ctrckinf = get_conntrackinfo(cmd)
    if getattr(tc.args, 'vmotion_enable', False):
        vmotion_utils.PrepareWorkloadVMotion(tc, [tc.client])

    return api.types.status.SUCCESS
Beispiel #25
0
def Trigger(tc):
    pairs = api.GetLocalWorkloadPairs()
    w1 = pairs[0][0]
    client = pairs[0][1]
    tc.cmd_cookies = []

    server, client = pairs[0]
    naples = server
    if not server.IsNaples():
        if not client.IsNaples():
            naples = client
            return api.types.status.SUCCESS
        else:
            client, server = pairs[0]

    req = api.Trigger_CreateExecuteCommandsRequest(serial=True)
    tc.cmd_descr = "Server: %s(%s) <--> Client: %s(%s)" %\
                   (server.workload_name, server.ip_address, client.workload_name, client.ip_address)
    api.Logger.info("Starting DNS test from %s" % (tc.cmd_descr))

    SetupDNSServer(server)

    api.Trigger_AddCommand(
        req, client.node_name, client.workload_name,
        "echo \"nameserver %s\" | tee -a /etc/resolv.conf" %
        (server.ip_address))
    tc.cmd_cookies.append("Setup resolv conf")

    api.Trigger_AddCommand(req, client.node_name, client.workload_name,
                           "nslookup test3.example.com")
    tc.cmd_cookies.append("Query DNS server")

    ## Add Naples command validation
    api.Trigger_AddNaplesCommand(
        req, naples.node_name,
        "/nic/bin/halctl show session --dstport 53 --dstip {}".format(
            server.ip_address))
    tc.cmd_cookies.append("Find session")

    trig_resp = api.Trigger(req)
    term_resp = api.Trigger_TerminateAllCommands(trig_resp)
    tc.resp = api.Trigger_AggregateCommandsResponse(trig_resp, term_resp)

    return api.types.status.SUCCESS
Beispiel #26
0
def Setup(tc):
    api.Logger.info("Fw compat test")
    if api.IsDryrun(): return api.types.status.SUCCESS

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

    tc.skip = False
    if tc.os == compat.OS_TYPE_BSD:  # Not supportig BSD & ESXi right now
        tc.skip = True
        return api.types.status.SUCCESS

    # Intention to test locally built FW with target-version driver
    tc.target_version = getattr(tc.iterators, 'release', 'latest')

    # this is required to bring the testbed into operation state
    # after driver unload interfaces need to be initialized
    tc.fw_changed = False
    if compat.LoadFirmware(tc.nodes, tc.os,
                           tc.target_version) == api.types.status.SUCCESS:
        api.Logger.info("Loaded %s Fw on %s" % (tc.target_version, node))
    else:
        return api.types.status.FAILURE

    tc.fw_changed = True
    if tc.os == compat.OS_TYPE_LINUX:
        for node in tc.nodes:
            # this is required to bring the testbed into operation state
            # after driver unload interfaces need to be initialized
            wl_api.ReAddWorkloads(node)

    if getattr(tc.args, 'type', 'local_only') == 'local_only':
        tc.workload_pairs = api.GetLocalWorkloadPairs()
    else:
        tc.workload_pairs = api.GetRemoteWorkloadPairs()

    if len(tc.workload_pairs) == 0:
        api.Logger.info(
            "Skipping ping part of testcase due to no workload pairs.")
        tc.skip = True

    return api.types.status.SUCCESS
Beispiel #27
0
def Setup(tc):
    tc.server_port = api.AllocateTcpPort()
    tc.client_port = api.AllocateTcpPort()
    api.Logger.info("Setup.")
    if tc.iterators.kind == "remote":
        pairs = api.GetRemoteWorkloadPairs()
        if not pairs:
            api.Logger.info("no remtote eps")
            return api.types.status.SUCCESS
    else:
        pairs = api.GetLocalWorkloadPairs()

    tc.resp_flow = getattr(tc.args, "resp_flow", 0)
    tc.cmd_cookies = {}
    req = api.Trigger_CreateExecuteCommandsRequest(serial = True)

    #for w1,w2 in pairs:
    if pairs[0][0].IsNaples():
        tc.client,tc.server = pairs[0]
    else:
        tc.server,tc.client = pairs[0]
    
    cmd_cookie = start_nc_server(tc.server, tc.server_port)
    add_command(req, tc, 'server', tc.server, cmd_cookie, True) 


    cmd_cookie = start_nc_client(tc.server, tc.client_port, tc.server_port)
    add_command(req, tc, 'client', tc.client, cmd_cookie, True)
       
    cmd_cookie = "/nic/bin/halctl show session --dstport {} --dstip {} --yaml".format(tc.server_port, tc.server.ip_address)
    add_command(req, tc, 'show before', tc.client, cmd_cookie, naples=True)

    
    tc.setup_cmd_resp = api.Trigger(req)
    cmd = tc.setup_cmd_resp.commands[-1] 
    api.PrintCommandResults(cmd)
    tc.pre_ctrckinf = get_conntrackinfo(cmd)
    if getattr(tc.args, 'vmotion_enable', False):
        vmotion_utils.PrepareWorkloadVMotion(tc, [tc.client])

    return api.types.status.SUCCESS
Beispiel #28
0
def Setup(tc):
    tc.client, tc.server, tc.naples = None, None, None

    if tc.args.type == 'local_only':
        pairs = api.GetLocalWorkloadPairs(naples=True)
    else:
        pairs = api.GetRemoteWorkloadPairs()

    if len(pairs) == 0:
        api.Logger.error("Failed to get client server pair")
        return api.types.status.FAILURE

    ret = chooseNaples(tc, pairs[0])
    if ret != api.types.status.SUCCESS:
        return ret

    if not addPktFltrRuleOnEp(tc):
        api.Logger.error("Failed to add packet filter on EP")
        return api.types.status.FAILURE

    return api.types.status.SUCCESS
Beispiel #29
0
def chooseWorkload(tc):
    tc.skip = False
    if tc.selected:
        tc.workload_pairs = tc.selected
    else:
        if tc.args.type == 'local_only':
            tc.workload_pairs = api.GetLocalWorkloadPairs()
        else:
            tc.workload_pairs = api.GetRemoteWorkloadPairs()

    naples_node_name_list = api.GetNaplesHostnames()
    random.seed(tc.seed)

    while 1:
        w1, w2 = random.choice(tc.workload_pairs)
        tc.workload_pair = [w1, w2]

        if w1.node_name in naples_node_name_list or \
           w2.node_name in naples_node_name_list:
            tc.workload_pair = (w1, w2)
            return
Beispiel #30
0
def Setup(tc):
    tc.loop_count = 0
    tc.policy_db = {}

    tc.nodes = api.GetNaplesHostnames()
    #netagent_cfg_api.ReadJsons()
    tc.sgpolicy = sgpolicy_obj.gl_sg_json_template
    #get rules list - it is list of dictionary
    policy_rules = tc.sgpolicy['sgpolicies'][0]['spec']['policy-rules']
    meta = tc.sgpolicy['sgpolicies'][0]['meta']
    meta['name'] = 'default_policies'
    meta['namespace'] = 'default'
    meta['tenant'] = 'default'
    print('Initial policy rules {}'.format(policy_rules))
    print(api.GetWorkloads())
    tc.workload_pairs = api.GetLocalWorkloadPairs()
    print(tc.workload_pairs)
    for pair in tc.workload_pairs:
        w1 = pair[0]
        w2 = pair[1]
        for proto in proto_list:
            if proto is not 'icmp':
                port = str(random.randint(1, 65535))
            else:
                port = '1'
            action = random.choice(action_list)
            rule = Rule((w1, w2, proto, port), (action))
            tc.policy_db[rule.key] = rule.action

    for match, action_tuple in tc.policy_db.items():
        src, dst, proto, dst_port = match
        action = action_tuple
        policy_rules.append(
            get_rule(dst.ip_address, src.ip_address, proto, dst_port, action))
    print(tc.sgpolicy)
    json_str = json.dumps(tc.sgpolicy)
    obj = api.parser.ParseJsonStream(json_str)
    agent_api.ConfigureSecurityGroupPolicies(obj.sgpolicies,
                                             oper=agent_api.CfgOper.UPDATE)
    return api.types.status.SUCCESS