summaryrefslogtreecommitdiff
path: root/kpov_judge/tasks
diff options
context:
space:
mode:
authormp7462@student.uni-lj.si <mp7462@student.uni-lj.si@5cf9fbd1-b2bc-434c-b4b7-e852f4f63414>2014-12-15 19:41:31 +0000
committermp7462@student.uni-lj.si <mp7462@student.uni-lj.si@5cf9fbd1-b2bc-434c-b4b7-e852f4f63414>2014-12-15 19:41:31 +0000
commit5de1272b40fb095b42a6d3e48d5cd8e726c2b290 (patch)
treea40ad42b92e579682399ca6a5729382413743e60 /kpov_judge/tasks
parent8e197f0a07e743f7f9163f64fa03056efc81b797 (diff)
Added to task(), simplified VPN checks on server
git-svn-id: https://svn.lusy.fri.uni-lj.si/kpov-public-svn/kpov-public@80 5cf9fbd1-b2bc-434c-b4b7-e852f4f63414
Diffstat (limited to 'kpov_judge/tasks')
-rw-r--r--kpov_judge/tasks/openvpn_simple_smb/task.py110
1 files changed, 81 insertions, 29 deletions
diff --git a/kpov_judge/tasks/openvpn_simple_smb/task.py b/kpov_judge/tasks/openvpn_simple_smb/task.py
index 59a73fe..4ac5f76 100644
--- a/kpov_judge/tasks/openvpn_simple_smb/task.py
+++ b/kpov_judge/tasks/openvpn_simple_smb/task.py
@@ -143,10 +143,10 @@ params_meta = {
}
-def task(IP_NM, DNS_NM, IP_static, DNS_static):
+def task(IP_SimpleArbiterVPN, DNS_SimpleArbiterVPN, IP_VPNClient1, DNS_VPNClient1, IP_VPNClient2, DNS_VPNClient2):
import pxssh # Used to set up an SSH connection to a remote machine
- import pexpect # Allows the script to spawn a child application and control it as if a human were typing commands
+ #import pexpect # Allows the script to spawn a child application and control it as if a human were typing commands
# the necessary things we need to check if the task was performed correctly
@@ -156,62 +156,114 @@ def task(IP_NM, DNS_NM, IP_static, DNS_static):
peer_user = 'student'
peer_passwd = 'vaje'
+ ###
# Sets up the SSH connections to the machines
+ ###
+ # SimpleArbiter
sA = pxssh.pxssh()
- sB = pxssh.pxssh()
+ # VPNClient1
+ sC1 = pxssh.pxssh()
+ # VPNClient2
+ sC2 = pxssh.pxssh()
# Logs in to the machines with the default login params
- sA.login(IP_NM, peer_user, peer_passwd)
- sB.login(IP_static, peer_user, peer_passwd)
+ sA.login(
+ IP_SimpleArbiterVPN,
+ peer_user,
+ peer_passwd
+ )
+ sC1.login(
+ IP_VPNClient1,
+ peer_user,
+ peer_passwd
+ )
+ sC2.login(
+ IP_VPNClient2,
+ peer_user,
+ peer_passwd
+ )
+
######
# sA
######
- # TODO what is this exactly?
# Make sure NM is not handling eth0
- results['NM_nmcli'] = sA.run('nmcli d')
+ results['SimpleArbiter_nmcli'] = sA.run('nmcli d')
+
+ # Get the IP of the network as per a DNS server (used to check if all computers are on the same network)
+ results['SimpleArbiter_nslookup'] = sA.run('nslookup www.arnes.si')
+
+ # Check if the VPN is set up
+ # Returns 1 if ok, else 0
+ sA.sendline('ls /sys/class/net/ | grep "tap0"')
+ sA.prompt()
+ output = sA.before
+ output.split('\n')[1]
+ results['SimpleArbiter_is_VPN_set_up'] = output
+
+ # Check if the VPN server is running
+ # Returns 1 if ok, else 0
+ sA.sendline('ls /sys/class/net | grep "tun0"')
+ sA.prompt()
+ output = sA.before
+ output.split('\n')[1]
+ results['SimpleArbiter_is_VPN_running'] = output
- # Get the IP of the network as per a DNS server
- results['NM_nslookup'] = sA.run('nslookup www.arnes.si')
+ # Pings each of the clients
+ # 10.8.0.6 and 10.8.0.10 are the first two default addresses distributed by OpenVPN
+ # Will output everything ping outputs (set to ping 3 times)
+ sA.sendLine('ping -c 3 10.8.0.6')
+ sA.prompt()
+ output = sA.before
+ results['SimpleArbiter_ping_C1'] = output
+ sA.sendLine('ping -c 3 10.8.0.10')
+ sA.prompt()
+ output = sA.before
+ results['SimpleArbiter_ping_C2'] = output
+ # TODO
+ # Check if both clients are connected to the correct VPN
+ # (check if first 24 bits of IP addr are the same as the server's)
+ #sB.sendline('sudo apt-get install nmap --assume-yes')
+ #sB.sendline('sudo nmap -sP 10.8.0.0/24')
######
- # sB
+ # sC1
######
- # check whether NM is handling eth0
- results['static_nmcli'] = sB.run('nmcli d')
+ results['VPNClient1_nmcli'] = sC1.run('nmcli d')
- # Get the IP of the network as per a DNS server
- results['static_nslookup'] = sB.run('nslookup www.arnes.si')
+ results['VPNClient1_nslookup'] = sC1.run('nslookup www.arnes.si')
- # Check if the tap exists
- # Must return a non-empty string
- results['is_tap_exists'] = sA.run('ls /sys/class/net | grep "tap0"');
- # Check if the VPN server is running
- # Must return a non-empty string
- results['is_VPN_running'] = sA.run('ls /sys/class/net | grep "tun0"');
+ # Ping the VPN server
+ sC1.sendLine( 'ping -c 3 {0}'.format( DNS_SimpleArbiterVPN ) )
+ sC1.prompt()
+ output = sC1.before
+ results['VPNClient1_ping_VPN_server'] = output
- # TODO
- # Check if both clients are connected
- #sB.run('sudo apt-get install nmap --assume-yes')
- #sB.run('sudo nmap -sP 10.8.0.0/24')
- # TODO
- # Check if both clients are connected to the correct VPN (check if first 24 bits of IP addr are the same as the server's)
+ ######
+ # sC2
+ ######
+ results['VPNClient2_nmcli'] = sC2.run('nmcli d')
- # Pings each of the clients
- # 10.8.0.6 and 10.8.0.10 are the first two default addresses distributed by OpenVPN
+ results['VPNClient2_nslookup'] = sC2.run('nslookup www.arnes.si')
+ # Ping the VPN server
+ sC2.sendLine( 'ping -c 3 {0}'.format( DNS_SimpleArbiterVPN ) )
+ sC2.prompt()
+ output = sC2.before
+ results['VPNClient2_ping_VPN_server'] = output
sA.logout()
- sB.logout()
+ sC1.logout()
+ sC2.logout()
return results