summaryrefslogtreecommitdiff
path: root/kpov_judge/tasks/snmp_agent_uptime
diff options
context:
space:
mode:
authorTimotej Lazar <timotej.lazar@fri.uni-lj.si>2018-09-26 16:23:29 +0200
committerTimotej Lazar <timotej.lazar@fri.uni-lj.si>2018-09-26 16:23:29 +0200
commit03c9d6d8441e3293b058fed270866419781b734c (patch)
treea456f12f5c26c836685c6e47c95cfe2897e43723 /kpov_judge/tasks/snmp_agent_uptime
parent3938c69f3e1586c1ffbcae5395414ca8480e6ba4 (diff)
Run 2to3
Some stuff is broken now.
Diffstat (limited to 'kpov_judge/tasks/snmp_agent_uptime')
-rw-r--r--kpov_judge/tasks/snmp_agent_uptime/task.py22
1 files changed, 11 insertions, 11 deletions
diff --git a/kpov_judge/tasks/snmp_agent_uptime/task.py b/kpov_judge/tasks/snmp_agent_uptime/task.py
index 1ec037b..c636549 100644
--- a/kpov_judge/tasks/snmp_agent_uptime/task.py
+++ b/kpov_judge/tasks/snmp_agent_uptime/task.py
@@ -4,7 +4,7 @@
# kpov_random_helpers should be imported by add_assignment.py
# TODO: finish this.
instructions = {
- 'si':u"""
+ 'si':"""
Naloga: Postavi tri navidezne racunalnike:
- SimpleArbiter s sliko diska simpleArbiterDhcpGW,
- SNMPServer in
@@ -26,7 +26,7 @@ Postavi jo na SNMP klienta, v domaci imenik uporabnika test z geslom test.
Poskrbi, da bodo podatki na SNMPServer dostopni za skupino (community) studentje.
""",
- 'en':u"""
+ 'en':"""
Set up three virtual computers, SimpleArbiter with the disk image simpleArbiterDhcp,
SNMPServer and SNMPClient. Write a program called upminutes. This program should output
the uptime of the computer in minutes. Set it up on SNMPClient in the home directory
@@ -95,11 +95,11 @@ computers = {
networks = { 'net1': {'public': False}, 'test-net': {'public': True} }
params_meta = {
- 'SNMP_VALUE': {'descriptions': {'si': u'Vrednost, dostopna prek SNMP', 'en': 'The value available over SNMP'}, 'w': False, 'public':False, 'type': 'short', 'generated': True},
- 'SNMP_UPTIME_OID': {'descriptions': {'si': u'SNMP_UPTIME_OID (za uptime)', 'en': 'SNMP_UPTIME_OID (for the uptime)'}, 'w': False, 'public':True, 'type': 'str', 'generated': True},
- 'SNMP_CLIENT_OID': {'descriptions': {'si': u'SNMP_CLIENT_OID, ki naj ga klient bere', 'en':'The OID that the client should read'}, 'w': False, 'public':True, 'type': 'OID', 'generated': True},
- 'SERVER_IP': {'descriptions': {'si': u'IP SNMP strežnika', 'en':'IP of the SNMP server'}, 'w': True, 'public':True, 'type': 'IP', 'generated': False},
- 'CLIENT_IP': {'descriptions': {'si': u'IP SNMP klienta', 'en': 'IP of the SNMP client'}, 'w': True, 'public':True, 'type': 'IP', 'generated': False},
+ 'SNMP_VALUE': {'descriptions': {'si': 'Vrednost, dostopna prek SNMP', 'en': 'The value available over SNMP'}, 'w': False, 'public':False, 'type': 'short', 'generated': True},
+ 'SNMP_UPTIME_OID': {'descriptions': {'si': 'SNMP_UPTIME_OID (za uptime)', 'en': 'SNMP_UPTIME_OID (for the uptime)'}, 'w': False, 'public':True, 'type': 'str', 'generated': True},
+ 'SNMP_CLIENT_OID': {'descriptions': {'si': 'SNMP_CLIENT_OID, ki naj ga klient bere', 'en':'The OID that the client should read'}, 'w': False, 'public':True, 'type': 'OID', 'generated': True},
+ 'SERVER_IP': {'descriptions': {'si': 'IP SNMP strežnika', 'en':'IP of the SNMP server'}, 'w': True, 'public':True, 'type': 'IP', 'generated': False},
+ 'CLIENT_IP': {'descriptions': {'si': 'IP SNMP klienta', 'en': 'IP of the SNMP client'}, 'w': True, 'public':True, 'type': 'IP', 'generated': False},
}
@@ -131,8 +131,8 @@ def task(SERVER_IP, CLIENT_IP, SNMP_UPTIME_OID, SNMP_CLIENT_OID):
return_results['server_OID'] = "\n".join(result_list)
except Exception as exception_error:
# Check for errors and print out results
- print ('ERROR: Occurred during SNMPget for OID %s from %s: '
- '(%s)') % (SNMP_UPTIME_OID, CLIENT_IP, exception_error)
+ print(('ERROR: Occurred during SNMPget for OID %s from %s: '
+ '(%s)') % (SNMP_UPTIME_OID, CLIENT_IP, exception_error))
sys.exit(2)
client.connect(CLIENT_IP, username='test', password='test')
@@ -194,7 +194,7 @@ def task_check(results, params):
if oid.strip() == server_oid and d >= -2 and d <= 5:
found_uptime = True
break
- except Exception, e:
+ except Exception as e:
pass
if len(lines) <= 50 and found_uptime:
score += 3
@@ -232,5 +232,5 @@ if action != '-s' and oid == foo_oid:
print "{val}"
""".format(oid = task_params['SNMP_CLIENT_OID'], val = task_params['SNMP_VALUE'])
templates['simpleArbiterDhcpGWSNMP'].write('/usr/local/bin/snmpext.py', prog)
- templates['simpleArbiterDhcpGWSNMP'].chmod(0755, '/usr/local/bin/snmpext.py')
+ templates['simpleArbiterDhcpGWSNMP'].chmod(0o755, '/usr/local/bin/snmpext.py')
write_default_config(templates['simpleArbiterDhcpGWSNMP'], global_params)