cc1
v2.1
CC1 source code docs
Main Page
Related Pages
Packages
Classes
Files
File List
All
Classes
Namespaces
Files
Functions
Variables
Pages
s002_create_services.py
Go to the documentation of this file.
1
# -*- coding: utf-8 -*-
2
# @COPYRIGHT_begin
3
#
4
# Copyright [2010-2014] Institute of Nuclear Physics PAN, Krakow, Poland
5
#
6
# Licensed under the Apache License, Version 2.0 (the "License");
7
# you may not use this file except in compliance with the License.
8
# You may obtain a copy of the License at
9
#
10
# http://www.apache.org/licenses/LICENSE-2.0
11
#
12
# Unless required by applicable law or agreed to in writing, software
13
# distributed under the License is distributed on an "AS IS" BASIS,
14
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
# See the License for the specific language governing permissions and
16
# limitations under the License.
17
#
18
# @COPYRIGHT_end
19
20
from
settings
import
SERVICES_TMP, BASIC_IMAGE, SSH_KEY, SYSTEM_VERSION
21
import
os
22
23
# Prepare vm definitions
24
wi =
"""<domain type='qemu'>
25
<name>wi</name>
26
<memory>262144</memory>
27
<currentMemory>262144</currentMemory>
28
<vcpu>1</vcpu>
29
<os>
30
<type arch='x86_64' machine='pc'>hvm</type>
31
<boot dev='hd'/>
32
</os>
33
<features>
34
<acpi/>
35
<apic/>
36
<pae/>
37
</features>
38
<clock offset='utc'/>
39
<on_poweroff>destroy</on_poweroff>
40
<on_reboot>restart</on_reboot>
41
<on_crash>restart</on_crash>
42
<devices>
43
<emulator>/usr/bin/qemu-system-x86_64</emulator>
44
<disk type='file' device='disk'>
45
<driver name='qemu' type='qcow2'/>
46
<source file='%s/wi.qcow'/>
47
<target dev='hda' bus='ide'/>
48
<address type='drive' controller='0' bus='0' unit='0'/>
49
</disk>
50
<controller type='ide' index='0'>
51
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
52
</controller>
53
<interface type='network'>
54
<mac address='00:00:00:00:01:02'/>
55
<source network='wi_clm'/>
56
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
57
</interface>
58
<serial type='pty'>
59
<target port='0'/>
60
</serial>
61
<console type='pty'>
62
<target type='serial' port='0'/>
63
</console>
64
<input type='mouse' bus='ps2'/>
65
<graphics type='vnc' port='5900'/>
66
<video>
67
<model type='cirrus' vram='9216' heads='1'/>
68
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
69
</video>
70
<memballoon model='virtio'>
71
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
72
</memballoon>
73
</devices>
74
</domain>"""
% SERVICES_TMP
75
76
clm =
"""<domain type='qemu'>
77
<name>clm</name>
78
<memory>262144</memory>
79
<currentMemory>262144</currentMemory>
80
<vcpu>1</vcpu>
81
<os>
82
<type arch='x86_64' machine='pc'>hvm</type>
83
<boot dev='hd'/>
84
</os>
85
<features>
86
<acpi/>
87
<apic/>
88
<pae/>
89
</features>
90
<clock offset='utc'/>
91
<on_poweroff>destroy</on_poweroff>
92
<on_reboot>restart</on_reboot>
93
<on_crash>restart</on_crash>
94
<devices>
95
<emulator>/usr/bin/qemu-system-x86_64</emulator>
96
<disk type='file' device='disk'>
97
<driver name='qemu' type='qcow2'/>
98
<source file='%s/clm.qcow'/>
99
<target dev='hda' bus='ide'/>
100
<address type='drive' controller='0' bus='0' unit='0'/>
101
</disk>
102
<controller type='ide' index='0'>
103
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
104
</controller>
105
<interface type='network'>
106
<mac address='00:00:00:00:01:03'/>
107
<source network='wi_clm'/>
108
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
109
</interface>
110
<interface type='network'>
111
<mac address='00:00:00:00:02:02'/>
112
<source network='clm_cm'/>
113
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
114
</interface>
115
<serial type='pty'>
116
<target port='0'/>
117
</serial>
118
<console type='pty'>
119
<target type='serial' port='0'/>
120
</console>
121
<input type='mouse' bus='ps2'/>
122
<graphics type='vnc' port='5901'/>
123
<video>
124
<model type='cirrus' vram='9216' heads='1'/>
125
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
126
</video>
127
<memballoon model='virtio'>
128
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
129
</memballoon>
130
</devices>
131
</domain>"""
% SERVICES_TMP
132
133
cm =
"""<domain type='qemu'>
134
<name>cm</name>
135
<memory>262144</memory>
136
<currentMemory>262144</currentMemory>
137
<vcpu>1</vcpu>
138
<os>
139
<type arch='x86_64' machine='pc'>hvm</type>
140
<boot dev='hd'/>
141
</os>
142
<features>
143
<acpi/>
144
<apic/>
145
<pae/>
146
</features>
147
<clock offset='utc'/>
148
<on_poweroff>destroy</on_poweroff>
149
<on_reboot>restart</on_reboot>
150
<on_crash>restart</on_crash>
151
<devices>
152
<emulator>/usr/bin/qemu-system-x86_64</emulator>
153
<disk type='file' device='disk'>
154
<driver name='qemu' type='qcow2'/>
155
<source file='%s/cm.qcow'/>
156
<target dev='hda' bus='ide'/>
157
<address type='drive' controller='0' bus='0' unit='0'/>
158
</disk>
159
<controller type='ide' index='0'>
160
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
161
</controller>
162
<interface type='network'>
163
<mac address='00:00:00:00:02:03'/>
164
<source network='clm_cm'/>
165
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
166
</interface>
167
<interface type='network'>
168
<mac address='00:00:00:00:03:02'/>
169
<source network='cm_cluster'/>
170
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
171
</interface>
172
<serial type='pty'>
173
<target port='0'/>
174
</serial>
175
<console type='pty'>
176
<target type='serial' port='0'/>
177
</console>
178
<input type='mouse' bus='ps2'/>
179
<graphics type='vnc' port='5902'/>
180
<video>
181
<model type='cirrus' vram='9216' heads='1'/>
182
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
183
</video>
184
<memballoon model='virtio'>
185
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
186
</memballoon>
187
</devices>
188
</domain>"""
% SERVICES_TMP
189
190
rm =
"""<domain type='qemu'>
191
<name>rm</name>
192
<memory>262144</memory>
193
<currentMemory>262144</currentMemory>
194
<vcpu>1</vcpu>
195
<os>
196
<type arch='x86_64' machine='pc'>hvm</type>
197
<boot dev='hd'/>
198
</os>
199
<features>
200
<acpi/>
201
<apic/>
202
<pae/>
203
</features>
204
<clock offset='utc'/>
205
<on_poweroff>destroy</on_poweroff>
206
<on_reboot>restart</on_reboot>
207
<on_crash>restart</on_crash>
208
<devices>
209
<emulator>/usr/bin/qemu-system-x86_64</emulator>
210
<disk type='file' device='disk'>
211
<driver name='qemu' type='qcow2'/>
212
<source file='%s/rm.qcow'/>
213
<target dev='hda' bus='ide'/>
214
<address type='drive' controller='0' bus='0' unit='0'/>
215
</disk>
216
<controller type='ide' index='0'>
217
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
218
</controller>
219
<interface type='network'>
220
<mac address='00:00:00:00:03:03'/>
221
<source network='cm_cluster'/>
222
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
223
</interface>
224
<serial type='pty'>
225
<target port='0'/>
226
</serial>
227
<console type='pty'>
228
<target type='serial' port='0'/>
229
</console>
230
<input type='mouse' bus='ps2'/>
231
<graphics type='vnc' port='5903'/>
232
<video>
233
<model type='cirrus' vram='9216' heads='1'/>
234
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
235
</video>
236
<memballoon model='virtio'>
237
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
238
</memballoon>
239
</devices>
240
</domain>"""
% SERVICES_TMP
241
242
node =
"""<domain type='qemu'>
243
<name>node%(node)s</name>
244
<memory>262144</memory>
245
<currentMemory>262144</currentMemory>
246
<vcpu>1</vcpu>
247
<os>
248
<type arch='x86_64' machine='pc'>hvm</type>
249
<boot dev='hd'/>
250
</os>
251
<features>
252
<acpi/>
253
<apic/>
254
<pae/>
255
</features>
256
<clock offset='utc'/>
257
<on_poweroff>destroy</on_poweroff>
258
<on_reboot>restart</on_reboot>
259
<on_crash>restart</on_crash>
260
<devices>
261
<emulator>/usr/bin/qemu-system-x86_64</emulator>
262
<disk type='file' device='disk'>
263
<driver name='qemu' type='qcow2'/>
264
<source file='%(tmp)s/node%(node)s.qcow'/>
265
<target dev='hda' bus='ide'/>
266
<address type='drive' controller='0' bus='0' unit='0'/>
267
</disk>
268
<controller type='ide' index='0'>
269
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
270
</controller>
271
<interface type='network'>
272
<mac address='00:00:00:00:03:%(node)s'/>
273
<source network='cm_cluster'/>
274
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
275
</interface>
276
<serial type='pty'>
277
<target port='0'/>
278
</serial>
279
<console type='pty'>
280
<target type='serial' port='0'/>
281
</console>
282
<input type='mouse' bus='ps2'/>
283
<graphics type='vnc' port='59%(node)s'/>
284
<video>
285
<model type='cirrus' vram='9216' heads='1'/>
286
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
287
</video>
288
<memballoon model='virtio'>
289
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
290
</memballoon>
291
</devices>
292
</domain>"""
293
294
open(
'%s/wi.xml'
% SERVICES_TMP,
'w'
).write(wi)
295
open(
'%s/clm.xml'
% SERVICES_TMP,
'w'
).write(clm)
296
open(
'%s/cm.xml'
% SERVICES_TMP,
'w'
).write(cm)
297
open(
'%s/rm.xml'
% SERVICES_TMP,
'w'
).write(rm)
298
open(
'%s/node04.xml'
% SERVICES_TMP,
'w'
).write(node % {
'node'
:
'04'
,
'tmp'
: SERVICES_TMP})
299
open(
'%s/node05.xml'
% SERVICES_TMP,
'w'
).write(node % {
'node'
:
'05'
,
'tmp'
: SERVICES_TMP,
'vnc'
: 59})
300
301
actions = []
302
303
# Prepare vm images
304
actions.append({
'type'
:
'exec'
,
305
'command'
:
'qemu-img'
,
306
'args'
: [
'create'
,
'-o'
,
'backing_fmt=raw,backing_file=%s'
% BASIC_IMAGE,
'-f'
,
'qcow2'
,
'%s/wi.qcow'
% SERVICES_TMP]})
307
actions.append({
'type'
:
'exec'
,
308
'command'
:
'qemu-img'
,
309
'args'
: [
'create'
,
'-o'
,
'backing_fmt=raw,backing_file=%s'
% BASIC_IMAGE,
'-f'
,
'qcow2'
,
'%s/clm.qcow'
% SERVICES_TMP]})
310
actions.append({
'type'
:
'exec'
,
311
'command'
:
'qemu-img'
,
312
'args'
: [
'create'
,
'-o'
,
'backing_fmt=raw,backing_file=%s'
% BASIC_IMAGE,
'-f'
,
'qcow2'
,
'%s/cm.qcow'
% SERVICES_TMP]})
313
actions.append({
'type'
:
'exec'
,
314
'command'
:
'qemu-img'
,
315
'args'
: [
'create'
,
'-o'
,
'backing_fmt=raw,backing_file=%s'
% BASIC_IMAGE,
'-f'
,
'qcow2'
,
'%s/rm.qcow'
% SERVICES_TMP]})
316
actions.append({
'type'
:
'exec'
,
317
'command'
:
'qemu-img'
,
318
'args'
: [
'create'
,
'-o'
,
'backing_fmt=raw,backing_file=%s'
% BASIC_IMAGE,
'-f'
,
'qcow2'
,
'%s/node04.qcow'
% SERVICES_TMP]})
319
actions.append({
'type'
:
'exec'
,
320
'command'
:
'qemu-img'
,
321
'args'
: [
'create'
,
'-o'
,
'backing_fmt=raw,backing_file=%s'
% BASIC_IMAGE,
'-f'
,
'qcow2'
,
'%s/node05.qcow'
% SERVICES_TMP]})
322
323
# Chmod images
324
actions.append({
'type'
:
'exec'
,
325
'command'
:
'chmod'
,
326
'args'
: [
'a+rw'
,
'%s/wi.qcow'
% SERVICES_TMP]})
327
actions.append({
'type'
:
'exec'
,
328
'command'
:
'chmod'
,
329
'args'
: [
'a+rw'
,
'%s/clm.qcow'
% SERVICES_TMP]})
330
actions.append({
'type'
:
'exec'
,
331
'command'
:
'chmod'
,
332
'args'
: [
'a+rw'
,
'%s/cm.qcow'
% SERVICES_TMP]})
333
actions.append({
'type'
:
'exec'
,
334
'command'
:
'chmod'
,
335
'args'
: [
'a+rw'
,
'%s/rm.qcow'
% SERVICES_TMP]})
336
actions.append({
'type'
:
'exec'
,
337
'command'
:
'chmod'
,
338
'args'
: [
'a+rw'
,
'%s/node04.qcow'
% SERVICES_TMP]})
339
actions.append({
'type'
:
'exec'
,
340
'command'
:
'chmod'
,
341
'args'
: [
'a+rw'
,
'%s/node05.qcow'
% SERVICES_TMP]})
342
343
# Create new machines with cc1 services
344
actions.append({
'type'
:
'exec'
,
345
'command'
:
'virsh'
,
346
'args'
: [
'-c'
,
'qemu:///system'
,
'create'
,
'%s/wi.xml'
% SERVICES_TMP]})
347
348
actions.append({
'type'
:
'exec'
,
349
'command'
:
'virsh'
,
350
'args'
: [
'-c'
,
'qemu:///system'
,
'create'
,
'%s/clm.xml'
% SERVICES_TMP]})
351
352
actions.append({
'type'
:
'exec'
,
353
'command'
:
'virsh'
,
354
'args'
: [
'-c'
,
'qemu:///system'
,
'create'
,
'%s/cm.xml'
% SERVICES_TMP]})
355
356
actions.append({
'type'
:
'exec'
,
357
'command'
:
'virsh'
,
358
'args'
: [
'-c'
,
'qemu:///system'
,
'create'
,
'%s/rm.xml'
% SERVICES_TMP]})
359
360
actions.append({
'type'
:
'exec'
,
361
'command'
:
'virsh'
,
362
'args'
: [
'-c'
,
'qemu:///system'
,
'create'
,
'%s/node04.xml'
% SERVICES_TMP]})
363
364
actions.append({
'type'
:
'exec'
,
365
'command'
:
'virsh'
,
366
'args'
: [
'-c'
,
'qemu:///system'
,
'create'
,
'%s/node05.xml'
% SERVICES_TMP]})
367
clm
old-tests
scripts
s002_create_services.py
Generated on Wed Jun 18 2014 13:32:54 for cc1 by
1.8.1.2