This is my first question on serverfault so I hope I'm doing this right as I'm usually on Stackoverflow :-)
I have two Ubuntu 14.04 LTS servers, server A and B.
Server A runs the web server where my customer portal runs and where customers can order virtual machines.
Server B is the hypervisor with KVM where images and ultimately virtual machines are created.
I recently created a bash script on server A that:
- gets information from a mysql table with virtual machines that still need to be created and loops through them;
- checks free disk space of server B and if sufficient space then
- creates images with the fallocate program on server B;
- creates the virtual machine with vert-install on server B with the use of previously created image.
All these commands are executed with the use of SSH. This means that for every virtual machine I need to do 3 SSH commands. More if a hypervisor does not have enough disk space left for the creation of images.
This script sort of works fine when there is only 1 customer ordering a virtual machine and when there is only 1 hypervisor. Having multiple customers ordering VM's and having multiple hypervisors will probably break the script. Then I thought of the following solution:
Whenever a customer clicks on the button 'Order VM', a telnet call to a hypervisor + port is done and a daemon listening on that port runs a script, for example:
- Port 7000: create the image
- Port 7001: create the virtual machine
The problem however is my lack of knowledge about this kind of stuff. For example:
- In what language would i write the daemon? PHP is my primary language, but as it is 'the language that dies' it might not be good for writing daemons.
- How can this daemon listen on multiple ports and take the correct action according to which port something comes in?
- Is telnet the correct protocol to use for this kind of process? The daemon would only listen on private addresses in our own network, that means that the security is no problem here. Are there different technologies that suits better?
I have not tried much because I don't know where to start. There is a lot to think about, but I just need a little push in the right direction to get things started. I don't necessarily need example code (it might help of course). I can provide the bash script I have created if needed.