summaryrefslogtreecommitdiffstats
path: root/zarb-ml/mageia-sysadm/attachments/20110330/35cf881a
diff options
context:
space:
mode:
Diffstat (limited to 'zarb-ml/mageia-sysadm/attachments/20110330/35cf881a')
-rw-r--r--zarb-ml/mageia-sysadm/attachments/20110330/35cf881a/attachment-0001.py98
-rw-r--r--zarb-ml/mageia-sysadm/attachments/20110330/35cf881a/attachment.py98
2 files changed, 196 insertions, 0 deletions
diff --git a/zarb-ml/mageia-sysadm/attachments/20110330/35cf881a/attachment-0001.py b/zarb-ml/mageia-sysadm/attachments/20110330/35cf881a/attachment-0001.py
new file mode 100644
index 000000000..5b26edab2
--- /dev/null
+++ b/zarb-ml/mageia-sysadm/attachments/20110330/35cf881a/attachment-0001.py
@@ -0,0 +1,98 @@
+#!/usr/bin/python
+import libvirt
+import sys
+
+c = libvirt.open("qemu:///system")
+s = c.storagePoolLookupByName('default')
+
+mac_counter = 0
+for wm in ['kde','gnome','lxde']:
+ for arch in ['i686','x86_64']:
+ mac_counter += 1
+
+ name = 'mandriva_%s_%s' % (wm,arch)
+ # clean previous vm
+ if name in c.listDefinedDomains():
+ c.lookupByName(name).undefine()
+
+ boot = '/var/lib/libvirt/netboot/'
+ if arch == 'i686':
+ boot += 'mandriva_2010.1_i586_boot.iso'
+ else:
+ boot += 'mandriva_2010.1_x86_64_boot.iso'
+
+ # faire un pool
+ vol_xml = """
+<volume>
+ <name>%s.img</name>
+ <capacity unit='G'>5</capacity>
+ <target>
+ <format type='raw'/>
+ <permissions>
+ <owner>0</owner>
+ <group>0</group>
+ <mode>0744</mode>
+ </permissions>
+ </target>
+</volume>""" % name
+ if name + ".img" in s.listVolumes():
+ s.storageVolLookupByName(name + ".img").delete(0)
+ v = s.createXML(vol_xml, 0)
+
+ vm_xml = """
+<domain type='kvm'>
+ <name>%s</name>
+ <memory>1048576</memory>
+ <currentMemory>1048576</currentMemory>
+ <vcpu>1</vcpu>
+ <os>
+ <type arch='%s' machine='pc-0.12'>hvm</type>
+ <boot dev='hd'/>
+ <boot dev='cdrom'/>
+ </os>
+ <features>
+ <pae/>
+ </features>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>restart</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-kvm</emulator>
+ <disk type='file' device='disk'>
+ <driver name='qemu' type='raw'/>
+ <source file='/var/lib/libvirt/images/%s.img'/>
+ <target dev='hda' bus='ide'/>
+ </disk>
+ <disk type='file' device='cdrom'>
+ <driver name='qemu' type='raw'/>
+ <source file='%s'/>
+ <target dev='hdc' bus='ide'/>
+ <readonly/>
+ <address type='drive' controller='0' bus='1' unit='0'/>
+ </disk>
+ <controller type='ide' index='0'/>
+ <interface type='network'>
+ <mac address='52:54:00:8b:0a:%02i'/>
+ <source network='default'/>
+ </interface>
+ <serial type='pty'>
+ <target port='0'/>
+ </serial>
+ <console type='pty'>
+ <target type='serial' port='0'/>
+ </console>
+ <input type='mouse' bus='ps2'/>
+ <graphics type='vnc' port='-1' autoport='yes'/>
+ <video>
+ <model type='cirrus' vram='9216' heads='1'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
+ </video>
+ <memballoon model='virtio'>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
+ </memballoon>
+ </devices>
+</domain>""" % ( name, arch, name, boot, mac_counter )
+ c.defineXML(vm_xml)
+ print name + " created"
+
diff --git a/zarb-ml/mageia-sysadm/attachments/20110330/35cf881a/attachment.py b/zarb-ml/mageia-sysadm/attachments/20110330/35cf881a/attachment.py
new file mode 100644
index 000000000..5b26edab2
--- /dev/null
+++ b/zarb-ml/mageia-sysadm/attachments/20110330/35cf881a/attachment.py
@@ -0,0 +1,98 @@
+#!/usr/bin/python
+import libvirt
+import sys
+
+c = libvirt.open("qemu:///system")
+s = c.storagePoolLookupByName('default')
+
+mac_counter = 0
+for wm in ['kde','gnome','lxde']:
+ for arch in ['i686','x86_64']:
+ mac_counter += 1
+
+ name = 'mandriva_%s_%s' % (wm,arch)
+ # clean previous vm
+ if name in c.listDefinedDomains():
+ c.lookupByName(name).undefine()
+
+ boot = '/var/lib/libvirt/netboot/'
+ if arch == 'i686':
+ boot += 'mandriva_2010.1_i586_boot.iso'
+ else:
+ boot += 'mandriva_2010.1_x86_64_boot.iso'
+
+ # faire un pool
+ vol_xml = """
+<volume>
+ <name>%s.img</name>
+ <capacity unit='G'>5</capacity>
+ <target>
+ <format type='raw'/>
+ <permissions>
+ <owner>0</owner>
+ <group>0</group>
+ <mode>0744</mode>
+ </permissions>
+ </target>
+</volume>""" % name
+ if name + ".img" in s.listVolumes():
+ s.storageVolLookupByName(name + ".img").delete(0)
+ v = s.createXML(vol_xml, 0)
+
+ vm_xml = """
+<domain type='kvm'>
+ <name>%s</name>
+ <memory>1048576</memory>
+ <currentMemory>1048576</currentMemory>
+ <vcpu>1</vcpu>
+ <os>
+ <type arch='%s' machine='pc-0.12'>hvm</type>
+ <boot dev='hd'/>
+ <boot dev='cdrom'/>
+ </os>
+ <features>
+ <pae/>
+ </features>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>restart</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-kvm</emulator>
+ <disk type='file' device='disk'>
+ <driver name='qemu' type='raw'/>
+ <source file='/var/lib/libvirt/images/%s.img'/>
+ <target dev='hda' bus='ide'/>
+ </disk>
+ <disk type='file' device='cdrom'>
+ <driver name='qemu' type='raw'/>
+ <source file='%s'/>
+ <target dev='hdc' bus='ide'/>
+ <readonly/>
+ <address type='drive' controller='0' bus='1' unit='0'/>
+ </disk>
+ <controller type='ide' index='0'/>
+ <interface type='network'>
+ <mac address='52:54:00:8b:0a:%02i'/>
+ <source network='default'/>
+ </interface>
+ <serial type='pty'>
+ <target port='0'/>
+ </serial>
+ <console type='pty'>
+ <target type='serial' port='0'/>
+ </console>
+ <input type='mouse' bus='ps2'/>
+ <graphics type='vnc' port='-1' autoport='yes'/>
+ <video>
+ <model type='cirrus' vram='9216' heads='1'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
+ </video>
+ <memballoon model='virtio'>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
+ </memballoon>
+ </devices>
+</domain>""" % ( name, arch, name, boot, mac_counter )
+ c.defineXML(vm_xml)
+ print name + " created"
+