Commit f168f722 authored by Paul John King's avatar Paul John King

Initial commit --

parents
#!/bin/sh
echo_stdin(){
while IFS="" read -r line ;
do
echo "${line}" ;
done ;
} ;
print_usage_message(){
echo_stdin <<- __END_OF_STDIN__
The command call
${0##*/} <domain> <cpu_count> <ram> <image> <bridge>
creates a KVM domain <domain> with <cpu_count> CPUs, <ram> MiB of RAM, the
file-system image <image>, and a connection to the bridge device <bridge>.
__END_OF_STDIN__
} ;
print_xml(){
local _DOMAIN="${1}" ;
local _CPU_COUNT="${2}" ;
local _RAM="${3}" ;
local _IMAGE="${4}" ;
local _BRIDGE="${5}" ;
shift 5 ;
echo_stdin <<- __END_OF_STDIN__
<domain type='kvm'>
<name>${_DOMAIN}</name>
<vcpu>${_CPU_COUNR}</vcpu>
<memory unit='MiB'>${_RAM}</memory>
<resource>
<partition>/machine</partition>
</resource>
<os>
<type arch='x86_64'>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>
<disk type='file' device='disk'>
<source file='${_IMAGE}'/>
<target dev='vda' bus='virtio'/>
<driver name='qemu' type='qcow2'/>
</disk>
<controller type='pci' model='pci-root'/>
<controller type='ide'/>
<interface type='bridge'>
<source bridge='${_BRIDGE}'/>
<model type='virtio'/>
</interface>
<serial type='pty'/>
<console type='pty'/>
<graphics type='vnc'>
<listen type='address' address='127.0.0.1'/>
</graphics>
<memballoon model='virtio'/>
</devices>
</domain>
__END_OF_STDIN__
} ;
if test $# != 5 ;
then
print_usage_message >&2 ;
exit 1 ;
fi ;
DOMAIN="${1}" ;
CPU_COUNT="${2}" ;
RAM="${3}" ;
IMAGE="${4}" ;
BRIDGE="${5}" ;
shift 5 ;
print_xml "${DOMAIN}" "${CPU_COUNT}" "${RAM}" "${IMAGE}" "${BRIDGE}" |
virsh -q define "/dev/stdin" ;
#!/bin/sh
echo_stdin(){
while IFS="" read -r line ;
do
echo "${line}" ;
done ;
} ;
print_usage_message(){
echo_stdin <<- __END_OF_STDIN__
The command call
${0##*/} <domain> <cpu_count> <ram> <image> <bridge>
creates a KVM domain <domain> with <cpu_count> CPUs, <ram> MiB of RAM, an
eponymous qcow2 storage volume in the 'default' storage pool with the qcow2
file-system image <image> as its backing storage volume, and a connection to
the bridge device <bridge>.
__END_OF_STDIN__
} ;
if test $# != 5 ;
then
print_usage_message >&2 ;
exit 1 ;
fi ;
DOMAIN="${1}" ;
CPU_COUNT="${2}" ;
RAM="${3}" ;
IMAGE="${4}" ;
BRIDGE="${5}" ;
shift 5 ;
POOL="default" ;
create_volume "${DOMAIN}" "${POOL}" "${IMAGE}" &&
path=$(get_image "${DOMAIN}" "${POOL}") &&
create_domain "${DOMAIN}" "${CPU_COUNT}" "${RAM}" "${PATH}" "${BRIDGE}" ;
#!/bin/sh
echo_stdin(){
while IFS="" read -r line ;
do
echo "${line}" ;
done ;
} ;
print_usage_message(){
echo_stdin <<- __END_OF_STDIN__
The command call
${0##*/} <pool> <directory>
creates a directory-type storage pool <pool> under the directory <directory>.
__END_OF_STDIN__
} ;
print_xml(){
local _POOL="${1}" ;
local _DIRECTORY="${2}" ;
shift 2 ;
echo_stdin <<- __END_OF_STDIN__
<pool type="dir">
<name>${_POOL}</name>
<target>
<path>${_DIRECTORY}</path>
</target>
</pool>
__END_OF_STDIN__
} ;
if test $# != 2 ;
then
print_usage_message >&2 ;
exit 1 ;
fi ;
POOL="${1}" ;
DIRECTORY="${2}" ;
shift 2 ;
print_xml "${POOL}" "${DIRECTORY}" |
virsh -q pool-define "/dev/stdin" &&
virsh -q pool-autostart "${POOL}" &&
virsh -q pool-start "${POOL}" ;
#!/bin/sh
echo_stdin(){
while IFS="" read -r line ;
do
echo "${line}" ;
done ;
} ;
print_usage_message(){
echo_stdin <<- __END_OF_STDIN__
The command call
${0##*/} <volume> <pool> <image>
creates a qcow2 storage volume <volume> in the storage pool <pool> with the
qcow2 file-system image <image> as its backing storage volume.
__END_OF_STDIN__
} ;
print_xml(){
local _VOLUME="${1}" ;
local _IMAGE="${2}" ;
shift 2 ;
echo_stdin <<- __END_OF_STDIN__
<volume type='file'>
<name>${_VOLUME}</name>
<target>
<format type='qcow2'/>
<compat>1.1</compat>
</target>
<backingStore>
<path>${_IMAGE}</path>
<format type='qcow2'/>
</backingStore>
</volume>
__END_OF_STDIN__
} ;
if test $# != 3 ;
then
print_usage_message >&2 ;
exit 1 ;
fi ;
VOLUME="${1}" ;
POOL="${2}" ;
IMAGE="${3}" ;
shift 3 ;
print_xml "${VOLUME}" "${IMAGE}" |
virsh -q vol-create "${POOL}" "/dev/stdin" ;
#!/bin/sh
echo_stdin(){
while IFS="" read -r line ;
do
echo "${line}" ;
done ;
} ;
print_usage_message() {
echo_stdin <<- __END_OF_STDIN__
The command call
${0##*/} <domain>
destroys the domain <domain>, as well as any managed save image and snapshots.
If the domain is running then it continues to run but will be destroyed when
stopped.
__END_OF_STDIN__
} ;
if test $# != 1 ;
then
print_usage_message >&2 ;
exit 1 ;
fi ;
DOMAIN="${1}" ;
shift 1 ;
virsh -q undefine "${DOMAIN}" --managed-save --snapshots-metadata ;
#!/usr/bin/env bash
echo_stdin(){
while IFS="" read -r line ;
do
echo "${line}" ;
done ;
} ;
print_usage_message() {
echo_stdin <<- __END_OF_STDIN__
The command call
${0##*/} <domain> <pool>
destroys the domain <domain> and its eponymous volume in the 'default' storage
pool.
__END_OF_STDIN__
} ;
if test $# != 1 ;
then
print_usage_message >&2 ;
exit 1 ;
fi ;
DOMAIN="${1}" ;
shift 1 ;
POOL="default" ;
destroy_domain "${DOMAIN}" &&
destroy_volume "${DOMAIN}" "${POOL}" ;
#!/bin/sh
echo_stdin(){
while IFS="" read -r line ;
do
echo "${line}" ;
done ;
} ;
print_usage_message(){
echo_stdin <<- __END_OF_STDIN__
The command call
${0##*/} <pool>
destroys the storage pool <pool>.
__END_OF_STDIN__
} ;
if test $# != 1 ;
then
print_usage_message >&2 ;
exit 1 ;
fi ;
POOL="${1}" ;
shift 1 ;
virsh -q pool-destroy "${POOL}" &&
virsh -q pool-undefine "${POOL}" ;
#!/bin/sh
echo_stdin(){
while IFS="" read -r line ;
do
echo "${line}" ;
done ;
} ;
print_usage_message() {
echo_stdin <<- __END_OF_STDIN__
The command call
${0##*/} <volume> <pool>
destroys the storage volume <volume> in the storage pool <pool>.
__END_OF_STDIN__
} ;
if test $# != 2 ;
then
print_usage_message >&2 ;
exit 1 ;
fi ;
VOLUME="${1}" ;
POOL="${2}" ;
shift 2 ;
virsh -q vol-delete "${VOLUME}" --pool "${POOL}" ;
#!/bin/sh
echo_stdin(){
while IFS="" read -r line ;
do
echo "${line}" ;
done ;
} ;
print_usage_message(){
echo_stdin <<- __END_OF_STDIN__
The command call
${0##*/} <volume> <pool>
outputs the location of the file-system image of the storage volume <volume> in
the storage pool <pool>.
__END_OF_STDIN__
} ;
if test $# != 2 ;
then
print_usage_message >&2 ;
exit 1 ;
fi ;
VOLUME="${1}" ;
POOL="${2}" ;
shift 2 ;
virsh -q vol-path "${VOLUME}" --pool "${POOL}" ;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment