smartdc 0.2.0
Experimental Joyent SmartDataCenter 6.5 & 7.0 CloudAPI connector using http-signature authentication via Requests
License: MIT
Keywords: http,web,joyent,admin,operations

Python SmartDataCenter
======================

Connect with Joyent_'s SmartDataCenter CloudAPI_ via Python, using secure 
http-signature_ signed requests. It enables you to programmatically provision
and otherwise control machines within Joyent_'s public cloud.

This is a third-party effort.

This module currently supports:

* Secure connections (via http_signature_ and optionally, ssh-agent)
* Key management
* Browsing and access of datacenters, datasets (OS distributions/VM bundles), 
  and packages (machine sizes and resources)
* Machine listing, search, creation, management 
  (start/stop/reboot/resize/delete), snapshotting, metadata, and tags
* Installing boot scripts on machines

It attempts to provide Pythonic objects (for Data Centers, Machines and 
Snapshots) and convenience methods only when appropriate, and otherwise deals 
with string identifiers or dicts as lightweight objects.

Requirements
------------

* requests_
* http_signature_
* PyCrypto_ (required by http_signature)

Optional:

* ssh_  or paramiko_ (post-1.8.0) 
  (used by http_signature for its ``ssh-agent`` integration)

We assume that ``json`` is present because requests now requires py2.6 and 
up.

Python SmartDataCenter Links
----------------------------

* `Python SmartDataCenter Tutorial`_ 
* `smartdc in PyPI`_
* `http_signature in PyPI`_
* `py-smartdc at GitHub`_
* `py-http-signature at GitHub`_
* `py-smartdc Documentation`_ & API reference
* `Joyent CloudAPI Documentation`_

.. _Joyent: http://joyentcloud.com/
.. _CloudAPI: https://api.joyentcloud.com/docs
.. _Joyent CloudAPI Documentation: CloudAPI_
.. _http-signature: 
    https://github.com/joyent/node-http-signature/blob/master/http_signing.md
.. _requests: http://pypi.python.org/pypi/requests
.. _PyCrypto: http://pypi.python.org/pypi/pycrypto
.. _ssh: http://pypi.python.org/pypi/ssh
.. _paramiko: http://pypi.python.org/pypi/paramiko
.. _Python SmartDataCenter Tutorial: 
    http://pythonhosted.org/smartdc/tutorial.html
.. _smartdc in PyPI: http://pypi.python.org/pypi/smartdc
.. _http_signature in PyPI: http://pypi.python.org/pypi/http_signature
.. _http_signature: `http_signature in PyPI`_
.. _py-http-signature at GitHub: https://github.com/atl/py-http-signature
.. _py-smartdc at GitHub: https://github.com/atl/py-smartdc
.. _py-smartdc Documentation: http://pythonhosted.org/smartdc/
.. _Telefónica's InstantServers: http://cloud.telefonica.com/instantservers/

Installation
------------

::

    pip install smartdc

Quickstart
----------

This requires a Joyent Public Cloud account with valid payment information and
at least one SSH key uploaded. The example as presented should cost a maximum
of 0.01USD::

    from smartdc import DataCenter
    
    sdc = DataCenter(location='us-sw-1', key_id='/accountname/keys/keyname')
    
    sdc.datasets()
    
    sm = sdc.create_machine(name='test', dataset='sdc:sdc:standard:1.0.7',
          package='g3-standard-0.25-smartos')
    
    sm.poll_until('running')
    
    import urllib2
    
    urllib2.urlopen('http://' + sm.public_ips[0]).headers.dict
    
    sm.stop()
    
    sm.poll_until('stopped')
    
    sm.delete()

Connecting with `Telefónica's InstantServers`_::

    from smartdc import DataCenter, TELEFONICA_LOCATIONS
    
    mad = DataCenter(location='eu-mad-1', 
                  known_locations=TELEFONICA_LOCATIONS,
                  key_id='/accountname/keys/keyname')
    
    mad.default_package()

Why?
----

A colleague and I wanted something Pythonic to fit into our preferred 
toolchain, and the easiest approach was to build it myself. Requests made some 
aspects stupidly easy, which is why I created the dependency for the first 
version. The colleague wanted integration with ``ssh-agent``, and using ssh_ 
was the easiest path to that.

Authors
-------

`Adam T. Lindsay`_

.. _Adam T. Lindsay: http://atl.me/

License
-------

MIT


Changes
-------

0.2.0 (2013-06-17)
~~~~~~~~~~~~~~~~~~
This is an initial release to accommodate demand for basic SDC API v7.0 features. Further work is to come, so the API and features are to be considered unstable and in flux.

* Support SmartDC API Version 7.0 by default
* Add legacy mode for places where version 6.5 calls are necessary -- calling a v7.0 machine in v6.5 mode will lead to unexpected results.
* Added list/get networks, list/get images methods
* Support new REST API-level filtering for listing packages and images
* ``create_machine()`` now accepts a network parameter
* Eliminated the previously-deprecated ``DataCenter(config=)`` parameter

0.1.13 (2013-06-13)
~~~~~~~~~~~~~~~~~~~
* Changes to allow for connections to vmwebadm hubs
* Be resilient to IP addresses not being present immediately on creation
* Adapt documentation to allow for late v6.5 API deployment changes

0.1.12 (2013-01-08)
~~~~~~~~~~~~~~~~~~~
* Telefónica has updated the endpoints for its known locations. These locations are capable of SSL-verifiable connections.
* Move print statements in library to print functions (still pending issue with versioneer)
* Requests 1.0 release removed ``config`` from request's keyword arguments, so created a workaround that works in old and new versions
* ``verbose`` (bool) is now the preferred keyword argument in DataCenter initialization since we no longer piggy-back on requests config. ``config`` issues a warning.

0.1.11 (2012-12-07)
~~~~~~~~~~~~~~~~~~~
* Minor update to the README quickstart
* Machines are hashable based on their UUIDs
* Pre-programmed Telefónica locations are based on FQDNs
* KNOWN ISSUE: DataCenter equality not guaranteed with Telefónica servers (due to how they are identified by Telefónica)

0.1.10 (2012-11-07)
~~~~~~~~~~~~~~~~~~~
* This version accommodates communication with Telefónica's InstantServers service
* Change documentation to account for underlying shift in py-http-signature accommodating both (new) paramiko and ssh
* Add "verify" option to DataCenter to allow for opt-out of SSL Certificate verification (necessitated by Telefónica's initial release of InstantServers)
* Save more state from current DataCenter when transferring to another one
* Be a little more resourceful in resolving a DataCenter.datacenter() argument by name

0.1.9 (2012-10-02)
~~~~~~~~~~~~~~~~~~
* Bug fix: POSTs including data would get mangled while looking for a correct ssh-agent key (thanks, @thekad)
* Bug fix: ssh-agent would throw wrong error if it failed to find any keys
* Set `allow-agent` to False by default, thanks in part to this less-explored code path

0.1.8 (2012-05-02)
~~~~~~~~~~~~~~~~~~
* Bug fix: double-json encoding on add_key got in way of proper upload
* Introduce python-versioneer to hopefully make version management more palatable

0.1.7 (2012-05-01)
~~~~~~~~~~~~~~~~~~
* Renamed metadata_dict and tag_dict parameters to metadata and tags
* POST data as JSON, rather than encoded in URL
* Added boot_script option on machine creation
* Process and expose credentials
* Slight tutorial and other documentation cleanup
* Local filtering on datasets and packages

0.1.6 (2012-04-30)
~~~~~~~~~~~~~~~~~~
* Fixed release issues (README)
* Moved long tutorial out of the README
* Integrated with ``ssh-agent`` changes in ``http_signature``