Check-in [c97821cce1]
Not logged in
Overview
Comment:Fix first screen of wizard
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: c97821cce128ac01863744d162257db380b7bf4c
User & Date: vitus on 2015-11-10 15:21:05
Other Links: manifest | tags
Context
2015-11-13
16:29
Fixed launch of the viewer in start command check-in: cb26ea490c user: vitus tags: trunk
2015-11-10
15:21
Fix first screen of wizard check-in: c97821cce1 user: vitus tags: trunk
14:51
start to implement setup wizard check-in: c38a852bdf user: vitus tags: trunk
Changes

Modified mkvm from [87feb6980a] to [c9b2ef6117].

1
2
3

4
5
6
7
8
9
10
1
2

3
4
5
6
7
8
9
10


-
+







#!/usr/bin/python
import os,sys
from snack import SnackScreen,GridForm,Listbox,Entry,Label,Checkbox,Button
from snack import SnackScreen,GridForm,Listbox,Entry,Label,Checkbox,Button,RadioBar
bridge="lxc0"
secno=3
macaddr="52:54:00:7d:7f:%02x"%secno
options={'qemubinary':'qemu-system-x86_64',
"accel":"-enable-kvm",
"memory":"1024M",
"drive":"-drive media=disk,index=0,if=virtio,file=drive0.qcow2",
65
66
67
68
69
70
71
72

73
74
75
76
77

78
79
80
81
82
83
84
85
86
65
66
67
68
69
70
71

72
73
74
75
76

77


78
79
80
81
82
83
84







-
+




-
+
-
-







    """
    Selects storage subsystem to use
    import existing drive, use cdrom,
    connect some image on first run
    """
    grid = GridForm(screen,"Setting up a disk drives",1,5)
    
def mkradiogroup(choices, current)
def mkradiogroup(choices, current):
    """
    choises is an array of value,text tuples
    current is value, which have to be selected
    """
    rg = RadioGroup()
    rg = RadioBar(screen,map(lambda x: (x[1],x[0],1 if x[0]==current else 0),choices) )
    for choice in choices:
        rg.add(choices[1],choices[0],current=choices[0])
    return rg

def net_brige_conf():
    """
    Choose net bridge based on /etc/qemu/bridge.conf"
    """

96
97
98
99
100
101
102
103

104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120

121
122
123
124
125
126
127
128



129
130
131
132



133
134

135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154

155
156
157
158
159
160
161
94
95
96
97
98
99
100

101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117

118
119
120
121
122
123



124
125
126
127



128
129
130
131

132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151

152
153
154
155
156
157
158
159







-
+
















-
+





-
-
-
+
+
+

-
-
-
+
+
+

-
+



















-
+







        ('tap','Use TAP device'),
        ('user','User mode networking'),
        ('vde','VDE virtual switch')],
        netmode)
    cardlbl = Label("Emulated hardware")    
    cardbox= Listbox(height=6,width=20,scroll=1)
    grid.add(typlbl,0,0,padding=(3,1,3,0))
    grid.add(rg,0,1,padding(3,0,3,0)
    grid.add(rg,0,1,padding=(3,0,3,0))
    grid.add(cardlbl,1,0,padding=(3,1,3,0))
    grid.add(cardbox,1,1,padding=(3,0,3,0))
    prevbtn=Button("<<Back")
    nextbtn=Button("Next>>")
    grid.add(prevbtn,0,2,anchorLeft=1)
    grid.add(nextbtn,1,2,anchorRight=1)
name=''
vmtype='private'
def choose_name():
    """
    Selects name of virtual machine and sharing type
    """
    global name,vmtype
    grid = GridForm(screen,"Choosing name of virtual machine",1,5)
    namelbl=Label("Enter a virtual machine name")
    nameline=Entry(40,text=name)
    shlbl = Lable("Select virtual machine accessability")
    shlbl = Label("Select virtual machine accessability")
    rg = mkradiogroup([('private','Private VM'),('shared','Shared VM'),
                ('auto','AutoStart VM')],vmtype)

    grid.add(namelbl,0,0,padding=(3,1,3,0),anchorLeft=1)
    grid.add(nameline,0,1,padding=(3,0,3,0),anchorLeft=1)
    grid.add(shlbl,0,2,padding=(3,1,3,0),anchorleft=1)
    grid.add(rg,0,3,padding=(3,0,3,0),anchorleft=1)
    prevbtn=Button("<<Back")
    grid.add(shlbl,0,2,padding=(3,1,3,0),anchorLeft=1)
    grid.add(rg,0,3)
    #prevbtn=Button("<<Back")
    nextbtn=Button("Next>>")
    grid.add(prevbtn,0,4,anchorLeft=1)
    grid.add(nextbtn,1,4,anchorRight=1)
    while not name.value():
    #grid.add(prevbtn,0,4,anchorLeft=1)
    grid.add(nextbtn,0,4,anchorRight=1)
    while not nameline.value():
        answer=grid.runOnce()
        if answer == prevbtn or answer == u'ESC':
        if  answer == u'ESC':
            return False
    name = nameline.value()
    vmtype = rg.getSelection()
    return True

wizard=[choose_name,choose_conf,choose_drive,choose_net,None]    

try:
    screen=SnackScreen()
    i=0
    while i<len(wizard):
        if wizard[i]:
            nxt=wizard[i]()
        else:
            nxt=True
        if callable(nxt):
            wizard[i+1] = nxt
        if nxt:
            i+=1
        else 
        else :
            i-=1
        if (i<0):
            sys.exit(1)

finally:
    screen.finish()
with open("start.template","r") as f: