[背景]最近事情特别多,前段时间搞搞openstack,发现过与复杂,就想把KVM先好好学学,再过来搞它.因为工作关系,又用twisted开发了一个c/s的监控程序,但因还没有写完,所以暂时没有发出来.如果不是强逼自己,我想我这个工具,也可能需要再等几日才能发布吧.扯远了,先不说这些,就说我这款工具能干嘛吧.简单的说就像openstack的镜像功能一般,不过,人家是提供Web Gui,点两下就OK了,我这需要修改下配置文件vm.ini,不过它那个点两下,不一定OK噢,反正我试过,没那么灵光.我的配置文件很简单,就是告诉我是添加还是删除虚拟机,如果添加则需要告诉模板镜像文件在哪?模板xml文件在哪.当然这些都是要定义好的.也就是提前将镜像文件做好嘛.openstack的glance也是需要的嘛.
[过程]
(1)安装模板系统
略
(2)将模板img文件和xml文件分别copy到/template/img,/template/xml下,当然,你也可以更改,不过,程序也需要做修改.
(3)修改vm.ini文件
参考
模板xml文件
more /template/xml/Template_CentOS55x64_LAMP.xml
<!--
WARNING: THIS IS AN AUTO-GENERATED FILE. CHANGES TO IT ARE LIKELY TO BE
OVERWRITTEN AND LOST. Changes to this xml configuration should be made using:
virsh edit Template_Centos55x64_LAMP
or other application using the libvirt API.
-->
<domain type='kvm'>
<name>Template_Centos55x64_LAMP</name>
<uuid>e7bbc1b0-e9b1-a0f2-bd1e-dd9f3fd48823</uuid>
<memory unit='KiB'>524288</memory>
<currentMemory unit='KiB'>524288</currentMemory>
<vcpu placement='static'>2</vcpu>
<os>
<type arch='x86_64' machine='rhel6.3.0'>hvm</type>
<boot dev='hd'/>
</os>
<features>
<acpi/>
<apic/>
<pae/>
</features>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<devices>
<emulator>/usr/libexec/qemu-kvm</emulator>
<disk type='file' device='disk'>
<driver type='raw'/>
<source file='/var/lib/libvirt/images/Template_Centos55x64_LAMP.img'/>
<target dev='hda' bus='ide'/>
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
</disk>
<interface type='bridge'>
<mac address='52:54:00:88:d0:51'/>
<source bridge='br0'/>
<model type='virtio'/>
</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'/>
</video>
</devices>
</domain>