Coder Social home page Coder Social logo

doto's Introduction

Build Status

doto

Doto is a Python interface to Digital Ocean with an emphasis on production usage. doto supports the full Digital Ocean API:

Full Documentation at: http://quasiben.github.io/doto/

To get started with doto create a .dotorc file in a directory named, ~/.doto, with your api_key and client_id listed:

[Credentials]
client_id = XXXXXXXXXXXXX
api_key = 99999999999999999999999

You are now ready to use doto

import doto
d0 = doto.connect_d0()

new_key = d0.create_key_pair('my_new_key_pair')
droplet = d0.create_droplet(name='Random',
                            size_id=66, #512MB
                            image_id=2158507, #Docker 0.8 Ubuntu 13.04 x64
                            region_id=1, #New York
                            ssh_key_ids=[new_key['id']]
                            )
while droplet.percentage_update() != '100':
    print droplet.percentage

Doto is designed to support both Python 2.7 and Python 3 and provides an interface with filtering options similar to boto.

In [1]: import doto
d0
In [2]: d0 = doto.connect_d0()

In [3]: filters = {'distribution':u'CentOS','name':'x64'}

In [4]: d0.get_all_images(filters=filters)
>>> Getting /images
Out[4]: [Image:1601, Image:562354, Image:1646467]

In [5]: images = d0.get_all_images(filters=filters)
>>> Getting /images

In [6]: for img in images:
    print img.distribution, img.name, img.id
   ...:
CentOS CentOS 5.8 x64 1601
CentOS CentOS 6.4 x64 562354
CentOS CentOS 6.5 x64 1646467

Using the table=True argument, for a number of get funcs prints a well formatted table for inline exploratory

sessions:

In [3]: d0.get_all_images(table=True)
>>> Getting /images
| Ubuntu       | None | True   | 1505699 | Ubuntu 13.10 x64                                |
| Ubuntu       | None | True   | 1608711 | Ruby on Rails on Ubuntu 12.10 (Nginx + Unicorn) |
| CentOS       | None | True   | 1646467 | CentOS 6.5 x64                                  |
| CentOS       | None | True   | 1646732 | CentOS 6.5 x32                                  |
| Ubuntu       | None | True   | 1687372 | Redmine on Ubuntu 12.04                         |
| Ubuntu       | None | True   | 1860934 | Ghost 0.4.0 on Ubuntu 12.04                     |
| Ubuntu       | None | True   | 2105243 | GitLab 6.5.1 CE                                 |
| Ubuntu       | None | True   | 2118237 | Dokku-v0.2.1 on Ubuntu 13.04                    |
| Ubuntu       | None | True   | 2158507 | Docker 0.8 Ubuntu 13.04 x64                     |
...

doto's People

Contributors

quasiben avatar bkreider avatar andresvia avatar srossross avatar

Stargazers

 avatar Boo Bear avatar Luis R. Lavina Jr. avatar Raymond Joseph Usher Roche avatar Arthur Alvim avatar gregory nicholas avatar Allen Sallinger avatar Mohamed Elsayed avatar Jürgen Hermann avatar Omer Katz avatar Rakan Al-Huneiti avatar Philip Branning avatar Javier Alba avatar Guillermo Palafox avatar Joemar Taganna avatar Sviatoslav Sydorenko (Святослав Сидоренко) avatar Luiz Boaretto avatar Travis Swicegood avatar Scott Tsai avatar Gustavo Lacoste avatar Itxaka avatar Dan Gayle avatar Anthony Scalisi avatar  avatar Stephen Diehl avatar

Watchers

Luiz Boaretto avatar Omer Katz avatar James Cloos avatar  avatar Derek Pauley avatar

doto's Issues

Bad config file raises exception

I have an old config file at ~/.doto instead of the ~/.doto/.dotorc

In [2]: d0 = doto.connect_d0()
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-2-8d93069f8804> in <module>()
----> 1 d0 = doto.connect_d0()

/Users/bkreider/mine/doto-ben/doto/__init__.py in __init__(self, path)
     28 
     29     def __init__(self, path=None):
---> 30         config = Config(path)
     31         self._client_id = config.get('Credentials','client_id')
     32         self._api_key = config.get('Credentials','api_key')

/Users/bkreider/mine/doto-ben/doto/config.py in __init__(self, path)
     49         else:
     50             f = self.read(DotoConfigLocations)
---> 51             self.file_path = f[0]
     52 
     53     def get(self, section, name, default=None):

IndexError: list index out of range

versioneer error

I first did a conda install doto from the wakari channel (out of date). It didn't have the "use_current" option for rebuilding a droplet, so i went to pip install on top of it and got this error:

[root@downloads wakari-deploy]# pip install doto --upgrade
Downloading/unpacking doto from https://pypi.python.org/packages/source/d/doto/doto-v0.3.tar.gz#md5=58bd150c0654e1dcb0ad675f18eef757
  Downloading doto-v0.3.tar.gz
  Running setup.py egg_info for package doto
    Traceback (most recent call last):
      File "<string>", line 16, in <module>
      File "/tmp/pip_build_root/doto/setup.py", line 5, in <module>
        import versioneer
    ImportError: No module named versioneer
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

  File "<string>", line 16, in <module>

  File "/tmp/pip_build_root/doto/setup.py", line 5, in <module>

    import versioneer

ImportError: No module named versioneer

----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /tmp/pip_build_root/doto

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.