当前位置: 首页>>代码示例>>Python>>正文


Python Linux.configure_ip_interface方法代码示例

本文整理汇总了Python中Linux.Linux.configure_ip_interface方法的典型用法代码示例。如果您正苦于以下问题:Python Linux.configure_ip_interface方法的具体用法?Python Linux.configure_ip_interface怎么用?Python Linux.configure_ip_interface使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Linux.Linux的用法示例。


在下文中一共展示了Linux.configure_ip_interface方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_ip_atk_021

# 需要导入模块: from Linux import Linux [as 别名]
# 或者: from Linux.Linux import configure_ip_interface [as 别名]
class test_ip_atk_021(test_case):
    myLog = getLogger()	

    def setUp(self):
        #Establish a telnet session to the SSX box.
	self.ssx = SSX(ssx1["ip_addr"])
        self.ssx.telnet()

        # Clear the SSX config
        #self.ssx.clear_config()

        #Establish a telnet session to the linux1 client box.
        self.linux1 = Linux(linux1["ip_addr"],linux1["user_name"],
					linux1["password"])
        self.linux1.telnet()
	
	# wait for card to come up 
	self.ssx.wait4cards()
        self.ssx.clear_health_stats()


    def tearDown(self):
	# Close the telnet session of SSX
	self.ssx.close()    
	# Close the telnet session of linux1 Client
	self.linux1.close()             

    def test_ip_atk_021(self):

	 #vgroup b/w SSX and linux
        vgroup_new(vgroup_cfg_dos)


	self.myLog.output("\n**********start the test**************\n")

        #Push the SSX configuration	
	self.ssx.config_from_string(script_var['DOS_FUN_005'])

	self.ssx.cmd("clear log debug")
	self.linux1.configure_ip_interface(p1_ssx_linux1[1],script_var['linux1_ip_addr/m'])
   

	
	#clearing ip,sys and port counters
	self.ssx.cmd("context %s"%script_var['context_name'])

	self.ssx.cmd("clear ip counters ")
        self.myLog.output("IP counters exist on SSX:%s"%self.ssx.cmd("show ip counters"))

        self.ssx.cmd("clear syscount")
        self.myLog.output("System counters exist on SSX:%s"%self.ssx.cmd("show syscount"))

        self.ssx.cmd("clear port %s counters drop"%script_var['ssx_port'])
        self.myLog.output("Port counters exist on SSX:%s"%self.ssx.cmd("show port %s counters drop"%script_var['ssx_port']))
	#Capturing slot from port
        p1_ssx_linux1_slot = p1_ssx_linux1[0].split("/")[0]	
	#Send ICMP Source Quench messages to SSX
	out = self.linux1.cmd("sudo /usr/sbin/hping -1 -I eth1 -C 4 -K 0 %s -p 23 --flood &"%(script_var['linux1_ip_addr']))
	time.sleep(30)

	#killing hping process
        self.linux1.cmd("sudo pkill -9 hping") 
	
	# displaying ip,sys and port counters And process Cpu utilization
	self.myLog.output("Displaying control plane rate limiter %s"%self.ssx.cmd("show dos slot %s counters"%p1_ssx_linux1_slot))


	self.myLog.output("IP counters exist on SSX after flooding traffic:%s"%self.ssx.cmd("show ip counters"))

        self.myLog.output("System counters exist on SSX after flooding traffic:%s"%self.ssx.cmd("show syscount"))

        self.myLog.output("Port counters exist on SSX after flooding traffic:%s"%self.ssx.cmd("show port %s counters drop"%script_var['ssx_port']))

        Cpu_out = self.ssx.cmd("show process cpu slot %s"%((p1_ssx_linux1[0].split("/"))[0]))

        self.myLog.output(Cpu_out)

        self.failUnless("100.00%" not in Cpu_out)
	

        # Checking SSX Health
        hs = self.ssx.get_health_stats()
        self.failUnless(is_healthy(hs,Warn_logs = 100), "Platform is not healthy")
开发者ID:muttu2244,项目名称:MyPython,代码行数:85,代码来源:ip_atk_021.py

示例2: test_ip_atk_007

# 需要导入模块: from Linux import Linux [as 别名]
# 或者: from Linux.Linux import configure_ip_interface [as 别名]
class test_ip_atk_007(test_case):
    myLog = getLogger()	

    def setUp(self):
        #Establish a telnet session to the SSX box.
	self.ssx = SSX(ssx1["ip_addr"])
        self.ssx.telnet()

        # Clear the SSX config
        #self.ssx.clear_config()

        #Establish a telnet session to the linux1 client box.
        self.linux1 = Linux(linux1["ip_addr"],linux1["user_name"],
					linux1["password"])
        self.linux1.telnet()
	
	# wait for card to come up 
	self.ssx.wait4cards()
        self.ssx.clear_health_stats()


    def tearDown(self):
	# Close the telnet session of SSX
	self.ssx.close()    
	# Close the telnet session of linux1 Client
	self.linux1.close()             

    def test_ip_atk_007(self):


	self.myLog.output("\n**********start the test**************\n")


	  #vgroup b/w SSX and linux
        vgroup_new(vgroup_cfg_dos)

        #Push the SSX configuration	
	self.ssx.config_from_string(script_var['DOS_FUN_005'])
	self.linux1.configure_ip_interface(p1_ssx_linux1[1],script_var['linux1_ip_addr/m'])

	       #Capturing slot from port
        p1_ssx_linux1_slot = p1_ssx_linux1[0].split("/")[0]

	 #Ping operation.
        self.ssx.cmd("context %s"%script_var['context_name'])
        time.sleep(5)
	Ping_out = self.ssx.ping(script_var['linux1_ip_addr'])
	time.sleep(5)
	Ping_out = self.ssx.ping(script_var['linux1_ip_addr'])
        self.failUnless(Ping_out == 1,"no connectivity b/w ssx and linux")

	self.ssx.cmd("clear log debug")
	#clearing ip,sys and port counters
        self.ssx.cmd("context %s"%script_var['context_name'])
	 
       	self.ssx.cmd("clear ip counters ")
        self.myLog.output("IP counters exist on SSX:%s"%self.ssx.cmd("show ip counters"))

        self.ssx.cmd("clear syscount")
        self.myLog.output("System counters exist on SSX:%s"%self.ssx.cmd("show syscount"))

        self.ssx.cmd("clear port %s counters drop"%script_var['ssx_port'])
        self.myLog.output("Port counters exist on SSX:%s"%self.ssx.cmd("show port %s counters drop"%script_var['ssx_port']))


	"""this API will return the mac_address of directly connected port of
           SSX machine to linux machine which runs scapy which takes
           slot/port as argumnet   """

	slot_port = p1_ssx_linux1[0]
	print slot_port
	dst_mac_address = get_mac_address(self.ssx,port=slot_port)
	print dst_mac_address
      
	dst_ip_adr = script_var['linux1_ip_addr']
	
        #sending packets with any option.
        invoke_scapy(self.linux1,dst_mac_adr = dst_mac_address,sudo_passwd=linux1['password'],dst_ip_adr = dst_ip_adr ,ip_options = 'primesoft',from_interface=p1_ssx_linux1[1],ip_hdr_len = 10,log = self.myLog, count =100)


        #displaying ip,port and syscounters and Cpu utilization

	self.myLog.output("Displaying control plane rate limiter %s"%self.ssx.cmd("show dos slot %s counters"%p1_ssx_linux1_slot))
	
	self.myLog.output("IP counters exist on SSX after flooding traffic:%s"%self.ssx.cmd("show ip counters"))

        self.myLog.output("System counters exist on SSX after flooding traffic:%s"%self.ssx.cmd("show syscount"))

        self.myLog.output("Port counters exist on SSX after flooding traffic:%s"%self.ssx.cmd("show port %s counters drop"%script_var['ssx_port']))

        Cpu_out = self.ssx.cmd("show process cpu slot %s"%((p1_ssx_linux1[0].split("/"))[0]))
        self.myLog.output(Cpu_out)

        self.failUnless("100.00%" not in Cpu_out)



        # Checking SSX Health
        hs = self.ssx.get_health_stats()
	self.failUnless(is_healthy(hs,Warn_logs = 100), "Platform is not healthy")
开发者ID:muttu2244,项目名称:MyPython,代码行数:102,代码来源:ip_atk_007.py

示例3: test_DoCoMo_6_2_1

# 需要导入模块: from Linux import Linux [as 别名]
# 或者: from Linux.Linux import configure_ip_interface [as 别名]
class test_DoCoMo_6_2_1(test_case):
    myLog = getLogger()
    global pskFlag
    pskFlag = 0

    def setUp(self):
	self.myLog.info(__doc__)
        """Establish a telnet session to the SSX box."""
        self.ssx = SSX(topo.ssx['ip_addr'])
	self.ssx.telnet()

        #Establish a telnet session to the Xpress VPN client box.
        self.xpress_vpn = Linux(topo.linux1["ip_addr"])
        self.xpress_vpn.telnet()

	# Telnet session to radisu server
	self.rad = Linux(topo.radius1["ip_addr"])
	self.rad.telnet()

        # wait for card to come up
        self.ssx.wait4cards()

        # CLear SSX configuration
	self.ssx.clear_config()
	self.ssx.clear_health_stats()

    def tearDown(self):

	self.ssx.wait4cards()
	self.ssx.cmd("system glc-switchback")
	time.sleep(10)
	self.ssx.wait4cards()
        # Close the telnet session of SSX
        self.ssx.close()

        # Close the telnet session of Xpress VPN Client
	if pskFlag:
		self.xpress_vpn.cmd("ike reset")
	        time.sleep(10)
 	        self.xpress_vpn.cmd("quit")
        self.xpress_vpn.close()
	self.rad.close()

    def test_DoCoMo_6_2_1(self):
        """
        Test case Id: -  DoCoMo_6_2_1
	"""

        self.myLog.output("\n**********start the test**************\n")
	self.myLog.info("Running vgroup")
	ssx_name= ssx["ip_addr"].split("-mc")[0]
        vportssx1 = port_ssx_linux1[0].replace('/',':')
        vportssx2 = port_ssx_radius1[0].replace('/',':')
	vportl1   = port_ssx_linux1[1].replace('eth','e')
	vportl2   = port_ssx_radius1[1].replace('eth','e')

	vgroup_new("%s:%s %s:%s"%(ssx_name,vportssx1,linux1['ip_addr'],vportl1))
	vgroup_new("%s:%s %s:%s"%(ssx_name,vportssx2,radius1['ip_addr'],vportl2))
	
        # Push SSX config
        self.ssx.config_from_string(docomo_var['DoCoMo_6_2_1'])
	
	#configuring tunnel on linux machine
        self.xpress_vpn.configure_ip_interface(port_ssx_linux1[1], docomo_var['xpress_phy_iface1_ip_mask'])
        self.rad.configure_ip_interface(port_ssx_radius1[1], docomo_var['radius1_ip_mask'])
	self.rad.cmd("sudo /sbin/route add -host %s gw %s"%(docomo_var['ip_pool_mask'],docomo_var['ssx_rad1_ip']))
	
	# start the radius, if not started
	self.myLog.output("Start the radius, if not started")
	self.rad.cmd("sudo pkill radius")
	self.rad.cmd("sudo /a/radius1/sbin/radiusd xX")

        # Push xpress vpn config
        self.xpress_vpn.write_to_file(docomo_var['xpm_autoexec'],"autoexec.cfg","/xpm/")


        # Enable debug logs for iked
        self.ssx.cmd("context %s" % docomo_var['context_name'])
        self.ssx.cmd("debug module iked all")
        self.ssx.cmd("debug module aaad all")
        # Flush the debug logs in SSX, if any
        self.ssx.cmd("clear log debug")

        # Initiate IKE Session from Xpress VPN Client (takama)
	self.xpress_vpn.cmd("sudo /sbin/ip addr add dev %s %s/16 brd +"%(port_ssx_linux1[1],docomo_var['ip_pool']))
	self.xpress_vpn.cmd("sudo /sbin/ip route add %s via %s dev %s src %s"%(docomo_var['ses_lo_ip'],docomo_var['ssx_clnt_ip'],port_ssx_linux1[1],docomo_var['ip_pool']))
	self.xpress_vpn.cmd("sudo /sbin/ip route add %s via %s dev %s src %s"%(docomo_var['radius1_route'],docomo_var['ssx_clnt_ip'],port_ssx_linux1[1],docomo_var['ip_pool']))
	self.xpress_vpn.cmd("sudo /sbin/ifconfig %s:1 %s netmask 255.255.0.0"%(port_ssx_linux1[1],docomo_var['xpress_phy_iface1_ip']))
	time.sleep(3)
	self.xpress_vpn.cmd("cd /xpm")
        op_client_cmd = self.xpress_vpn.cmd("sudo ./start_ike")
	time.sleep(30)

        ses_yn = self.ssx.cmd("show ike-session brief")
        self.myLog.output("show ike-session brief : %s"%ses_yn)
        if ses_yn.splitlines()[-1].split()[2] != 'Y':
                self.fail("FAIL : ipv4 session is not establised")

	op1 = self.ssx.cmd("show session") + self.ssx.cmd("show ike-session brief") + self.ssx.cmd("show ike-session list") + self.ssx.cmd("show ike-session detail remote %s"%docomo_var['xpress_phy_iface1_ip'])
        self.myLog.output("Session Details: %s"%op1)
#.........这里部分代码省略.........
开发者ID:muttu2244,项目名称:MyPython,代码行数:103,代码来源:DoCoMo_6_2_1.py

示例4: test_ip_atk_072

# 需要导入模块: from Linux import Linux [as 别名]
# 或者: from Linux.Linux import configure_ip_interface [as 别名]
class test_ip_atk_072(test_case):
    myLog = getLogger()	

    def setUp(self):
        #Establish a telnet session to the SSX box.
	self.ssx = SSX(ssx1["ip_addr"])
        self.ssx.telnet()

        # Clear the SSX config
        #self.ssx.clear_config()

        #Establish a telnet session to the linux1 client box.
        self.linux1 = Linux(linux1["ip_addr"],linux1["user_name"],
					linux1["password"])
        self.linux1.telnet()
	
	# wait for card to come up 
	self.ssx.wait4cards()
        self.ssx.clear_health_stats()


    def tearDown(self):
	# Close the telnet session of SSX
	self.ssx.close()    
	# Close the telnet session of linux1 Client
	self.linux1.close()             

    def test_ip_atk_072(self):

        #vgroup code
        vgroup_new(vgroup_cfg_dos)


	self.myLog.output("\n**********start the test**************\n")

        #Push the SSX configuration	
	self.ssx.config_from_string(script_var['DOS_FUN_017'])

	#Configure interface on linux.
	self.linux1.configure_ip_interface(p1_ssx_linux1[1],script_var['linux1_ip_addr/m'])

	 #Ping operation.
        self.ssx.cmd("context %s"%script_var['context_name'])
        time.sleep(5)
        Ping_out = self.ssx.ping(script_var['linux1_ip_addr'])
        self.failUnless(Ping_out == 1,"no connectivity b/w ssx and linux")

	
	 #Capturing slot from port
        p1_ssx_linux1_slot = p1_ssx_linux1[0].split("/")[0]

	self.ssx.cmd("clear log debug")

	#clearing ip,sys and port counters and displaying ip,sys and port counters 
	self.ssx.cmd("context %s"%script_var['context_name'])


	self.ssx.cmd("clear ip counters ")
        self.myLog.output("IP counters exist on SSX:%s"%self.ssx.cmd("show ip counters"))

        self.ssx.cmd("clear syscount")
        self.myLog.output("System counters exist on SSX:%s"%self.ssx.cmd("show syscount"))

        self.ssx.cmd("clear port %s counters drop"%script_var['ssx_port'])
        self.myLog.output("Port counters exist on SSX:%s"%self.ssx.cmd("show port %s counters drop"%script_var['ssx_port']))
        
	
	#Run nmap tool onto SSX to send window scan
	out = self.linux1.cmd("sudo /usr/bin/nmap -sW %s  & "%(script_var['ssx_ip_addr']))
	time.sleep(30)

	#killing NAMP process on Linux.
        self.linux1.cmd("sudo pkill -9 nmap") 

	# displaying ip,sys and port counters And process Cpu utilization
        self.myLog.output("Displaying control plane rate limiter %s"%self.ssx.cmd("show dos slot %s counters"%p1_ssx_linux1_slot))


	self.myLog.output("IP counters exist on SSX after flooding traffic:%s"%self.ssx.cmd("show ip counters"))

	self.myLog.output("System counters exist on SSX after flooding traffic:%s"%self.ssx.cmd("show syscount"))

	self.myLog.output("Port counters exist on SSX after flooding traffic:%s"%self.ssx.cmd("show port %s counters drop"%script_var['ssx_port']))

	Cpu_out = self.ssx.cmd("show process cpu slot %s"%((p1_ssx_linux1[0].split("/"))[0]))
	self.myLog.output(Cpu_out)

	self.failUnless("100.00%" not in Cpu_out)



        # Checking SSX Health
        hs = self.ssx.get_health_stats()
        self.failUnless(is_healthy(hs,Warn_logs = 100), "Platform is not healthy")
开发者ID:muttu2244,项目名称:MyPython,代码行数:96,代码来源:ip_atk_072.py

示例5: test_ip_atk_078

# 需要导入模块: from Linux import Linux [as 别名]
# 或者: from Linux.Linux import configure_ip_interface [as 别名]
class test_ip_atk_078(test_case):
    myLog = getLogger()	

    def setUp(self):
        #Establish a telnet session to the SSX box.
	self.ssx = SSX(ssx1["ip_addr"])
        self.ssx.telnet()

	#Establish a telnet session to the Netscreen.
        self.ns5gt = NS(ns['ipaddr'])
        self.ns5gt.telnet()
	# Inserting the code of Linux1 object -- Ashu
	#Establish a telnet session to the linux1 client box.
        self.linux1 = Linux(linux1["ip_addr"],linux1["user_name"],
                                        linux1["password"])
        self.linux1.telnet()

        #clear the configuration on Netscreen
        self.ns5gt.clear_config()


        # Clear the SSX config
   #     self.ssx.clear_config()


	# wait for card to come up 
	self.ssx.wait4cards()
        self.ssx.clear_health_stats()


    def tearDown(self):
	# Close the telnet session of SSX
	self.ssx.close()    
	# Close the telnet session of Netscreen
	self.ns5gt.close()
	#Inserting code of linux1 -- Ashu
	# Close the telnet session of linux1 Client
        self.linux1.close()



    def test_ip_atk_078(self):


	self.myLog.output("\n**********start the test**************\n")

	#vgroup b/w SSX and linux
	vgroup_new(vgroup_cfg_dos)

	#vgroup b/w SSX and NS5.
	vgroup_new(vgroup_cfg_dos2)

	 #Get the configuration from a string in a config file config.py and Load it in SSX.
        self.ssx.config_from_string(script_var['common_ssx_for_ikev1'])
        self.ssx.config_from_string(script_var['ikev1_fun_019_ssx'])

	 #Push the SSX configuration     
        self.ssx.config_from_string(script_var['DOS_FUN_017'])

        #Configure interface on linux.
        self.linux1.configure_ip_interface(p1_ssx_linux1[1],script_var['linux1_ip_addr/m'])

	 #Ping operation.
        self.ssx.cmd("context %s"%script_var['context_name'])
        time.sleep(5)
        Ping_out = self.ssx.ping(script_var['linux1_ip_addr'])
        self.failUnless(Ping_out == 1,"no connectivity b/w ssx and linux")


         #Capturing slot from port
        p1_ssx_linux1_slot = p1_ssx_linux1[0].split("/")[0]
	

        #Get the configuration from a string in a config file config.py and Load it in NS-5GT.
        self.ns5gt.config_from_string(script_var['common_ns5gt'])
        self.ns5gt.config_from_string(script_var['ikev1_fun_019_ns5gt'])


        # Enable debug logs for iked
        self.ssx.cmd("context %s" %script_var['context_name'])
	
        self.ssx.cmd("clear ip counters ")
        self.myLog.output("IP counters exist on SSX:%s"%self.ssx.cmd("show ip counters"))

        self.ssx.cmd("clear syscount")
        self.myLog.output("System counters exist on SSX:%s"%self.ssx.cmd("show syscount"))

        self.ssx.cmd("clear port %s counters drop"%script_var['ssx_port'])
        self.myLog.output("Port counters exist on SSX:%s"%self.ssx.cmd("show port %s counters drop"%script_var['ssx_port']))

	
        self.ssx.cmd("debug module iked all")
        #Flush the debug logs in SSX, if any
        self.ssx.cmd("clear log debug")

        #Give Ping from ns5gt to SSX.
        ping_output=self.ns5gt.ping(script_var['ssx_ses_ip'],source="untrust")
        ping_output=self.ns5gt.ping(script_var['ssx_ses_ip'],source="untrust")
        self.failUnless( ping_output, "PINGING IS FAILED")
        time.sleep(10)
#.........这里部分代码省略.........
开发者ID:muttu2244,项目名称:MyPython,代码行数:103,代码来源:ip_atk_078.py

示例6: test_DoCoMo_6_2_5

# 需要导入模块: from Linux import Linux [as 别名]
# 或者: from Linux.Linux import configure_ip_interface [as 别名]
class test_DoCoMo_6_2_5(test_case):
    myLog = getLogger()
    global pskFlag
    pskFlag = 1

    def setUp(self):
	self.myLog.info(__doc__)
        """Establish a telnet session to the SSX box."""
        self.ssx = SSX(topo.ssx['ip_addr'])
	self.ssx.telnet()

        #Establish a telnet session to the Xpress VPN client box.
        self.xpress_vpn = Linux(topo.linux1["ip_addr"])
        self.xpress_vpn.telnet()

	# Sniffer.
        self.sniffer = Linux(topo.linux1["ip_addr"])
        self.sniffer.telnet()

	# Telnet session to radisu server
	self.rad = Linux(topo.radius1["ip_addr"])
	self.rad.telnet()

        # wait for card to come up
        self.ssx.wait4cards()

        # CLear SSX configuration
	self.ssx.clear_config()
	self.ssx.clear_health_stats()

    def tearDown(self):

        # Close the telnet session of SSX
        self.ssx.close()

        # Close the telnet session of Xpress VPN Client
	if pskFlag:
		self.xpress_vpn.cmd("ike reset")
	        time.sleep(10)
 	        self.xpress_vpn.cmd("quit")
        self.xpress_vpn.close()
	self.rad.close()

    def test_DoCoMo_6_2_5(self):
        """
        Test case Id: -  DoCoMo_6_2_5
	"""

        self.myLog.output("\n**********start the test**************\n")
	self.myLog.info("Running vgroup")
	ssx_name= ssx["ip_addr"].split("-mc")[0]
        vportssx1 = port_ssx_linux1[0].replace('/',':')
        vportssx2 = port_ssx_radius1[0].replace('/',':')
	vportl1   = port_ssx_linux1[1].replace('eth','e')
	vportl2   = port_ssx_radius1[1].replace('eth','e')

	vgroup_new("%s:%s %s:%s"%(ssx_name,vportssx1,linux1['ip_addr'],vportl1))
	vgroup_new("%s:%s %s:%s"%(ssx_name,vportssx2,radius1['ip_addr'],vportl2))
	
        # Push SSX config
        self.ssx.config_from_string(docomo_var['DoCoMo_6_2_5'])
	
	#configuring tunnel on linux machine
        self.xpress_vpn.configure_ip_interface(port_ssx_linux1[1], docomo_var['xpress_phy_iface1_ip_mask'])
        self.rad.configure_ip_interface(port_ssx_radius1[1], docomo_var['radius1_ip_mask'])
	self.rad.cmd("sudo /sbin/route add -host %s gw %s"%(docomo_var['ip_pool_mask'],docomo_var['ssx_rad1_ip']))
	
	# start the radius, if not started
	self.myLog.output("Start the radius, if not started")
	radOp = self.rad.cmd("sudo /sbin/service radiusd status")
	if ("stop" or "dead" or "not running" in radOp):
		self.rad.cmd("sudo /sbin/service radiusd start")

        # Push xpress vpn config
        self.xpress_vpn.write_to_file(docomo_var['xpm_autoexec'],"autoexec.cfg","/xpm/")


        # Enable debug logs for iked
        self.ssx.cmd("context %s" % docomo_var['context_name'])
        self.ssx.cmd("debug module iked all")
        self.ssx.cmd("debug module aaad all")
        # Flush the debug logs in SSX, if any
        self.ssx.cmd("clear log debug")

        # Initiate IKE Session from Xpress VPN Client (takama)
	self.xpress_vpn.cmd("sudo /sbin/ip addr add dev %s %s/16 brd +"%(port_ssx_linux1[1],docomo_var['ip_pool']))
	self.xpress_vpn.cmd("sudo /sbin/ip route add %s via %s dev %s src %s"%(docomo_var['ses_lo_ip'],docomo_var['ssx_clnt_ip'],port_ssx_linux1[1],docomo_var['ip_pool']))
	self.xpress_vpn.cmd("sudo /sbin/ip route add %s via %s dev %s src %s"%(docomo_var['radius1_route'],docomo_var['ssx_clnt_ip'],port_ssx_linux1[1],docomo_var['ip_pool']))
	self.xpress_vpn.cmd("sudo /sbin/ifconfig %s:1 %s netmask 255.255.0.0"%(port_ssx_linux1[1],docomo_var['xpress_phy_iface1_ip']))
	time.sleep(3)
	self.xpress_vpn.cmd("cd /xpm")
        op_client_cmd = self.xpress_vpn.cmd("sudo ./start_ike")
	time.sleep(10)

        ses_yn = self.ssx.cmd("show ike-session brief")
        self.myLog.output("show ike-session brief : %s"%ses_yn)
        if ses_yn.splitlines()[-1].split()[2] != 'Y':
                self.fail("FAIL : ipv4 session is not establised")

	op1 = self.ssx.cmd("show session") + self.ssx.cmd("show ike-session brief") + self.ssx.cmd("show ike-session list") + self.ssx.cmd("show ike-session detail remote %s"%docomo_var['xpress_phy_iface1_ip'])
#.........这里部分代码省略.........
开发者ID:muttu2244,项目名称:MyPython,代码行数:103,代码来源:DoCoMo_6_2_5.py

示例7: test_ip_atk_089

# 需要导入模块: from Linux import Linux [as 别名]
# 或者: from Linux.Linux import configure_ip_interface [as 别名]
class test_ip_atk_089(test_case):
    myLog = getLogger()	

    def setUp(self):
        #Establish a telnet session to the SSX box.
	self.ssx = SSX(ssx1["ip_addr"].split("-")[0])
        self.ssx.telnet()

        # Clear the SSX config
   #     self.ssx.clear_config()

        #Establish a telnet session to the linux1 client box.
        self.linux1 = Linux(linux1["ip_addr"],linux1["user_name"],linux1["password"])
        self.linux1.telnet()

	# wait for card to come up 
	self.ssx.wait4cards()
        self.ssx.clear_health_stats()


    def tearDown(self):
	# Close the telnet session of SSX
	self.ssx.close()    
	# Close the telnet session of linux1 Client
	self.linux1.close() 

    def test_ip_atk_089(self):


	self.myLog.output("\n**********start the test**************\n")
	#vgroup b/w SSX and LINUX.
   #     vg_output1 = vgroup_new(topo3[:])
    #    self.failUnless(vg_output1 == None,"vgroup FAILED")
        #vgroup code
        vgroup_new(vgroup_cfg_dos)




        #Push the SSX configuration	
	self.ssx.config_from_string(script_var['common_ssx'])
	self.ssx.config_from_string(script_var['DOS_FUN_005'])
	self.linux1.configure_ip_interface(p1_ssx_linux1[1],script_var['xpress_phy_iface1_ip_mask'])

	self.ssx.cmd("clear log debug")
	
	   #Ping operation.
        self.ssx.cmd("context %s"%script_var['context_name'])
        time.sleep(5)
	Ping_out = self.ssx.ping(script_var['linux1_ip_addr'])
	time.sleep(5)
	Ping_out = self.ssx.ping(script_var['linux1_ip_addr'])

        self.failUnless(Ping_out == 1,"no connectivity b/w ssx and linux")


         #Capturing slot from port
        p1_ssx_linux1_slot = p1_ssx_linux1[0].split("/")[0]


	 #clearing ip,sys and port counters and displaying ip,sys and port counters 

        self.ssx.cmd("clear ip counters ")
        self.myLog.output("IP counters exist on SSX:%s"%self.ssx.cmd("show ip counters"))

        self.ssx.cmd("clear syscount")
        self.myLog.output("System counters exist on SSX:%s"%self.ssx.cmd("show syscount"))

        self.ssx.cmd("clear port %s counters drop"%script_var['ssx_port'])
        self.myLog.output("Port counters exist on SSX:%s"%self.ssx.cmd("show port %s counters drop"%script_var['ssx_port']))

 	#Send SYN flood to SSX while icmp traffic is passing through SSX
	self.linux1.cmd("sudo /usr/sbin/hping -S -p 111  %s --flood &"%script_var['ssx_ip_addr'])
        time.sleep(40)
        self.linux1.cmd("sudo pkill -9 hping")

	
	
	# displaying ip,sys and port counters And process Cpu utilization

	self.myLog.output("Displaying control plane rate limiter %s"%self.ssx.cmd("show dos slot %s counters"%p1_ssx_linux1_slot))

	
        self.myLog.output("IP counters exist on SSX after flooding traffic:%s"%self.ssx.cmd("show ip counters"))

        self.myLog.output("System counters exist on SSX after flooding traffic:%s"%self.ssx.cmd("show syscount"))

        self.myLog.output("Port counters exist on SSX after flooding traffic:%s"%self.ssx.cmd("show port %s counters drop"%script_var['ssx_port']))

        Cpu_out = self.ssx.cmd("show process cpu slot %s"%((p1_ssx_linux1[0].split("/"))[0]))
        self.myLog.output(Cpu_out)

        self.failUnless("100.00%" not in Cpu_out)

        # Checking SSX Health
        hs = self.ssx.get_health_stats()
        self.failUnless(is_healthy(hs,Warn_logs = 100), "Platform is not healthy")
开发者ID:muttu2244,项目名称:MyPython,代码行数:99,代码来源:ip_atk_089.py

示例8: test_ip_atk_008

# 需要导入模块: from Linux import Linux [as 别名]
# 或者: from Linux.Linux import configure_ip_interface [as 别名]
class test_ip_atk_008(test_case):
    myLog = getLogger()	

    def setUp(self):
        #Establish a telnet session to the SSX box.
	self.ssx = SSX(ssx1["ip_addr"])
        self.ssx.telnet()

        # Clear the SSX config
        #self.ssx.clear_config()

        #Establish a telnet session to the linux1 client box.
        self.linux1 = Linux(linux1["ip_addr"],linux1["user_name"],
					linux1["password"])
        self.linux1.telnet()
	
	# wait for card to come up 
	self.ssx.wait4cards()
        self.ssx.clear_health_stats()


    def tearDown(self):
	# Close the telnet session of SSX
	self.ssx.close()    
	# Close the telnet session of linux1 Client
	self.linux1.close()             

    def test_ip_atk_008(self):


	self.myLog.output("\n**********start the test**************\n")

	  #vgroup b/w SSX and linux
        vgroup_new(vgroup_cfg_dos)

        #Push the SSX configuration	
	self.ssx.config_from_string(script_var['DOS_FUN_005'])
	self.linux1.configure_ip_interface(p1_ssx_linux1[1],script_var['linux1_ip_addr/m'])

	        #Capturing slot from port
        p1_ssx_linux1_slot = p1_ssx_linux1[0].split("/")[0]

         #Ping operation.
        self.ssx.cmd("context %s"%script_var['context_name'])
        time.sleep(5)
        Ping_out = self.ssx.ping(script_var['linux1_ip_addr'])
        time.sleep(5)
        Ping_out = self.ssx.ping(script_var['linux1_ip_addr'])
        self.failUnless(Ping_out == 1,"no connectivity b/w ssx and linux")

	#clearing ip,sys and port counters
        self.ssx.cmd("context test")

       	self.ssx.cmd("clear ip counters ")
        self.myLog.output("IP counters exist on SSX:%s"%self.ssx.cmd("show ip counters"))

        self.ssx.cmd("clear syscount")
        self.myLog.output("System counters exist on SSX:%s"%self.ssx.cmd("show syscount"))

        self.ssx.cmd("clear port %s counters drop"%script_var['ssx_port'])
        self.myLog.output("Port counters exist on SSX:%s"%self.ssx.cmd("show port %s counters drop"%script_var['ssx_port']))
	# displaying the rate limiter counter before sending the foold--ashu
	self.myLog.output("Displaying control plane rate limiter %s"%self.ssx.cmd("show dos slot %s counters"%p1_ssx_linux1_slot))

        # Sending packet with IP spoofed address
	out = self.linux1.cmd("sudo /usr/sbin/hping -a 30.1.1.1 --flood %s & "%script_var['ssx_ip_addr'])

        time.sleep(40)

        #killing hping
        self.linux1.cmd("sudo pkill -9 hping")

        #displaying ip,port and syscounters and Cpu utilization

	self.myLog.output("Displaying control plane rate limiter %s"%self.ssx.cmd("show dos slot %s counters"%p1_ssx_linux1_slot))
	
	self.myLog.output("IP counters exist on SSX after flooding traffic:%s"%self.ssx.cmd("show ip counters"))

        self.myLog.output("System counters exist on SSX after flooding traffic:%s"%self.ssx.cmd("show syscount"))

        self.myLog.output("Port counters exist on SSX after flooding traffic:%s"%self.ssx.cmd("show port %s counters drop"%script_var['ssx_port']))

        Cpu_out = self.ssx.cmd("show process cpu slot %s"%((p1_ssx_linux1[0].split("/"))[0]))
        self.myLog.output(Cpu_out)

        self.failUnless("100.00%" not in Cpu_out)



        # Checking SSX Health
        hs = self.ssx.get_health_stats()
	self.failUnless(is_healthy(hs,Warn_logs = 100), "Platform is not healthy")
开发者ID:muttu2244,项目名称:MyPython,代码行数:94,代码来源:ip_atk_008.py

示例9: test_ip_atk_080

# 需要导入模块: from Linux import Linux [as 别名]
# 或者: from Linux.Linux import configure_ip_interface [as 别名]
class test_ip_atk_080(test_case):
    myLog = getLogger()	

    def setUp(self):
        #Establish a telnet session to the SSX box.
	self.ssx = SSX(ssx1["ip_addr"])
        self.ssx.telnet()

        # Clear the SSX config
   #     self.ssx.clear_config()

        #Establish a telnet session to the linux1 client box.
        self.linux1 = Linux(linux1["ip_addr"],linux1["user_name"],linux1["password"])
        self.linux1.telnet()

	# wait for card to come up 
	self.ssx.wait4cards()
        self.ssx.clear_health_stats()


    def tearDown(self):
	# Close the telnet session of SSX
	self.ssx.close()    
	# Close the telnet session of linux1 Client
	self.linux1.close() 

    def test_ip_atk_080(self):


	self.myLog.output("\n**********start the test**************\n")
       #vgroup b/w SSX and linux
        vgroup_new(vgroup_cfg_dos)


        #Push the SSX configuration	
        self.ssx.config_from_string(script_var['common_ssx'])
        self.ssx.config_from_string(script_var['pppoe_fun_001_ssx'])

	#Configuring interface on linux.
	self.linux1.configure_ip_interface(p1_ssx_linux1[1],script_var['linux1_ip_addr/m'])

        #Capturing slot from port
        p1_ssx_linux1_slot = p1_ssx_linux1[0].split("/")[0]

         #Ping operation.
        self.ssx.cmd("context %s"%script_var['context_name'])
        time.sleep(5)
        Ping_out = self.ssx.ping(script_var['linux1_ip_addr'])
        time.sleep(5)
        Ping_out = self.ssx.ping(script_var['linux1_ip_addr'])
        self.failUnless(Ping_out == 1,"no connectivity b/w ssx and linux")


         #clearing ip,sys and port counters and displaying ip,sys and port counters 
        self.ssx.cmd("context test")

        self.ssx.cmd("clear ip counters ")
        self.myLog.output("IP counters exist on SSX:%s"%self.ssx.cmd("show ip counters"))

        self.ssx.cmd("clear syscount")
        self.myLog.output("System counters exist on SSX:%s"%self.ssx.cmd("show syscount"))

        self.ssx.cmd("clear port %s counters drop"%script_var['ssx_port'])
        self.myLog.output("Port counters exist on SSX:%s"%self.ssx.cmd("show port %s counters drop"%script_var['ssx_port']))

        #Push the Linux(PPPoE)client configuration

        self.linux1.write_to_file(script_var['pppoe_cnf_032_linux1'],"pppoe.conf"," /rp-pppoe-3.8/configs/")

        self.linux1.cmd("sudo cp  /rp-pppoe-3.8/configs/pppoe.conf /etc/ppp/")

        self.linux1.cmd("cd /usr/rp-pppoe-3.8/scripts")

        self.linux1.cmd("sudo pkill pppoe-connect")

        pppoe_output=self.linux1.cmd("sudo ./pppoe-start")

        self.failUnless( 'Connected!' in  pppoe_output,'testcase FAILED due to pppoe session has not established')

	#Flooding of UDP traffic.	
	self.linux1.cmd("sudo /usr/sbin/hping3 -2 -p 22 %s --flood "%(script_var['ssx1_ip_addr']),timeout = 150)
	time.sleep(40)
	self.linux1.cmd("sudo pkill -9 hping")

	# displaying ip,sys and port counters And process Cpu utilization
        self.myLog.output("IP counters exist on SSX after flooding traffic:%s"%self.ssx.cmd("show ip counters"))

        self.myLog.output("System counters exist on SSX after flooding traffic:%s"%self.ssx.cmd("show syscount"))

        self.myLog.output("Port counters exist on SSX after flooding traffic:%s"%self.ssx.cmd("show port %s counters drop"%script_var['ssx_port']))

        Cpu_out = self.ssx.cmd("show process cpu slot %s"%((p1_ssx_linux1[0].split("/"))[0]))
        self.myLog.output(Cpu_out)

        self.failUnless("100.00%" not in Cpu_out)

        # Checking SSX Health
        hs = self.ssx.get_health_stats()
        self.failUnless(is_healthy(hs,Warn_logs = 100), "Platform is not healthy")
开发者ID:muttu2244,项目名称:MyPython,代码行数:101,代码来源:ip_atk_080.py

示例10: test_CDR_MISC_001

# 需要导入模块: from Linux import Linux [as 别名]
# 或者: from Linux.Linux import configure_ip_interface [as 别名]
class test_CDR_MISC_001(test_case):
    myLog = getLogger()

    def setUp(self):

        """Establish a telnet session to the SSX box."""
        self.ssx = SSX(topo.ssx['ip_addr'])
	self.ssx.telnet()
        self.ssx.clear_health_stats()
	self.ssx.wait4cards()
        # CLear SSX configuration
	self.ssx.clear_config()



        #Establish a telnet session to the Xpress VPN client box.
        self.xpress_vpn = Linux(topo.linux["ip_addr"],topo.linux["user_name"],
				topo.linux["password"])
        self.xpress_vpn.telnet()

        # Establish a telnet session to the radius servers
        self.radclient_radius1 = Linux(xpress_vpn2_multi['ip_addr'],xpress_vpn2_multi['user_name'],
				xpress_vpn2_multi['password'])
        self.radclient_radius1.telnet()

    def tearDown(self):

        # Close the telnet session of SSX
        self.ssx.close()
        # Close the telnet session of Xpress VPN Client and radius server
        self.xpress_vpn.close()
	self.radclient_radius1.close()

    def test_CDR_MISC_001(self):
        """
        Test case Id: -  CDR_MISC_001
        Description: - Verify the DM functionality on SSX, 
		by sending a DM request from the Radius server using radclient.
	"""

        self.myLog.output("\n**********start the test**************\n")

        #Clearing already existing files on the linux machine
        self.xpress_vpn.cmd("cd ~krao")
        self.xpress_vpn.cmd("sudo rm -rf *.asn1")
        self.xpress_vpn.cmd("sudo rm -rf *.xml")
        self.xpress_vpn.cmd("sudo rm -rf *.ttlv")

        self.xpress_vpn.cmd("cd /tftpboot/")
        #self.linux.cmd("sudo rm *.*")
        self.xpress_vpn.cmd("sudo rm -rf *.asn1")
        self.xpress_vpn.cmd("sudo rm -rf *.xml")
        self.xpress_vpn.cmd("sudo rm -rf *.ttlv")


        #configuring interface on linux machine
        #self.xpress_vpn.configure_ip_interface(p1_ssx_xpressvpn1[1], script_var['xpress_phy_iface1_ip_mask'])
        self.radclient_radius1.configure_ip_interface(ssx_vgroup1[1], script_var['radius1_ip_mask'])


        #Vgrouping the Topology 
        vgroup_new(vlan_cfg_str1)

        # Push xpress vpn config on linux
        #self.xpress_vpn.write_to_file(script_var['autoexec_config'],"autoexec.cfg","/xpm/")
        #self.xpress_vpn.write_to_file(script_var['add_iptakama'],"add_ip_takama","/xpm/")


        # Push SSX config
        self.ssx.config_from_string(script_var['CDR_MISC_001'])

        # Push xpress vpn config
        self.xpress_vpn.write_to_file(script_var['autoexec_config_EAP'],"autoexec.cfg","/xpm/")
        self.xpress_vpn.write_to_file(script_var['add_ip_takama'],"add_ip_takama","/xpm/")

        # Initiate IKE Session from Xpress VPN Client (takama)
        self.xpress_vpn.cmd("cd /xpm/")
        self.xpress_vpn.cmd("sudo chmod 777 add_ip_takama")
        self.xpress_vpn.cmd("sudo ./add_ip_takama")


        # Enable debug logs for RDA
        self.ssx.cmd("clear log debug")
	self.ssx.cmd("context %s" % script_var['context_name'])
	self.ssx.cmd("debug module aaad radius-dynamic-authorization")
	self.ssx.cmd("clear radius dynamic-authorization counters")

        # Initiate IKE Session from Xpress VPN Client (takama)
        self.xpress_vpn.cmd("cd /xpm/")
        op_client_cmd = self.xpress_vpn.cmd("sudo ./start_ike")
	time.sleep(10)
        op1 = self.ssx.configcmd("show session")
        self.ssx.configcmd("exit")
        time.sleep(10)
        self.failUnless("IPSECv4" in op1,"Failed because there is no session of IPSEC")
        self.xpress_vpn.cmd("!ping %s -I %s -w 2 -c 2" %(script_var['ses_loopip'],script_var['pool_ip']))
        self.xpress_vpn.cmd("quit")


        ## Check weather IPsec session established or not  
#.........这里部分代码省略.........
开发者ID:muttu2244,项目名称:MyPython,代码行数:103,代码来源:CDR_MISC_001.py

示例11: test_DoCoMo_6_1_2

# 需要导入模块: from Linux import Linux [as 别名]
# 或者: from Linux.Linux import configure_ip_interface [as 别名]
class test_DoCoMo_6_1_2(test_case):
    myLog = getLogger()
    global pskFlag
    pskFlag = 0

    def setUp(self):
	self.myLog.info(__doc__)
        """Establish a telnet session to the SSX box."""
        self.ssx = SSX(topo.ssx['ip_addr'])
	self.ssx.telnet()

        #Establish a telnet session to the Xpress VPN client box.
        self.xpress_vpn = Linux(topo.linux1["ip_addr"])
        self.xpress_vpn.telnet()

	# Telnet session to radisu server
	self.rad = Linux(topo.radius1["ip_addr"])
	self.rad.telnet()

        # wait for card to come up
        self.ssx.wait4cards()

        # CLear SSX configuration
	self.ssx.clear_config()
	self.ssx.clear_health_stats()

    def tearDown(self):

        # Close the telnet session of SSX
        self.ssx.close()

        # Close the telnet session of Xpress VPN Client
	if pskFlag:
		self.xpress_vpn.cmd("ike reset")
	        time.sleep(10)
 	        self.xpress_vpn.cmd("quit")
        self.xpress_vpn.close()
	self.rad.close()

    def test_DoCoMo_6_1_2(self):
        """
        Test case Id: -  DoCoMo_6_1_2
	"""

        self.myLog.output("\n**********start the test**************\n")
	'''
	self.myLog.info("Running vgroup")
	ssx_name= ssx["ip_addr"].split("-mc")[0]
        vportssx1 = port_ssx_linux1[0].replace('/',':')
        vportssx2 = port_ssx_radius1[0].replace('/',':')
	vportl1   = port_ssx_linux1[1].replace('eth','e')
	vportl2   = port_ssx_radius1[1].replace('eth','e')

	vgroup_new("%s:%s %s:%s"%(ssx_name,vportssx1,linux1['ip_addr'],vportl1))
	vgroup_new("%s:%s %s:%s"%(ssx_name,vportssx2,radius1['ip_addr'],vportl2))
	'''
        # Push SSX config
        self.ssx.config_from_string(docomo_var['DoCoMo_6_1_2'])
	
	#configuring tunnel on linux machine
        self.xpress_vpn.configure_ip_interface(port_ssx_linux1[1], docomo_var['xpress_phy_iface1_ip_mask'])
        self.rad.configure_ip_interface(port_ssx_radius1[1], docomo_var['radius1_ip_mask'])
	
	# start the radius, if not started
	self.myLog.output("Start the radius, if not started")
	radOp = self.rad.cmd("sudo /sbin/service radiusd status")
	if ("stop" or "dead" or "not running" in radOp):
		self.rad.cmd("sudo /sbin/service radiusd start")

        # Push xpress vpn config
        self.xpress_vpn.write_to_file(docomo_var['xpm_autoexec'],"autoexec.cfg","/xpm/")


        # Enable debug logs for iked
        self.ssx.cmd("context %s" % docomo_var['context_name'])
        self.ssx.cmd("debug module iked all")
        self.ssx.cmd("debug module aaad all")
        # Flush the debug logs in SSX, if any
        self.ssx.cmd("clear log debug")

        # Initiate IKE Session from Xpress VPN Client (takama)
	self.xpress_vpn.cmd("sudo /sbin/ip addr add dev %s %s/16 brd +"%(port_ssx_linux1[1],docomo_var['ip_pool']))
	self.xpress_vpn.cmd("sudo /sbin/ip route add %s via %s dev %s src %s"%(docomo_var['ses_lo_ip'],docomo_var['ssx_clnt_ip'],port_ssx_linux1[1],docomo_var['ip_pool']))
	self.xpress_vpn.cmd("sudo /sbin/ifconfig %s:1 %s netmask 255.255.0.0"%(port_ssx_linux1[1],docomo_var['xpress_phy_iface1_ip']))
	time.sleep(3)
	self.xpress_vpn.cmd("cd /xpm")
        op_client_cmd = self.xpress_vpn.cmd("sudo start_ike")
	time.sleep(10)

        ses_yn = self.ssx.cmd("show ike-session brief")
        self.myLog.output("show ike-session brief : %s"%ses_yn)
        if ses_yn.splitlines()[-1].split()[2] != 'Y':
                self.fail("FAIL : ipv4 session is not establised with correct psk")

	op1 = self.ssx.cmd("show session") + self.ssx.cmd("show ike-session brief") + self.ssx.cmd("show ike-session list") + self.ssx.cmd("show ike-session detail remote %s"%docomo_var['xpress_phy_iface1_ip'])
        self.myLog.output("Session Details: %s"%op1)
        time.sleep(4)

	self.xpress_vpn.cmd("ike reset")
        time.sleep(10)
#.........这里部分代码省略.........
开发者ID:muttu2244,项目名称:MyPython,代码行数:103,代码来源:DoCoMo_6_1_2.py

示例12: test_CDR_HA_FUN_002

# 需要导入模块: from Linux import Linux [as 别名]
# 或者: from Linux.Linux import configure_ip_interface [as 别名]
class test_CDR_HA_FUN_002(test_case):
    myLog = getLogger()

    def setUp(self):

        """Establish a telnet session to the SSX box."""
        self.ssx = SSX(ssx_HA['ip_addr'])
	self.ssx.telnet()
        self.ssx.clear_health_stats()

        # CLear SSX configuration
	self.ssx.clear_config()
        self.ssx.wait4cards()

        #Establish a telnet session to the Xpress VPN client box.
        self.linux = Linux(linux["ip_addr"],linux["user_name"],
				linux["password"])
        self.linux.telnet()

        #Establish a telnet session to the RADIUS server box.
	self.radius1=Linux(xpress_vpn2_multi['ip_addr'],xpress_vpn2_multi['user_name'],xpress_vpn2_multi['password'])
        self.radius1.telnet()

    def tearDown(self):

        # Close the telnet session of SSX
        self.ssx.close()
        # Close the telnet session of Xpress VPN Client and radius server
        self.linux.close()
        self.radius1.close()

    def test_CDR_HA_FUN_002(self):
        """
        Test case Id: -  CDR_HA_FUN_002
	"""

        self.myLog.output("\n**********start the test**************\n")

        #Clearing already existing files on the linux machine
        self.linux.cmd("su root")
        time.sleep(5)
        self.linux.cmd("su krao")
        time.sleep(5)
        self.linux.cmd("cd")
        time.sleep(5)
        self.linux.cmd("rm -rf *.asn1")
        self.linux.cmd("rm -rf *.xml")
        self.linux.cmd("rm -rf *.ttlv")
        self.linux.cmd("exit")
        self.linux.cmd("exit")

        self.linux.cmd("cd /tftpboot/")
        #self.linux.cmd("sudo rm *.*")
        self.linux.cmd("sudo rm -rf *.asn1")
        self.linux.cmd("sudo rm -rf *.xml")
        self.linux.cmd("sudo rm -rf *.ttlv")



        #configuring interface on linux machine
        self.linux.configure_ip_interface(p1_ssx_xpressvpn1[1], script_var['xpress_phy_iface1_ip_mask'])
        self.radius1.configure_ip_interface(ssx_vgroup1[1], script_var['radius1_ip_mask'])


	#Vgrouping the Topology 
	vgroup_new(vlan_cfg_str1)

        # Push xpress vpn config on linux
        self.linux.write_to_file(script_var['autoexec_config'],"autoexec.cfg","/xpm/")
        self.linux.write_to_file(script_var['add_iptakama'],"add_ip_takama","/xpm/")

        # Push SSX config
        self.ssx.config_from_string(script_var['CDR_FUN_039'])


        # Initiate IKE Session from Xpress VPN Client (takama)
        self.linux.cmd("cd")
        self.linux.cmd("cd /xpm")
        self.linux.cmd("sudo chmod 777 add_ip_takama")
        self.linux.cmd("sudo ./add_ip_takama")
        time.sleep(5)

        op_client_cmd = self.linux.cmd("sudo ./start_ike")
        time.sleep(5)
        op1 = self.ssx.configcmd("show session")
        #self.ssx.configcmd("exit")
        self.failUnless("IPSEC" in op1,"Failed because there is no session of IPSEC")


        self.linux.cmd("!ping %s -I %s -w 4 -c 4" %(script_var['ses_loopip'],script_var['pool_ip']))
        self.linux.cmd("quit")

        #Displaying the saved configuration
        saved_conf =  self.ssx.cmd("show configuration cdr")
        self.myLog.output(saved_conf)


        #Executing IMC-Switc-Over
	self.ssx.imc_switchover_mgmt("system imc-switchover")

#.........这里部分代码省略.........
开发者ID:muttu2244,项目名称:MyPython,代码行数:103,代码来源:CDR_HA_FUN_002.py

示例13: test_ip_atk_076

# 需要导入模块: from Linux import Linux [as 别名]
# 或者: from Linux.Linux import configure_ip_interface [as 别名]
class test_ip_atk_076(test_case):
    myLog = getLogger()	

    def setUp(self):
        #Establish a telnet session to the SSX box.
	self.ssx = SSX(ssx1["ip_addr"])
        self.ssx.telnet()

        # Clear the SSX config
        self.ssx.clear_config()

        #Establish a telnet session to the xpressvpn1 client box.
        self.xpressvpn1 = Linux(xpressvpn1["ip_addr"],xpressvpn1["user_name"],xpressvpn1["password"])
        self.xpressvpn1.telnet()
	self.linux1 = Linux(linux1["ip_addr"],linux1["user_name"],linux1["password"])
	self.linux1.telnet()
	# wait for card to come up 
	self.ssx.wait4cards()
        self.ssx.clear_health_stats()


    def tearDown(self):
	# Close the telnet session of SSX
	self.ssx.close()    
	# Close the telnet session of xpressvpn1 Client
	self.xpressvpn1.close() 
	self.linux1.close()

	time.sleep(60)
	time.sleep(60)
    def test_ip_atk_076(self):



	self.myLog.output("\n**********start the test**************\n")

	#vgroup b/w SSX and XPRESSVPN.
	vgroup_new(vgroup_cfg_dos1)	
        #vgroup code
        vgroup_new(vgroup_cfg_dos)


	#Push the SSX configuration     
        self.ssx.config_from_string(script_var['common_ssx_ikev2'])
        self.ssx.config_from_string(script_var['DOS_FUN_076'])
        self.xpressvpn1.configure_ip_interface(p1_ssx1_xpressvpn1[1],script_var['xpressvpn1_phy_iface1_ip_mask'])


	    #Ping operation.
	self.ssx.cmd("context %s"%script_var['context_name'])
        time.sleep(50)
	Ping_out = self.ssx.ping(script_var['xpressvpn1_phy_iface1_ip'])
        self.failUnless(Ping_out == 1,"no connectivity b/w ssx and linux")


         #Capturing slot from port
        p1_ssx_linux1_slot = p1_ssx_linux1[0].split("/")[0]

	ssx_ph2_life = 60

	 #clearing ip,sys and port counters and displaying ip,sys and port counters 
        self.ssx.cmd("context test")

        self.ssx.cmd("clear ip counters ")
        self.myLog.output("IP counters exist on SSX:%s"%self.ssx.cmd("show ip counters"))

        self.ssx.cmd("clear syscount")
        self.myLog.output("System counters exist on SSX:%s"%self.ssx.cmd("show syscount"))

        self.ssx.cmd("clear port %s counters drop"%script_var['ssx_port'])
        self.myLog.output("Port counters exist on SSX:%s"%self.ssx.cmd("show port %s counters drop"%script_var['ssx_port']))

	
        # Push xpress vpn config on linux
        self.xpressvpn1.write_to_file(script_var['fun_014_xpressvpn'],"autoexec.cfg","/xpm/")

        #clearing sessions on ssx
        self.ssx.cmd("clear session all")

        # Initiate IKE Session from Xpress VPN Client (takama)
        self.xpressvpn1.cmd("cd /xpm")
	self.xpressvpn1.cmd("sudo ./add_ip_takama_qos-ashu") #copy this file from takama box to xpressvpn1 if not existing
        op_client_cmd = self.xpressvpn1.cmd("sudo ./start_ike",timeout = 200)


	 # Check SA in SSX with the remote 
        ssx_show_op = parse_show_ike_session_detail(self.ssx,script_var['xpress_phy_iface1_ip'])

        self.failUnless("ESTABLISHED" in ssx_show_op["session_state"],"failed to find SA")

        # Wait for SSX ph2 life-time

        time_diff = 0
        time.sleep(1)
        self.linux1.cmd("sudo /usr/sbin/hping3 -2 -p 22 %s --flood &"%(script_var['ssx_phy_iface1_ip_mask']),timeout = 150)
        while time_diff <= ssx_ph2_life:
          show_clock_op = self.ssx.cmd("show clock")
          time_diff = diff_in_time_ssx(ssx_show_op['child_sa_time_established'],show_clock_op)

        time.sleep(10)
#.........这里部分代码省略.........
开发者ID:muttu2244,项目名称:MyPython,代码行数:103,代码来源:ip_atk_076.py


注:本文中的Linux.Linux.configure_ip_interface方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。