diff options
author | gasperfele@fri1.uni-lj.si <gasperfele@fri1.uni-lj.si@5cf9fbd1-b2bc-434c-b4b7-e852f4f63414> | 2015-01-28 16:41:23 +0000 |
---|---|---|
committer | gasperfele@fri1.uni-lj.si <gasperfele@fri1.uni-lj.si@5cf9fbd1-b2bc-434c-b4b7-e852f4f63414> | 2015-01-28 16:41:23 +0000 |
commit | 455519325cf7c72a6501cb60c7aab305d36601e8 (patch) | |
tree | 677e4fc8c5eebf88e6694803cbc2e9c0eda4e1d6 | |
parent | 677e3ac2a4687e15f40dbc060f1bbb96b01d2c58 (diff) |
Fixed set_ip_static_dhcp
git-svn-id: https://svn.lusy.fri.uni-lj.si/kpov-public-svn/kpov-public@248 5cf9fbd1-b2bc-434c-b4b7-e852f4f63414
-rw-r--r-- | kpov_judge/tasks/set_ip_static_dhcp/task.py | 37 | ||||
-rwxr-xr-x | kpov_judge/test_task.py | 3 |
2 files changed, 27 insertions, 13 deletions
diff --git a/kpov_judge/tasks/set_ip_static_dhcp/task.py b/kpov_judge/tasks/set_ip_static_dhcp/task.py index 14869f0..8c33a90 100644 --- a/kpov_judge/tasks/set_ip_static_dhcp/task.py +++ b/kpov_judge/tasks/set_ip_static_dhcp/task.py @@ -6,12 +6,12 @@ instructions = { 'si':u""" Ustvari tri navidezne racunalnike. Za prvega -uporabi sliko diska simpleArbiterGW, za drugega sliko diska +uporabi sliko diska simpleArbiterDhcpGW, za drugega sliko diska maliNetworkManager, za tretjega sliko diska maliBrezNetworkManager. Racunalnike imenujmo enako kot slike diska. Na maliBrezNetworkManager izklopi networkmanager in uporabljaj konzolo. Na obeh rocno nastavi IP naslova ter naslova -DNS strežnikov. Naslove dobiš na simpleArbiterGW. +DNS strežnikov. Naslove dobiš na simpleArbiterDhcpGW. """ } @@ -46,7 +46,7 @@ computers = { }, 'SimpleArbiter': { 'disks': [ - { 'name': 'simpleArbiterDhcp', + { 'name': 'simpleArbiterDhcpGW', # attempt automount }, #{ 'name': 'CDROM', @@ -75,17 +75,25 @@ def task(IP_NM, DNS_NM, IP_static, DNS_static): results = dict() peer_user = 'student' peer_passwd = 'vaje' + # sA - network manager sA = pxssh.pxssh() - sB = pxssh.pxssh() sA.login(IP_NM, peer_user, peer_passwd) - sB.login(IP_static, peer_user, peer_passwd) - # sA - network manager - results['NM_nmcli'] = sA.run('nmcli d') - results['NM_nslookup'] = sA.run('nslookup www.arnes.si') - # sB - brez network manager - results['static_nmcli'] = sB.run('nmcli d') - results['static_nslookup'] = sB.run('nslookup www.arnes.si') + sA.sendline('nmcli d') + sA.prompt() + results['NM_nmcli'] = sA.before + sA.sendline('nslookup www.arnes.si') + sA.prompt() + results['NM_nslookup'] = sA.before sA.logout() + # sB - brez network manager + sB = pxssh.pxssh() + sB.login(IP_static, peer_user, peer_passwd) + sB.sendline('nmcli d') + sB.prompt() + results['static_nmcli'] = sB.before + sB.sendline('nslookup www.arnes.si') + sB.prompt() + results['static_nslookup'] = sB.before sB.logout() return results @@ -103,13 +111,18 @@ def gen_params(user_id, params_meta): def task_check(results, params): import re score = 0 + #print results, params if results['NM_nslookup'].find(params['DNS_NM']) > -1: + # print "NM_nslookup OK" score += 3 if results['static_nslookup'].find(params['DNS_static']) > -1: + # print "static_nslookup OK" score += 3 if re.search(r'eth0 +802-.*connected', results['NM_nmcli']): + # print "NM_nmcli OK" score += 2 - if not re.search(r'eth0 +802-.*unmanaged', results['static_nmcli']): + if re.search(r'eth0 +802-.*unmanaged', results['static_nmcli']): + # print "static_nmcli OK" score += 2 return score diff --git a/kpov_judge/test_task.py b/kpov_judge/test_task.py index bf20f1f..33922d1 100755 --- a/kpov_judge/test_task.py +++ b/kpov_judge/test_task.py @@ -64,7 +64,7 @@ def add_meta_to_argparser(argparser, meta, defaults = {}): desc = v['descriptions'][language].encode("utf-8") except: desc = k - print("{} {}".format(desc, type(desc))) + # print("{} {}".format(desc, type(desc))) argparser.add_argument('--'+k, nargs=1, help=desc, type=unicode, default=defaults.get(k, None)) return argparser @@ -210,6 +210,7 @@ if __name__ == '__main__': except Exception as e: print("Error running task(...):") print(e) + exit(1) try: result = task_check(task_result, task_params) print result |