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

Added -s and -a options in order to start and autostart domains upon creation --

parent 84c220c6
......@@ -106,15 +106,15 @@ Usage:
${0##*/} destroy volume «name» «pool»
${0##*/} help volume
${0##*/} create domain [-x] [-c «connection_1»] ... [-c «connection_n»] «name» «cpu_count» «ram» «path»
${0##*/} create domain [-c «connection_1»] ... [-c «connection_n»] [-s] [-a] [-x] «name» «socket_count» «core_count» «thread_count» «ram» «path»
${0##*/} examine domain «name»
${0##*/} verify domain «name» «cpu_count» «ram» «path»
${0##*/} verify domain «name» «socket_count» «core_count» «thread_count» «ram» «path»
${0##*/} destroy domain «name»
${0##*/} help domain
${0##*/} create machine [-x] [-c «connection_1»] ... [-c «connection_n»] «name» «cpu_count» «ram» «path»
${0##*/} create machine [-c «connection_1»] ... [-c «connection_n»] [-s] [-a] [-x] «name» «socket_count» «core_count» «thread_count» «ram» «pool» «path»
${0##*/} examine machine «name»
${0##*/} verify machine «name» «cpu_count» «ram» «path»
${0##*/} verify machine «name» «socket_count» «core_count» «thread_count» «ram» «pool» «path»
${0##*/} destroy machine «name»
${0##*/} help machine
......@@ -678,16 +678,14 @@ _get_domain_xml(){
create_domain(){
local _xml_only=false ;
local _connections ;
local _start=false ;
local _autostart=false ;
local _xml_only=false ;
local OPTIND=1 ;
while getopts ":xc:" OPTION ;
while getopts ":c:sax" OPTION ;
do
case "${OPTION}" in
"x")
_xml_only=true ;
;;
"c")
_string="${OPTARG}" ;
_BRIDGE="${_string%%,*}" ;
......@@ -706,6 +704,18 @@ create_domain(){
_connections="${_connections} _${_BRIDGE} _${_ADDRESS}" ;
;;
"s")
_start=true ;
;;
"a")
_autostart=true ;
;;
"x")
_xml_only=true ;
;;
"?")
echo "The command-line option '-${OPTARG}' is invalid." >&2 ;
echo "" >&2 ;
......@@ -738,6 +748,14 @@ create_domain(){
else
_get_domain_xml "${_NAME}" "${_SOCKET_COUNT}" "${_CORE_COUNT}" "${_THREAD_COUNT}" "${_RAM}" "${_PATH}" ${_connections} |
virsh -q define "/dev/stdin" || return 1 ;
if ${_autostart} ;
then
virsh autostart "${_NAME}" || return 1 ;
fi ;
if ${_start} ;
then
virsh start "${_NAME}" || return 1 ;
fi ;
fi ;
return 0 ;
......@@ -860,7 +878,7 @@ Domain Commands
The command call
${0##*/} create domain [-x] [-c «connection_1»] ... [-c «connection_n»] «name» «socket_count» «core_count» «thread_count» «ram» «path»
${0##*/} create domain [-c «connection_1»] ... [-c «connection_n»] [-s] [-a] [-x] «name» «socket_count» «core_count» «thread_count» «ram» «path»
creates a KVM domain with the name \`«name»\`, \`«socket_count»\` CPU sockets,
\`«core_count»\` cores per CPU socket, \`«thread_count»\` threads per core,
......@@ -871,9 +889,10 @@ option
adds a connection to the bridge \`«bridge»\`, and optionally gives the
connecting device the MAC address \`«mac_address»\`. The option can be used
any number of times. The \`-x\` option outputs to standard output the
\`libvirt\` XML that would be used to create the domain, but does not create
it.
any number of times. The option \`-s\` starts the domain after creation. The
option \`-a\` configures \`libvirt\` to automatically start the domain when the
KVM host boots. The \`-x\` option outputs to standard output the XML that
\`libvirt\` would use to create the domain, but does not create it.
The command call
......@@ -921,16 +940,12 @@ __END_OF_STDIN__
create_machine(){
local _xml_only=false ;
local _domain_options=" " ;
local _xml_only=false ;
local OPTIND=1 ;
while getopts ":xc:" OPTION ;
while getopts ":c:sax" OPTION ;
do
case "${OPTION}" in
"x")
_xml_only=true ;
;;
"c")
_string="${OPTARG}" ;
_prefix="${_string%%,*}" ;
......@@ -952,7 +967,15 @@ create_machine(){
fi ;
fi ;
_domain_options="${_domain_options}-c ${_PREFIX}${_ADDRESS}${_SUFFIX} " || return 1
_domain_options="${_domain_options}-${OPTION} ${_PREFIX}${_ADDRESS}${_SUFFIX} " || return 1
;;
"a"|"s")
_domain_options="${_domain_options}-${OPTION} "
;;
"x")
_xml_only=true ;
;;
"?")
......@@ -1115,7 +1138,7 @@ Machine Commands
The command call
${0##*/} create machine [-x] [-c «connection_1»] ... [-c «connection_n»] «name» «socket_count» «core_count» «thread_count» «ram» «pool» «path»
${0##*/} create machine [-c «connection_1»] ... [-c «connection_n»] [-s] [-a] [-x] «name» «socket_count» «core_count» «thread_count» «ram» «pool» «path»
creates a KVM domain with the name \`«name»\`, \`«socket_count»\` CPU sockets,
\`«core_count»\` cores per CPU socket, \`«thread_count»\` threads per core,
......@@ -1131,6 +1154,12 @@ that output by
${0##*/} get mac address «ipv4_address»
The option can be used any number of times. The option \`-s\` starts the
domain after creation. The option \`-a\` configures \`libvirt\` to
automatically start the domain when the KVM host boots. The \`-x\` option
outputs to standard output the XML that \`libvirt\` would use to create the
domain, but does not create it.
The command call
${0##*/} examine machine «name»
......
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