diff options
Diffstat (limited to 'kpov_judge')
-rw-r--r-- | kpov_judge/tasks/snmp_agent_uptime/task.py | 54 | ||||
-rwxr-xr-x | kpov_judge/test_task.py | 1 |
2 files changed, 28 insertions, 27 deletions
diff --git a/kpov_judge/tasks/snmp_agent_uptime/task.py b/kpov_judge/tasks/snmp_agent_uptime/task.py index e01da96..d59cd2f 100644 --- a/kpov_judge/tasks/snmp_agent_uptime/task.py +++ b/kpov_judge/tasks/snmp_agent_uptime/task.py @@ -94,7 +94,7 @@ computers = { networks = { 'net1': {'public': False}, 'test-net': {'public': True} } -params_meta = {'SNMP_VALUE': {'descriptions': {'si': 'Vrednost, dostopna prek SNMP'}, 'w': False, 'public':True, 'type': 'number', 'generated': True}, 'SNMP_OID_ON_SERVER': {'descriptions': {'si': 'OID, na katerem je vrednost dostopna'}, 'w': False, 'public':True, 'type': 'OID', 'generated': True}, 'SNMP_OID_ON_CLIENT': {'descriptions': {'si': 'OID, ki naj ga klient bere'}, 'w': False, 'public':True, 'type': 'OID', 'generated': True}, } +params_meta = {'SNMP_VALUE': {'descriptions': {'si': 'Vrednost, dostopna prek SNMP'}, 'w': False, 'public':True, 'type': 'number', 'generated': True}, 'SNMP_OID_ON_SERVER': {'descriptions': {'si': 'OID, na katerem je vrednost dostopna'}, 'w': False, 'public':True, 'type': 'str', 'generated': True}, 'SNMP_OID_ON_CLIENT': {'descriptions': {'si': 'OID, ki naj ga klient bere'}, 'w': False, 'public':True, 'type': 'OID', 'generated': True}, } def task(SNMP_VALUE, SNMP_OID_ON_SERVER, SNMP_OID_ON_CLIENT): print SNMP_VALUE @@ -120,35 +120,35 @@ def task(SNMP_VALUE, SNMP_OID_ON_SERVER, SNMP_OID_ON_CLIENT): return 0 def gen_params(user_id, params_meta): - import random - params = dict() - # TODO (polz) this is wrong. Try something like: - r = random.Random(user_id) - #params['SNMP_VALUE'] = r.randint(0, 255) - #params_meta['SNMP_OID_ON_SERVER'] = '1.3.6.1.4.1.8072.1.3.2.4.1.4' - #params_meta['SNMP_OID_ON_CLIENT'] = '1.3.6.1.4.1.8072.1.3.2.4.1.4.' - # You can also create an OID creation function in kpov_random_helpers. - # this should probably return params_meta - - params['SNMP_VALUE'] = None #r.randint(0, 255) - params['SNMP_OID_ON_SERVER'] = None # 'NET-SNMP-EXTEND-MIB::nsExtendOutput2Table' - params['SNMP_OID_ON_CLIENT'] = None # '1.3.6.1.4.1.8072.1.3.2.4.1.4' - print 'gen', params - return params + import random + params = dict() + # TODO (polz) this is wrong. Try something like: + r = random.Random(user_id) + #params['SNMP_VALUE'] = r.randint(0, 255) + #params_meta['SNMP_OID_ON_SERVER'] = '1.3.6.1.4.1.8072.1.3.2.4.1.4' + #params_meta['SNMP_OID_ON_CLIENT'] = '1.3.6.1.4.1.8072.1.3.2.4.1.4.' + # You can also create an OID creation function in kpov_random_helpers. + # this should probably return params_meta + + params['SNMP_VALUE'] = str(r.randint(0, 255)) + params['SNMP_OID_ON_SERVER'] = 'NET-SNMP-EXTEND-MIB::nsExtendOutput2Table' + params['SNMP_OID_ON_CLIENT'] = '1.3.6.1.4.1.8072.1.3.2.4.1.4' + print 'gen', params + return params def task_check(results, params): # TODO (polz) Zacnite s pisanjem testov glede na to, kar vidite v task() - import re - score = 0 - if results['NM_nslookup'].find('Server:\t\t{0}\r'.format(params['DNS_NM'])) > -1: - score += 3 - if results['static_nslookup'].find('Server:\t\t{0}\r'.format(params['DNS_static'])) > -1: - score += 3 - if re.search(r'eth0 +802-.*connected', results['NM_nmcli']): - score += 2 - if not re.search(r'eth0 +802-.*connected', results['static_nmcli']): - score += 2 - return score + import re + score = 0 + if results['NM_nslookup'].find('Server:\t\t{0}\r'.format(params['DNS_NM'])) > -1: + score += 3 + if results['static_nslookup'].find('Server:\t\t{0}\r'.format(params['DNS_static'])) > -1: + score += 3 + if re.search(r'eth0 +802-.*connected', results['NM_nmcli']): + score += 2 + if not re.search(r'eth0 +802-.*connected', results['static_nmcli']): + score += 2 + return score def prepare_disks(templates, params): # d = templates['simpleArbiterDhcp'] diff --git a/kpov_judge/test_task.py b/kpov_judge/test_task.py index 103df56..681955c 100755 --- a/kpov_judge/test_task.py +++ b/kpov_judge/test_task.py @@ -170,6 +170,7 @@ if __name__ == '__main__': params['task_params'][params['task_name']] = params['task_params'].get(params['task_name'], dict()) task_params = params['task_params'][params['task_name']] if basic_args.generate_params: + #prejema lahko samo stringe in ne številk (potrebno je str(int) print "params before", params, task_params task_params.update(gen_params(params['username'], task_params_meta)) print "params after", params, task_params |