summaryrefslogtreecommitdiff
path: root/kpov_judge
diff options
context:
space:
mode:
authorsr5154@student.uni-lj.si <sr5154@student.uni-lj.si@5cf9fbd1-b2bc-434c-b4b7-e852f4f63414>2017-06-19 10:44:30 +0000
committersr5154@student.uni-lj.si <sr5154@student.uni-lj.si@5cf9fbd1-b2bc-434c-b4b7-e852f4f63414>2017-06-19 10:44:30 +0000
commit1a38dfcd64eb8c07d4b0baa024268b50e64a144c (patch)
treecc51c850f9521fc7f17d586b26ff1892be8629f2 /kpov_judge
parent1e62d7ad2da10196b52a6b703659501ff1b1d5bb (diff)
dhcp_dns_predefined_ip preverja dhcp
git-svn-id: https://svn.lusy.fri.uni-lj.si/kpov-public-svn/kpov-public@417 5cf9fbd1-b2bc-434c-b4b7-e852f4f63414
Diffstat (limited to 'kpov_judge')
-rw-r--r--kpov_judge/tasks/dhcp_dns_predefined_ip/task.py54
1 files changed, 38 insertions, 16 deletions
diff --git a/kpov_judge/tasks/dhcp_dns_predefined_ip/task.py b/kpov_judge/tasks/dhcp_dns_predefined_ip/task.py
index 5c215fd..01a9941 100644
--- a/kpov_judge/tasks/dhcp_dns_predefined_ip/task.py
+++ b/kpov_judge/tasks/dhcp_dns_predefined_ip/task.py
@@ -5,8 +5,10 @@
instructions = {
'si':u"""
-Ustvari tri navidezne računalnike. Za enega (SimpleArbiter) uporabi sliko diska simpleArbiterGW. Na drugega (DHCP_server) postavi strežnika
-DHCP in DNS. Poskrbi, da bo preostali računalnik (DHCP_client) dobil naslov {Client_IP}.
+Ustvari tri navidezne računalnike. Za enega (SimpleArbiter) uporabi sliko diska simpleArbiterGW.
+Na drugega (DHCP_server) postavi strežnika DHCP in DNS. Za gateway uporabi IP naslov simple arbiterja.
+Poskrbi, da bo preostali računalnik (DHCP_client) dobil naslov {Client_IP}.
+
Poskrbi, da bo DNS strežnik za domeno test.net vrnil naslov {HOSTNAME_X_IP}.
DHCP_server naj za DNS strežnik uporabi {DNS_NM}.
DHCP_client naj za DNS strežnik uporabi {DNS_static}.
@@ -66,10 +68,10 @@ params_meta = {
'IP_static': {'descriptions': {'si': 'Naslov maliBrezNetworkManager'}, 'w': False, 'public': True, 'type': 'IP', 'generated': True},
'DNS_static': {'descriptions': {'si': 'DNS za maliBrezNetworkManager'}, 'w': False, 'public': True, 'type': 'IP', 'generated': True},
'HOSTNAME_X_IP': {'descriptions': {'si': 'Naslov HOSTNAME_X'}, 'w': False, 'public':True, 'type': 'IP', 'generated': True},
- 'Client_IP': {'descriptions': {'si': 'Naslov za DHCP_Client'}, 'w': False, 'public':True, 'type': 'IP', 'generated': True},
+ 'Client_IP': {'descriptions': {'si': 'Naslov za DHCP_Client'}, 'w': False, 'public':True, 'type': 'IP', 'generated': True},
}
-def task(IP_NM, DNS_NM, IP_static, DNS_static, HOSTNAME_X_IP, Client_IP):
+def task(IP_NM, DNS_NM, IP_static, DNS_static, HOSTNAME_X_IP, Client_IP, MAC_BOOT):
from pexpect import pxssh
import pexpect
results = dict()
@@ -81,18 +83,20 @@ def task(IP_NM, DNS_NM, IP_static, DNS_static, HOSTNAME_X_IP, Client_IP):
sB.login(IP_static, peer_user, peer_passwd)
# sA
# make sure NM is not handling eth0
- sA.sendline('nmcli -c no d')
+ sA.sendline('nmcli -c no d')
sA.prompt()
results['NM_nmcli'] = sA.before
results['NM_nslookup'] = sA.run('nslookup www.arnes.si')
# sB
# check whether NM is handling eth0
- sB.sendline('nmcli -c no d')
+ sB.sendline('nmcli -c no d')
sB.prompt()
results['static_nmcli'] = sB.before
results['static_nslookup'] = sB.run('nslookup www.arnes.si')
- # test the DNS server
- results['NM_dns_test'] = sA.run('nslookup test.net 127.0.0.1')
+ # test the DNS server
+ results['NM_dns_test'] = sA.run('nslookup test.net 127.0.0.1')
+ # test DHCP
+ results['client_ip'] = sB.run('ifconfig')
sA.logout()
sB.logout()
return results
@@ -115,25 +119,43 @@ def task_check(results, params):
if results['NM_nslookup'].find('Server:\t\t{0}\r'.format(params['DNS_NM'])) > -1:
score += 2
else:
- hint += ["NM DNS wrong"]
+ hints += ["NM DNS wrong"]
if results['static_nslookup'].find('Server:\t\t{0}\r'.format(params['DNS_static'])) > -1:
score += 2
else:
- hint += ["Static DNS wrong"]
- if re.search(r'e(th0|np0s3|ns3) +ethernet +connected', results['NM_nmcli']):
+ hints += ["Static DNS wrong"]
+ if re.search(r'e(th0|np0s3|ns3) +ethernet +connected', results['NM_nmcli']):
score += 2
else:
hints += ['nmcli incorrect']
- if re.search(r'e(th0|np0s3|ns3) +ethernet +unmanaged', results['static_nmcli']):
+ if re.search(r'e(th0|np0s3|ns3) +ethernet +unmanaged', results['static_nmcli']):
score += 2
else:
hints += ['nmcli on malibrez incorrect']
- if results['NM_dns_test'].find('Address: {0}'.format(params['HOSTNAME_X_IP'])) > -1:
- score += 2
- else:
- hints += ['DNS query wrong']
+ if results['client_ip'].find('inet {0}'.format(params['Client_IP'])) > -1:
+ score += 1
+ else:
+ hints += ['DHCP_Client DHCP incorrect']
+ if results['NM_dns_test'].find('Address: {0}'.format(params['HOSTNAME_X_IP'])) > -1:
+ score += 1
+ else:
+ hints += ['DNS query wrong']
return score, hints
def prepare_disks(templates, task_params, global_params):
+ d = templates['simpleArbiterGW']
+ s = """auto lo
+iface lo inet loopback
+
+auto ens3
+iface ens3 inet dhcp
+
+auto enp0s3
+iface enp0s3 inet dhcp
+
+auto enp0s8
+iface enp0s8 inet dhcp
+"""
+ d.write("/etc/network/interfaces", s)
write_default_config(templates['simpleArbiterGW'], global_params)