Check datastore name is unique during add

This commit is contained in:
Matt Churchyard
2016-04-19 11:27:03 +01:00
parent 11e4925c42
commit 097a3e1542
2 changed files with 9 additions and 2 deletions

View File

@@ -82,12 +82,19 @@ __datastore_list(){
__datastore_add(){
local _name="$1"
local _spec="$2"
local _mount _num=0
local _mount _num=0 _list _curr
[ -z "${_name}" -o -z "${_spec}" ] && __usage
[ "${_name}" = "default" ] && __err "additional datastore cannot be named 'default'"
__vm_check_name "${_name}" || __err "invalid datastore name - '${_name}'"
# check name not in use
__config_core_get "_list" "datastore_list"
for _curr in ${_list}; do
[ "${_curr}" = "${_name}" ] && __err "datstore ${_name} already exists!"
done
# look for zfs
if [ "${_spec%%:*}" = "zfs" ]; then
# try to find mountpoint