Commit 9a10240d authored by Paul John King's avatar Paul John King

Made variable names a little more consistent --

WARNING: Not properly tested yet!
parent 94716e54
......@@ -215,13 +215,12 @@ print_domain_usage_message(){
create_domain(){
local OPTIND=1 ;
local _mac_address="" ;
while getopts ":m:" OPTION ;
do
case "${OPTION}" in
"m")
_mac_address="${OPTARG}" ;
local _MAC_ADDRESS="${OPTARG}" ;
;;
"?")
echo "The command-line option '-${OPTARG}' is invalid." >&2 ;
......@@ -240,7 +239,7 @@ create_domain(){
local _NAME="${1}" ;
local _CPU_COUNT="${2}" ;
local _RAM="${3}" ;
local _IMAGE="${4}" ;
local _PATH="${4}" ;
local _BRIDGE="${5}" ;
shift 5 ;
......@@ -270,14 +269,14 @@ create_domain(){
<on_crash>restart</on_crash>
<devices>
<disk type='file' device='disk'>
<source file='${_IMAGE}'/>
<source file='${_PATH}'/>
<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}'/>${_mac_address:+<mac address='${_mac_address}'/>}
<source bridge='${_BRIDGE}'/>${_MAC_ADDRESS:+<mac address='${_MAC_ADDRESS}'/>}
<model type='virtio'/>
</interface>
<serial type='pty'/>
......@@ -302,7 +301,7 @@ examine_domain(){
local _interface_xml ;
local _cpu_count ;
local _ram ;
local _image ;
local _path ;
local _mac_address ;
if _domain_xml=$(virsh -q dumpxml "${_NAME}" 2> /dev/null) ;
......@@ -317,13 +316,13 @@ examine_domain(){
_cpu_count=$(_get_content_by_tag_from_xml "${_domain_xml}" "vcpu") ;
_ram=$(_get_content_by_tag_from_xml "${_domain_xml}" "memory") ;
_ram_units=$(_get_value_by_tag_and_attribute_from_xml "${_domain_xml}" "memory" "unit") ;
_image=$(_get_value_by_tag_and_attribute_from_xml "${_disk_vda_xml}" "source" "file") ;
_path=$(_get_value_by_tag_and_attribute_from_xml "${_disk_vda_xml}" "source" "file") ;
_bridge=$(_get_value_by_tag_and_attribute_from_xml "${_interface_xml}" "source" "bridge") ;
_mac_address=$(_get_value_by_tag_and_attribute_from_xml "${_interface_xml}" "mac" "address") ;
echo "CPU count: ${_cpu_count}" ;
echo "RAM: ${_ram} ${_ram_units}" ;
echo "Image: ${_image}" ;
echo "Path: ${_path}" ;
echo "Bridge: ${_bridge}" ;
echo "MAC address: ${_mac_address}" ;
......@@ -361,7 +360,7 @@ verify_domain(){
local _NAME="${1}" ;
local _CPU_COUNT="${2}" ;
local _RAM="${3}" ;
local _IMAGE="${4}" ;
local _PATH="${4}" ;
local _BRIDGE="${5}" ;
shift 5 ;
......@@ -370,7 +369,7 @@ verify_domain(){
local _interface_xml ;
local _cpu_count ;
local _ram ;
local _image ;
local _path ;
local _mac_address ;
if _domain_xml=$(virsh -q dumpxml "${_NAME}" 2> /dev/null) ;
......@@ -386,14 +385,14 @@ verify_domain(){
_cpu_count=$(_get_content_by_tag_from_xml "${_domain_xml}" "vcpu") ;
_ram=$(_get_content_by_tag_from_xml "${_domain_xml}" "memory") ;
_image=$(_get_value_by_tag_and_attribute_from_xml "${_disk_vda_xml}" "source" "file") ;
_path=$(_get_value_by_tag_and_attribute_from_xml "${_disk_vda_xml}" "source" "file") ;
_bridge=$(_get_value_by_tag_and_attribute_from_xml "${_interface_xml}" "source" "bridge") ;
_mac_address=$(_get_value_by_tag_and_attribute_from_xml "${_interface_xml}" "mac" "address") ;
if \
test $((_cpu_count)) -eq $((_CPU_COUNT)) &&
test $((_ram)) -eq $((_RAM * 1024)) &&
test "${_image}" = "${_IMAGE}" &&
test "${_path}" = "${_PATH}" &&
test "${_bridge}" = "${_BRIDGE}" &&
( test ! "${_MAC_ADDRESS}" || test "${_mac_address}" = "${_MAC_ADDRESS}" ) &&
true ;
......@@ -483,13 +482,12 @@ print_machine_usage_message(){
create_machine(){
local OPTIND=1 ;
local _ipv4_address="" ;
while getopts ":i:" OPTION ;
do
case "${OPTION}" in
"i")
_ipv4_address="${OPTARG}" ;
local _IPV4_ADDRESS="${OPTARG}" ;
;;
"?")
echo "The command-line option '-${OPTARG}' is invalid." >&2 ;
......@@ -516,20 +514,19 @@ create_machine(){
create_volume "${_NAME}" "default" "${_PATH}" &&
_path=$(get_image_path "${_NAME}" "default") &&
create_domain${_ipv4_address:+ -m $(get_mac_address "${_ipv4_address}")} "${_NAME}" "${_CPU_COUNT}" "${_RAM}" "${_path}" "${_BRIDGE}" ;
create_domain${_IPV4_ADDRESS:+ -m $(get_mac_address "${_IPV4_ADDRESS}")} "${_NAME}" "${_CPU_COUNT}" "${_RAM}" "${_path}" "${_BRIDGE}" ;
}
verify_machine(){
local OPTIND=1 ;
local _ipv4_address="" ;
while getopts ":i:" OPTION ;
do
case "${OPTION}" in
"i")
_ipv4_address="${OPTARG}" ;
local _IPV4_ADDRESS="${OPTARG}" ;
;;
"?")
echo "The command-line option '-${OPTARG}' is invalid." >&2 ;
......
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