Commit 4aa5accf authored by Paul John King's avatar Paul John King

Examine domain outputs shell assignments and verify domain uses them --

parent 9a10240d
......@@ -182,9 +182,10 @@ print_domain_usage_message(){
${0##*/} examine domain <name>
outputs the CPU count, RAM, file-system image, bridge device and MAC address of
the KVM domain with name <name> and returns 0 if the domain exists, and returns
1 otherwise.
outputs the CPU count, the RAM, the RAM units, a path to the file-system image,
the bridge device and the MAC address of the KVM domain with name <name> as
Bourne-shell variable assignments (suitable for shell evaluation) and returns 0
if the domain exists, and returns 1 otherwise.
The command call
......@@ -301,7 +302,9 @@ examine_domain(){
local _interface_xml ;
local _cpu_count ;
local _ram ;
local _ram_unit ;
local _path ;
local _bridge ;
local _mac_address ;
if _domain_xml=$(virsh -q dumpxml "${_NAME}" 2> /dev/null) ;
......@@ -315,16 +318,17 @@ 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") ;
_ram_unit=$(_get_value_by_tag_and_attribute_from_xml "${_domain_xml}" "memory" "unit") ;
_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 "Path: ${_path}" ;
echo "Bridge: ${_bridge}" ;
echo "MAC address: ${_mac_address}" ;
echo "DOMAIN_CPU_COUNT='${_cpu_count}'" ;
echo "DOMAIN_RAM='${_ram}'" ;
echo "DOMAIN_RAM_UNIT='${_ram_unit}'" ;
echo "DOMAIN_PATH='${_path}'" ;
echo "DOMAIN_BRIDGE='${_bridge}'" ;
echo "DOMAIN_MAC_ADDRESS='${_mac_address}'" ;
return 0 ;
else
......@@ -364,44 +368,26 @@ verify_domain(){
local _BRIDGE="${5}" ;
shift 5 ;
local _domain_xml ;
local _disk_vda_xml ;
local _interface_xml ;
local _cpu_count ;
local _ram ;
local _path ;
local _mac_address ;
local _PARAMETERS ;
if _domain_xml=$(virsh -q dumpxml "${_NAME}" 2> /dev/null) ;
if _PARAMETERS=$(examine_domain "${_NAME}") ;
then
# The domain exists.
_disk_vda_xml=$(_get_elements_by_tag_and_sub_tag_and_attribute_from_xml \
"${_domain_xml}" "disk" "target" "dev" "vda"
) ;
_interface_xml=$(_get_elements_by_tag_and_attribute_from_xml \
"${_domain_xml}" "interface" "type" "bridge"
) ;
_cpu_count=$(_get_content_by_tag_from_xml "${_domain_xml}" "vcpu") ;
_ram=$(_get_content_by_tag_from_xml "${_domain_xml}" "memory") ;
_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") ;
eval "${_PARAMETERS}" ;
if \
test $((_cpu_count)) -eq $((_CPU_COUNT)) &&
test $((_ram)) -eq $((_RAM * 1024)) &&
test "${_path}" = "${_PATH}" &&
test "${_bridge}" = "${_BRIDGE}" &&
( test ! "${_MAC_ADDRESS}" || test "${_mac_address}" = "${_MAC_ADDRESS}" ) &&
true ;
test "${DOMAIN_CPU_COUNT}" = "${_CPU_COUNT}" &&
test "${DOMAIN_RAM}" = $((_RAM * 1024)) &&
test "${DOMAIN_PATH}" = "${_PATH}" &&
test "${DOMAIN_BRIDGE}" = "${_BRIDGE}" &&
( test ! "${_MAC_ADDRESS}" || test "${DOMAIN_MAC_ADDRESS}" = "${_MAC_ADDRESS}" ) ;
then
# The domain exists and is verified.
return 0 ;
else
# The domain exists bit is not verified.
# The domain exists but is not verified.
return 1 ;
fi ;
......@@ -551,15 +537,10 @@ verify_machine(){
local _path ;
exit 0 ;
_path=$(get_image_path "${_NAME}" "default")
echo "_path: [${_path}]" ;
echo "_path: [${_path}]" ;
#verify_domain${_ipv4_address:+ -m $(get_mac_address "${_ipv4_address}")} "${_NAME}" "${_CPU_COUNT}" "${_RAM}" "${_path}" "${_BRIDGE}" ;
} ;
......
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