本文整理汇总了Python中Linux.Linux.write_to_file方法的典型用法代码示例。如果您正苦于以下问题:Python Linux.write_to_file方法的具体用法?Python Linux.write_to_file怎么用?Python Linux.write_to_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Linux.Linux
的用法示例。
在下文中一共展示了Linux.write_to_file方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_DoCoMo_6_2_5
# 需要导入模块: from Linux import Linux [as 别名]
# 或者: from Linux.Linux import write_to_file [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'])
#.........这里部分代码省略.........
示例2: test_DoCoMo_6_2_1
# 需要导入模块: from Linux import Linux [as 别名]
# 或者: from Linux.Linux import write_to_file [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)
#.........这里部分代码省略.........
示例3: test_RADIUS_NEG_003
# 需要导入模块: from Linux import Linux [as 别名]
# 或者: from Linux.Linux import write_to_file [as 别名]
class test_RADIUS_NEG_003(test_case):
myLog = getLogger()
def setUp(self):
"""Establish a telnet session to the SSX box."""
self.ssx = SSX(topo.ssx1['ip_addr'])
self.ssx.telnet()
# CLear SSX configuration
self.ssx.clear_config()
# wait for card to come up
self.ssx.wait4cards()
self.ssx.clear_health_stats()
#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.ether_radius1 = Linux(radius1['ip_addr'],radius1['user_name'],radius1['password'])
self.ether_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.ether_radius1.close()
def test_RADIUS_NEG_003(self):
"""
Test case Id: - RADIUS_NEG_003
Description: - With continuous session requests in the background,
Delete the interface on the SSX which is connected to the Radius server
"""
self.myLog.output("\n**********start the test**************\n")
# Push SSX config
self.ssx.config_from_string(script_var['common_ssx'])
self.ssx.config_from_string(script_var['rad_neg_003_ssx'])
# Push xpress vpn config
self.xpress_vpn.write_to_file(script_var['rad_neg_003_xpressvpn'],"autoexec.cfg","/xpm/")
# Enable debug logs for iked
self.ssx.cmd("context %s" % script_var['context'])
self.ssx.cmd("debug module iked 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("cd /xpm/")
self.xpress_vpn.cmd("sudo cat /etc/sudoers")
op_client_cmd = self.xpress_vpn.cmd("sudo ./start_ike &")
self.myLog.output("\nGoing to sleep for 10sec ")
time.sleep(2)
self.myLog.output("List of sessions eastablished before deleting the interface,which is connected to radius server")
op_ssx_sa = self.ssx.configcmd("show ike-session brief")
i=0
count1 =0
for i in range(0,len(clnt_ips)):
if clnt_ips[i] in op_ssx_sa:
count1 = count1+1
self.myLog.output("\n\n************* the no. of ike sessions:%d\n\n"%count1)
# Delete the interface on ssx
self.ssx.configcmd("context %s" % script_var['context'])
self.ssx.configcmd("no interface rad1")
self.myLog.output("List of sessions eastablished after deleting the interface,which is connected to radius server")
op_ssx_sa = self.ssx.configcmd("show ike-session brief")
i=0
count1 =0
for i in range(0,len(clnt_ips)):
if clnt_ips[i] in op_ssx_sa:
count1 = count1+1
self.myLog.output("\n\n************* the no. of ike sessions:%d\n\n"%count1)
self.myLog.output("\n Gonig to selp for 50sec for checking any session are coming up,\nEven after deleting radius interface\n")
time.sleep(50)
op_ssx_sa = self.ssx.configcmd("show ike-session brief")
time.sleep(5)
i=0
count2=0
for i in range(0,len(clnt_ips)):
if clnt_ips[i] in op_ssx_sa:
count2=count2+1
self.myLog.output("\n\n************* the no. of ike sessions:%d\n\n"%count2)
self.failUnless(count1== count2 ,"Mismatch with the no.of sessions before and deleting radius interface")
#### Start Ethereal capture the Radius
#self.myLog.output(" Step 1 - removing the file rad_neg_003.pcap")
#self.ether_radius1.cmd("sudo rm rad_neg_003.pcap -f")
#.........这里部分代码省略.........
示例4: test_RADIUS_FUN_033
# 需要导入模块: from Linux import Linux [as 别名]
# 或者: from Linux.Linux import write_to_file [as 别名]
class test_RADIUS_FUN_033(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 SSX configuration
self.ssx.clear_config()
# wait for card to come up
self.ssx.wait4cards()
self.ssx.clear_health_stats()
#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 Netscreen."""
self.ns5gt = NS(ns['ip_addr'])
self.ns5gt.telnet()
self.ns5gt.clear_config()
def tearDown(self):
"""Clear the config and Close down the telnet session."""
self.ssx.close()
self.ns5gt.close()
self.xpress_vpn.close()
def test_RADIUS_FUN_033(self):
"""
Test case Id: - RADIUS-FUN-033
"""
#On SSX configure an AAA profile with the session authentication set to Radius
self.ssx.config_from_string(script_var['common_ssx1'])
self.ssx.config_from_string(script_var['rad_fun_033_ssx'])
#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['rad_fun_033_ns5gt'])
# Push xpress vpn config
self.xpress_vpn.write_to_file(script_var['fun_007_xpressvpn'],"autoexec.cfg","/xpm/")
# Enable debug logs for aaad
self.ssx.cmd("context %s" % script_var['context'])
self.ssx.cmd("debug module aaad all")
self.ssx.cmd("debug module iked all")
# Flush the debug logs in SSX, if any
self.ssx.cmd("clear log debug")
# Initiate IKEv1 session from a Netscreen to the SSX
# ping ikev1 clent from ssx
self.ssx.ping('%s'% script_var['ns_phy_ip'])
time.sleep(5)
self.ns5gt.ping(script_var['ssx_ses_ip'],source="untrust")
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, "session authentication with Radius is not\
successed even with valid session credentials")
#Verify IKEv1 session authentication
#op_debug = aaa_verify_authentication(self.ssx,"[email protected]%s" %script_var['context'],"local")
#self.failUnless(op_debug, "phase-1 session authentication and establishment is not successful")
#op_debug = aaa_verify_authentication(self.ssx,"[email protected]%s" %script_var['context'],"radius")
#self.failUnless(op_debug, "Verifying in debug:X-auth not successful")
#Check out the SA status in SSX.
self.ssx.cmd("context %s" %script_var['context'])
#sa_output= sa_check(self.ssx,script_var['ns_phy_ip'])
#self.failUnless(sa_output,"SA not loaded")
# 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("cd /xpm/")
op_client_cmd = self.xpress_vpn.cmd("sudo ./start_ike")
time.sleep(5)
#Consider 9 client
op_ssx_sa = self.ssx.cmd("show session detail")
i=0
count=0
ssx_max_ses=2
for i in range(0,len(clnt_ips)):
if clnt_ips2[i] in op_ssx_sa:
count=count+1
self.myLog.output("\n\n************* the no. of ikev2 sessions:%d\n\n"%count)
self.failUnless(count==ssx_max_ses,"IKEv2 multiclient SA Formation Failed")
op_debug = aaa_verify_authentication(self.ssx,"[email protected]%s" %script_var['context'],"radius")
self.failUnless(op_debug, "Verifying in debug:X-auth not successful")
# Checking SSX Health
hs = self.ssx.get_health_stats()
self.failUnless(is_healthy(hs), "Platform is not healthy")
示例5: test_RADIUS_FUN_016_1
# 需要导入模块: from Linux import Linux [as 别名]
# 或者: from Linux.Linux import write_to_file [as 别名]
class test_RADIUS_FUN_016_1(test_case):
myLog = getLogger()
def setUp(self):
"""Establish a telnet session to the SSX box."""
self.ssx = SSX(topo.ssx1['ip_addr'])
self.ssx.telnet()
self.ssx.clear_health_stats()
# CLear SSX configuration
self.ssx.clear_config()
# wait for card to come up
self.ssx.wait4cards()
#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.ether_radius1 = Linux(radius1['ip_addr'],radius1['user_name'],radius1['password'])
self.ether_radius1.telnet()
def tearDown(self):
# Start The (stopped) radius process
self.ether_radius1.cmd("sudo /etc/init.d/radiusd start")
self.ether_radius1.cmd("sudo pkill tethereal")
# close the telnet session of the radius server
self.ether_radius1.telnet()
# Close the telnet session of SSX
self.ssx.close()
# Close the telnet session of Xpress VPN Client
self.xpress_vpn.close()
def test_RADIUS_FUN_016_1(self):
"""
Test case Id: - RADIUS_FUN_016_1
"""
self.myLog.output("\n**********start the test**************\n")
#### Start Ethereal capture on both the Radius servers
self.myLog.output(" Step 1 - removing the file rad_fun_016_1.pcap")
self.ether_radius1.cmd("sudo rm rad_fun_016_1.pcap -f")
self.myLog.output("Step 2 -Start tethereal to capture the packets and store the result in a pcap file")
self.ether_radius1.cmd('sudo /usr/sbin/tethereal -i %s -q -w rad_fun_016_1.pcap -R "radius" & '% topo.port_ssx_radius1[1])
# Push SSX config
self.ssx.config_from_string(script_var['common_ssx1'])
self.ssx.config_from_string(script_var['rad_fun_016_1_ssx'])
# Push xpress vpn config
self.xpress_vpn.write_to_file(script_var['rad_fun_016_1_xpressvpn'],"autoexec.cfg","/xpm/")
# Enable debug logs for iked
self.ssx.cmd("context %s" % script_var['context'])
self.ssx.cmd("debug module iked all")
# Flush the debug logs in SSX, if any
self.ssx.cmd("clear log debug")
# Stop the radius process
self.ether_radius1.cmd("sudo /etc/init.d/radiusd stop")
# Initiate IKE Session from Xpress VPN Client (takama)
self.xpress_vpn.cmd("cd /xpm/")
op_client_cmd = self.xpress_vpn.cmd("sudo ./start_ike")
#### terminate tethereal & read the pcap file contents
self.myLog.output (" Step 3 - stop tethereal by killing the tethereal application.")
time.sleep(15)
self.ether_radius1.cmd("sudo pkill tethereal")
# Check whether the pcap file is created
ll_output = self.ether_radius1.cmd("ls -lrt *.pcap")
self.failUnless( "rad_fun_016_1.pcap" in ll_output,"Testcase FAILED because pcap file has not created ")
self.myLog.output (" Step 4 - read the content of the file rad_fun_016_1.pcap ")
ether_op = self.ether_radius1.cmd('sudo /usr/sbin/tethereal -r rad_fun_016_1.pcap -R "radius.code == 4 && ! icmp"',timeout = 30)
self.failUnless("RADIUS" in ether_op, 'Expected - radius_accout_request for 2 sessions,but not recived')
# Checking SSX Health
hs = self.ssx.get_health_stats()
self.failUnless(is_healthy(hs), "Platform is not healthy")
示例6: test_RADIUS_FUN_034
# 需要导入模块: from Linux import Linux [as 别名]
# 或者: from Linux.Linux import write_to_file [as 别名]
class test_RADIUS_FUN_034(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 SSX configuration
self.ssx.clear_config()
# wait for card to come up
self.ssx.wait4cards()
self.ssx.clear_health_stats()
#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()
def tearDown(self):
"""Clear the config and Close down the telnet session."""
self.ssx.close()
self.xpress_vpn.close()
def test_RADIUS_FUN_034(self):
"""
Test case Id: - RADIUS-FUN-034
"""
#On SSX configure an AAA profile with the session authentication set to Radius
self.ssx.config_from_string(script_var['common_ssx1'])
self.ssx.config_from_string(script_var['rad_fun_034_ssx'])
# Push xpress vpn config
self.xpress_vpn.write_to_file(script_var['rad_fun_034_xpressvpn'],"autoexec.cfg","/xpm/")
# Enable debug logs for aaad
self.ssx.cmd("context %s" % script_var['context'])
self.ssx.cmd("debug module aaad all")
self.ssx.cmd("debug module iked 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("cd /xpm/")
op_client_cmd = self.xpress_vpn.cmd("sudo ./start_ike")
#Consider 9 client
op_ssx_sa = self.ssx.configcmd("show ike-session brief")
i=0
count=0
ssx_max_ses=1
#for i in range(0,len(clnt_ips)):
for i in range(0,1):
if clnt_ips[i] in op_ssx_sa:
count=count+1
self.myLog.output("\n\n************* the no. of ike sessions:%d\n\n"%count)
self.failUnless(count==ssx_max_ses,"IKEv2 multiclient SA Formation Failed")
op_debug = aaa_verify_authentication(self.ssx,"[email protected]%s" %script_var['context'],"radius")
self.failUnless(op_debug, "Verifying in debug:X-auth not successful")
# Change the RADIUS key under session authentication profile
self.ssx.configcmd("context %s" %script_var['context'])
self.ssx.configcmd("radius session authentication profile")
self.ssx.configcmd("server %s port 1812 key xyz" %script_var['radius1_ip'])
# Clear the sessions and re-initiate new sessions
self.ssx.cmd("context %s" %script_var['context'])
self.ssx.cmd("clear session all")
self.ssx.cmd("clear session all")
self.xpress_vpn.cmd("exit")
self.xpress_vpn.cmd("cd /xpm/")
op_client_cmd = self.xpress_vpn.cmd("sudo ./start_ike")
time.sleep(10)
self.xpress_vpn.cmd("exit")
#Consider 9 client
op_ssx_sa = self.ssx.configcmd("show ike-session brief")
i=0
count=0
ssx_max_ses=1
#for i in range(0,len(clnt_ips)):
for i in range(0,1):
if clnt_ips[i] in op_ssx_sa:
count=count+1
self.myLog.output("\n\n************* the no. of ike sessions:%d\n\n"%count)
self.failUnless(not count,"Sessions established even after changing the RADIUS key")
#time.sleep(5)
#op_debug = verify_in_debug(self.ssx,"XAUTH","fail")
#self.failUnless(op_debug,"In debug logs: No X-Auth Fail messgae ")
# Checking SSX Health
hs = self.ssx.get_health_stats()
self.failUnless(is_healthy(hs), "Platform is not healthy")
示例7: test_CDR_MISC_001
# 需要导入模块: from Linux import Linux [as 别名]
# 或者: from Linux.Linux import write_to_file [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
#.........这里部分代码省略.........
示例8: test_RADIUS_NEG_005
# 需要导入模块: from Linux import Linux [as 别名]
# 或者: from Linux.Linux import write_to_file [as 别名]
class test_RADIUS_NEG_005(test_case):
myLog = getLogger()
def setUp(self):
"""Establish a telnet session to the SSX box."""
self.ssx = SSX(topo.ssx1['ip_addr'])
self.ssx.telnet()
# CLear SSX configuration
self.ssx.clear_config()
# wait for card to come up
self.ssx.wait4cards()
self.ssx.clear_health_stats()
#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.ether_radius1 = Linux(radius1['ip_addr'],radius1['user_name'],radius1['password'])
self.ether_radius1.telnet()
def tearDown(self):
# Close the telnet session of SSX
self.ssx.close()
# Close the telnet session of Xpress VPN Client
self.xpress_vpn.close()
# Close the telnet session of Radius (tethereal capture machine)
self.ether_radius1.close()
def test_RADIUS_NEG_005(self):
"""
Test case Id: - RADIUS_NEG_005
Description: - With continuous session requests in the background,
Reload the Device.
"""
self.myLog.output("\n**********start the test**************\n")
# Push SSX config
self.ssx.config_from_string(script_var['common_ssx'])
self.ssx.config_from_string(script_var['rad_neg_005_ssx'])
# Push xpress vpn config
self.xpress_vpn.write_to_file(script_var['rad_neg_005_xpressvpn'],"autoexec.cfg","/xpm/")
self.xpress_vpn.write_to_file(script_var['add_ip_takama'],"add_ip_takama","/xpm/")
# Enable debug logs for iked
self.ssx.cmd("context %s" % script_var['context'])
self.ssx.cmd("debug module iked all")
# Flush the debug logs in SSX, if any
self.ssx.cmd("clear log debug")
#### Start Ethereal capture the Radius-1
self.myLog.output(" Step 1 - removing the file rad_neg_005.pcap")
self.ether_radius1.cmd("sudo rm rad_neg_005.pcap -f")
self.myLog.output("Step 2 -Start tethereal to capture the packets and store the result in a pcap file")
#self.ether_radius1.cmd('sudo /usr/sbin/tethereal -h')
self.ether_radius1.cmd('sudo /usr/sbin/tethereal -i %s -q -w rad_neg_005.pcap -R "radius" & '% topo.port_ssx_radius1[1])
# 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")
time.sleep(3)
op_client_cmd = self.xpress_vpn.cmd("sudo ./start_ike")
time.sleep(15)
op1 = self.ssx.configcmd("show session")
self.ssx.configcmd("exit")
self.failUnless("IPSEC" in op1,"Failed because there is no session of IPSEC")
self.xpress_vpn.cmd("quit")
#Saving the cofiguration
self.ssx.save_config(location='/cfint/stoke.cfg')
self.ssx.boot_config("/cfint/stoke.cfg")
# Reload the SSX
self.ssx.reload_device(timeout=500)
#### terminate tethereal & read the pcap file contents
self.myLog.output (" Step 3 - stop tethereal by killing the tethereal application.")
self.myLog.output (" \nGoing to sleep for 150sec ,to cath session requests sent by SSX to RASIUS server\n")
time.sleep(15)
self.ether_radius1.cmd("sudo pkill tethereal")
# Check whether the pcap file is created
ll_output = self.ether_radius1.cmd("ls -lrt *.pcap")
self.failUnless( "rad_neg_005.pcap" in ll_output,"Testcase FAILED because pcap file has not created ")
self.myLog.output (" Step 4 - read the content of the file rad_neg_005.pcap ")
output = self.ether_radius1.cmd('sudo /usr/sbin/tethereal -r rad_neg_005.pcap -R "radius.code == 2" ',timeout = 30)
#self.failUnless("RADIUS" in output, " Expected - packet with radius.code == 2 ")
#Consider 9 client
op_ssx_sa = self.ssx.configcmd("show ike-session brief")
'''
i=0
#.........这里部分代码省略.........
示例9: test_CDR_HA_FUN_002
# 需要导入模块: from Linux import Linux [as 别名]
# 或者: from Linux.Linux import write_to_file [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")
#.........这里部分代码省略.........
示例10: test_DoCoMo_6_1_2
# 需要导入模块: from Linux import Linux [as 别名]
# 或者: from Linux.Linux import write_to_file [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)
#.........这里部分代码省略.........
示例11: test_RADIUS_FUN_016
# 需要导入模块: from Linux import Linux [as 别名]
# 或者: from Linux.Linux import write_to_file [as 别名]
class test_RADIUS_FUN_016(test_case):
myLog = getLogger()
def setUp(self):
"""Establish a telnet session to the SSX box."""
self.ssx = SSX(topo.ssx1['ip_addr'])
self.ssx.telnet()
# CLear SSX configuration
self.ssx.clear_config()
# wait for card to come up
self.ssx.wait4cards()
self.ssx.clear_health_stats()
#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.ether_radius1 = Linux(radius1['ip_addr'],radius1['user_name'],radius1['password'])
self.ether_radius1.telnet()
def tearDown(self):
# Start The (stopped) radius process
self.ether_radius1.cmd("sudo /etc/init.d/radiusd start")
self.ether_radius1.cmd("sudo pkill tethereal")
# close the telnet session of the radius server
self.ether_radius1.telnet()
# Close the telnet session of SSX
self.ssx.close()
# Close the telnet session of Xpress VPN Client
self.xpress_vpn.close()
def test_RADIUS_FUN_016(self):
"""
Test case Id: - RADIUS_FUN_016
"""
self.myLog.output("\n**********start the test**************\n")
# Push SSX config
self.ssx.config_from_string(script_var['common_ssx1'])
self.ssx.config_from_string(script_var['rad_fun_016_ssx'])
# Push xpress vpn config
self.xpress_vpn.write_to_file(script_var['rad_fun_016_xpressvpn'],"autoexec.cfg","/xpm/")
# Enable debug logs for iked
self.ssx.cmd("context %s" % script_var['context'])
self.ssx.cmd("debug module iked all")
# Flush the debug logs in SSX, if any
self.ssx.cmd("clear log debug")
# Stop the radius process
self.ether_radius1.cmd("sudo /etc/init.d/radiusd stop")
#### Start Ethereal capture on both the Radius servers
self.myLog.output(" Step 1 - removing the file rad_fun_016.pcap")
self.ether_radius1.cmd("sudo rm rad_fun_016.pcap -f")
self.myLog.output("Step 2 -Start tethereal to capture the packets and store the result in a pcap file")
# self.ether_radius1.cmd('sudo /usr/sbin/tethereal -h')
self.ether_radius1.cmd('sudo /usr/sbin/tethereal -i %s -q -w rad_fun_016.pcap -R "radius" & '% topo.port_ssx_radius1[1])
# Initiate IKE Session from Xpress VPN Client (takama)
self.xpress_vpn.cmd("cd /xpm/")
op_client_cmd = self.xpress_vpn.cmd("sudo ./start_ike")
#Consider 9 client
op_ssx_sa = self.ssx.configcmd("show ike-session brief")
i=0
count=0
ssx_max_ses=5
for i in range(0,len(clnt_ips)):
if clnt_ips[i] in op_ssx_sa:
count=count+1
self.myLog.output("\n\n************* the no. of ike sessions:%d\n\n"%count)
#self.failUnless(count == 2,"Expected 'ike-sessions = 2',Actual is ike-sessions = %d "%count)
#### terminate tethereal & read the pcap file contents
self.myLog.output (" Step 3 - stop tethereal by killing the tethereal application.")
time.sleep(5)
self.ether_radius1.cmd("sudo pkill tethereal")
# Check whether the pcap file is created
ll_output = self.ether_radius1.cmd("ls")
self.failUnless( "rad_fun_016.pcap" in ll_output,"Testcase FAILED because pcap file has not created ")
self.myLog.output (" Step 4 - read the content of the file rad_fun_016.pcap ")
output=self.ether_radius1.cmd('sudo /usr/sbin/tethereal -r rad_fun_016.pcap -R "radius.code == 1" ',timeout = 30)
self.failUnless("RADIUS" in output, """ Expected - packet with radius.code == 2, Actual = %s"""% output)
# Checking SSX Health
hs = self.ssx.get_health_stats()
#.........这里部分代码省略.........
示例12: test_ip_atk_076
# 需要导入模块: from Linux import Linux [as 别名]
# 或者: from Linux.Linux import write_to_file [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)
#.........这里部分代码省略.........
示例13: test_RADIUS_NEG_002
# 需要导入模块: from Linux import Linux [as 别名]
# 或者: from Linux.Linux import write_to_file [as 别名]
class test_RADIUS_NEG_002(test_case):
myLog = getLogger()
def setUp(self):
"""Establish a telnet session to the SSX box."""
self.ssx = SSX(topo.ssx1['ip_addr'])
self.ssx.telnet()
# CLear SSX configuration
self.ssx.clear_config()
# wait for card to come up
self.ssx.wait4cards()
self.ssx.clear_health_stats()
#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.ether_radius1 = Linux(radius1['ip_addr'],radius1['user_name'],radius1['password'])
self.ether_radius1.telnet()
def tearDown(self):
# Close the telnet session of SSX
self.ssx.close()
# Close the telnet session of Xpress VPN Client
self.xpress_vpn.close()
self.ether_radius1.close()
def test_RADIUS_NEG_002(self):
"""
Test case Id: - RADIUS_NEG_002
Description: - With continuous session requests in the background,
delete the existing Radius session authentication profile.
"""
self.myLog.output("\n**********start the test**************\n")
# Push SSX config
self.ssx.config_from_string(script_var['common_ssx'])
self.ssx.config_from_string(script_var['rad_neg_002_ssx'])
# Push xpress vpn config
self.xpress_vpn.write_to_file(script_var['rad_neg_002_xpressvpn'],"autoexec.cfg","/xpm/")
# Enable debug logs for iked
self.ssx.cmd("context %s" % script_var['context'])
self.ssx.cmd("debug module iked 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("cd /xpm/")
self.xpress_vpn.cmd("sudo cat /etc/sudoers")
op_client_cmd = self.xpress_vpn.cmd("sudo ./start_ike &")
time.sleep(9)
self.myLog.output("List of sessions eastablished before deleting the session authentication profile")
#Consider 9 client
op_ssx_sa = self.ssx.configcmd("show ike-session brief")
i=0
count1 =0
for i in range(0,len(clnt_ips)):
if clnt_ips[i] in op_ssx_sa:
count1 = count1+1
self.myLog.output("\n\n************* the no. of ike sessions:%d\n\n"%count1)
#Delete the session authentication profile
self.ssx.configcmd("context %s" % script_var['context'])
self.ssx.configcmd("no radius session authentication profile")
time.sleep(2)
self.myLog.output("List of sessions eastablished after deleting the session authentication profile")
#Checking wheather sessions are establishing even after deleting the profile
op_ssx_sa = self.ssx.configcmd("show ike-session brief")
i=0
count1 =0
for i in range(0,len(clnt_ips)):
if clnt_ips[i] in op_ssx_sa:
count1 = count1+1
self.myLog.output("\n\n************* the no. of ike sessions:%d\n\n"%count1)
self.myLog.output("\nGoing to sleep for 20sec after deleting the session auth profile\n")
time.sleep(20)
op_ssx_sa = self.ssx.configcmd("show ike-session brief")
i=0
count2 =0
for i in range(0,len(clnt_ips)):
if clnt_ips[i] in op_ssx_sa:
count2 = count2+1
self.myLog.output("\n\n************* the no. of ike sessions:%d\n\n"%count2)
self.failUnless(count1 == count2,"Sessions established even afterdeleting the session")
# Checking SSX Health
hs = self.ssx.get_health_stats()
self.failUnless(is_healthy(hs), "Platform is not healthy")
示例14: test_RADIUS_FUN_015_1
# 需要导入模块: from Linux import Linux [as 别名]
# 或者: from Linux.Linux import write_to_file [as 别名]
class test_RADIUS_FUN_015_1(test_case):
myLog = getLogger()
def setUp(self):
"""Establish a telnet session to the SSX box."""
self.ssx = SSX(topo.ssx1['ip_addr'])
self.ssx.telnet()
self.ssx.clear_health_stats()
# CLear SSX configuration
self.ssx.clear_config()
# wait for card to come up
self.ssx.wait4cards()
#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.ether_radius1 = Linux(radius1['ip_addr'],radius1['user_name'],radius1['password'])
self.ether_radius1.telnet()
def tearDown(self):
# Close the telnet session of SSX
self.ssx.close()
# Close the telnet session of Xpress VPN Client
self.xpress_vpn.close()
# Start the radius process
self.ether_radius1.cmd("sudo /etc/init.d/radiusd start")
self.ether_radius1.close()
def test_RADIUS_FUN_015_1(self):
"""
Test case Id: - RADIUS_FUN_015_1
"""
self.myLog.output("\n**********start the test**************\n")
# Push SSX config
self.ssx.config_from_string(script_var['common_ssx1'])
self.ssx.config_from_string(script_var['rad_fun_015_1_ssx'])
# Push xpress vpn config
self.xpress_vpn.write_to_file(script_var['rad_fun_015_1_xpressvpn'],"autoexec.cfg","/xpm/")
# Enable debug logs for iked
self.ssx.cmd("context %s" % script_var['context'])
self.ssx.cmd("debug module iked all")
# Flush the debug logs in SSX, if any
self.ssx.cmd("clear log debug")
# Stop the radius process
self.ether_radius1.cmd("sudo /etc/init.d/radiusd stop")
# Initiate IKE Session from Xpress VPN Client (takama)
self.xpress_vpn.cmd("cd /xpm/")
op_client_cmd = self.xpress_vpn.cmd("sudo ./start_ike")
#Consider 9 client
op_ssx_sa = self.ssx.configcmd("show ike-session brief")
i=0
count=0
ssx_max_ses=5
for i in range(0,len(clnt_ips)):
if clnt_ips[i] in op_ssx_sa:
count=count+1
self.myLog.output("\n\n************* the no. of ike sessions:%d\n\n"%count)
self.failUnless(count == 0,"ike-session eastablish even radius server is unreachable")
# Checking SSX Health
hs = self.ssx.get_health_stats()
self.failUnless(is_healthy(hs), "Platform is not healthy")
示例15: test_ip_atk_080
# 需要导入模块: from Linux import Linux [as 别名]
# 或者: from Linux.Linux import write_to_file [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")