From d8a4969ffc7a9533f4d7e397a03bcd14acdda3c5 Mon Sep 17 00:00:00 2001 From: Ian Kelling Date: Wed, 19 Mar 2025 06:15:19 -0400 Subject: [PATCH] fixes --- roles/kvmhost/files/simple/usr/local/bin/create-vm | 10 ++++------ .../files/simple/usr/local/bin/savannah-virsh | 13 ++++++++++++- .../files/simple/usr/local/bin/unsafe-remove-vm | 3 ++- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/roles/kvmhost/files/simple/usr/local/bin/create-vm b/roles/kvmhost/files/simple/usr/local/bin/create-vm index f89cf67..3093408 100755 --- a/roles/kvmhost/files/simple/usr/local/bin/create-vm +++ b/roles/kvmhost/files/simple/usr/local/bin/create-vm @@ -335,8 +335,8 @@ EOF # our SSDs are already beyond a reasonable number of years. If you want # more space, bug Ian to go install new disks that are on his desk. - if (( new_disk_mb * 1024 > gb_available )); then - err "error: requested size $((new_disk_mb * 1024))GB is greater than the available space." + if (( new_disk_mb / 1024 > gb_available )); then + err "error: requested size $((new_disk_mb / 1024))GB is greater than the available space." exit 1 fi @@ -1183,9 +1183,9 @@ export LC_ALL=C pre="${0##*/}:" -for pkg in jq nmon; do +for pkg in jq ; do if ! type -p $pkg &>/dev/null; then - echo "installing missing dependency: jq" + echo "installing missing dependency: $pkg" apt-get -y install $pkg fi done @@ -1264,8 +1264,6 @@ if $dolist; then else nonceph-disk fi - read -r -t 300 -n1 -p "Press any key to start nmon. Tip: press 'l' for a useful cpu graph. (autostarts in 300 seconds)" ||: - nmon exit 0 fi diff --git a/roles/kvmhost/files/simple/usr/local/bin/savannah-virsh b/roles/kvmhost/files/simple/usr/local/bin/savannah-virsh index 4812aab..c9d1717 100755 --- a/roles/kvmhost/files/simple/usr/local/bin/savannah-virsh +++ b/roles/kvmhost/files/simple/usr/local/bin/savannah-virsh @@ -20,7 +20,8 @@ # See the License for the specific language governing permissions and # limitations under the License. - +# todo: document the command that requires ssh -t, and detect +# it with if tty -t; then terminal is allocated; fi ## Managed by Ansible, changes will be overwritten ## @@ -46,6 +47,10 @@ runs: virsh VIRSH_COMMAND VM runs: virsh detach-disk VM VIRTUAL_DEVICE_NAME --persistent +## Usage: nmon + +runs nmon. You may need to use ssh -t to request a pseudo-terminal. + ### Complex FSF scripts with separate docs: attach-vm-disk --help @@ -178,6 +183,12 @@ case "$arg0" in list) m virsh list --name ;; + nmon) + if ! type -p nmon &>/dev/null; then + m apt-get -y install nmon + fi + nmon + ;; list-verbose) m virsh list --all ;; diff --git a/roles/kvmhost/files/simple/usr/local/bin/unsafe-remove-vm b/roles/kvmhost/files/simple/usr/local/bin/unsafe-remove-vm index 5577bce..d3cbedc 100755 --- a/roles/kvmhost/files/simple/usr/local/bin/unsafe-remove-vm +++ b/roles/kvmhost/files/simple/usr/local/bin/unsafe-remove-vm @@ -234,7 +234,8 @@ cat $script_gen echo echo "end of cat $script_gen" -read -r -p "Do you want to completely remove $host from this kvmhost and delete its disks based on the planned commands? (y/N): " yn +echo "Do you want to completely remove $host from this kvmhost and delete its disks based on the planned commands? (y/N): " +read -r yn case $yn in Y|y|YES|Yes|yes) -- 2.25.1