frankspin Posted July 9, 2014 Share Posted July 9, 2014 (edited) Update 09-13-2014 Added a ton of control over your droplets. Ability to reboot, shutdown, power on, and even create snapshots Download: https://github.com/fspinillo/alfred-digital-ocean/blob/master/workflow/Digital%20Ocean%20status.alfredworkflow?raw=true Digital Ocean's API is still in beta, so this will be evolving as their API access evolves. This workflow allows you to interact with your droplets to perform various functions. Currently you can do the follow: Get the current status of your droplets Reboot a droplet Shutdown a droplet Power cycle a dropet Power on a droplet Create snapshots of a droplet The workflow uses standard Python packages, expcet for Workflow, so no additional requirements needed. Workflow is bundled in the file, and was created by Dean Jackson (deanishe). Setup & use---1. To set this up you'll first need get a token from your settings page https://cloud.digitalocean.com/settings/applications2. In order to control droplets you need to set your token scope to write. If it is not set to write you wont be able to power on, shutdown, or take snapshots 3. Run 'dotoken', and this will let you paste your token 4. A notification will display letting you know the token was saved Using the workflow --- 'dos' will return information pertaining to your droplets. You will get back activity status, name, CPUs, RAM, and HDD size. If the droplet is in the middle of a task it will inform you. 'dod' will return your available droplets. Select the one you want to shutdown and hit enter. 'dor' will return your available droplets. Select the one you want to reboot and hit enter. 'dopo' will return your available droplets. Select the one you want to power-on and hit enter 'dopc' will return your available droplets. Select the one you want to power cycle and hit enter. 'sshot' will check to see which droplets are currently off. If a droplet is not off, it will inform you to power it down first. Select a powered down droplet and hit enter to initiate the snapshot. Snapshots are generated based on the name and date. Example: DropletName-YYYY-MM-DD Edited October 9, 2014 by frankspin Link to comment
rice.shawn Posted July 9, 2014 Share Posted July 9, 2014 (edited) Thanks. This looks fun. The easiest way to set the key would be to store the key in a file and retrieve it on run. You could have the user just open it and drop their auth key into the file. Another option would be to set it through Alfred with a script action: just ask the user for an input and save it to the file. You could do the same above but have an Applescript Text Box pop up for the user to paste the auth key there and then save that into the file. Just poke around to see how some of the other workflows deal with configuration options. Just save the file in ~/Library/Application Support/Alfred 2/Workflow Data/YOURWORKFLOWBUNDLEID/ Edited July 9, 2014 by Shawn Rice Link to comment
frankspin Posted July 9, 2014 Author Share Posted July 9, 2014 Thanks for the tips Shawn. I'm still fairly new to programming, let alone working in Alfred, so it's been a slower process in this. The text file idea is a good one, and one I was considering, I just haven't gotten around to exploring it yet. The API is still in beta so I'm hoping it eventually delivers more stats (cpu% for example), but I'll work with what I can. I'm hoping to store the droplet info into a file so that you can call actions (reboot, power cycle, etc) on them, but first step is that authkey. Link to comment
rice.shawn Posted July 10, 2014 Share Posted July 10, 2014 Since you're using Dean's workflow library, you can actually generate the settings files fairly easily. Here's the relevant documentation: http://www.deanishe.net/alfred-workflow/howto.html#settings Link to comment
frankspin Posted September 13, 2014 Author Share Posted September 13, 2014 Pushed up an update for this that now gives you much more control over your droplets. I removed all my settings, python modules, etc and was able to get this up and working with all the changes. So if anyone runs into problems please let me know. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now