예제 #1
0
 def delete_traffic(self, **kwargs):
     t = test.Test()
     if 'node' not in kwargs:
         node = 'tg1'
     else:
         node = kwargs['node']
         del kwargs['node']
     tg_handle = t.traffic_generator(node).handle()
     return tg_handle.ix_delete_traffic()
예제 #2
0
 def stop_traffic(self, stream=None, **kwargs):
     t = test.Test()
     if 'node' not in kwargs:
         node = 'tg1'
     else:
         node = kwargs['node']
         del kwargs['node']
     tg_handle = t.traffic_generator(node).handle()
     return tg_handle.ix_stop_traffic(stream)
예제 #3
0
 def l3_chk_gw_arp(self, **kwargs):
     t = test.Test()
     if 'node' not in kwargs:
         node = 'tg1'
     else:
         node = kwargs['node']
         del kwargs['node']
     tg_handle = t.traffic_generator(node).handle()
     return tg_handle.ix_chk_arp(**kwargs)
예제 #4
0
파일: Host.py 프로젝트: bopopescu/bigrobot
 def bash_network_restart(self, node):
     """
     Function to restart the networking services for Ubuntu 12.04.
     """
     t = test.Test()
     n = t.node(node)
     n.sudo("/etc/init.d/networking restart")
     n.bash("route")
     return True
예제 #5
0
 def get_port_state(self, **kwargs):
     t = test.Test()
     if 'node' not in kwargs:
         node = 'tg1'
     else:
         node = kwargs['node']
         del kwargs['node']
     tg_handle = t.traffic_generator(node).handle()
     return tg_handle.ix_get_port_state(**kwargs)
예제 #6
0
 def raw_stream_add(self, **kwargs):
     t = test.Test()
     if 'node' not in kwargs:
         node = 'tg1'
     else:
         node = kwargs['node']
         del kwargs['node']
     tg_handle = t.traffic_generator(node).handle()
     return tg_handle.ix_raw_add(**kwargs)
예제 #7
0
 def cli_arista_disable_ip_routing(self, node):
     try:
         t = test.Test()
         switch = t.switch(node)
     except:
         return False
     else:
         switch.config("no ip routing")
         return True
예제 #8
0
 def bash_add_ip_address(self, node, ipaddr, intf):
     """
     Adding IP address to Host interface,For tagged interface user needs
     to specify interface.tagnumber (e.g eth1.10).
     """
     t = test.Test()
     n = t.node(node)
     n.sudo("ip addr add %s dev %s" % (ipaddr, intf))
     return True
예제 #9
0
 def rest_show_version(self):
     t = test.Test()
     c = t.controller('master')
     # url='http://%s:%s/rest/v1/system/version' % (c.ip,c.http_port)
     url = '/rest/v1/system/version'
     c.rest.get(url)
     content = c.rest.content()
     helpers.log("Output: %s" % content[0]['controller'])
     return content[0]['controller']
예제 #10
0
 def rest_snmp_getnext(self, snmpCommunity, snmpOID):
     t = test.Test()
     c = t.controller('master')
     url = "/usr/bin/snmpgetnext -v2c -c %s %s %s" % (str(snmpCommunity),
                                                      c.ip, str(snmpOID))
     returnVal = subprocess.Popen([url], stdout=subprocess.PIPE, shell=True)
     (out, err) = returnVal.communicate()
     helpers.log("URL: %s Output: %s" % (url, out))
     return out
예제 #11
0
 def cli_arista_delete_route(self, node, route, nexthop):
     try:
         t = test.Test()
         switch = t.switch(node)
     except:
         return False
     else:
         switch.config("no ip route %s %s" % (route, nexthop))
         return True
예제 #12
0
 def cli_arista_execute_command(self, node, command):
     try:
         t = test.Test()
         switch = t.switch(node)
     except:
         return False
     else:
         switch.config(command)
         return switch.cli_content()
예제 #13
0
 def cli_arista_reboot_switch(self, node):
     try:
         t = test.Test()
         switch = t.switch(node)
     except:
         return False
     else:
         switch.enable("reload now",
                       prompt="Broadcast message from root@app-arista")
예제 #14
0
파일: T5L3.py 프로젝트: bopopescu/bigrobot
    def rest_show_endpoints(self):
        t = test.Test()
        c = t.controller('master')

        url = '/api/v1/data/controller/applications/bvs/info/endpoint-manager/endpoints'
        c.rest.get(url)
        helpers.log("Output: %s" % c.rest.result_json())
        data = c.rest.content()
        return data
예제 #15
0
    def upgrade_to(self, package):
        '''
            Objective:
            - Execute CLI commands to download given upgrade package to Master (and Slave if exists) Controllers and upgrade them
        
            Input:
            | `package` |  URL to the upgrade package | 
            
            Return Value: 
            - True if configuration is successful
            - False otherwise
        '''

        try:
            t = test.Test()
        except:
            return False
        else:
            c = t.controllers()
            controller_qty = len(c)

            if controller_qty == 2:
                node = t.controller('slave')
            elif controller_qty == 1:
                node = t.controller('master')
            else:
                helpers.test_failure(
                    "More than two controllers or no controller configured")
                return False

            for i in range(0, controller_qty):
                try:
                    #node.config("debug bash")
                    node.bash("cd /home/images/")
                    node.bash("sudo rm *")
                    node.bash("sudo wget  %s" % package)
                    node.bash("exit")
                    helpers.log("Image downloaded successfully")

                    node.enable('enable')
                    node.send("upgrade")
                    node.expect(r"\(yes to continue\)")
                    node.send("yes")
                    node.expect(r"Password:"******"adminadmin", timeout=300)
                    node.send("reload")
                    node.expect(r"Confirm Reload \(yes to continue\)")
                    node.send("yes")
                    time.sleep(120)
                except:
                    helpers.test_failure("Output: %s" % node.cli_content())
                    return False

                if controller_qty == 2:
                    node = t.controller('slave')

            return True
예제 #16
0
    def bash_ping6(self,
                   node=None,
                   dest_ip=None,
                   dest_node=None,
                   return_stats=False,
                   *args,
                   **kwargs):
        """
        Perform a ping6 from the shell. Returns the loss percentage
        - 0   - 0% loss (default)
        - 100 - 100% loss (default)
        - Stats dict if return_stats is ${true}

        Inputs:
        - node:      The device name as defined in the topology file, e.g., 'c1', 's1', etc.
        - dest_ip:   Ping6 this destination IP address
        - dest_node  Ping6 this destination node ('c1', 's1', etc)
        - source_if: Source interface
        - count:     Number of ping6 packets to send
        - ttl:       IP Time-to-live
        - record_route:  ${true}  - to include RECORD ROUTE option
        - interval:  Time in seconds (floating point value allowed) to wait between sending packets.

        Example:
        | ${lossA} = | Bash Ping6 | h1          | 10.192.104.1 | source_if=eth1 |
        | ${lossB} = | Bash Ping6 | node=master | dest_node=s1 |                |
        =>
        - ${lossA} = 0
        - ${lossB} = 100

        Miscellaneous:
        - See also Controller.cli ping6
        - See also autobot.helpers.__init__.py to see what Unix ping6 command option is used for each input parameter.
        """
        t = test.Test()
        n = t.node(node)

        if not dest_ip and not dest_node:
            helpers.test_error("Must specify 'dest_ip' or 'dest_node'")
        if dest_ip and dest_node:
            helpers.test_error("Specify 'dest_ip' or 'dest_node' but not both")
        if dest_ip:
            dest = dest_ip
        if dest_node:
            dest = t.node(dest_node).ip()
        stats = helpers._ping6(dest,
                               node_handle=n,
                               mode='bash',
                               *args,
                               **kwargs)
        if kwargs.get('background', False):
            return stats
        elif return_stats:
            return stats
        else:
            return stats["packets_loss_pct"]
예제 #17
0
 def rest_verify_fabric_switch(self, dpid):
     # Function verify fabric switch status for default as well after fabric role configuration
     t = test.Test()
     c = t.controller()
     url = '%s/api/v1/data/controller/core/switch[dpid="%s"]' % (c.base_url,
                                                                 dpid)
     c.rest.get(url)
     data = c.rest.content()
     if data[0]["dpid"] == dpid:
         if data[0]["connected"]:
             if data[0]["fabric-switch-info"]["fabric-role"] != "virtual":
                 if data[0]["fabric-switch-info"][
                         "fabric-role"] == "spine" and data[0][
                             "fabric-switch-info"]["suspended"] == False:
                     helpers.log(
                         "Pass: Fabric switch connection status for spine is correct"
                     )
                     return True
                 elif data[0]["fabric-switch-info"][
                         "fabric-role"] == "leaf" and data[0][
                             "fabric-switch-info"][
                                 "suspended"] == False and data[0][
                                     "fabric-switch-info"][
                                         "leaf-group"] != '':
                     if data[0]["dpid"] == dpid and data[0][
                             "fabric-switch-info"]["lacp-port-offset"] == 0:
                         helpers.log(
                             "Pass: Fabric switch connection status for %s dual leaf is correct"
                             % str(data[0]["fabric-switch-info"]
                                   ["switch-name"]))
                         return True
                     elif data[0]["dpid"] == dpid and data[0][
                             "fabric-switch-info"][
                                 "lacp-port-offset"] == 100:
                         helpers.log(
                             "Pass: Fabric switch connection status for %s dual leaf is correct"
                             % str(data[0]["fabric-switch-info"]
                                   ["switch-name"]))
                         return True
             elif data[0]["fabric-switch-info"]["suspended"] == True:
                 helpers.log(
                     "Default fabric role is virtual for not added fabric switches"
                 )
                 return True
             else:
                 helpers.test_failure(
                     "Fabric role is virual but suspended = False ")
                 return False
         elif data[0]["fabric-switch-info"]["suspended"] == False or data[
                 0]["fabric-switch-info"]["suspended"] == True:
             helpers.test_failure(
                 "Fail: Switch is not connected , Fabric switch status still exists"
             )
             return False
     else:
         return False
예제 #18
0
 def rest_verify_forwarding_port_table(self, switch):
     t = test.Test()
     c = t.controller()
     url = '%s/api/v1/data/controller/applications/bvs/info/forwarding/network/switch[switch-name="%s"]/port-table' % (
         c.base_url, switch)
     c.rest.get(url)
     if not c.rest.status_code_ok():
         helpers.log(
             "Error: forwarding output table is not returning any value")
         helpers.test_failure(c.rest.error())
예제 #19
0
 def rest_snmp_show(self):
     t = test.Test()
     c = t.controller('master')
     url = 'http://%s:%s/rest/v1/model/snmp-server-config/' % (c.ip,
                                                               c.http_port)
     url = '/rest/v1/model/snmp-server-config/'
     c.rest.get(url)
     content = c.rest.content()
     helpers.log("Output: %s" % content)
     return content
예제 #20
0
 def cli_show_endpoint_pattern(self,pattern):
     '''
     '''
     helpers.test_log("Entering ==> cli_show_endpoint_filter: %s"  % pattern)           
     t = test.Test()
     c = t.controller('master')         
     cli= 'show endpoint | grep ' + pattern + ' | wc -l'
     content = c.cli(cli)['content']   
     temp = helpers.strip_cli_output(content)        
     return temp
예제 #21
0
 def cli_arista_delete_vrrp(self, node, interface, gp, vip):
     try:
         t = test.Test()
         switch = t.switch(node)
     except:
         return False
     else:
         switch.config("interface %s" % interface)
         switch.config("no vrrp %s ip %s " % (gp, vip))
         return True
예제 #22
0
 def cli_arista_change_vrrp_priority(self, node, interface, gp, priority):
     try:
         t = test.Test()
         switch = t.switch(node)
     except:
         return False
     else:
         switch.config("interface %s" % interface)
         switch.config("vrrp %s priority %s" % (gp, priority))
         return True
예제 #23
0
 def bash_kill_process(self, node, pname):
     '''
         kill process name
     '''
     t = test.Test()
     n = t.node(node)
     n.bash("ps aux | grep -i %s | grep -v grep" % pname)
     n.bash(
         "for x in `ps aux | grep -i %s | grep -v grep | awk '{print $2}'`; do sudo kill -9 $x; done"
         % pname)
예제 #24
0
 def bash_run_command(self, node, cmd):
     t = test.Test()
     n = t.node(node)
     try:
         content = n.bash("%s " % cmd)['content']
         str_list = helpers.strip_cli_output(content, to_list=True)
     except:
         helpers.test_error("Bash run command failed", soft_error=True)
         str_list = "Bash Run Command Failed"
     return str_list
예제 #25
0
    def set_mininet_ip(self, **kwargs):
        t = test.Test()
        node = kwargs.get("node", "c1")
        ip = kwargs.get("ip", None)
        get_ip = kwargs.get("get_ip", True)
        n = t.node(node)

        helpers.log("Sleeping 30 sec from mininet to come up..")
        time.sleep(45)
        if not ip:
            ip = n.ip()

        helpers.log("Setting IP : %s for Linux Node : %s using ifconfig" %
                    (ip, node))
        n_console = n.console()
        n_console.send('')
        #         helpers.log("Sleeping 20 secs...")
        #         time.sleep(20)
        n_console.expect(r'Escape character.*[\r\n]')
        n_console.send('')
        options = n_console.expect(
            [r't6-mininet login: '******'')
        else:
            helpers.log("Sending mininet password..")
            n_console.send('mininet')
            n_console.expect(r'Password: '******'mininet')
        time.sleep(1)
        output = n_console.expect()
        helpers.log("Expect output before sending IP: %s" % str(output))
        #         n_console.bash('pwd')
        #         n_console.expect()
        if get_ip:
            helpers.log("Just getting DHCP IP from Mininet VM ..")
            n_console.send('sudo ifconfig | grep inet | awk \'{print $2}\'')
            n_console.expect(n_console.get_prompt())
            output = n_console.content()
            output_lines = output.split('\n')
            helpers.log("Mininet IP Content: %s " % output_lines)
            ips = output_lines[1].split(':')
            helpers.log("Mininet IP is : %s" % ips[1])
            return ips[1]
        else:
            helpers.log("Setting IP on Mininet VM ...")
            n_console.send('sudo ifconfig eth0 %s netmask 255.255.192.0' % ip)
            n_console.expect()

        helpers.log("Success configuring Static IP !!")
        """
예제 #26
0
 def get_syslog_monitor_pid(self, role):
     '''Get the pid of tail processes
     Input: c1,c2,etc
     '''
     t = test.Test()
     c = t.controller(role)
     helpers.log("Verifing for monitor job")
     c_result = c.bash('ps ax | pgrep tail | awk \'{print $1}\'')
     split = re.split('\n', c_result['content'])
     pidList = split[1:-1]
     return pidList
예제 #27
0
 def rest_verify_forwarding_lag(self, dpid, switch):
     '''Verify Edge port  Information in Controller Forwarding Table
     
         Input:  Specific DPID of the switch and also the switch name of the specific device     
         
         Return: Match forwarding table lag/Port for peer switch edge ports
     '''
     t = test.Test()
     c = t.controller()
     url = '%s/api/v1/data/controller/applications/bvs/info/forwarding/network/switch[switch-name="%s"]/lag-table' % (
         c.base_url, switch)
     c.rest.get(url)
     data = c.rest.content()
     url1 = '%s/api/v1/data/controller/core/switch[dpid="%s"]' % (
         c.base_url, dpid)
     c.rest.get(url1)
     data1 = c.rest.content()
     url2 = '%s/api/v1/data/controller/core/switch[name="%s"]?select=fabric-lag' % (
         c.base_url, switch)
     c.rest.get(url2)
     data2 = c.rest.content()
     peer_intf = []
     for i in range(0, len(data2[0]["fabric-lag"])):
         if data2[0]["fabric-lag"][i]["lag-type"] == "leaf-lag":
             interface = re.sub(
                 "\D", "",
                 data2[0]["fabric-lag"][i]["member"][0]["src-interface"])
             peer_intf.append(int(interface))
     if data1[0]["fabric-switch-info"]["leaf-group"] == None:
         for i in range(0, len(data)):
             for j in range(0, len(data[i]["port"])):
                 if (data[i]["port"][j]["port-num"] == peer_intf[0]):
                     helpers.test_failure(
                         "Peer switch edge ports are not deleted from lag table"
                     )
                     return False
                 else:
                     helpers.log(
                         "Peer switch edge ports are deleted from forwarding lag table"
                     )
                     return True
     else:
         for i in range(0, len(data)):
             for j in range(0, len(data[i]["port"])):
                 if (data[i]["port"][j]["port-num"]) == (peer_intf[0]):
                     helpers.log(
                         "Peer switch edge ports are properly added in forwarding table"
                     )
                     return True
                 else:
                     helpers.test_failure(
                         "Peer switch edge ports are not added in forwarding table"
                     )
                     return False
예제 #28
0
    def rest_show_fabric_switch(self):
        '''Return the list of connected switches
                                       
            Returns: gives list of connected switches
        '''
        t = test.Test()
        c = t.controller()
        url = '%s/api/v1/data/controller/core/switch' % (c.base_url)
        c.rest.get(url)

        return True
예제 #29
0
 def rest_ha_role(self):
     t = test.Test()
     c = t.controller('master')
     # url = '%s/system/ha/role'  % (c.base_url)
     url = '/rest/v1/system/ha/role'
     c.rest.get(url)
     helpers.test_log("Ouput: %s" % c.rest.result_json())
     if not c.rest.status_code_ok():
         helpers.test_failure(c.rest.error())
     content = c.rest.content()
     return content['role']
예제 #30
0
 def bash_verify_arp(self, node, ip):
     t = test.Test()
     n = t.node(node)
     result = n.sudo("arp -n %s" % ip)
     output = result["content"]
     helpers.log("output: %s" % output)
     match = re.search(r'no entry|incomplete', output, re.S | re.I | re.M)
     if match:
         return False
     else:
         return True