Release of ProxmoxVE Command Line Interface Utilities

ahe

Renowned Member
Oct 9, 2011
21
0
66
I have created a small program to mass move disks, delete disks and eject cdroms.

The primary use is migrating to a new storage without clicking through every machine in the Proxmox Web interface.

Example usage

Move all disks from "oldstorage" to "newstorage" - using format raw on "newstorage"
Code:
$ ./pve-move-disks.php
Move disk to another storage or format - Usage:
-h Proxmox hostname (required)
-u Username (required)
-p Password (required)
-r Realm (Default: 'pam')
-P Port (Default: 8006)
-n Dry run
-d dest storage (required)
-s source storage
-t target format (raw, qcow2, vmdk)

$ ./pve-move-disks.php -h 192.168.0.10 -u root -p mypassword -s oldstorage -d newstorage -t raw
Moving virtio1 - oldstorage:100/vm-100-disk-1.qcow2,size=107374182 to newstorage raw on 100 : mymachine
Moving virtio2 - oldstorage:100/vm-100-disk-2.raw,size=214748364 to newstorage raw on 100 : mymachine

Delete Disks
Code:
$ ./pve-delete-disks.php
Delete unused disks - Usage:
-h Proxmox hostname (required)
-u Username (required)
-p Password (required)
-r Realm (Default: 'pam')
-P Port (Default: 8006)
-n Dry run
-d delete storage (required)

$ ./pve-delete-disks.php -h 192.168.0.10 -u root -p mypassword -d oldstorage -n
Delete disk unused0 - oldstorage:100/vm-100-disk-1.qcow2 on 100 : mymachine
Delete disk unused1 - oldstorage:100/vm-100-disk-2.raw on 100 : mymachine

Eject cdroms
Code:
$ ./pve-eject-cdroms.php
Eject cdroms - Usage:
-h Proxmox hostname (required)
-u Username (required)
-p Password (required)
-r Realm (Default: 'pam')
-P Port (Default: 8006)
-n Dry run
-d source storage (required)

$ ./pve-eject-cdroms.php -h 192.168.0.10 -u root -p mypassword -d oldstorage
Ejecting ide2 - oldstorage:iso/debian-9.1.0-amd64-netinst.iso,media=cdrom,size=290M on vmid 100 : mymachine

Download at https://github.com/aheahe/pve-cli-utils

Best Regards
 
Thank your for your effort, but using two lines of bash could solve also the problems you're solving. Maybe it would be best to incorporate your wishes directly into the perl core (qm and pct) of PVE so that all people can get it without installing a lot of additional packages to their hypervisors.
 
To my knowledge it is not possible to eg move all disk from X storage to Y storage to format qcow2 with two lines of bash with the current API. If it is, please share the details :)

It would be nice if the API and/or Web interface had a function to eg migrate all disks to a new storage, but it is also something which would be very rarely used and make the Web interface more complicated.

You do not need to install additional packages to the hypervisors. You can use the CLI utility from any machine with php5-cli installed.

Best Regards
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!