Commit 0ed962fb authored by Paul John King's avatar Paul John King

Added code to examine and verify machines --

Needs documenting and testing.
parent 4aa5accf
......@@ -11,6 +11,8 @@ echo_stdin(){
print_usage_message(){
# TODO: The current help call screws if an entity has name 'help'!
echo_stdin <<- __END_OF_STDIN__
Usages:
......@@ -22,13 +24,15 @@ print_usage_message(){
${0##*/} destroy volume <name> <pool>
${0##*/} create|destroy volume help
${0##*/} create domain [-m <mac_address>] <name> <cpu_count> <ram> <path> <bridge>
${0##*/} examine domain <name>
${0##*/} verify domain [-m <mac_address>] <name> <cpu_count> <ram> <path> <bridge>
${0##*/} destroy domain <name>
${0##*/} create|verify|destroy domain help
${0##*/} create|examine|verify|destroy domain help
${0##*/} create machine [-i ipv4_address] <name> <cpu_count> <ram> <path> <bridge>
${0##*/} examine machine <name>
${0##*/} verify machine [-i ipv4_address] <name> <cpu_count> <ram> <path> <bridge>
${0##*/} destroy machine <name>
${0##*/} create|verify|destroy machine help
${0##*/} create|examine|verify|destroy machine help
${0##*/} get image path <volume> <pool>
${0##*/} get image path help
${0##*/} get mac address <ipv4_address>
......@@ -372,8 +376,6 @@ verify_domain(){
if _PARAMETERS=$(examine_domain "${_NAME}") ;
then
# The domain exists.
eval "${_PARAMETERS}" ;
if \
......@@ -383,17 +385,11 @@ verify_domain(){
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 but is not verified.
return 1 ;
fi ;
else
# The domain does not exist.
return 2 ;
fi ;
......@@ -504,6 +500,38 @@ create_machine(){
}
examine_machine(){
local _NAME="${1}" ;
shift 1 ;
local _parameters ;
local _volume_xml ;
local _backing_store_xml ;
local _backing_path ;
if _parameters=$(examine_domain "${_NAME}") ;
then
eval "${_parameters}" ;
if _volume_xml=$(virsh vol-dumpxml "${DOMAIN_PATH}") ;
then
_backing_store_xml=$(_get_content_by_tag_from_xml "${_volume_xml}" "backingStore") ;
_backing_path=$(_get_content_by_tag_from_xml "${_backing_store_xml}" "path") ;
echo "${_parameters}" ;
echo "DOMAIN_BACKING_PATH='${_backing_path}'" ;
return 0 ;
else
return 1 ;
fi ;
else
return 1 ;
fi ;
} ;
verify_machine(){
local OPTIND=1 ;
......@@ -535,13 +563,32 @@ verify_machine(){
local _BRIDGE="${5}" ;
shift 5 ;
local _path ;
local _PARAMETERS ;
_path=$(get_image_path "${_NAME}" "default")
if _PARAMETERS=$(examine_machine "${_NAME}") ;
then
eval "${_PARAMETERS}" ;
echo "_path: [${_path}]" ;
if test "${_IPV4_ADDRESS}" ;
then
_MAC_ADDRESS=$(get_mac_address "${_IPV4_ADDRESS}") ;
fi ;
#verify_domain${_ipv4_address:+ -m $(get_mac_address "${_ipv4_address}")} "${_NAME}" "${_CPU_COUNT}" "${_RAM}" "${_path}" "${_BRIDGE}" ;
if \
test "${DOMAIN_CPU_COUNT}" = "${_CPU_COUNT}" &&
test "${DOMAIN_RAM}" = $((_RAM * 1024)) &&
test "${DOMAIN_BACKING_PATH}" = "${_PATH}" &&
test "${DOMAIN_BRIDGE}" = "${_BRIDGE}" &&
( test ! "${_MAC_ADDRESS}" || test "${DOMAIN_MAC_ADDRESS}" = "${_MAC_ADDRESS}" ) &&
true ;
then
return 0 ;
else
return 1 ;
fi ;
else
return 2 ;
fi ;
} ;
......@@ -1016,7 +1063,7 @@ case "${1} ${2} ${3}" in
exit 0 ;
;;
"create machine help"|"verfify machine help"|"destroy machine help")
"create machine help"|"examine machine help"|"verfify machine help"|"destroy machine help")
shift 3 ;
print_machine_usage_message ;
exit 0 ;
......@@ -1090,6 +1137,12 @@ case "${1} ${2}" in
exit $? ;
;;
"examine machine")
shift 2 ;
examine_machine "${@}" ;
exit $? ;
;;
"verify machine")
shift 2 ;
verify_machine "${@}" ;
......
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