summaryrefslogtreecommitdiff
path: root/kpov_judge/tasks/snmp_agent_uptime
diff options
context:
space:
mode:
authoraf7140@student.uni-lj.si <af7140@student.uni-lj.si@5cf9fbd1-b2bc-434c-b4b7-e852f4f63414>2014-12-22 12:15:51 +0000
committeraf7140@student.uni-lj.si <af7140@student.uni-lj.si@5cf9fbd1-b2bc-434c-b4b7-e852f4f63414>2014-12-22 12:15:51 +0000
commitfcfc2c57bb354aaecfc11dca2905ef9e236545b5 (patch)
tree6ecaafc8c49c68f7609fbde8c6101896b72a78ac /kpov_judge/tasks/snmp_agent_uptime
parent5fcb6ae12994d79ebbb4f7bcbab93449788e27b5 (diff)
v gen_parameters je potrebno v slovar shranjevat stevilke kot stringe !
git-svn-id: https://svn.lusy.fri.uni-lj.si/kpov-public-svn/kpov-public@115 5cf9fbd1-b2bc-434c-b4b7-e852f4f63414
Diffstat (limited to 'kpov_judge/tasks/snmp_agent_uptime')
-rw-r--r--kpov_judge/tasks/snmp_agent_uptime/task.py54
1 files changed, 27 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']