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


Python Linux.ping_xpress_vpn方法代码示例

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


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

示例1: test_DoCoMo_6_2_1

# 需要导入模块: from Linux import Linux [as 别名]
# 或者: from Linux.Linux import ping_xpress_vpn [as 别名]

#.........这里部分代码省略.........

        # 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)
        time.sleep(4)

        # Initiate Ping through tunnel
	self.myLog.output("Initiate Ping through tunnel")
        op_ping = self.xpress_vpn.ping_xpress_vpn(docomo_var['ip_pool'],docomo_var['radius1_ip'],"500","4")
        self.failUnless(op_ping,"Ping through tunnel to radius server failed")
        self.myLog.output("\n***************\n Ping through tunnel is success\n****************\n")

	# Get the Active card of the sesion
	self.myLog.info("Get the Active card of the session")
	activeCard = port_ssx_linux1[0].split('/')[0]
        # Change the IP addr of session interface
        self.ssx.configcmd("context %s" %docomo_var['context_name'])
        self.ssx.configcmd("interface sub session")
	self.ssx.configcmd("no ip address %s"%docomo_var['ssx_ses_ip_mask'])
	self.ssx.configcmd("ip address 1.1.1.1/24")
	self.ssx.cmd("end")

        # Reload the GLC card on which sessions are formed
	self.myLog.info("Reload the GLC card on which sessions are formed")
	self.ssx.cmd("reload card %s"%activeCard)
	self.ssx.wait4cards(maxtime=200, wait_interval=10)

        # Check whether card came up
        op_card=self.ssx.cmd("sh card %s"%activeCard)
        self.failUnless("Running" in op_card, "Card is not up/running")

        # Check SA after reset of card
        ssx_show_op = parse_show_ike_session_detail(self.ssx,docomo_var['xpress_phy_iface1_ip'])
        self.failUnless("None" in  ssx_show_op["session_state"],"Fond SA even after Unbinding the interface")

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

示例2: test_DoCoMo_6_2_5

# 需要导入模块: from Linux import Linux [as 别名]
# 或者: from Linux.Linux import ping_xpress_vpn [as 别名]

#.........这里部分代码省略.........
        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'])
        self.myLog.output("Session Details: %s"%op1)
        time.sleep(4)

        # Initiate Ping through tunnel
	self.myLog.output("Initiate Ping through tunnel")
        op_ping = self.xpress_vpn.ping_xpress_vpn(docomo_var['ip_pool'],docomo_var['radius1_ip'],"500","4")
        self.failUnless(op_ping,"Ping through tunnel to radius server failed")
        self.myLog.output("\n***************\n Ping through tunnel is success\n****************\n")

	# Start the pkt captur at client
	self.myLog.info("Start the pkt capture at the client")
	self.sniffer.cmd("sudo ls")
	self.sniffer.cmd("sudo /usr/sbin/tethereal -i %s -R isakmp -q -w isakmp.pcap &"% port_ssx_linux1[1])
	
	# Waiting for rekey
	ssx_show_op = parse_show_ike_session_detail(self.ssx,docomo_var['xpress_phy_iface1_ip'])
	self.myLog.info("Waiting for rekey")
	negCnt = ssx_show_op['child_sa_negotiation_count']
	time.sleep(int(ssx_show_op['child_sa_time_remaining']) + 10)
	self.sniffer.cmd("sudo pkill tethereal")
	time.sleep(5)
	strcap = self.sniffer.cmd("sudo /usr/sbin/tethereal -r isakmp.pcap")
	
	# Checing the negotiation count after rekey
	self.myLog.info("Checking the negotiation count after rekey")	
	ssx_show_op = parse_show_ike_session_detail(self.ssx,docomo_var['xpress_phy_iface1_ip'])
	negCnt1 = ssx_show_op['child_sa_negotiation_count']
	self.failIf( negCnt1 <= negCnt , "negotiation count is incremented")

	# Verify the pkt capture for Life time expire
	self.myLog.info("Verify the pkt capture for Life time expire")
	self.failIf("CREATE_CHILD_SA" not in strcap , "SSX did not send Create Child SA")
	self.failIf("INFORMATIONAL" not in strcap , "SSX did not send INFORMATIONAL msg")

	# Verify the debug logs
	self.myLog.info("Verify the debug logs")
	debugOp = self.ssx.cmd('show log debug | grep "IKED_SEND_CHILD_SA_DELETE"')
	self.failIf("IKED_SEND_CHILD_SA_DELETE" not in debugOp , "Debug is not added for CHILD_SA_DELETE")
	
	# Sending traffiic after rekay
	self.myLog.info("Sending traffiic after rekay")
	op_ping = self.xpress_vpn.ping_xpress_vpn(docomo_var['ip_pool'],docomo_var['radius1_ip'],"500","4")
        self.failUnless(op_ping,"Ping through tunnel to radius server failed")
        self.myLog.output("\n***************\n Ping through tunnel is success after rekey\n****************\n")

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


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