标签:虚拟机脚本
#!/bin/bash
case "$1" in
start)
virsh start $2
;;
view)
virt-viewer $2&>/dev/null
;;
poweroff)
virsh shutdown $2
;;
stop)
virsh destroy $2
;;
restart)
virsh reboot $2
;;
delete)
virsh undefine $2 #删除前端管理不删除存储
;;
create)
virt-install \
--name $2 \
--ram 1000 \
--file/var/lib/libvirt/images/$2.qcow2 \
--file-size 8 \
--cdrom/home/kiosk/Desktop/rhel-server-7.1-x86_64-dvd.iso &
;;
reset)
qemu-img create -f qcow2 -b/var/lib/libvirt/images/$2.qcow2 /var/lib/libvirt/images/node.qcow2&>/dev/null
virt-install \
--name node \
--ram 1000 \
--file/var/lib/libvirt/images/node.qcow2 \
--import
echo node.qcow2 created
;;
*)
echo ERROR
esac
本文出自 “12049878” 博客,转载请与作者联系!
标签:虚拟机脚本
原文地址:http://12059878.blog.51cto.com/12049878/1863525