docs: Add getting started page, update index page.

Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/acfceb4e
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/acfceb4e
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/acfceb4e

Branch: refs/heads/trunk
Commit: acfceb4e93cb268a92ddad79ed886106f4635080
Parents: 2dbcc74
Author: Tomaz Muraus <[email protected]>
Authored: Sat Aug 3 23:16:30 2013 +0200
Committer: Tomaz Muraus <[email protected]>
Committed: Sat Aug 3 23:16:30 2013 +0200

----------------------------------------------------------------------
 docs/_static/images/libcloud_logo.png           | Bin 0 -> 9716 bytes
 docs/_static/images/supported_providers.png     | Bin 0 -> 110558 bytes
 docs/conf.py                                    |   2 +-
 .../compute/bootstrapping_puppet_on_node.py     |  30 +++++++++++++
 docs/examples/compute/create_node.py            |  19 ++++++++
 docs/examples/compute/list_nodes.py             |  11 +++++
 .../list_nodes_across_multiple_providers.py     |  26 +++++++++++
 docs/getting-started.rst                        |  44 +++++++++++++++++++
 docs/index.rst                                  |   5 +++
 9 files changed, 136 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/acfceb4e/docs/_static/images/libcloud_logo.png
----------------------------------------------------------------------
diff --git a/docs/_static/images/libcloud_logo.png 
b/docs/_static/images/libcloud_logo.png
new file mode 100755
index 0000000..f583f93
Binary files /dev/null and b/docs/_static/images/libcloud_logo.png differ

http://git-wip-us.apache.org/repos/asf/libcloud/blob/acfceb4e/docs/_static/images/supported_providers.png
----------------------------------------------------------------------
diff --git a/docs/_static/images/supported_providers.png 
b/docs/_static/images/supported_providers.png
new file mode 100644
index 0000000..27645f6
Binary files /dev/null and b/docs/_static/images/supported_providers.png differ

http://git-wip-us.apache.org/repos/asf/libcloud/blob/acfceb4e/docs/conf.py
----------------------------------------------------------------------
diff --git a/docs/conf.py b/docs/conf.py
index 66355a5..5383442 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -125,7 +125,7 @@ else:
 # Add any paths that contain custom static files (such as style sheets) here,
 # relative to this directory. They are copied after the builtin static files,
 # so a file named "default.css" will overwrite the builtin "default.css".
-html_static_path = ['_static']
+html_static_path = ['_static', '_static/images/']
 
 # If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
 # using the given strftime format.

http://git-wip-us.apache.org/repos/asf/libcloud/blob/acfceb4e/docs/examples/compute/bootstrapping_puppet_on_node.py
----------------------------------------------------------------------
diff --git a/docs/examples/compute/bootstrapping_puppet_on_node.py 
b/docs/examples/compute/bootstrapping_puppet_on_node.py
new file mode 100644
index 0000000..c72921f
--- /dev/null
+++ b/docs/examples/compute/bootstrapping_puppet_on_node.py
@@ -0,0 +1,30 @@
+from libcloud.compute.types import Provider
+from libcloud.compute.providers import get_driver
+from libcloud.compute.deployment import MultiStepDeployment
+from libcloud.compute.deployment import ScriptDeployment, SSHKeyDeployment
+import os
+
+RACKSPACE_USER = 'your username'
+RACKSPACE_KEY = 'your key'
+
+Driver = get_driver(Provider.RACKSPACE)
+conn = Driver(RACKSPACE_USER, RACKSPACE_KEY)
+
+# read your public key in
+# Note: This key will be added to the authorized keys for the root user
+# (/root/.ssh/authorized_keys)
+sd = SSHKeyDeployment(open(os.path.expanduser("~/.ssh/id_rsa.pub")).read())
+# a simple script to install puppet post boot, can be much more complicated.
+script = ScriptDeployment("apt-get -y install puppet")
+# a task that first installs the ssh key, and then runs the script
+msd = MultiStepDeployment([sd, script])
+
+images = conn.list_images()
+sizes = conn.list_sizes()
+
+# deploy_node takes the same base keyword arguments as create_node.
+node = conn.deploy_node(name='test', image=images[0], size=sizes[0],
+                        deploy=msd)
+# <Node: uuid=..., name=test, state=3, public_ip=['1.1.1.1'],
+#  provider=Rackspace ...>
+# the node is now booted, with your ssh key and puppet installed.

http://git-wip-us.apache.org/repos/asf/libcloud/blob/acfceb4e/docs/examples/compute/create_node.py
----------------------------------------------------------------------
diff --git a/docs/examples/compute/create_node.py 
b/docs/examples/compute/create_node.py
new file mode 100644
index 0000000..9a645c8
--- /dev/null
+++ b/docs/examples/compute/create_node.py
@@ -0,0 +1,19 @@
+from libcloud.compute.types import Provider
+from libcloud.compute.providers import get_driver
+
+RACKSPACE_USER = 'your username'
+RACKSPACE_KEY = 'your key'
+
+Driver = get_driver(Provider.RACKSPACE)
+conn = Driver(RACKSPACE_USER, RACKSPACE_KEY)
+
+# retrieve available images and sizes
+images = conn.list_images()
+# [<NodeImage: id=3, name=Gentoo 2008.0, driver=Rackspace  ...>, ...]
+sizes = conn.list_sizes()
+# [<NodeSize: id=1, name=256 server, ram=256 ... driver=Rackspace ...>, ...]
+
+# create node with first image and first size
+node = conn.create_node(name='test', image=images[0], size=sizes[0])
+# <Node: uuid=..., name=test, state=3, public_ip=['1.1.1.1'],
+#   provider=Rackspace ...>

http://git-wip-us.apache.org/repos/asf/libcloud/blob/acfceb4e/docs/examples/compute/list_nodes.py
----------------------------------------------------------------------
diff --git a/docs/examples/compute/list_nodes.py 
b/docs/examples/compute/list_nodes.py
new file mode 100644
index 0000000..97afdcf
--- /dev/null
+++ b/docs/examples/compute/list_nodes.py
@@ -0,0 +1,11 @@
+from libcloud.compute.types import Provider
+from libcloud.compute.providers import get_driver
+
+EC2_ACCESS_ID = 'your access id'
+EC2_SECRET_KEY = 'your secret key'
+
+Driver = get_driver(Provider.EC2)
+conn = Driver(EC2_ACCESS_ID, EC2_SECRET_KEY)
+
+nodes = conn.list_nodes()
+# [<Node: uuid=..., state=3, public_ip=['1.1.1.1'], provider=EC2 ...>, ...]

http://git-wip-us.apache.org/repos/asf/libcloud/blob/acfceb4e/docs/examples/compute/list_nodes_across_multiple_providers.py
----------------------------------------------------------------------
diff --git a/docs/examples/compute/list_nodes_across_multiple_providers.py 
b/docs/examples/compute/list_nodes_across_multiple_providers.py
new file mode 100644
index 0000000..d3d19fc
--- /dev/null
+++ b/docs/examples/compute/list_nodes_across_multiple_providers.py
@@ -0,0 +1,26 @@
+from libcloud.compute.types import Provider
+from libcloud.compute.providers import get_driver
+
+EC2_ACCESS_ID = 'your access id'
+EC2_SECRET_KEY = 'your secret key'
+SLICEHOST_API_KEY = 'your api key'
+RACKSPACE_USER = 'your username'
+RACKSPACE_KEY = 'your key'
+
+EC2Driver = get_driver(Provider.EC2)
+SlicehostDriver = get_driver(Provider.SLICEHOST)
+RackspaceDriver = get_driver(Provider.RACKSPACE)
+
+drivers = [EC2Driver(EC2_ACCESS_ID, EC2_SECRET_KEY),
+           SlicehostDriver(SLICEHOST_API_KEY),
+           RackspaceDriver(RACKSPACE_USER, RACKSPACE_KEY)]
+
+nodes = []
+for driver in drivers:
+    nodes += driver.list_nodes()
+print nodes
+# [ <Node: provider=Amazon, status=RUNNING, name=bob, ip=1.2.3.4.5>,
+#   <Node: provider=Slicehost, status=REBOOT, name=korine, ip=6.7.8.9>, ... ]
+
+# Reboot all nodes named 'test'
+[node.reboot() for node in nodes if node.name == 'test']

http://git-wip-us.apache.org/repos/asf/libcloud/blob/acfceb4e/docs/getting-started.rst
----------------------------------------------------------------------
diff --git a/docs/getting-started.rst b/docs/getting-started.rst
new file mode 100644
index 0000000..7352480
--- /dev/null
+++ b/docs/getting-started.rst
@@ -0,0 +1,44 @@
+Getting Started
+===============
+
+Installation
+------------
+
+Libcloud is available on PyPi and can be installed using pip:
+
+.. sourcecode:: bash
+
+    pip install apache-libcloud
+
+Upgrading
+---------
+
+If you used pip to install the library you can also use it to upgrade it:
+
+.. sourcecode:: bash
+
+    pip install --upgrade apache-libcloud
+
+Example: Connecting with a Driver
+---------------------------------
+
+.. literalinclude:: /examples/compute/list_nodes.py
+   :language: python
+
+Example: Creating a Node
+------------------------
+
+.. literalinclude:: /examples/compute/create_node.py
+   :language: python
+
+Example: List Nodes Across Multiple Providers
+---------------------------------------------
+
+.. literalinclude:: /examples/compute/list_nodes_across_multiple_providers.py
+   :language: python
+
+Example: Bootstrapping Puppet on a Node
+---------------------------------------
+
+.. literalinclude:: /examples/compute/bootstrapping_puppet_on_node.py
+   :language: python

http://git-wip-us.apache.org/repos/asf/libcloud/blob/acfceb4e/docs/index.rst
----------------------------------------------------------------------
diff --git a/docs/index.rst b/docs/index.rst
index 8ee7bbe..9305655 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -25,6 +25,11 @@ Resource you can manage with Libcloud are divided in the 
following categories:
 * :doc:`Load Balancers as a Service </loadbalancer/index>`
 * :doc:`DNS as a Service </dns/index>`
 
+.. figure:: /_static/images/supported_providers.png
+    :align: center
+
+    A subset of supported providers in Libcloud.
+
 .. toctree::
     :glob:
     :maxdepth: 2

Reply via email to