Page 1 of 1

Python Script for managing a VM on digitalocean

Posted: Fri May 13, 2016 9:45 am
by EndOfFile
Hi,

i am hosting my factorio headless server on a VM on digitalocean.
Since you pay there for the actual runtime ($0.015/h for the second smallest one) of your VM and can save up to 5 snapshots for free its really cheap ;)
And you can always make a bigger VM if you need more performance.

So i had to always had to create the VM, play, take snapshot, destroy VM manually...

Since that is boring as hell i made a script for that: https://github.com/EndOfFile/factorio_on_DO (Use with caution, deletes stuff)

Regards
EOF
Change log

Re: Python Script for managing a VM on digitalocean

Posted: Fri May 13, 2016 11:29 am
by HanziQ
Regarding the assumptions you have, you should at least ask before destroying anything, I didn't see anything like that in the code. Or actually select the VM to destroy by name, which should be somehow possible, not sure.

Re: Python Script for managing a VM on digitalocean

Posted: Fri May 13, 2016 4:33 pm
by EndOfFile
I don't want to ask for permission since i just want to run it and forget.

But i did now change it to only stop/snapshot/destroy the VM that matches the defined vm_name inside the script (Assuming that the set vm_name is unique for all VMs).
For cleaning up old snapshots now only those are considered that match the snapshot naming scheme. (Oldest one gets deleted if there are more than 2)