- Apr 25, 2015
- 1,845
- 2
- 2,199
- 327
Code:
Promise.promisifyAll(ovh);
function requestVirtualMac(ip_address) {
return ovh.requestAsync('POST', '/dedicated/server/' + config.SERVICE_NAME + '/virtualMac', {
ipAddress: ip_address,
type: 'ovh',
virtualMachineName: uuid.v4()
}).then(function(result) {
arclog.log("OVH is now working on a MAC for " + ip_address + "...", "info");
return checkRequestStatus(result, ip_address);
}).catch(function(err) {
arclog.error("Got problem requesting virtualMac for IP " + ip_address, err);
});
}
From the above, I sourced this. One could just pre-build all the different distros/flavors in your hypervisor VM export of choice. Then just import all your bare exported VM instances on-the-fly, have the VMAC generated, assigned, queue (pool) the IP assignment or DHCP and listen for IP.
Just like that, you have a 1-2-3 fresh VM up and running. The developer of the above script claims Virtkick is a solution but in my opinion I would just script everything in PHP.
I hate paying $50+ monthly just for something that is basic cron scheduling, database calls, payment processing via gateways in PayPal/Stripe, and.. at the end of the day, all this is entirely scriptable in a way to have automated with minimal effort really. Let a user register/login, select a VM to deploy with customizable RAM/CPU, make sure the hypervisor has the resources. Deploy!
This could be a really fun project
You at least know it is possible though, I've done some basic groundwork. I'll do the rest later as I get to it