Commit 13036eaf authored by Paul John King's avatar Paul John King

Added funtion to help set virsh connection URI --

parent 67dc20ef
......@@ -157,6 +157,20 @@ name `«name»` in the `default` storage pool.
Utility Commands
----------------
The command call
kvm_tool get connection uri [«user»@]«host»
outputs Bourne-shell instructions that first assign a `virsh` SSH-connection
URI for the host `«host»` (optionally, as the user `«user»`) to the variable
`VIRSH_DEFAULT_CONNECT_URI`, and then export the variable. Evaluating the
output of the the call, for example, by running the command
eval $(kvm_tool get connection uri fred@flintstone.bedrock.bc)
causes all subsequent calls to `virsh` and `kvm_tool` to be directed to the
host `flintstone.bedrock.bc` to be executed as the user `fred`.
The command call
kvm_tool get image path «volume» «pool»
......
#!/bin/sh
# TODO: Implement set_target_host.
# TODO: Implement examine and verify commands for pools and volumes.
# TODO: Add a -j option to the examine commands that outputs JSON suitable
......@@ -49,7 +47,7 @@ Usage:
${0##*/} destroy machine «name»
${0##*/} help machine
${0##*/} set target host «host» -- NOT YET IMPLEMENTED
${0##*/} get connection uri [«user»@]«host»
${0##*/} get image path «volume» «pool»
${0##*/} get mac address «ipv4_address»
${0##*/} help utility
......@@ -717,6 +715,20 @@ help_utility(){
Utility Commands
----------------
The command call
${0##*/} get connection uri [«user»@]«host»
outputs Bourne-shell instructions that first assign a \`virsh\` SSH-connection
URI for the host \`«host»\` (optionally, as the user \`«user»\`) to the variable
\`VIRSH_DEFAULT_CONNECT_URI\`, and then export the variable. Evaluating the
output of the the call, for example, by running the command
eval \$(${0##*/} get connection uri fred@flintstone.bedrock.bc)
causes all subsequent calls to \`virsh\` and \`${0##*/}\` to be directed to the
host \`flintstone.bedrock.bc\` to be executed as the user \`fred\`.
The command call
${0##*/} get image path «volume» «pool»
......@@ -764,6 +776,22 @@ __END_OF_STDIN__
} ;
get_connection_uri(){
if test $# != 1 ;
then
help_utility >&2 ;
return 1 ;
fi ;
local _HOST="${1}" ;
shift 1 ;
echo "VIRSH_DEFAULT_CONNECT_URI='qemu+ssh://${_HOST}/system' && export VIRSH_DEFAULT_CONNECT_URI" ;
return 0 ;
} ;
get_image_path(){
if test $# != 2 ;
......@@ -1340,6 +1368,12 @@ _main(){
return 0 ;
;;
"get connection uri "*)
shift 3 ;
get_connection_uri "${@}" ;
return $? ;
;;
"get image path "*)
shift 3 ;
get_image_path "${@}" ;
......
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