Small datastore fixes

This commit is contained in:
Matt Churchyard
2016-04-19 20:49:36 +01:00
parent 0e493ea651
commit 650db5efc2
6 changed files with 19 additions and 19 deletions

View File

@@ -105,7 +105,7 @@ __vm_create(){
# check guest name
__vm_check_name "${_name}" || __err "invalid virtual machine name - '${_name}'"
__datastore_load_guest "${_name}" && __err "virtual machine already exists in ${VM_DS_PATH}/${_name}"
__datastore_get_guest "${_name}" && __err "virtual machine already exists in ${VM_DS_PATH}/${_name}"
__datastore_get "${_ds}" || __err "unable to load datastore - '${_ds}'"
[ ! -f "${vm_dir}/.templates/${_template}.conf" ] && \
@@ -200,7 +200,7 @@ __vm_add(){
# check guest
[ -z "${_name}" ] && __usage
__datastore_load_guest "${_name}" || "${_name} does not appear to be a valid virtual machine"
__datastore_get_guest "${_name}" || "${_name} does not appear to be a valid virtual machine"
case "${_device}" in
disk)
@@ -370,7 +370,7 @@ __vm_start(){
[ -z "${_name}" ] && __usage
# try to find guest
if ! __datastore_load_guest "${_name}"; then
if ! __datastore_get_guest "${_name}"; then
__warn "${_name} does not seem to be a valid virtual machine"
return 1
fi
@@ -475,7 +475,7 @@ __vm_destroy(){
local _name="$1"
[ -z "${_name}" ] && __usage
__datastore_load_guest "${_name}" || __err "${_name} doesn't appear to be a valid virtual machine"
__datastore_get_guest "${_name}" || __err "${_name} doesn't appear to be a valid virtual machine"
# make sure it's stopped!
__vm_confirm_stopped "${_name}" || exit 1
@@ -498,8 +498,8 @@ __vm_rename(){
[ -z "${_old}" -o -z "${_new}" ] && __usage
__vm_check_name "${_new}" || __err "invalid virtual machine name - '${_name}'"
__datastore_load_guest "${_new}" && __err "directory ${VM_DS_PATH}/${_new} already exists"
__datastore_load_guest "${_old}" || __err "${_old} doesn't appear to be a valid virtual machine"
__datastore_get_guest "${_new}" && __err "directory ${VM_DS_PATH}/${_new} already exists"
__datastore_get_guest "${_old}" || __err "${_old} doesn't appear to be a valid virtual machine"
# confirm guest stopped
__vm_confirm_stopped "${_old}" || exit 1
@@ -535,7 +535,7 @@ __vm_console(){
[ -z "${_name}" ] && __usage
__datastore_load_guest "${_name}" || __err "${_name} doesn't appear to be a valid virtual machine"
__datastore_get_guest "${_name}" || __err "${_name} doesn't appear to be a valid virtual machine"
[ ! -e "/dev/vmm/${_name}" ] && __err "${_name} doesn't appear to be a running virtual machine"
[ ! -e "${VM_DS_PATH}/${_name}/console" ] && __err "can't locate console data for ${_name}"
@@ -562,7 +562,7 @@ __vm_configure(){
[ -z "${_name}" ] && __usage
[ -z "${EDITOR}" ] && EDITOR=vi
__datastore_load_guest "${_name}" || \
__datastore_get_guest "${_name}" || \
__err "cannot locate configuration file for virtual machine: ${_name}"
$EDITOR "${VM_DS_PATH}/${_name}/${_name}.conf"

View File

@@ -28,7 +28,7 @@
# show configured datastores
#
__datastore_list(){
local _format="%-15s%-11s%-26s%s"
local _format="%-15s %-11s %-25s %s"
local _name _type _dataset _path _ds _spec
# headings
@@ -178,7 +178,7 @@ __datastore_load(){
# @return non-zero on error
# @modifies VM_DS_NAME VM_DS_PATH VM_DS_ZFS VM_DS_ZFS_DATASET
#
__datastore_load_guest(){
__datastore_get_guest(){
local _guest="$1"
local _ds _spec _path _found _zfs _dataset

View File

@@ -39,13 +39,13 @@ __vm_info(){
# see if one guest provided
if [ -n "${_name}" ]; then
__datastore_load_guest "${_name}" || __err "unable to locate virtual machine '${_name}'"
__datastore_get_guest "${_name}" || __err "unable to locate virtual machine '${_name}'"
__vm_info_guest "${_name}"
exit
fi
# show all guests from all datastores
for _ds in $VM_DATASTORE_LIST; do
for _ds in ${VM_DATASTORE_LIST}; do
__datastore_get "${_ds}"
ls -1 "${VM_DS_PATH}" | \
while read _name; do

View File

@@ -41,7 +41,7 @@ __vm_run(){
local _com _comports _comstring _logpath="/dev/null"
# try to load datstore details
__datastore_load_guest "${_name}" || exit 5
__datastore_get_guest "${_name}" || exit 5
# bail out immediately if guest running
__vm_confirm_stopped "${_name}" "1" || exit 10

View File

@@ -181,7 +181,7 @@ __zfs_snapshot(){
fi
[ -z "${_name}" ] && __usage
__datastore_load_guest "${_name}" || __err "${_name} does not appear to be an existing virtual machine"
__datastore_get_guest "${_name}" || __err "${_name} does not appear to be an existing virtual machine"
[ ! "${VM_DS_ZFS}" = "1" ] && __err "cannot snapshot guests on non-zfs datastores"
[ -z "${_snap}" ] && _snap=$(date +"%Y-%m-%d-%H:%M:%S")
@@ -223,7 +223,7 @@ __zfs_rollback(){
[ -z "${_name}" -o -z "${_snap}" ] && __usage
__datastore_load_guest "${_name}" || __err "${_name} does not appear to be an existing virtual machine"
__datastore_get_guest "${_name}" || __err "${_name} does not appear to be an existing virtual machine"
[ ! "${VM_DS_ZFS}" = "1" ] && __err "cannot rollback guests on non-zfs datastores"
__vm_confirm_stopped "${_name}" || exit 1
@@ -252,8 +252,8 @@ __zfs_clone(){
[ -z "${_old}" -o -z "${_name}" ] && __usage
__datastore_load_guest "${_name}" && __err "new guest already exists in ${VM_DS_PATH}/${_name}"
__datastore_load_guest "${_old}" || __err "${_name} does not appear to be an existing virtual machine"
__datastore_get_guest "${_name}" && __err "new guest already exists in ${VM_DS_PATH}/${_name}"
__datastore_get_guest "${_old}" || __err "${_name} does not appear to be an existing virtual machine"
[ ! "${VM_DS_ZFS}" = "1" ] && __err "cannot clone guests on non-zfs datastores"
# try to get snapshot name
@@ -336,7 +336,7 @@ __zfs_image_create(){
[ -z "${_desc}" ] && _desc="No description provided"
__datastore_load_guest "${_name}" || __err "${_name} does not appear to be a valid virtual machine"
__datastore_get_guest "${_name}" || __err "${_name} does not appear to be a valid virtual machine"
[ -z "${VM_ZFS}" -o -z "${VM_DS_ZFS}" ] && __err "this command is only supported on zfs datastores"
# create the image dataset if we don't have it

2
vm
View File

@@ -25,7 +25,7 @@
# POSSIBILITY OF SUCH DAMAGE.
VERSION=1.1-alpha
VERSION_INT=101023
VERSION_INT=101024
VERSION_BSD=$(uname -K)
PATH=${PATH}:/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin