Virtual Machine script

Source: Internet
Author: User

#! /Bin/bash

Case "$1" in

Start)

Virsh start $2

Echo starting $2

;;

View)

Virt-Viewer $2

Echo viewing $2

;;

Shutdown)

Virsh shutdown $2

Echo being shutdown $2

;;

Destroy)

Virsh destroy $2

Echo being destroy $2

;;

Restart)

Echo poweroff $2...

Virsh destroy $2 &>/dev/null

Echo del $ 1.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 created $3 successful !!!

;;

*)

Echo "Please input exactly ."

Esac


Virtual Machine script

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.