示例#1
0
 def execute_switch_command_return_output(self, ip_address, input):
     '''Execute a generic command on the switch and return ouput.
     
         Input:
             ip_address        IP Address of Switch
             input            Command to be executed on switch
             
         Return Value: Output from command execution
         
         Example:
         
         |${syslog_op}=  |  execute switch command return output | 10.192.75.7  |  debug ofad 'help; cat /var/log/syslog | grep \"Disabling port port-channel1\"' |
                 
     '''
     try:
         t = test.Test()
         conn = SSH2()
         conn.connect(ip_address)
         conn.login(Account("admin", "adminadmin"))
         conn.execute('enable')
         helpers.sleep(float(1))
         conn.execute(input)
         helpers.sleep(float(1))
         output = conn.response
         conn.send('logout\r')
         helpers.log("Input is '%s' \n Output is %s" % (input, output))
         conn.close()
         return output
     except:
         helpers.test_failure(
             "Could not execute command. Please check log for errors")
         return False
示例#2
0
 def delete_support_bundles(self, node_name="master"):
     t = test.Test()
     node = t.controller(node_name)
     data = self.get_support_bundles()
     helpers.prettify(data)
     if len(data) == 0:
         helpers.log("No Support Bundles on controller %s" % node_name)
         return True
     else:
         for i in range(0, len(data)):
             helpers.log("Deleting Support Bundle Name: %s" %
                         data[i]['name'])
             delete_url = '/api/v1/data/controller/support/bundle[name="%s"]' % data[
                 i]['name']
             node.rest.delete(delete_url, {})
             helpers.log("Success Deleting Support Bundle: %s" %
                         data[i]['name'])
     helpers.log(
         "Checking again to check all the support bundles are deleted..")
     data = self.get_support_bundles()
     helpers.prettify(data)
     if len(data) == 0:
         helpers.log("No Support Bundles on controller %s" % node_name)
         return True
     else:
         helpers.test_failure("Unable to Delete all Support bundles..")
示例#3
0
 def _switch_upgrade_steps(self, switchIp=None, package=None):    
     ''' 
         To upgrade the switches to the latest switchLight image 
         Input : switchIpList : provide switch Ip List 
         Output : True if upgrade successful
     '''
     
     try:
         t = test.Test()
         switch= t.switch(switchIp)
         if not package:
             helpers.log("no package provided")
             swpackage= "latest.switchlight-powerpc-internal-t5.swi"
     
         imagepath= "http://switch-nfs/export/switchlight/autobuilds/master/"
         full_path= str(imagepath) + str(swpackage)
         bash_cmd1= 'cd /mnt/flash2'
         switch.bash(bash_cmd1)
         bash_cmd2= 'rm ' + str(swpackage)
         switch.bash(bash_cmd2)
         bash_cmd3= 'wget ' + str(full_path)
         switch.bash(bash_cmd3)
         bash_cmd4= 'reboot'
         switch.bash(bash_cmd4)
         return True
     #cmdList= [
     #    'cd /mnt/flash2'
     #    'mv latest.switchlight-powerpc-internal-t5.swi latest.switchlight-powerpc-internal-t5.swi.old'     
     #    'wget http://10.192.74.102/export/switchlight/autobuilds/master/latest.switchlight-powerpc-internal-t5.swi'
     #    'reboot'                  
     #          ]
     except:
         helpers.test_failure("Could not complete the upgrade process, check log")   
         return False
示例#4
0
 def rest_add_switch_datacenter(self,datacenter_name,switch_dpid,zone_name):
     '''Add switch to a datacenter
     
        Input:
            datacenter_name        Datacenter Name
            
            switch_dpid        DPID of switch
            
            zone_name     Zone to which switch belongs
        
       Returns: True if configuration is successful, false otherwise
     '''
     try:
         t = test.Test()
     except:
         return False
     else:
         c= t.controller('master')
         try:
             url='/api/v1/data/controller/applications/bigwire/datacenter[name="%s"]/member-switch[dpid="%s"]' % (str(datacenter_name),str(switch_dpid))
             c.rest.put(url, {"zone": str(zone_name), "dpid": str(switch_dpid)})
         except:
             helpers.test_failure(c.rest.error())
             return False
         else:  
             if not c.rest.status_code_ok():
                 helpers.test_failure(c.rest.error())
                 return False
             else:
                 helpers.test_log(c.rest.content_json())
                 return True        
示例#5
0
 def rest_verify_fabric_interface(self, switch, intf):
     ''' 
     Function to verify the specific fabric interface status 
     Input:  Rest Output from the function (show_fabric_interface())
     Output" validation of the fabric interface status
     '''
     t = test.Test()
     c = t.controller()
     url = '%s/api/v1/data/controller/core/switch[name="%s"]/interface[name="%s"]' % (
         c.base_url, switch, intf)
     c.rest.get(url)
     data = c.rest.content()
     helpers.log("Data %s" % data)
     if len(data) != 0:
         if data[0]["state"] == "down" and data[0]["type"] == "unknown":
             helpers.log(
                 "Interface is connected to spine or Physical Interface status is down for the leaf switch"
             )
         elif data[0]["state"] == "up" and data[0]["type"] == "edge":
             helpers.log(
                 "Inteface is connected to leaf and it is a edge port")
         elif data[0]["state"] == "up" and data[0]["type"] == "leaf" or data[
                 0]["state"] == "up" and data[0]["type"] == "spine":
             helpers.log("Interface is fabric interface")
         else:
             helpers.test_failure(
                 "Interface status is not known to the fabric system , Please check the logs"
             )
     else:
         helpers.test_failure("Given fabric interface is not valid")
示例#6
0
 def rest_create_bigwire_pseudowire(self,pseudowire_name,switch_dpid_1,intf_name_1,switch_dpid_2,intf_name_2,vlan=0):
     '''Create a bigwire pseudowire
     
         Input:
             pseudowire_name     Name of bigwire pseudowire
             switch_dpid_1    DPID of first Switch
             intf_name_1      Uplink port/interface name for first Switch
             switch_dpid_2    DPID of second Switch
             intf_name_2      Uplink port/interface name for second Switch
             Vlan           Vlan Number (in case of Vlan Mode, defaults to 0 for port-mode)
        
       Returns: True if configuration is successful, false otherwise
     '''
     try:
         t = test.Test()
     except:
         return False
     else:
         c= t.controller('master')
         try:
             url='/api/v1/data/controller/applications/bigwire/pseudo-wire[name="%s"]' % (str(pseudowire_name))
             if vlan == 0:
                 c.rest.put(url, {"interface1": str(intf_name_1), "switch2": str(switch_dpid_2), "switch1": str(switch_dpid_1), "interface2": str(intf_name_2), "name": str(pseudowire_name)})
             else:
                 c.rest.put(url, {"interface1": str(intf_name_1), "switch2": str(switch_dpid_2), "switch1": str(switch_dpid_1), "interface2": str(intf_name_2), "name": str(pseudowire_name), "vlan": int(vlan) })
         except:
             helpers.test_failure(c.rest.error())
             return False
         else:  
             if not c.rest.status_code_ok():
                 helpers.test_failure(c.rest.error())
                 return False
             else:
                 helpers.test_log(c.rest.content_json())
                 return True        
示例#7
0
 def rest_delete_pseudowire(self,pseudowire_name):
     '''Delete a pseudowire
     
        Input:
            pseudowire_name    Pseudowire Name
        
       Returns: True if configuration is successful, false otherwise
     '''
     try:
         t = test.Test()
     except:
         return False
     else:
         c= t.controller('master')
         try:
             url='/api/v1/data/controller/applications/bigwire/pseudo-wire[name="%s"]'  % (str(pseudowire_name))    
             c.rest.delete(url, {})
         except:
             helpers.test_failure(c.rest.error())
             return False
         else:  
             if not c.rest.status_code_ok():
                 helpers.test_failure(c.rest.error())
                 return False
             else:
                 helpers.test_log(c.rest.content_json())
                 return True        
示例#8
0
 def delete_snmp_keyword(self, ip_address, snmpKey, snmpValue):
     ''' Delete SNMP Key/Value
     
         Input: 
             ip_address        IP Address of switch
             
             snmpKey           SNMP Key like location, community etc
             
             snmpValue         Value corresponding to SNMP Key    
     '''
     try:
         t = test.Test()
         conn = SSH2()
         conn.connect(ip_address)
         conn.login(Account("admin", "adminadmin"))
         conn.execute('enable')
         conn.execute('conf t')
         input = "no snmp-server %s %s" % (str(snmpKey), str(snmpValue))
         conn.execute(input)
         conn.send('exit\r')
         conn.send('exit\r')
         conn.send('exit\r')
         conn.close()
         return True
     except:
         helpers.test_failure(
             "Could not execute command. Please check log for errors")
         return False
示例#9
0
 def verify_portchannel(self, ip_address, pcNumber):
     '''Verify portchannel shows as up
     
         Input:
             ip_address        IP Address of switch
             
             pcNumber           PortChannel number. Range is between 1 and 30
             
         Returns: true if interface is up, false otherwise
     '''
     try:
         t = test.Test()
         conn = SSH2()
         conn.connect(ip_address)
         conn.login(Account("admin", "adminadmin"))
         conn.execute('enable')
         intf_name = "port-channel" + pcNumber
         input = "show interface " + intf_name
         conn.execute(input)
         helpers.log("Multiline is %s" %
                     (string.split(conn.response, '\n')))
         lagNumber = 60 + int(pcNumber)
         input1 = str(lagNumber) + "* " + intf_name
         if str(input1) in conn.response:
             return True
         else:
             return False
     except:
         helpers.test_failure(
             "Could not execute command. Please check log for errors")
         return False
示例#10
0
 def snmp_cmd_opt(self, ip_address, snmp_cmd, snmpOpt, snmpCommunity,
                  snmpOID):
     '''Execute snmp command which  require options from local machine for a particular SNMP OID
     
         Input:
             ip_address        IP Address of switch
             
             snmp_cmd          SNMP Command like snmpbulkwalk, snmpbulkget, etc.
             
             snmpCommunity    SNMP Community
             
             snmpOID           OID for which walk is being performed
         
         Returns:  Output from SNMP Walk.
     '''
     try:
         t = test.Test()
         url = "/usr/bin/%s  -v2c %s -c %s %s %s" % (
             str(snmp_cmd), str(snmpOpt), str(snmpCommunity), ip_address,
             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
     except:
         helpers.test_failure(
             "Could not execute command. Please check log for errors")
         return False
示例#11
0
 def show_interfaces(self, ip_address):
     '''Verify all 52 interfaces are seen in switch
     '''
     try:
         t = test.Test()
         conn = SSH2()
         conn.connect(ip_address)
         conn.login(Account("admin", "adminadmin"))
         conn.execute('enable')
         count = 1
         intf_pass_count = 0
         while count < 53:
             intf_name = "ethernet" + str(count)
             input = "show interface ethernet" + str(count) + " detail"
             conn.execute(input)
             if intf_name in conn.response:
                 intf_pass_count = intf_pass_count + 1
             helpers.log("Interface %s \n Output is %s \n ======\n" %
                         (intf_name, conn.response))
             count = count + 1
         conn.send('logout\r')
         conn.close()
         if intf_pass_count == 52:
             return True
         else:
             return False
     except:
         helpers.test_failure(
             "Could not execute command. Please check log for errors")
         return False
示例#12
0
 def delete_dhcp_ip(self, console_ip, console_port, ip_address, subnet,
                    gateway):
     '''Configure static IP address configuration on switch.
     '''
     try:
         user = "******"
         password = "******"
         tn = telnetlib.Telnet(str(console_ip), int(console_port))
         tn.read_until("login: "******"\r\n")
         tn.read_until("Password: "******"\r\n")
         tn.read_until('')
         tn.write("\r\n" + "no interface ma1 dhcp \r\n")
         tn.write("\r\n" + "no interface ma1 ip-address " +
                  str(ip_address) + "/" + str(subnet) + " \r\n")
         tn.write("\r\n" + "no ip default-gateway " + str(gateway) +
                  " \r\n")
         tn.write("exit" + "\r\n")
         tn.write("exit" + "\r\n")
         tn.close()
         return True
     except:
         helpers.test_failure(
             "Could not configure static IP address configuration on switch. Please check log for errors"
         )
         return False
示例#13
0
 def configure_dhcp_ip(self, console_ip, console_port):
     '''Configure static IP address configuration on switch.
     '''
     try:
         user = "******"
         password = "******"
         tn = telnetlib.Telnet(str(console_ip), int(console_port))
         tn.read_until("login: "******"\r\n")
         tn.read_until("Password: "******"\r\n")
         tn.read_until('')
         tn.write("enable \r\n")
         tn.write("conf t \r\n")
         tn.write("interface ma1 ip-address dhcp \r\n")
         helpers.sleep(10)
         tn.read_until(">")
         tn.write("exit \r\n")
         tn.write("exit \r\n")
         tn.close()
         return True
     except:
         helpers.test_failure(
             "Could not execute command. Please check log for errors")
         return False
示例#14
0
 def return_intf_state(self, ip_address, intf_name):
     '''Return the Interface State of a given interface on a switch
     
         Input:
                 ip_address        IP Address of switch
                 
                 intf_name        Interface Name eg. ethernet1 or portchannel1
                 
         Returns: Interface State of interface.
     '''
     try:
         t = test.Test()
         conn = SSH2()
         conn.connect(ip_address)
         conn.login(Account("admin", "adminadmin"))
         input = "show interface " + str(intf_name) + " detail"
         conn.execute(input)
         content = string.split(conn.response, '\n')
         helpers.log("Value in content[1] is '%s' " % (content[1]))
         (firstvalue, colon,
          lastvalue) = content[1].rstrip('\n').strip().split(' ')
         intf_state = lastvalue.rstrip('\n')
         helpers.log("Value in content[1] is %s \n and intf_state is %s" %
                     (content[1], intf_state))
         return intf_state
     except:
         helpers.test_failure(
             "Could not execute command. Please check log for errors")
         return False
示例#15
0
 def rest_verify_nat_endpoint(self, tenant, nat_profile, remote_tenant,
                              remote_segment):
     '''Function to verify nat endpoint
     Input: tenant name, nat profile, external tenant name, external segment name
     '''
     t = test.Test()
     c = t.controller('master')
     url = '/api/v1/data/controller/applications/bcf/tenant[name="%s"]?select=logical-router&config=true' % tenant
     c.rest.get(url)
     data = c.rest.content()
     for i in range(0, len(data[0]["logical-router"]["nat-profile"])):
         if data[0]["logical-router"]["nat-profile"][i][
                 "name"] == nat_profile:
             if "pat" in data[0]["logical-router"]["nat-profile"][i]:
                 public_ip = data[0]["logical-router"]["nat-profile"][i][
                     "pat"]["ip-address"]
                 break
             else:
                 return False
     url1 = '/api/v1/data/controller/applications/bcf/info/endpoint-manager/endpoint[ip="%s"]' % public_ip
     c.rest.get(url1)
     data1 = c.rest.content()
     helpers.log("content %s" % data1)
     if data1[0]["ip-address"][0]["ip-address"] == public_ip and data1[0][
             "ip-address"][0]["ip-state"] == "static" and data1[0][
                 "state"] == "Active":
         helpers.log("nat container endpoint is present")
         return True
     else:
         helpers.test_failure("nat container endpoint is not present")
         return False
示例#16
0
    def rest_bigtap_add_policy(self,
                               rbac_view_name,
                               policy_name,
                               policy_action="inactive"):
        '''Add a bigtap policy.

            Input:
                `rbac_view_name`    :    RBAC View Name for eg. admin-view
                `policy_name`  :    Policy Name
                `policy_action`:    Policy action. The permitted values are "forward" or "rate-measure", default is inactive

            Returns: True if policy configuration is successful, false otherwise
        '''
        try:
            t = test.Test()
        except:
            return False
        else:
            c = t.controller('master')
            try:
                url = '/api/v1/data/controller/applications/bigtap/view[name="%s"]/policy[name="%s"]' % (
                    str(rbac_view_name), str(policy_name))
                c.rest.put(url, {'name': str(policy_name)})
            except:
                helpers.test_failure(c.rest.error())
                return False
            else:
                try:
                    c.rest.patch(url, {"action": str(policy_action)})
                except:
                    helpers.test_failure(c.rest.error())
                    return False
                else:
                    return True
示例#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_bigtap_delete_policy(self, rbac_view_name, policy_name):
        '''Delete a bigtap policy.

            Input:
                `rbac_view_name`    :    RBAC View Name for eg. admin-view
                `policy_name`  :    Policy Name

            Returns: True if policy delete is successful, False otherwise
        '''
        try:
            t = test.Test()
        except:
            return False
        else:
            c = t.controller('master')
            try:
                url = '/api/v1/data/controller/applications/bigtap/view[name="%s"]/policy[name="%s"]' % (
                    str(rbac_view_name), str(policy_name))
                c.rest.delete(url, {})
            except:
                helpers.test_failure(c.rest.error())
                return False
            else:
                if not c.rest.status_code_ok():
                    helpers.test_failure(c.rest.error())
                    return False
                else:
                    return True
示例#19
0
 def rest_add_switch_to_tenant(self,tenant_name,switch_dpid,intf_name,vlan=0):
     '''Add switch to a tenant
     
        Input:
            tenant_name    Tenant Name
            
            switch_dpid        DPID of switch
            
            intf_name     Interface Name
            
            Vlan            Tenant Vlan Number
        
       Returns: True if configuration is successful, false otherwise
     '''
     try:
         t = test.Test()
     except:
         return False
     else:
         c= t.controller('master')
         try:  
             url='/api/v1/data/controller/applications/bigwire/tenant[name="%s"]/tenant-interface[interface="%s"][switch="%s"]' %(str(tenant_name),str(intf_name),str(switch_dpid))
             if vlan == 0:
                 c.rest.put(url,{"interface": str(intf_name), "switch": str(switch_dpid)})
             else:
                 c.rest.put(url,{"interface": str(intf_name), "tenant-vlan": [{"vlan": int(vlan)}], "switch": str(switch_dpid)})
         except:
             helpers.test_failure(c.rest.error())
             return False
         else:  
             helpers.test_log(c.rest.content_json())
             return True
示例#20
0
    def rest_bigtap_add_policy_match(self, rbac_view_name, policy_name,
                                     match_number, data):
        '''Add a bigtap policy match condition.

            Input:
                `rbac_view_name`    :    RBAC View Name for eg. admin-view
                `policy_name`  :    Policy Name
                `match_number`    :    Match number like the '1' in  '1 match tcp
                `data`    :    Formatted data field like  {"ether-type": 2048, "dst-tp-port": 80, "ip-proto": 6, "sequence": 1}

            Returns: True if policy configuration is successful, false otherwise
        '''
        try:
            t = test.Test()
        except:
            return False
        else:
            c = t.controller('master')
            try:
                url = '/api/v1/data/controller/applications/bigtap/view[name="%s"]/policy[name="%s"]/rule[sequence=%s]' % (
                    str(rbac_view_name), str(policy_name), str(match_number))
                data_dict = helpers.from_json(data)
                c.rest.put(url, data_dict)
            except:
                helpers.test_failure(c.rest.error())
                return False
            else:
                if not c.rest.status_code_ok():
                    helpers.test_failure(c.rest.error())
                    return False
                else:
                    return True
示例#21
0
 def rest_create_bigwire_datacenter(self,datacenter_name):
     '''Create BigWire Datacenter. Similar to cli command "bigwire datacenter datacenter_name"
     
         Input:    
             datacenter_name        Datacenter Name
         
         Returns: True if configuration is successful, false otherwise
     '''
     try:
         t = test.Test()
     except:
         return False
     else:
         c= t.controller('master')
         try:
             url='/api/v1/data/controller/applications/bigwire/datacenter[name="%s"]' % (str(datacenter_name))
             c.rest.put(url, {"name": str(datacenter_name)})
         except:
             helpers.test_failure(c.rest.error())
             return False
         else:  
             if not c.rest.status_code_ok():
                 helpers.test_failure(c.rest.error())
                 return False
             else:
                 return True
示例#22
0
    def rest_bigtap_delete_policy_match(self, rbac_view_name, policy_name,
                                        match_number):
        '''Delete a bigtap policy match condition.

            Input:
                `rbac_view_name`    :    RBAC View Name for eg. admin-view
                `policy_name`  :    Policy Name
                `match_number`    :    Match number like the '1' in  '1 match tcp

            Returns: True if policy delete is successful, false otherwise
        '''
        try:
            t = test.Test()
        except:
            return False
        else:
            c = t.controller('master')
            try:
                url = '/api/v1/data/controller/applications/bigtap/view[name="%s"]/policy[name="%s"]/rule[sequence="%s"]' % (
                    str(rbac_view_name), str(policy_name), str(match_number))
                c.rest.delete(url, {})
            except:
                helpers.test_failure(c.rest.error())
                return False
            else:
                return True
示例#23
0
 def rest_verify_fabric_link(self):
     t = test.Test()
     c = t.controller()
     url = '%s/api/v1/data/controller/core/switch/interface' % (c.base_url)
     c.rest.get(url)
     data = c.rest.content()
     fabric_interface = 0
     for i in range(0, len(data)):
         if data[i]["type"] == "leaf" or data[i]["type"] == "spine":
             fabric_interface = fabric_interface + 1
     url1 = '%s/api/v1/data/controller/applications/bvs/info/fabric?select=link' % (
         c.base_url)
     c.rest.get(url1)
     data1 = c.rest.content()
     bidir_link = 0
     if not ((data1 and True) or False):
         for i in range(0, len(data1[0]["link"])):
             if data1[0]["link"][i]["link-direction"] == "bidirectional":
                 bidir_link = bidir_link + 1
                 if bidir_link == fabric_interface / 2:
                     helpers.log(
                         "Pass: All Fabric links states are bidirectional")
                 else:
                     helpers.test_failure(
                         "Fail: Inconsistent state of fabric links. Fabric_Interface = %d , bidir_link = %d"
                         % (fabric_interface, bidir_link))
     else:
         helpers.log("Fabric switches are misconfigued")
示例#24
0
    def rest_bigtap_delete_service(self, service_name):
        '''Delete a bigtap service.

            Input:
                `service_name`        : Name of Service

            Returns: True if service deletion is successful, false otherwise

        '''
        try:
            t = test.Test()
        except:
            return False
        else:
            c = t.controller('master')
            try:
                url = '/api/v1/data/controller/applications/bigtap/service[name="%s"]' % (
                    str(service_name))
                c.rest.delete(url, {})
            except:
                helpers.test_failure(c.rest.error())
                return False
            else:
                if not c.rest.status_code_ok():
                    helpers.test_failure(c.rest.error())
                    return False
                else:
                    helpers.test_log(c.rest.content_json())
                    return True
示例#25
0
    def rest_cleanconfig_bigtap_user_defined_offset(self):
        '''Get all the user-defined-groups and delete them

        Input: None

        show command used: show running-config bigtap user-defined-group

        Output: Return false if groups are not deleted properly
        '''
        t = test.Test()
        try:
            c = t.controller('master')
        except:
            return False

        show_url = "/api/v1/data/controller/applications/bigtap/user-defined-offset?config=true"
        try:
            c.rest.get(show_url)
            show_data = c.rest.content()
        except:
            helpers.test_failure(c.rest.error())
            return False
        delete_url = "/api/v1/data/controller/applications/bigtap/user-defined-offset/%s/anchor {}"
        if len(show_data) != 0:
            for ugrp in show_data:
                for grp in ugrp.keys():
                    helpers.test_log("Deleting the group %s" % (grp))
                    c.rest.delete(delete_url % (grp))
                    return True
        else:
            helpers.test_log("There are no user-defined offsets to delete")
            return True
示例#26
0
    def rest_bigtap_delete_service_from_policy(self, rbac_view_name,
                                               policy_name, service_name):
        '''Delete a service from a policy. This is similar to executing CLI command "no use-service S1-LB7 sequence 1"

            Input:
                `rbac_view_name`           :    RBAC View Name for eg. admin-view
                `policy_name`         :    Policy Name
                `service_name`        : Name of Service

            Returns: True if deletion of service from policy is successful, false otherwise

        '''
        try:
            t = test.Test()
        except:
            return False
        else:
            c = t.controller('master')
            try:
                url = '/api/v1/data/controller/applications/bigtap/view[name="%s"]/policy[name="%s"]/service[name="%s"]' % (
                    str(rbac_view_name), str(policy_name), str(service_name))
                c.rest.delete(url, {})
            except:
                helpers.test_failure(c.rest.error())
                return False
            else:
                if not c.rest.status_code_ok():
                    helpers.test_failure(c.rest.error())
                    return False
                else:
                    helpers.test_log(c.rest.content_json())
                    return True
示例#27
0
 def check_partitions_for_diagnostics(self, node_name='master'):
     t = test.Test()
     node = t.controller(node_name)
     mount_output = node.bash("mount | grep diagnostic")
     helpers.log(mount_output['content'])
     lines = mount_output['content'].split('\n')
     helpers.log(str(len(lines)))
     mount_points = 0
     for line in lines:
         # helpers.log("matching line: \n%s" % line)
         if re.match(r'.*\/var\/lib\/floodlight\/coredumps.*', line):
             helpers.log("Found /var/lib/floodlight/coredumps  Mount point")
             mount_points = mount_points + 1
         if re.match(r'.*\/var\/lib\/floodlight\/heapdumps.*', line):
             helpers.log("Found /var/lib/floodlight/heapdumps  Mount point")
             mount_points = mount_points + 1
         if re.match(r'.*\/var\/lib\/floodlight\/support.*', line):
             helpers.log("Found /var/lib/floodlight/support  Mount point")
             mount_points = mount_points + 1
     helpers.log("mount points: %s" % str(mount_points))
     if mount_points == 3:
         return True
     else:
         helpers.test_failure(
             "Mount cmd from controller did not fine diagnostic mounts points"
         )
         return False
示例#28
0
    def rest_bigtap_enable_feature(self, feature_name):
        '''Enable a bigtap feature

           Input:
                `feature_name`           :    Bigtap Feature Name. Currently allowed feature names are `overlap`,`inport-mask`,`tracked-host`,`l3-l4-mode`

           Returns: True if feature is enabled successfully, false otherwise
            Examples:
                | rest enable feature  |  overlap |
        '''
        try:
            t = test.Test()
        except:
            return False
        else:
            c = t.controller('master')
            try:
                url = '/api/v1/data/controller/applications/bigtap/feature'
                c.rest.patch(url, {str(feature_name): True})
            except:
                helpers.test_failure(c.rest.error())
                return False
            else:
                if not c.rest.status_code_ok():
                    helpers.test_failure(c.rest.error())
                    return False
                else:
                    helpers.test_log(c.rest.content_json())
                    return True
示例#29
0
    def switch_upgrade_test(self, switchIpList, package=None):    
        '''
           To upgrade parallel with switchIpList
           package: None - default 
           Input : switchIpList
           Output : true if upgrade successful
        '''
        try:
            if not switchIpList:
                helpers.test_failure("Please provide switchIpList")
                return False   
            if not package:
                helpers.log("no package provided")
                package= "latest.switchlight-powerpc-internal-t5.swi"            
            if __name__ == '__init__':
                jobs= []
                for switch in switchIpList:
                    p = Process(target= '_switch_upgrade_steps', args=(switch, package ))
                    p.start()
                    jobs.append(p)
                    p.join()
                    return True     

        except: 
            helpers.test_failure("could not complete the upgrade process")
            return False 
示例#30
0
 def flap_interface_ma1(self, console_ip, console_port):
     '''Flap interface ma1 on switch
     
         Inputs:
             console_ip        IP Address of Console Server
             
             console_port      Console Port Number
     '''
     try:
         user = "******"
         password = "******"
         tn = telnetlib.Telnet(str(console_ip), int(console_port))
         tn.read_until("login: "******"\r\n")
         tn.read_until("Password: "******"\r\n")
         tn.read_until('')
         tn.write("\r\n" + "show running-config" + "\r\n")
         tn.write("\r\n" + "debug bash" + "\r\n")
         tn.write("ifconfig ma1 " + "\r\n")
         tn.write("ifconfig ma1 down" + "\r\n")
         time.sleep(2)
         tn.write("ifconfig ma1 up" + "\r\n")
         tn.write("exit" + "\r\n")
         tn.write("exit" + "\r\n")
         tn.close()
         return True
     except:
         helpers.test_failure(
             "Could not execute command. Please check log for errors")
         return False