summaryrefslogtreecommitdiff
path: root/kpov_judge
diff options
context:
space:
mode:
Diffstat (limited to 'kpov_judge')
-rw-r--r--kpov_judge/tasks/custom_rdate/task.py6
-rw-r--r--kpov_judge/tasks/smb_nfs/task.py48
2 files changed, 29 insertions, 25 deletions
diff --git a/kpov_judge/tasks/custom_rdate/task.py b/kpov_judge/tasks/custom_rdate/task.py
index 1e3ad15..fd5d070 100644
--- a/kpov_judge/tasks/custom_rdate/task.py
+++ b/kpov_judge/tasks/custom_rdate/task.py
@@ -77,9 +77,9 @@ networks = { 'net1': {'public': False}, 'test-net': {'public': True} }
# Tu sem dolocil parametre
params_meta = {
- 'Ime':{}
- 'Datum':{}
- 'Sifra':{}
+ 'Ime':{},
+ 'Datum':{},
+ 'Sifra':{},
}
def task(IP_NM, DNS_NM, IP_static, DNS_static):
diff --git a/kpov_judge/tasks/smb_nfs/task.py b/kpov_judge/tasks/smb_nfs/task.py
index 8fd97e7..7d6e481 100644
--- a/kpov_judge/tasks/smb_nfs/task.py
+++ b/kpov_judge/tasks/smb_nfs/task.py
@@ -66,26 +66,32 @@ computers = {
networks = { 'net1': {'public': False}, 'test-net': {'public': True} }
params_meta = {
- 'SMB_NAME': {'descriptions': {'si': 'SMB ime streznika'}, 'w': False, 'public':True, 'type': 'hostname', 'generated': True},
+ 'FILESERVER_NAME': {'descriptions': {'si': 'Ime streznika'}, 'w': False, 'public':True, 'type': 'hostname', 'generated': True},
'SMB_SHARENAME': {'descriptions': {'si': 'Imenik v skupni rabi'}, 'w': False, 'public':True, 'type': 'filename', 'generated': True},
'NFS_MOUNT': {'descriptions': {'si': 'Imenik, dostopen prek NFS'}, 'w': False, 'public': True, 'type': 'filename', 'generated': True},
'SHARED_FILENAME': {'descriptions': {'si': 'Ime datoteke, ki je deljena'}, 'w': False, 'public': True, 'type': 'filename', 'generated': True},
'SHARED_FILENAME_CONTENT': {'descriptions': {'si': 'Vsebina datoteke'}, 'w': False, 'public': True, 'type': 'filename', 'generated': True},
}
-def task(SMB_NAME, NFS_MOUNT, SHARED_FILENAME, SHARED_FILENAME_CONTENT):
+def task(FILESERVER_NAME, NFS_MOUNT, SHARED_FILENAME, SHARED_FILENAME_CONTENT):
import subprocess
-
+ import pexpect
# Naslov, na katerem se nahaja streznik.
- address = SMB_NAME
+ address = FILESERVER_NAME
# TODO: (polz) Try using pexpect instead of subprocess, it's much nicer.
# Tabela vseh mountov.
mounts = subprocess.check_output("mount").split("\n")
# Samo mounti na streznik.
srvmounts = []
- for m in mounts:
- if str.find(m, address) >= 0:
- srvmounts.append(m)
+ results['try_mount_nfs'] = pexpect.run('sudo mount -t nfs {}:/{} /mnt/nfs'.format(
+ FILESERVER_NAME, NFS_MOUNT))
+ results['try_mount_smb'] = pexpect.run('sudo mount -t cifs //{}/{} /mnt/smb'.format(
+ FILESERVER_NAME, SMB_SHARENAME))
+ results['ls_smbmount'] = pexpect.run('ls /mnt/smb')
+ results['ls_nfs'] = pexpect.run('ls /mnt/nfs')
+ testfile = kpov_random_helpers.filename_gen()
+ pexpect.run('echo "HHAHAHA" > /mnt/nfs/{}'.format(filename_gen))
+
# Mounti so v formatu:
# ["//SMB_NAME/<pot_do_direktorija> on NFS_MOUNT type cifs (rw)", ... ]
# example: ["//192.168.1.92/srv/samba on /mnt/samba type cifs (rw)", ... ]
@@ -93,31 +99,29 @@ def task(SMB_NAME, NFS_MOUNT, SHARED_FILENAME, SHARED_FILENAME_CONTENT):
# ++ PIKE za namountan SMB/NFS
# TODO: (polz) prej ali slej tole kodo premaknite v task_check, v results pa porinite
# le mounts (npr. results['mounts'] = mounts
- for m in srvmounts:
+ #for m in srvmounts:
# Dobimo pot, filesystem in pravice iz mounta:
- split = m.split()
- pot = split[2]
- fstype = split[4] #mogoče bomo kaj rabli?
- pravice = split[5]
+ # split = m.split()
+ # pot = split[2]
+ # fstype = split[4] #mogoče bomo kaj rabli?
+ # pravice = split[5]
# Preverimo če je namountano na pravilen direktorij:
- if pot == NFS_MOUNT:
+ # if pot == NFS_MOUNT:
# ++PIKE za pravo pot
# Pregledamo datoteke v temu direktoriju:
- ls = subprocess.check_output(["ls", pot]).split()
+ # ls = subprocess.check_output(["ls", pot]).split()
# Preverimo ce je v imeniku datoteka:
- if SHARED_FILENAME in ls:
+ # if SHARED_FILENAME in ls:
# Če je, primerjamo vsebino:
- cat = subprocess.check_output(["cat", pot+"/"+SHARED_FILENAME])
- if cat == SHARED_FILENAME_CONTENT:
+ # cat = subprocess.check_output(["cat", pot+"/"+SHARED_FILENAME])
+ # if cat == SHARED_FILENAME_CONTENT:
# DING DING DING PLUS PIKE ZA PRAVO VSEBINO
- pass
- if pravice == "(rw)":
+ # pass
+ # if pravice == "(rw)":
# BONUS PIKE ZA READ/WRITE PRAVICE
- pass
+ # pass
# Samo delno stestirano!
-
- results = ''.join(random.choice(string.ascii_uppercase) for i in range(12))
#results = "test"
return results