From f3e2c6f2add893710dc9a54098acff13c5934a90 Mon Sep 17 00:00:00 2001 From: "gasperfele@fri1.uni-lj.si" Date: Tue, 21 Oct 2014 21:35:40 +0000 Subject: Separated tasks from lectures git-svn-id: https://svn.lusy.fri.uni-lj.si/kpov-public-svn/kpov-public@2 5cf9fbd1-b2bc-434c-b4b7-e852f4f63414 --- .../set_ip_static_dhcp/evaluation/navodila.html | 9 -- .../tasks/set_ip_static_dhcp/howtos/images/04.png | Bin 0 -> 11706 bytes .../tasks/set_ip_static_dhcp/howtos/images/09.png | Bin 0 -> 187608 bytes .../tasks/set_ip_static_dhcp/howtos/images/10.png | Bin 0 -> 193147 bytes .../tasks/set_ip_static_dhcp/howtos/images/11.png | Bin 0 -> 189272 bytes .../tasks/set_ip_static_dhcp/howtos/images/12.png | Bin 0 -> 163954 bytes .../tasks/set_ip_static_dhcp/howtos/images/13.png | Bin 0 -> 175600 bytes .../tasks/set_ip_static_dhcp/howtos/images/17.png | Bin 0 -> 7062 bytes .../tasks/set_ip_static_dhcp/howtos/si/index.html | 73 +++++++++++++ .../preparation/howtos/images/04.png | Bin 11706 -> 0 bytes .../preparation/howtos/images/09.png | Bin 187608 -> 0 bytes .../preparation/howtos/images/10.png | Bin 193147 -> 0 bytes .../preparation/howtos/images/11.png | Bin 189272 -> 0 bytes .../preparation/howtos/images/12.png | Bin 163954 -> 0 bytes .../preparation/howtos/images/13.png | Bin 175600 -> 0 bytes .../preparation/howtos/images/17.png | Bin 7062 -> 0 bytes .../preparation/howtos/si/index.html | 73 ------------- .../tasks/set_ip_static_dhcp/preparation/task.py | 121 --------------------- kpov_judge/tasks/set_ip_static_dhcp/task.py | 121 +++++++++++++++++++++ 19 files changed, 194 insertions(+), 203 deletions(-) delete mode 100644 kpov_judge/tasks/set_ip_static_dhcp/evaluation/navodila.html create mode 100644 kpov_judge/tasks/set_ip_static_dhcp/howtos/images/04.png create mode 100644 kpov_judge/tasks/set_ip_static_dhcp/howtos/images/09.png create mode 100644 kpov_judge/tasks/set_ip_static_dhcp/howtos/images/10.png create mode 100644 kpov_judge/tasks/set_ip_static_dhcp/howtos/images/11.png create mode 100644 kpov_judge/tasks/set_ip_static_dhcp/howtos/images/12.png create mode 100644 kpov_judge/tasks/set_ip_static_dhcp/howtos/images/13.png create mode 100644 kpov_judge/tasks/set_ip_static_dhcp/howtos/images/17.png create mode 100644 kpov_judge/tasks/set_ip_static_dhcp/howtos/si/index.html delete mode 100644 kpov_judge/tasks/set_ip_static_dhcp/preparation/howtos/images/04.png delete mode 100644 kpov_judge/tasks/set_ip_static_dhcp/preparation/howtos/images/09.png delete mode 100644 kpov_judge/tasks/set_ip_static_dhcp/preparation/howtos/images/10.png delete mode 100644 kpov_judge/tasks/set_ip_static_dhcp/preparation/howtos/images/11.png delete mode 100644 kpov_judge/tasks/set_ip_static_dhcp/preparation/howtos/images/12.png delete mode 100644 kpov_judge/tasks/set_ip_static_dhcp/preparation/howtos/images/13.png delete mode 100644 kpov_judge/tasks/set_ip_static_dhcp/preparation/howtos/images/17.png delete mode 100644 kpov_judge/tasks/set_ip_static_dhcp/preparation/howtos/si/index.html delete mode 100644 kpov_judge/tasks/set_ip_static_dhcp/preparation/task.py create mode 100644 kpov_judge/tasks/set_ip_static_dhcp/task.py (limited to 'kpov_judge/tasks/set_ip_static_dhcp') diff --git a/kpov_judge/tasks/set_ip_static_dhcp/evaluation/navodila.html b/kpov_judge/tasks/set_ip_static_dhcp/evaluation/navodila.html deleted file mode 100644 index df4c68d..0000000 --- a/kpov_judge/tasks/set_ip_static_dhcp/evaluation/navodila.html +++ /dev/null @@ -1,9 +0,0 @@ -

Usposobite tri računalnike: -

-

-

Prvi omrežni vmesnik računalnika SimpleArbiter naj bo povezan na Internet. Drugi naj bo povezan na neko lokalno omrežje, na katerega bosta priklopljena računalnika Z_DHCP ter BREZ_DHCP. Na računalniku Z_DHCP poskrbite, da bo ob pridobivanju naslova DHCP strežniku poslal tudi posebej nastavljeno ime računalnika (hostname), ki ne bo enako dejanskemu imenu računalnika (tistemu, ki ga izpiše ukaz hostname).

-

Naslov BREZ_DHCP ter ime računalnika za Z_DHCP dobite ob zagonu run_test.py na računalniku SimpleArbiter. Uporabniško ime ter geslo na SimpleArbiter sta

tester
in
SedemKrogovPekla
.

diff --git a/kpov_judge/tasks/set_ip_static_dhcp/howtos/images/04.png b/kpov_judge/tasks/set_ip_static_dhcp/howtos/images/04.png new file mode 100644 index 0000000..754c200 Binary files /dev/null and b/kpov_judge/tasks/set_ip_static_dhcp/howtos/images/04.png differ diff --git a/kpov_judge/tasks/set_ip_static_dhcp/howtos/images/09.png b/kpov_judge/tasks/set_ip_static_dhcp/howtos/images/09.png new file mode 100644 index 0000000..866a51d Binary files /dev/null and b/kpov_judge/tasks/set_ip_static_dhcp/howtos/images/09.png differ diff --git a/kpov_judge/tasks/set_ip_static_dhcp/howtos/images/10.png b/kpov_judge/tasks/set_ip_static_dhcp/howtos/images/10.png new file mode 100644 index 0000000..d6ccf42 Binary files /dev/null and b/kpov_judge/tasks/set_ip_static_dhcp/howtos/images/10.png differ diff --git a/kpov_judge/tasks/set_ip_static_dhcp/howtos/images/11.png b/kpov_judge/tasks/set_ip_static_dhcp/howtos/images/11.png new file mode 100644 index 0000000..10b5ec7 Binary files /dev/null and b/kpov_judge/tasks/set_ip_static_dhcp/howtos/images/11.png differ diff --git a/kpov_judge/tasks/set_ip_static_dhcp/howtos/images/12.png b/kpov_judge/tasks/set_ip_static_dhcp/howtos/images/12.png new file mode 100644 index 0000000..0a87ae6 Binary files /dev/null and b/kpov_judge/tasks/set_ip_static_dhcp/howtos/images/12.png differ diff --git a/kpov_judge/tasks/set_ip_static_dhcp/howtos/images/13.png b/kpov_judge/tasks/set_ip_static_dhcp/howtos/images/13.png new file mode 100644 index 0000000..e71474a Binary files /dev/null and b/kpov_judge/tasks/set_ip_static_dhcp/howtos/images/13.png differ diff --git a/kpov_judge/tasks/set_ip_static_dhcp/howtos/images/17.png b/kpov_judge/tasks/set_ip_static_dhcp/howtos/images/17.png new file mode 100644 index 0000000..d4bba87 Binary files /dev/null and b/kpov_judge/tasks/set_ip_static_dhcp/howtos/images/17.png differ diff --git a/kpov_judge/tasks/set_ip_static_dhcp/howtos/si/index.html b/kpov_judge/tasks/set_ip_static_dhcp/howtos/si/index.html new file mode 100644 index 0000000..9b56a81 --- /dev/null +++ b/kpov_judge/tasks/set_ip_static_dhcp/howtos/si/index.html @@ -0,0 +1,73 @@ +

+

Namen vaje

+Naučite se, kako se nastavljajo omrežni vmesniki v večini sodobnih Linux distribucij (NetworkManager). +

+

+

Naloga na hitro

+Nastavi statičen IP v NetworkManager-ju, nastavi statični IP in DNS strežnik v /etc/network/interfaces. Oba naslova računalnikov in DNS strežnikov dobite ob zagonu run_test.py. +

+

+

Navodila

+
    +
  1. Iz imenika s slikami virtualnih računalnikov povlecite slike maliNetworkManager, maliBrezNetworkManager, SimpleArbiterDhcp
  2. + +
  3. Nastavite omrežja navideznih računalnikov tako, da bo
    1. omrežni vmesnik SimpleArbiterDhcp povezan na isto omrežje kot edini omrežni vmesnik maliNetworkManager in maliBrezNetworkManager,
    + 2. vmesnik SimpleArbiterDhcp bo povezan na NAT ali fizično omrežje, kjer prek DHCP dobi naslov in pot (prehod, gateway) do Interneta.
  4. + +
  5. Zaženite SimpleArbiterDhcp. Prijavite se kot uporabnik tester z geslom SedemKrogovPekla
  6. +
  7. +slika-04
    +Z ukazom
    ping 193.2.1.66
    preverite, ali je SimpleArbiterDhcp na Internetu. Če je, boste približno vsako sekundo dobili odziv. Ping prekinete +s kombinacijo tipk CTRL+C.
    + Če SimpleArbiterDhcp ne pride do Interneta, v VirtualBox zamenjajte nastavitve 1. in 2. omrežni vmesnik ter ponovno zaženite navidezni računalnik. +
  8. +
  9. Poženite run_test.py.
  10. + +
  11. Kot ime naloge vpišite 03.predvaja
  12. + +
  13. Preberite statični IP maliNetworkManager. Pustite SimpleArbiterDhcp da teče v ozadju, dokler niste nastavili maliNetworkManager
  14. + +
  15. Zaženite maliNetworkManager.
  16. + +
  17. +Prijavite se v grafično okolje z uporabniškim imenom student, geslom vaje
  18. +
  19. ikona network manager
    +Desno-kliknite na ikono za mrežne nastavitve
    + +
  20. +Menu NetworkManager
    +Izberite "Edit Connections"
  21. + +
  22. +Menu NetworkManager
    +Kliknite "Edit"
  23. + +
  24. +Menu NetworkManager
    +V zavihku "IPv4" spremenite "Method" na "Manual". Kliknite na "Add". Nastavite statični IP, ki ste ga prebrali na SimpleArbiterDhcp kot statični IP A.
    +V DNS servers dodajte naslov Arnesovega DNS: 193.2.1.66 +
  25. +
  26. Kliknite "Save"
  27. + +
  28. Preklopite na SimpleArbiterDhcp. Pritisnite "Enter" oz. "OK".
  29. + +
  30. Preberite IP maliBrezNetworkManager. Pritisnite "OK". Preberite naslov DNS strežnika.
  31. + +
  32. Preklopite na maliBrezNetworkManager. Preklopite na prvo konzolo s kombinacijo CTRL+ALT+F1. Prijavite se kot root z geslom kaboom.
  33. + +
  34. Odprite datoteko /etc/network/interfaces. Popravite nastavitve v skladu s podatki, ki ste jih dobili na SimpleArbiter. Vnos za omrežni vmesnik mora izgledati približno takole:
    +
    +allow-hotplug eth0
    +iface eth0 inet static
    +    10.0.1.2
    +    netmask 255.255.255.128
    +    dns-nameservers 10.0.1.5
    +
    +
  35. + +
  36. Shranite nastavitve. Z ukazom reboot ponovno zaženite maliBrezNetworkManager. NetworkManager ob zagonu računalnika +prebere, kateri omrežni vmesniki so nastavljeni v /etc/network/interfaces. Za te vmesnike potem ne skrbi več.
  37. + +Na SimpleArbiterDhcp pritisnite OK. Če je šlo vse po sreči, ste opravili tokratno nalogo. +
+

diff --git a/kpov_judge/tasks/set_ip_static_dhcp/preparation/howtos/images/04.png b/kpov_judge/tasks/set_ip_static_dhcp/preparation/howtos/images/04.png deleted file mode 100644 index 754c200..0000000 Binary files a/kpov_judge/tasks/set_ip_static_dhcp/preparation/howtos/images/04.png and /dev/null differ diff --git a/kpov_judge/tasks/set_ip_static_dhcp/preparation/howtos/images/09.png b/kpov_judge/tasks/set_ip_static_dhcp/preparation/howtos/images/09.png deleted file mode 100644 index 866a51d..0000000 Binary files a/kpov_judge/tasks/set_ip_static_dhcp/preparation/howtos/images/09.png and /dev/null differ diff --git a/kpov_judge/tasks/set_ip_static_dhcp/preparation/howtos/images/10.png b/kpov_judge/tasks/set_ip_static_dhcp/preparation/howtos/images/10.png deleted file mode 100644 index d6ccf42..0000000 Binary files a/kpov_judge/tasks/set_ip_static_dhcp/preparation/howtos/images/10.png and /dev/null differ diff --git a/kpov_judge/tasks/set_ip_static_dhcp/preparation/howtos/images/11.png b/kpov_judge/tasks/set_ip_static_dhcp/preparation/howtos/images/11.png deleted file mode 100644 index 10b5ec7..0000000 Binary files a/kpov_judge/tasks/set_ip_static_dhcp/preparation/howtos/images/11.png and /dev/null differ diff --git a/kpov_judge/tasks/set_ip_static_dhcp/preparation/howtos/images/12.png b/kpov_judge/tasks/set_ip_static_dhcp/preparation/howtos/images/12.png deleted file mode 100644 index 0a87ae6..0000000 Binary files a/kpov_judge/tasks/set_ip_static_dhcp/preparation/howtos/images/12.png and /dev/null differ diff --git a/kpov_judge/tasks/set_ip_static_dhcp/preparation/howtos/images/13.png b/kpov_judge/tasks/set_ip_static_dhcp/preparation/howtos/images/13.png deleted file mode 100644 index e71474a..0000000 Binary files a/kpov_judge/tasks/set_ip_static_dhcp/preparation/howtos/images/13.png and /dev/null differ diff --git a/kpov_judge/tasks/set_ip_static_dhcp/preparation/howtos/images/17.png b/kpov_judge/tasks/set_ip_static_dhcp/preparation/howtos/images/17.png deleted file mode 100644 index d4bba87..0000000 Binary files a/kpov_judge/tasks/set_ip_static_dhcp/preparation/howtos/images/17.png and /dev/null differ diff --git a/kpov_judge/tasks/set_ip_static_dhcp/preparation/howtos/si/index.html b/kpov_judge/tasks/set_ip_static_dhcp/preparation/howtos/si/index.html deleted file mode 100644 index 9b56a81..0000000 --- a/kpov_judge/tasks/set_ip_static_dhcp/preparation/howtos/si/index.html +++ /dev/null @@ -1,73 +0,0 @@ -

-

Namen vaje

-Naučite se, kako se nastavljajo omrežni vmesniki v večini sodobnih Linux distribucij (NetworkManager). -

-

-

Naloga na hitro

-Nastavi statičen IP v NetworkManager-ju, nastavi statični IP in DNS strežnik v /etc/network/interfaces. Oba naslova računalnikov in DNS strežnikov dobite ob zagonu run_test.py. -

-

-

Navodila

-
    -
  1. Iz imenika s slikami virtualnih računalnikov povlecite slike maliNetworkManager, maliBrezNetworkManager, SimpleArbiterDhcp
  2. - -
  3. Nastavite omrežja navideznih računalnikov tako, da bo
    1. omrežni vmesnik SimpleArbiterDhcp povezan na isto omrežje kot edini omrežni vmesnik maliNetworkManager in maliBrezNetworkManager,
    - 2. vmesnik SimpleArbiterDhcp bo povezan na NAT ali fizično omrežje, kjer prek DHCP dobi naslov in pot (prehod, gateway) do Interneta.
  4. - -
  5. Zaženite SimpleArbiterDhcp. Prijavite se kot uporabnik tester z geslom SedemKrogovPekla
  6. -
  7. -slika-04
    -Z ukazom
    ping 193.2.1.66
    preverite, ali je SimpleArbiterDhcp na Internetu. Če je, boste približno vsako sekundo dobili odziv. Ping prekinete -s kombinacijo tipk CTRL+C.
    - Če SimpleArbiterDhcp ne pride do Interneta, v VirtualBox zamenjajte nastavitve 1. in 2. omrežni vmesnik ter ponovno zaženite navidezni računalnik. -
  8. -
  9. Poženite run_test.py.
  10. - -
  11. Kot ime naloge vpišite 03.predvaja
  12. - -
  13. Preberite statični IP maliNetworkManager. Pustite SimpleArbiterDhcp da teče v ozadju, dokler niste nastavili maliNetworkManager
  14. - -
  15. Zaženite maliNetworkManager.
  16. - -
  17. -Prijavite se v grafično okolje z uporabniškim imenom student, geslom vaje
  18. -
  19. ikona network manager
    -Desno-kliknite na ikono za mrežne nastavitve
    - -
  20. -Menu NetworkManager
    -Izberite "Edit Connections"
  21. - -
  22. -Menu NetworkManager
    -Kliknite "Edit"
  23. - -
  24. -Menu NetworkManager
    -V zavihku "IPv4" spremenite "Method" na "Manual". Kliknite na "Add". Nastavite statični IP, ki ste ga prebrali na SimpleArbiterDhcp kot statični IP A.
    -V DNS servers dodajte naslov Arnesovega DNS: 193.2.1.66 -
  25. -
  26. Kliknite "Save"
  27. - -
  28. Preklopite na SimpleArbiterDhcp. Pritisnite "Enter" oz. "OK".
  29. - -
  30. Preberite IP maliBrezNetworkManager. Pritisnite "OK". Preberite naslov DNS strežnika.
  31. - -
  32. Preklopite na maliBrezNetworkManager. Preklopite na prvo konzolo s kombinacijo CTRL+ALT+F1. Prijavite se kot root z geslom kaboom.
  33. - -
  34. Odprite datoteko /etc/network/interfaces. Popravite nastavitve v skladu s podatki, ki ste jih dobili na SimpleArbiter. Vnos za omrežni vmesnik mora izgledati približno takole:
    -
    -allow-hotplug eth0
    -iface eth0 inet static
    -    10.0.1.2
    -    netmask 255.255.255.128
    -    dns-nameservers 10.0.1.5
    -
    -
  35. - -
  36. Shranite nastavitve. Z ukazom reboot ponovno zaženite maliBrezNetworkManager. NetworkManager ob zagonu računalnika -prebere, kateri omrežni vmesniki so nastavljeni v /etc/network/interfaces. Za te vmesnike potem ne skrbi več.
  37. - -Na SimpleArbiterDhcp pritisnite OK. Če je šlo vse po sreči, ste opravili tokratno nalogo. -
-

diff --git a/kpov_judge/tasks/set_ip_static_dhcp/preparation/task.py b/kpov_judge/tasks/set_ip_static_dhcp/preparation/task.py deleted file mode 100644 index 1d79a61..0000000 --- a/kpov_judge/tasks/set_ip_static_dhcp/preparation/task.py +++ /dev/null @@ -1,121 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -# kpovRandomHelpers should be imported by add_assignment.py - -instructions = { - 'si':u""" -Ustvari tri navidezne računalnike. Za prvega -uporabi sliko diska simpleArbiterDhcp, za drugega sliko diska -maliNetworkManager, za tretjega sliko diska maliBrezNetworkManager. -Računalnike imenujmo enako kot slike diska. -Na maliBrezNetworkManager izklopi networkmanager. Na -Izklopi NetworkManager. Na obeh ročno nastavi IP naslova ter naslova -DNS strežnikov. Naslove dobiš na simpleArbiterDhcp. -""" -} - -computers = { - 'maliNetworkManager': { - 'disks': [ - { 'name': 'maliNetworkManager', - }, - #{ 'name': 'CDROM', - # 'options':{'readonly': True}, - # 'parts': [],# no parts, no mounting. - #} - ], - 'network_interfaces': [{'network': 'net1'}], - 'flavor': 'm1.tiny', - 'config_drive': False - - }, - 'maliBrezNetworkManager': { - 'disks': [ - { 'name': 'maliBrezNetworkManager', - }, - #{ 'name': 'CDROM', - # 'options':{'readonly': True}, - # 'parts': [],# no parts, no mounting. - #} - ], - 'network_interfaces': [{'network': 'net1'}], - 'flavor': 'm1.tiny', - 'config_drive': False - - }, - 'SimpleArbiter': { - 'disks': [ - { 'name': 'simpleArbiterDhcp', - # attempt automount - }, - #{ 'name': 'CDROM', - # 'options': {'readonly': True}, - # 'parts': [{'dev': 'b1', 'path': '/cdrom'}], - #}, - ], - 'network_interfaces': [{'network': 'net1'}, {'network': 'test-net'}], - 'flavor': 'm1.tiny', - 'config_drive': False - } -} - -networks = { 'net1': {'public': False}, 'test-net': {'public': True} } - -params_meta = { - 'IP_NM': {'opis': 'Naslov maliNetworkManager', 'w': False, 'public':True, 'type': 'IP', 'generated': True}, - 'DNS_NM': {'opis': 'DNS za maliNetworkManager', 'w': False, 'public':True, 'type': 'IP', 'generated': True}, - 'IP_static': {'opis': 'Naslov maliBrezNetworkManager', 'w': False, 'public': True, 'type': 'IP', 'generated': True}, - 'DNS_static': {'opis': 'DNS za maliBrezNetworkManager', 'w': False, 'public': True, 'type': 'IP', 'generated': True}, -} - -def task(IP_NM, DNS_NM, IP_static, DNS_static): - import pxssh - import pexpect - results = dict() - peer_user = 'student' - peer_passwd = 'vaje' - sA = pxssh.pxssh() - sB = pxssh.pxssh() - sA.login(IP_NM, peer_user, peer_passwd) - sB.login(IP_static, peer_user, peer_passwd) - # sA - # make sure NM is not handling eth0 - results['NM_nmcli'] = sA.run('nmcli d') - results['NM_nslookup'] = sA.run('nslookup www.arnes.si') - # sB - # check whether NM is handling eth0 - results['static_nmcli'] = sB.run('nmcli d') - results['static_nslookup'] = sB.run('nslookup www.arnes.si') - sA.logout() - sB.logout() - return results - -def gen_params(user_id, params_meta): - params = dict() - r = random.Random(user_id) - # IP_NM, DNS_NM, IP_static, DNS_static) - dns_servers = ['193.2.1.66', '193.2.1.72', '8.8.8.8', '8.8.4.4', '208.67.222.222', '208.67.220.220'] - net = kpovRandomHelpers.IPv4_subnet_gen(r, '172.23.128.0/18', 24) - params['DNS_NM'] = r.choice(dns_servers) - params['IP_NM'], params['IP_static'] = kpovRandomHelpers.IPv4_addr_gen(r, net, 2) - params['DNS_static'] = r.choice(dns_servers) - return params - -def task_check(results, params): - import re - score = -9 - 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'] - pass - diff --git a/kpov_judge/tasks/set_ip_static_dhcp/task.py b/kpov_judge/tasks/set_ip_static_dhcp/task.py new file mode 100644 index 0000000..1d79a61 --- /dev/null +++ b/kpov_judge/tasks/set_ip_static_dhcp/task.py @@ -0,0 +1,121 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +# kpovRandomHelpers should be imported by add_assignment.py + +instructions = { + 'si':u""" +Ustvari tri navidezne računalnike. Za prvega +uporabi sliko diska simpleArbiterDhcp, za drugega sliko diska +maliNetworkManager, za tretjega sliko diska maliBrezNetworkManager. +Računalnike imenujmo enako kot slike diska. +Na maliBrezNetworkManager izklopi networkmanager. Na +Izklopi NetworkManager. Na obeh ročno nastavi IP naslova ter naslova +DNS strežnikov. Naslove dobiš na simpleArbiterDhcp. +""" +} + +computers = { + 'maliNetworkManager': { + 'disks': [ + { 'name': 'maliNetworkManager', + }, + #{ 'name': 'CDROM', + # 'options':{'readonly': True}, + # 'parts': [],# no parts, no mounting. + #} + ], + 'network_interfaces': [{'network': 'net1'}], + 'flavor': 'm1.tiny', + 'config_drive': False + + }, + 'maliBrezNetworkManager': { + 'disks': [ + { 'name': 'maliBrezNetworkManager', + }, + #{ 'name': 'CDROM', + # 'options':{'readonly': True}, + # 'parts': [],# no parts, no mounting. + #} + ], + 'network_interfaces': [{'network': 'net1'}], + 'flavor': 'm1.tiny', + 'config_drive': False + + }, + 'SimpleArbiter': { + 'disks': [ + { 'name': 'simpleArbiterDhcp', + # attempt automount + }, + #{ 'name': 'CDROM', + # 'options': {'readonly': True}, + # 'parts': [{'dev': 'b1', 'path': '/cdrom'}], + #}, + ], + 'network_interfaces': [{'network': 'net1'}, {'network': 'test-net'}], + 'flavor': 'm1.tiny', + 'config_drive': False + } +} + +networks = { 'net1': {'public': False}, 'test-net': {'public': True} } + +params_meta = { + 'IP_NM': {'opis': 'Naslov maliNetworkManager', 'w': False, 'public':True, 'type': 'IP', 'generated': True}, + 'DNS_NM': {'opis': 'DNS za maliNetworkManager', 'w': False, 'public':True, 'type': 'IP', 'generated': True}, + 'IP_static': {'opis': 'Naslov maliBrezNetworkManager', 'w': False, 'public': True, 'type': 'IP', 'generated': True}, + 'DNS_static': {'opis': 'DNS za maliBrezNetworkManager', 'w': False, 'public': True, 'type': 'IP', 'generated': True}, +} + +def task(IP_NM, DNS_NM, IP_static, DNS_static): + import pxssh + import pexpect + results = dict() + peer_user = 'student' + peer_passwd = 'vaje' + sA = pxssh.pxssh() + sB = pxssh.pxssh() + sA.login(IP_NM, peer_user, peer_passwd) + sB.login(IP_static, peer_user, peer_passwd) + # sA + # make sure NM is not handling eth0 + results['NM_nmcli'] = sA.run('nmcli d') + results['NM_nslookup'] = sA.run('nslookup www.arnes.si') + # sB + # check whether NM is handling eth0 + results['static_nmcli'] = sB.run('nmcli d') + results['static_nslookup'] = sB.run('nslookup www.arnes.si') + sA.logout() + sB.logout() + return results + +def gen_params(user_id, params_meta): + params = dict() + r = random.Random(user_id) + # IP_NM, DNS_NM, IP_static, DNS_static) + dns_servers = ['193.2.1.66', '193.2.1.72', '8.8.8.8', '8.8.4.4', '208.67.222.222', '208.67.220.220'] + net = kpovRandomHelpers.IPv4_subnet_gen(r, '172.23.128.0/18', 24) + params['DNS_NM'] = r.choice(dns_servers) + params['IP_NM'], params['IP_static'] = kpovRandomHelpers.IPv4_addr_gen(r, net, 2) + params['DNS_static'] = r.choice(dns_servers) + return params + +def task_check(results, params): + import re + score = -9 + 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'] + pass + -- cgit v1.2.1