Interface to 'Digital Ocean'

Provides a set of functions for interacting with the 'Digital Ocean' API at < https://developers.digitalocean.com/documentation/v2>, including creating images, destroying them, rebooting, getting details on regions, and available images.


Build Status Build status codecov.io rstudio mirror downloads cran version

analogsea is an R client for version 2 of the Digital Ocean API. It allows you to programatically create and destroy droplets (remote computers), and install various R related tools: (these are still a work in progress):

  • R (done)
  • RStudio Server (done)
  • RStudio Shiny Server (done)
  • OpenCPU (not yet)
  • Use packrat to move a project to a droplet (not yet)

Stable version from CRAN

install.packages("analogsea")

Development version from GitHub

devtools::install_github("sckott/analogsea")
library("analogsea")

Create a DO account

If you don't already have one, create a DO account. By using this link, you'll start with $10 in credits (enough for >600 hours of computing on a 1 gb machine), and if you become a digital ocean customer we'll get some DO credits for us to offset our costs for testing. Thanks :)

Authenticate

The best way to authenticate is to generate a personal access token (https://cloud.digitalocean.com/settings/tokens/new) and save it in an environment variable called DO_PAT. If you don't do this, you'll be prompted to authenticate in your browser the first time you use analogsea.

Make sure you provide digitial ocean your public key at https://cloud.digitalocean.com/ssh_keys. Github has some good advice on creating a new public key if you don't already have one: https://help.github.com/articles/generating-ssh-keys/.

Get droplets

All droplets

droplets()
<r> droplets()
$unintrenchable
<droplet>unintrenchable (2724525)
  Status: off
  Region: San Francisco 1
  Image: Ubuntu 14.04 x64
  Size: 512mb ($0.00744 / hr)
 
$basipterygium
<droplet>basipterygium (2724526)
  Status: active
  Region: San Francisco 1
  Image: Ubuntu 14.04 x64
  Size: 512mb ($0.00744 / hr)

A single droplet. Pass in a single droplet id.

droplet(2724525)
<droplet>unintrenchable (2724525)
  Status: off
  Region: San Francisco 1
  Image: Ubuntu 14.04 x64
  Size: 512mb ($0.00744 / hr)

Spin up a new droplet

To make this as dead simple as possible, you just use one function, without any parameters.

droplet_create()
Using default ssh key: Scott Chamberlain
NB: This costs $0.00744 / hour  until you droplet_delete() it
<droplet>sabaoth (2727258)
  Status: new
  Region: San Francisco 1
  Image: Ubuntu 14.04 x64
  Size: 512mb ($0.00744 / hr)

You can of course pass in lots of options for name of the droplet, RAM size, disk size, ssh keys, etc. See regions() and sizes() to list available regions and sizes.

Delete a droplet

droplet_delete(1707487)

Chaining

Most of the droplet_* functions can be chained together using the %>% function. For example, you can turn a droplet off, snapshot, and then turn it back on with:

d %>%
   droplet_power_off() %>%
   droplet_snapshot() %>%
   droplet_power_on() %>%

R

We're still working on these, but would love feedback.

Install RStudio Server

This requires a "docklet", a droplet with docker installed:

docklet_create() %>%
  docklet_rstudio()

This will install R, RStudio Server and it's dependencies. It will automatically pop open the RStudio server instance in your default browser, with default username/password of rstudio/rstudio.

Meta

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

News

analogsea 0.6.0

NEW FEATURES

  • as.key function changed to as.sshkey to avoid collision with openssl package (#126)
  • Gains new functions domain_record_update to update a domain record and domain_record to get a domain record by id (#124)
  • domain_record_create gains paramater ttl for time to live for the domain record, in seconds (#124)

MINOR IMPROVEMENTS

  • Fixed some typos (#131) thanks @patperu
  • docklet_rstudio, docklet_shinyserver, and docklet_shinyapp now return a droplet instead of a URL so they can be piped - docs now contain how to construct the URL for the rstudio or shiny server instance in case user sets browse = FALSE (#134)
  • domain_record_create and domain_record_update gain parameters flags and tag for CAA support for Domain Record resources (#137)
  • docklet_images gets an all param, with default value of TRUE (#135)
  • Added examples to docs for how to install specific R versions easily with docker, see ?docklet_create (#106)

BUG FIXES

  • Fix to droplet_create: it couldn't generate a random name without first loading the package via library (#125) thanks @trestletech
  • debian_add_swap adds swap memory, but was not persisted across reboots. fixed now (#127) thanks @trestletech
  • In droplet_create, the parameters ssh_keys and tags now default to list() instead of NULL as they path pass to I() that warns now on NULL (#129)

DEPRECATED AND DEFUNCT

  • tag_rename is now defunct as is you can no longer rename tags (#123)

analogsea 0.5.0

NEW FEATURES

  • New function docklets_create() to create many docklets at once (similar to droplets_create()) (#120)
  • New volumes methods for the new block storage (aka volumes) https://www.digitalocean.com/products/storage/: volume, volume_action, volume_actions, volume_attach, volume_create, volume_delete, volume_detach, volume_resize, volume_snapshot_create, volume_snapshots, volumes, as.volume (#121)
  • New methods for new unified snapshots DO endpoints: snapshot, snapshots, snapshot_delete, and as.shapshot (#121)

MINOR IMPROVEMENTS

  • You can now pass tags to the parameter of the same name when creating droplets, with either droplet_create, droplets_create, docklet_create, or docklets_create. The tags can be existing ones, or if not they will be created (#122)
  • Added more help on ssh keys to pkg level man file and to vignette (#115)

analogsea 0.4.0

NEW FEATURES

  • Suite of new functions for tags: tag(), tag_create(), tag_delete(), tag_rename(), tag_resource(), tag_resource_delete(), tags(), and as.tag() (#117)
  • Related to last bulllet: droplet_delete() gains new parameter tag; droplets() gains new parameter tag, and examples added to its man file for tag usage.
  • New functions docklet_shinyserver() and docklet_shinyapp() to spin up Shiny server and a Shiny app, respectively. (#100)
  • New function droplet_enable_backups() (#110)
  • New function droplets_create() to create many droplets at once (#112)
  • New function droplets_cost() to calculate cost of droplets across one or more droplets.

MINOR IMPROVEMENTS

  • Added floating_ip_limit field to account() print method (#111)
  • Improved description of name parameter for droplet_create() and docklet_create()

BUG FIXES

  • Fixed problem with docklet_create() when port 22 is not open before further action is taken on the droplet. We now check if port 22 is open and error with informative message about waiting a bit for it to open (#113) thanks @fmichonneau @hrbrmstr
  • Fixed problem in the print.droplet due to problem in droplet_ip() internal function (#109)
  • Fix to *_create to allow flexibility in how often DO API is pinged. Previously we pinged every second, meaning you could hit your API rate limit fastish. Now you can set an option do.wait_time to tweak time bewtween pings to check for droplet creation (or other actions). See https://github.com/sckott/analogsea/issues/108#issuecomment-151519855 for example of doing droplet creation in parallel. (#108) thanks @simecek !
  • Fixed parsing bug in sizes() (#119)

analogsea 0.3.0

NEW FEATURES

  • Released to CRAN.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("analogsea")

0.7.2 by Scott Chamberlain, 3 months ago


https://github.com/sckott/analogsea


Report a bug at https://github.com/sckott/analogsea/issues


Browse source code at https://github.com/cran/analogsea


Authors: Scott Chamberlain [aut, cre] , Hadley Wickham [aut] , Winston Chang [aut] , Bob Rudis [ctb] , Bryce Mecum [ctb] , RStudio [cph]


Documentation:   PDF Manual  


Task views: Web Technologies and Services


MIT + file LICENSE license


Imports stats, utils, httr, jsonlite, magrittr, yaml, aws.s3

Suggests roxygen2, testthat, knitr, ssh


Suggested by plumber.


See at CRAN