All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
BashProx.sh: alternative to the Proxmox VE webinterface
So I've been writing a bash script to manage proxmox. It now can create, start, stop and delete openvz VM's. If you don't give a vm ID it will ask you. And it has a openVZ shell dropper.
Creating a CT
./proxbash.sh createct test1 passw0rd ubuntu12 512 5 192.168.0.91 Creating ovz CT #: 920 test1 on proxmox with password passw0rd, template: ubuntu12, IP: 192.168.0.91, HDD: 5 GB, RAM: 512 MB. Are you sure? Please enter y(es) or n(o): y Creating OpenVZ Container CT 920 Creating container private area (/var/lib/vz/template/cache/ubuntu-12.04-x86.tar.gz) Performing postcreate actions CT configuration saved to /etc/pve/openvz/920.conf Container private area was created 200 OK UPID:proxmox:0000453A:000BB323:5013B844:vzcreate:920:root@pam:Starting CT 920 Starting container ... Container is mounted Adding IP address(es): 192.168.0.91 Setting CPU units: 1000 Setting CPUs: 1 Container start in progress... 200 OK UPID:proxmox:00004578:000BBE63:5013B861:vzstart:920:root@pam: Command finished
List all the VM's (including KVM):
(You will also see this if you do something without a vm id)
./proxbash.sh listcts OpenVZ Containers 200 OK "name" : "freedombox.raymii.nl", "vmid" : "103" "name" : "test1.raymii.nl", "vmid" : "920" "name" : "chatserver.raymii.nl", "vmid" : "101" "name" : "share.raymii.nl", "vmid" : "102" KVM Virtual Machines: 200 OK "name" : "win2k8-ad-dns1", "vmid" : "100"
Start/Stop:
./proxbash.sh stopct 920 Stopping CT 920 Stopping container ... Container was stopped Container is unmounted 200 OK UPID:proxmox:00004A40:000C4ECD:5013B9D2:vzstop:920:root@pam Command finished
./proxbash.sh startct 920 Starting CT 920 Starting container ... Container is mounted Adding IP address(es): 192.168.0.91 Setting CPU units: 1000 Setting CPUs: 1 Container start in progress... 200 OK UPID:proxmox:00004AA3:000C65EC:5013BA0E:vzstart:920:root@pam: Command finished
Deleting a CT:
./proxbash.sh deletect OpenVZ Containers 200 OK "name" : "freedombox.raymii.nl", "vmid" : "103" "name" : "test1.raymii.nl", "vmid" : "920" "name" : "chatserver.raymii.nl", "vmid" : "101" "name" : "share.raymii.nl", "vmid" : "102" Enter VM ID please: 920 Are you sure you want to REMOVE VM 920? Please enter y(es) or n(o): y Are you really sure you want to remove VM 920? it will be gone forever and forever is a long time... Please enter y(es) or n(o): y Stopping CT 920 Stopping container ... Container was stopped Container is unmounted 200 OK UPID:proxmox:00004D02:000C7AFF:5013BA44:vzstop:920:root@pam:Removing CT 920 Destroying container private area: /var/lib/vz/private/920 Container private area was destroyed 200 OK UPID:proxmox:00004D1E:000C7BAB:5013BA45:vzdestroy:920:root@pam: Command finished
Shell dropper:
./proxbash.sh shelldrop 103 Entering CT 103 entered into CT 103 root@freedombox:/# whoami root root@freedombox:/# uname -a Linux freedombox 2.6.32-11-pve #1 SMP Wed Apr 11 07:17:05 CEST 2012 i686 athlon i386 GNU/Linux root@freedombox:/# exit logout exited from CT 103 Command finished
(Note: fuck stupid pseudo-terminals and ssh. But after a few hours, nano and dialog now work...)
So you need to deploy 120 vms?
#!/bin/bash ./proxbash.sh createct test1 "passw0rd" centos5 512 5 10.0.0.5 301 ./proxbash.sh createct test2 "passw0rd" ubuntu12 512 5 10.0.0.6 302 ./proxbash.sh createct test3 "passw0rd" ubuntu10 512 5 10.0.0.7 303 ./proxbash.sh createct test4 "WhyUNoPassw0rd" centos6 1024 5 10.0.0.8 304 [...]
(note how you can also give the ct an vmid)
You need to delete them?
#!/bin/bash ./proxbash.sh deletect 301 ./proxbash.sh deletect 302 ./proxbash.sh deletect 303 ./proxbash.sh deletect 304 [...]
Will be released under my regular license (MIT/X11). Needs SSH passwordles key auth to the proxmox vm. Templates are defined via a case and need to be in the proxmox host. Supports multiple proxmox nodes.
Planned is KVM. Also planned is set command execution (install git, run Chef, deploy app e.d.)
Written all in bash.
Opinions?
Comments
Cool
Cool work mate, look forward to kvm support
Seems like you could drop the proxmox overhead and just use the OpenVZ CLI tools, but good work either way
very nice...
can you do re-install template to a existing container.
@djvdorp for the KVM it's imho better to use the web interface. You then can right away use the proxmox java console to get into the vm. If you use the command line a graphical install console would be a bit hard.
@jarland correct but the install op openvz is very easy and fast, and it allows openvz and KVM machines without a lot of hassle. If your need to set it up yourself it would take longer then just popping in the proxmox cd.
@pats I'm looking in the API docs, but I cannot seem to find that. I've heard multiple people complain about that. Recreating the container would be the temp solution.
2 new features
first: container info:
And nicest one, command execution in CT:
So, now imagine:
from zero to full deploy of your app (assuming you have a cap script and a chef config, but can also be a shell script or whatever) in no time with only two commands?
If you can get to input it an script to execute, maybe I am sold.
ok so a feature that way would be nice..
./proxbash.sh retemplate debian6min 103
internally it gets the values 'ctinfo' & recreates the container with template debian6min
@yomero executing a script I wrote, which should fail because no X, but script executes
@Pats It is faster to just recreate the container yourself. pvesh outputs the variables all in json-like format and bash does not like to parse that. I can do it, but it would require a lot of effort for a feature that I'm not going to use a lot. Also, because it is requested a lot, I hope the proxmox team builds it in so that I only have to do an API call. If they do that, i'll add it.
Release!!!!!!!
First version released: https://raymii.org/cms/p_Proxbash_-_Bash_script_to_manage_Proxmox_VE
(and if the cluster is not up to date yet: http://let.raymii.org/cms/p_Proxbash_-_Bash_script_to_manage_Proxmox_VE )
comments and such are very welcome.
btw @kuJoe do you still use Proxmox?
Nope, too many problems with it. I do everything via CLI now.
Problems like?
Performance issues (mostly disk I/O)
Security issues (Debian 5 is EOL)
Usability issues (Proxmox 2.x did not fit my needs at all)
the bare metal is Debian 6
and i also installed manually on Debian6 64bit
can u elaborate on - Performance issues (mostly disk I/O) ?
Proxmox 1.9 (the only one I will use) is Debian 5.
Here's what I experienced with the exact same hardware:
Max write speeds with Proxmox installed = ~50MB/s
Max write speeds without Proxmox installed = ~160MB/s
These results are the same regardless if I use OpenVZ or KVM so I just dropped Proxmox all together for the increased performance.
So, this are kernel issues with your hardware I guess
Probably, the Proxmox kernel was the only thing different besides the software itself but the software shouldn't have any impact on the performance I would think. I tried 4 different hardware setups without any luck though.
@KuJoe why do you only want to use ProxMox 1.9? I've only used it since 2...
2.0 is to complex and does not fit my needs. I was only using Proxmox for internal services and 2.0 offers to many extras that make using it both difficult and annoying for my needs. I do not need user accounts, groups, or permissions and setting up these things is time wasted and adds a larger attack surface for hackers. 1.9 was very basic and fit my needs perfectly as far as a web interface goes, it was unfortunate that 2.0 did not follow in its footsteps.
To give you an idea, this is infinitely times better than Proxmox for my uses.
Complex? Bah!
I got it in a couple of days! (like a baussss!)
Ok ok tbh, I don't have idea on the clustering stuff and the live migration with LVM (wtf?)
And if you don't need permissions, just use the root account like me :P
@KuJoe would you consider using it again (maybe with the bash script?)
@Raymii I don't really have a need anymore. Everything I need I can do through the CLI, if anything I'll make a simple PHP page to manage my services.
Web GUI?
Like this: https://raymii.org/cms/content/tmp/vmgui/
@Raymii Yes, just like that. As long as it can run on the OpenVZ server itself.
@Kujoe thinking of turning it into a ruby on rails web application. For Proxmox.
Well it does look nice, I'm sure somebody will use it.