summaryrefslogtreecommitdiff
path: root/kpov_judge/tasks/nat_vlc
diff options
context:
space:
mode:
Diffstat (limited to 'kpov_judge/tasks/nat_vlc')
-rw-r--r--kpov_judge/tasks/nat_vlc/task.py40
1 files changed, 12 insertions, 28 deletions
diff --git a/kpov_judge/tasks/nat_vlc/task.py b/kpov_judge/tasks/nat_vlc/task.py
index 89d0f13..ed24b95 100644
--- a/kpov_judge/tasks/nat_vlc/task.py
+++ b/kpov_judge/tasks/nat_vlc/task.py
@@ -20,7 +20,7 @@ ustvarite še uporabnika {IP_NAT_user}.
Poskrbi, da bo SimpleArbiter prek DHCP dobil naslov {IP_simple}.
Poskrbi, da bo NATServer deloval kot prehod za SimpleArbiter in izvajal NAT.
""",
- 'en':"""
+ 'en':"""
Set up two virtual machines - SimpleArbiter (using the disc simpleArbiter) and
NATServer. NATServer should have two network adapters. Connect the first
adapter to SimpleArbiter and the second adapter to the Internet. Configure the
@@ -38,12 +38,7 @@ computers = {
'NATServer': {
'disks': [
{ 'name': 'student-NATServer',
- # attempt automount
},
- #{ 'name': 'CDROM',
- # 'options': {'readonly': True},
- # 'parts': [{'dev': 'b1', 'path': '/cdrom'}],
- #},
],
'network_interfaces': [{'network': 'net1'}, {'network': 'test-net'}],
'flavor': 'm1.tiny',
@@ -53,17 +48,11 @@ computers = {
'disks': [
{ 'name': 'simpleArbiter',
},
- #{ 'name': 'CDROM',
- # 'options':{'readonly': True},
- # 'parts': [],# no parts, no mounting.
- #}
],
'network_interfaces': [{'network': 'net1'}],
'flavor': 'm1.tiny',
'config_drive': False
-
},
-
}
networks = { 'net1': {'public': False}, 'test-net': {'public': True} }
@@ -77,24 +66,19 @@ params_meta = {
}
def task(IP_simple, IP_NAT, IP_NAT_user, IP_NAT_passwd):
- from pexpect import pxssh
import pexpect
- results = dict()
- # Connect to NAT
- povezava = pxssh.pxssh()
- povezava.login(IP_NAT,IP_NAT_user,IP_NAT_passwd)
+
+ results = kpov_util.ssh_test(IP_NAT, IP_NAT_user, IP_NAT_passwd, (
+ ('IP_NAT_ip_forward', 'cat /proc/sys/net/ipv4/ip_forward'),
+ ))
+
# Check if If IP_simple is connected to NAT
- results['IP_simple_ping_to_NAT'] = pexpect.run('ping -c 5 {}'.format(IP_NAT))
+ results['IP_simple_ping_to_NAT'] = pexpect.run('ping -c 5 {}'.format(IP_NAT), encoding='utf-8')
# Check routing table on IP_simple
- results['IP_simple_routing_table'] = pexpect.run('/sbin/route -n')
+ results['IP_simple_routing_table'] = pexpect.run('route -n', encoding='utf-8', env={'PATH': '/bin:/sbin'})
# Tracert Check if IP_simple is connected to internet
- povezava.prompt()
- results['IP_simple_to_internet'] = pexpect.run('/usr/sbin/traceroute 8.8.8.8')
- povezava.prompt()
- povezava.sendline('cat /proc/sys/net/ipv4/ip_forward')
- povezava.prompt()
- results['IP_NAT_ip_forward'] = povezava.before
- povezava.logout()
+ results['IP_simple_to_internet'] = pexpect.run('traceroute 8.8.8.8', encoding='utf-8')
+
return results
def gen_params(user_id, params_meta):
@@ -121,8 +105,8 @@ def task_check(results, params):
score += 3
else:
hints.append("Ping to NAT incorrect")
- if results['IP_NAT_ip_forward']=="cat /proc/sys/net/ipv4/ip_forward\r\n1\r\n":
- score += 2
+ if results['IP_NAT_ip_forward'].strip() == "1":
+ score += 2
else:
hints.append("ip_forward not set on NAT?")
rs = r"1 +{0} +\({0}\)".format(params['IP_NAT'])