码迷,mamicode.com
首页 > 其他好文 > 详细

vm脚本文件

时间:2016-10-19 14:24:42      阅读:177      评论:0      收藏:0      [点我收藏+]

标签:create   start   null   

#!/bin/bash
case $1 in
    "view")
        echo "view the $2"
        virsh-viewer $2
        ;;
    "start")
        virsh start $2
        echo "start the $2"
        ;;
    "shutdown")
        virsh start $2 &
        echo "shutdown the $2"
        ;;
    "destroy")
        virsh destroy $2 &
        echo "destroy the $2"
        ;;
    "reset")
        echo poweroff $2 ...
        virsh destroy $2 &>/dev/null
        echo del $2.xml ...
        virsh undefine $2 &> /dev/null
        echo create disk ...
        qemu-img create -f qcow2 -b /var/lib/libvirt/images/$2.qcow2 /var/lib/libvirt/images/$3.qcow2 &> /dev/null
        echo create $2 vm ...
        virt-install \
        --name $3 \
        --ram 1000 \
        --disk /var/lib/libvirt/images/$3.qcow2 \
        --import &> /dev/null &
        echo Reset Successful!
        ;;
    "")
        echo "You must input parameters!"
        ;;
esac

vm脚本文件

标签:create   start   null   

原文地址:http://12114576.blog.51cto.com/12104576/1863359

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!