1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# bson.son.SON an
# kpov_random_helpers should be imported by add_assignment.py
OrderedDict = SON
instructions = {
'si':"""
Ustvari dva navidezna računalnika. Za disk enega (imenujmo ga SimpleArbiter) uporabite
sliko diska Test. Na drugega (imenujmo ga A) namesti poljubno Linux distribucijo. Na SimpleArbiter
preberi uporabniško ime in geslo uporabnika, ki ga moraš ustvariti na A. Poskrbi, da se bo novoustvarjeni
uporabnik s svojim geslom lahko na A prijavil z Interneta.
"""
}
computers = {
'SimpleArbiter': {
'disks':[
{ 'name': 'simpleArbiter' }],
'network_interfaces':[{'network':'net1'}],
},
'A': {
'disks':[],
'network_interfaces':[{'network':'net2'}],
}
}
networks = { 'net1': {'public': True}, 'net2': {'public': True} }
params_meta = {
'peer_ip': {'descriptions': {'si': 'Naslov ssh strežnika'}, 'w': True, 'public':True, 'type': 'IP', 'generated': False},
'peer_user': {'descriptions': {'si': 'ime uporabnika'}, 'w': False, 'public': True, 'type': 'username', 'generated': True},
'peer_passwd': {'descriptions': {'si': 'geslo uporabnika'}, 'w': False, 'public': True, 'type': 'password', 'generated': True},
}
def task(peer_ip, peer_user, peer_passwd):
return dict()
def gen_params(user_id, params_meta):
return kpov_random_helpers.default_gen(user_id, params_meta)
def task_check(results, params):
from pexpect import pxssh
import pexpect
results = dict()
s = pxssh.pxssh()
peer_ip, peer_user, peer_passwd = params['peer_ip'], params['peer_user'], params['peer_passwd']
try:
s.login(peer_ip, peer_user, peer_passwd)
s.logout()
except Exception as e:
return 0, [str(e)]
return 10, []
def prepare_disks(templates, task_params, global_params):
write_default_config(templates['simpleArbiter'], global_params)
# print d1.ls('/')
|