Tuesday, January 24, 2017

Migrating Proxmox VMs with Python

Using the Proxmox API with Python to Migrate Virtual Machines

I hate doing repetitive tasks, and am always on the lookout for a way to save myself time.

I noticed the other day how much time it was taking me to move virtual machines around using the Proxmox web interface. When doing updates I like to move all the virtual machines off of the machine being updated in the cluster. This is easy to do with the "migrate all" option inside of the web interface. However moving those machines back to the original host was a pain and required a lot of clicking. So I spent an hour and whipped up a quick and dirty python script to do the migrations for me. It only works with KVM based virtual machines right now but it would be simple to adapt to move container based virtual machines. It also only authenticates against PAM right now, again it would be a fairly trivial change to fix that.

Usage

To use the script edit the PROXMOX_HOST global variable and put in the host, FQDN or IP address of your proxmox cluster and adjust the Proxmox port if necessary. Then just call:
./proxmoxMigrate.py -n <node where vms currently reside> -t <node where you want them to end up> <space seperated list of VM ids>

For example:
./proxmoxMigrate.py -n proxmox1 -t proxmox2 100 101 103 104


The Script


1 comment:

  1. If would possibly be} keen to study the best online playing Malaysia sites that settle for gamers from the nation, then would possibly be} a hundred percent in the best place. Those 바카라 사이트 taking part in sports activities betting do not need to be Michigan residents, however should be situated inside the state's borders when placing bets by way of smartphone app or pc. Those from Ohio, where online sports activities betting isn't legal, could therefore use Michigan's new betting apps in the event that they} do so in Michigan. Online playing that’s supplied by legit, fully-licensed online betting sites isn’t rigged. This is end result of|as a result of} these top playing sites use an algorithm called Random Number Generator to find out} the random end result of their video games.

    ReplyDelete