You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by rb...@apache.org on 2011/03/27 06:59:56 UTC
svn commit: r1085874 -
/incubator/libcloud/site/trunk/content/libcloud/getting-started.mdtext
Author: rbogorodskiy
Date: Sun Mar 27 04:59:55 2011
New Revision: 1085874
URL: http://svn.apache.org/viewvc?rev=1085874&view=rev
Log:
Remove garbage char and clean up trailing whitespaces.
Modified:
incubator/libcloud/site/trunk/content/libcloud/getting-started.mdtext
Modified: incubator/libcloud/site/trunk/content/libcloud/getting-started.mdtext
URL: http://svn.apache.org/viewvc/incubator/libcloud/site/trunk/content/libcloud/getting-started.mdtext?rev=1085874&r1=1085873&r2=1085874&view=diff
==============================================================================
--- incubator/libcloud/site/trunk/content/libcloud/getting-started.mdtext (original)
+++ incubator/libcloud/site/trunk/content/libcloud/getting-started.mdtext Sun Mar 27 04:59:55 2011
@@ -1,7 +1,7 @@
title: Getting started
## Installation ##
-s
+
libcloud's current release is **0.4.2**, and can be [downloaded](downloads.html), but it is also [available on PyPi](http://pypi.python.org/pypi/apache-libcloud)
::bash
@@ -10,9 +10,9 @@ libcloud's current release is **0.4.2**,
## API Reference Documentation ##
[Available here](http://ci.apache.org/projects/libcloud/apidocs/).
-
+
## Example: Connecting with a Driver ##
-
+
::python
from libcloud.types import Provider
from libcloud.providers import get_driver
@@ -38,14 +38,14 @@ libcloud's current release is **0.4.2**,
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])
+ # 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 ...>
## Example: List Nodes Across Multiple Providers ##
@@ -53,64 +53,64 @@ libcloud's current release is **0.4.2**,
The following example will list servers across Amazon EC2, Slicehost, and Rackspace Cloud Servers using the same API call. The servers will be represented in a standard Node object.
::python
- from libcloud.types import Provider
- from libcloud.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'
+ from libcloud.types import Provider
+ from libcloud.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']
## Example: Bootstrapping Puppet on a Node ##
Just creating a node isn't that helpful because each cloud gives you
-back nodes in different states. The deploy_node API lets
-you do more complex actions in cross-cloud portable manner. It works by
-calling create_node, and then SSHing into the node to run a script
+back nodes in different states. The deploy_node API lets
+you do more complex actions in cross-cloud portable manner. It works by
+calling create_node, and then SSHing into the node to run a script
or install an SSH Key.
::python
- from libcloud.types import Provider
- from libcloud.providers import get_driver
- from libcloud.deployment import MultiStepDeployment, 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
- sd = SSHKeyDeployment(open(os.path.expanduser("~/.ssh/id_dsa.pub")).read())
- # a simple script to install puppet post boot, can be much more complicated.
- script = ScriptDeployment("apt-get 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.
+ from libcloud.types import Provider
+ from libcloud.providers import get_driver
+ from libcloud.deployment import MultiStepDeployment, 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
+ sd = SSHKeyDeployment(open(os.path.expanduser("~/.ssh/id_dsa.pub")).read())
+ # a simple script to install puppet post boot, can be much more complicated.
+ script = ScriptDeployment("apt-get 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.