From 8081a5520a441b43a8a7a73f3a90c7aacfaa8e10 Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Sun, 24 Feb 2019 21:05:27 +0100 Subject: Move everything one level up --- kpov_judge/tasks/smb_nfs/howtos/en/index.html | 341 --------------------- .../tasks/smb_nfs/howtos/images/parameters.png | Bin 8403 -> 0 bytes kpov_judge/tasks/smb_nfs/howtos/si/index.html | 71 ----- kpov_judge/tasks/smb_nfs/task.py | 138 --------- 4 files changed, 550 deletions(-) delete mode 100644 kpov_judge/tasks/smb_nfs/howtos/en/index.html delete mode 100644 kpov_judge/tasks/smb_nfs/howtos/images/parameters.png delete mode 100644 kpov_judge/tasks/smb_nfs/howtos/si/index.html delete mode 100644 kpov_judge/tasks/smb_nfs/task.py (limited to 'kpov_judge/tasks/smb_nfs') diff --git a/kpov_judge/tasks/smb_nfs/howtos/en/index.html b/kpov_judge/tasks/smb_nfs/howtos/en/index.html deleted file mode 100644 index fe056b4..0000000 --- a/kpov_judge/tasks/smb_nfs/howtos/en/index.html +++ /dev/null @@ -1,341 +0,0 @@ - - - -smb_nfs - - - -

- smb_nfs -

-

- VirtualBox | Server | Client | NFS | Samba | DHCP -

-

- Quick guide -

-

- Set up two virtual computers - SimpleArbiterDhcp and FileServer. -

-

- Make sure that the directory /srv/nfs/ERLbbBrT on FileServer is accessible - over NFS and over SMB under the sharename urania-03. - Set the SMB server name to zarptica-32. -

-

- SimpleArbiterDhcp should have write access to /srv/nfs/ERLbbBrT over NFS. -

- -

- Instructions -

- - - \ No newline at end of file diff --git a/kpov_judge/tasks/smb_nfs/howtos/images/parameters.png b/kpov_judge/tasks/smb_nfs/howtos/images/parameters.png deleted file mode 100644 index 7d3db83..0000000 Binary files a/kpov_judge/tasks/smb_nfs/howtos/images/parameters.png and /dev/null differ diff --git a/kpov_judge/tasks/smb_nfs/howtos/si/index.html b/kpov_judge/tasks/smb_nfs/howtos/si/index.html deleted file mode 100644 index 80d910d..0000000 --- a/kpov_judge/tasks/smb_nfs/howtos/si/index.html +++ /dev/null @@ -1,71 +0,0 @@ - - - - - SMB NFS How To - - - - - -

KPOV Judge 7 (SMB NFS)

-

V tej vaji postavimo na linux-u strežnik za nudenje datotek prek mreže in strežnik za SMB, s katerim lahko na Windows sistemih postavimo datoteko v skupno rabo. Pazi da bo simpleArbiterDhcpGW imel NFS pravico pisanja po imeniku!

-

Virtualni računalniki

- -

simpleArbiterDhcpGW

-

Naj ima 2 omrežna vmesnika, prvi naj bo preko NAT povezan na svetovni splet, drugi vmesnik pa naj vsebuje interno povezavo znotraj virtualnih sistemov na tvojem računalniku “intnet”.

-

student-fileserver

-

Naj ima 1 omrežni vmesnik, povezan na interno omrežje “intnet”.

-

Parametri

-
- Parametri -

Parametri za reševanje naloge

-
-

Tokrat imamo tri parametre. “Imenovani” dir, smb-share, smb-server.

-

Oziroma iz slike so to:

- -

Postopek

-

Ko zaženemo simpleArbiterDhcpGW in student-fileserver se najprej prijavimo v oba sistema. Nato pa na student-fileserver poženemo

-
apt-get update && apt-get install nfs-kernel-server samba
-

Nastavitve NFS

-

V datoteki /etc/exports dodamo sledečo vrtstico: /srv/nfs/[dir] [IP simpleArbiterDhcpGW](rw).

Datoteko shranimo in znova poženemo NFS strežnik.

-
service nfs-kernel-server restart
-

Ustvarimo imenik, ki smo ga malce prej navedli v nastavitvah NFS. In nato omogočimo vsem pisanje po tem imeniku.

-
-
-mkdir /srv/nfs/[dir]
-chmod oug+w /srv/nfs/[dir]
-
-
-

Nastavitve SMB

-

Vse nastavitvene datoteke SMB se nahajajo v imeniku: /etc/samba. Zanima pa nas datoteka smb.conf.

-
# Datoteka smb.conf
-    [global]
-
-    workgroup = WORKGROUP
-    netbios name = [smb-server] # Nadomestek DNS, ki si ga je izmislil Microsoft
-
-    # Malce nižje pod vrstico =========== Share Definitions =========== dodamo svoje nastavitve
-
-    [[smb-share]] # Primer iz slike: [aurora-85]
-    path = /srv/nfs/[dir]
-    read only = no
-    guest ok = yes
-    browseable = yes
-

Ko popravimo to datoteko restartamo SMB in NetBios s spodnjima ukazoma.

-
service smbd restart
-service nmbd restart
-

Testiranje

-

Sedaj samo še testiranje :) Za to pa na simpleArbiterDhcpGW poženi testno skripto.

-
./test_task.py
- - - - diff --git a/kpov_judge/tasks/smb_nfs/task.py b/kpov_judge/tasks/smb_nfs/task.py deleted file mode 100644 index 6d1e51d..0000000 --- a/kpov_judge/tasks/smb_nfs/task.py +++ /dev/null @@ -1,138 +0,0 @@ -# kpov_util should be imported by add_assignment.py - -# TODO: dokoncaj! -instructions = { - 'si': '''\ -

-Postavi dva navidezna računalnika: simpleArbiterDhcp in FileServer. - -

-Poskrbi, da bo imenik {{NFS_MOUNT}} na FileServer dostopen prek NFS in prek SMB kot imenik v skupni rabi {{SMB_SHARENAME}}. Ime strežnika SMB nastavite na {{FILESERVER_NAME}}. - -

-SimpleArbiterDhcp naj ima prek NFS pravico pisati po imeniku. -''', - 'en': '''\ -

-Set up two virtual computers: simpleArbiterDhcp and FileServer. - -

-Make sure that the directory {{NFS_MOUNT}} on FileServer is accessible over NFS and over SMB under the sharename {{SMB_SHARENAME}}. Set the SMB server name to {{FILESERVER_NAME}}. - -

-SimpleArbiterDhcp should have write access to {{NFS_MOUNT}} over NFS. -''', -} - -computers = { - 'FileServer': { - 'disks': [ - { 'name': 'student-fileserver', - }, - ], - 'network_interfaces': [{'network': 'net1'}], - 'flavor': 'm1.tiny', - 'config_drive': False - - }, - 'SimpleArbiter': { - 'disks': [ - { 'name': 'simpleArbiterDhcpGW', - }, - ], - 'network_interfaces': [{'network': 'net1'}, {'network': 'test-net'}], - 'flavor': 'm1.tiny', - 'config_drive': False - } -} - -networks = { 'net1': {'public': False}, 'test-net': {'public': True} } - -params_meta = { - 'FILESERVER_IP': {'descriptions': {'si': 'IP streznika'}, 'w': True, 'public':True, 'type': 'IP', 'generated': False}, - 'FILESERVER_NAME': {'descriptions': {'si': 'Ime streznika'}, 'w': False, 'public':True, 'type': 'hostname', 'generated': True}, - 'SMB_SHARENAME': {'descriptions': {'si': 'Ime imenika v skupni rabi prek SMB', 'en': 'SMB sharename'}, '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': 'Iskana datoteka'}, 'w': False, 'public': True, 'type': 'filename', 'generated': True}, - 'SHARED_CONTENT': {'descriptions': {'si': 'Vsebina iskane datoteke'}, 'w': False, 'public': False, 'type': 'short', 'generated': True}, - 'SHARED_FILE_SEED': {'descriptions': {'si': 'Dodatni podatek za testiranje'}, 'w': False, 'public': True, 'type': 'filename', 'generated': True}, -} - -def task(FILESERVER_IP, FILESERVER_NAME, NFS_MOUNT, SMB_SHARENAME, SHARED_FILE_SEED): - import pexpect - import random - # TODO: (polz) Try using pexpect instead of subprocess, it's much nicer. - # Tabela vseh mountov. - # Samo mounti na streznik. - results = dict() - results['mount'] = pexpect.run('mount') - results['try_mount_nfs'] = pexpect.run('sudo mount -t nfs {}:/{} /mnt/nfs'.format( - FILESERVER_IP, NFS_MOUNT)) - results['try_mount_smb'] = pexpect.run( - 'sudo mount -t cifs //{}/{} /mnt/smb -o ip={},guest'.format( - FILESERVER_NAME, SMB_SHARENAME, FILESERVER_IP)) - results['mount_after'] = pexpect.run('mount') - results['ls_smbmount'] = pexpect.run('ls /mnt/smb') - results['ls_nfs'] = pexpect.run('ls /mnt/nfs') - r = random.Random(SHARED_FILE_SEED) - testfile = kpov_util.fname_gen(r) - teststring = kpov_util.alnum_gen(r, 200) - with open('/mnt/nfs/{}'.format(testfile),'w') as f: - f.write(teststring) - results['filestr'] = pexpect.run( - 'cat /mnt/smb/{}'.format(testfile)) - results['filels'] = pexpect.run( - 'ls /mnt/smb/'.format(testfile)) - pexpect.run('rm /mnt/nfs/{}'.format(testfile)) - results['filels_later'] = pexpect.run('ls /mnt/smb') - pexpect.run("sudo umount /mnt/nfs") - pexpect.run("sudo umount /mnt/smb") - return results - -def gen_params(user_id, params_meta): - d = kpov_util.default_gen(user_id, params_meta) - r = random.Random(user_id) - d['FILESERVER_NAME'] = kpov_util.hostname_gen(r) - d['SMB_SHARENAME'] = kpov_util.hostname_gen(r) - d['NFS_MOUNT'] = "/srv/nfs/" + kpov_util.fname_gen(r, False) - d['SHARED_FILENAME'] = kpov_util.fname_gen(r) - d['SHARED_CONTENT'] = kpov_util.fortune(r, 4096) - d['SHARED_FILE_SEED'] = kpov_util.alnum_gen(r, 42) - return d - -def task_check(results, params): - score = 0 - hints = [] - r = random.Random(params['SHARED_FILE_SEED']) - testfile = kpov_util.fname_gen(r) - teststring = kpov_util.alnum_gen(r, 200) - # no need to check results['mount'] or results['try_mount_nfs'] - # or results['try_mount_smb'] - if results['mount_after'].find('//{}/{} on /mnt/smb type cifs'.format( - params['FILESERVER_NAME'], params['SMB_SHARENAME'])) >= 0: - score += 2 - if results['mount_after'].find('{}:{} on /mnt/nfs type nfs'.format( - params['FILESERVER_IP'], params['NFS_MOUNT'])) >= 0: - score += 2 - if results['ls_smbmount'].find(params['SHARED_FILENAME']) >= 0: - score += 1 - if results['ls_nfs'].find(params['SHARED_FILENAME']) >= 0: - score += 1 - if results['filestr'] == teststring: - score += 2 - filels_later = set(results['filels_later'].split()) - filels = set(results['filels'].split()) - if "".join(filels - filels_later).find(testfile) >= 0: - score += 2 - return score, hints - -def prepare_disks(templates, task_params, global_params): - d = templates['student-fileserver'] - d.mkdir("/srv/nfs") - d.mkdir(task_params['NFS_MOUNT']) - d.write(task_params['NFS_MOUNT'] + "/" + task_params["SHARED_FILENAME"], - task_params["SHARED_CONTENT"]) - d = templates['simpleArbiterDhcpGW'] - d.mkdir('/mnt/nfs') - d.mkdir('/mnt/smb') - write_default_config(templates['simpleArbiterDhcpGW'], global_params) -- cgit v1.2.1