You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by to...@apache.org on 2013/08/15 20:31:06 UTC

git commit: docs: Add an example which shows how to create an EC2 node with a custom AMI.

Updated Branches:
  refs/heads/trunk f1d11318f -> d7e08d340


docs: Add an example which shows how to create an EC2 node with a custom AMI.


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

Branch: refs/heads/trunk
Commit: d7e08d340e233b635f2d791dae24957bfdf375dd
Parents: f1d1131
Author: Tomaz Muraus <to...@apache.org>
Authored: Thu Aug 15 20:30:45 2013 +0200
Committer: Tomaz Muraus <to...@apache.org>
Committed: Thu Aug 15 20:30:45 2013 +0200

----------------------------------------------------------------------
 docs/compute/examples.rst                       | 21 ++++++++++++++++-
 .../compute/create_ec2_node_custom_ami.py       | 24 ++++++++++++++++++++
 2 files changed, 44 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/d7e08d34/docs/compute/examples.rst
----------------------------------------------------------------------
diff --git a/docs/compute/examples.rst b/docs/compute/examples.rst
index 95b2d3e..47167af 100644
--- a/docs/compute/examples.rst
+++ b/docs/compute/examples.rst
@@ -48,10 +48,29 @@ Create a VMware vCloud v1.5 node using generic provider
 -------------------------------------------------------
 
 This example demonstrates how to launch a VMware vCloud v1.5 node on a
-generic provider such as a test lab.
+generic provider such as a test lab
 
 .. note::
     This example works with Libcloud version 0.10.1 and above.
 
 .. literalinclude:: /examples/compute/vmware_vcloud_1.5.py
    :language: python
+
+
+Create EC2 node using a custom AMI
+----------------------------------
+
+This examples demonstrates how to create an EC2 node using a custom AMI (Amazon
+Machine Image).
+
+AMI's are region specific which means you need to select AMI which is available
+in the region of an EC2 driver you have instantiated.
+
+In Libcloud 0.13.0 and lower, region is determined based on the provider
+constant (``us-east-1`` is available as ``Provider.EC2_US_EAST``, ``us-west-1``
+is available as ``Provider.EC2_US_WEST`` and so on). For a full list of
+supported providers and provider constants, see
+:doc:`supported providers page </compute/supported_providers>`
+
+.. literalinclude:: /examples/compute/create_ec2_node_custom_ami.py
+   :language: python

http://git-wip-us.apache.org/repos/asf/libcloud/blob/d7e08d34/docs/examples/compute/create_ec2_node_custom_ami.py
----------------------------------------------------------------------
diff --git a/docs/examples/compute/create_ec2_node_custom_ami.py b/docs/examples/compute/create_ec2_node_custom_ami.py
new file mode 100644
index 0000000..4d70d58
--- /dev/null
+++ b/docs/examples/compute/create_ec2_node_custom_ami.py
@@ -0,0 +1,24 @@
+from libcloud.compute.types import Provider
+from libcloud.compute.providers import get_driver
+from libcloud.compute.base import NodeImage
+
+ACCESS_ID = 'your access id'
+SECRET_KEY = 'your secret key'
+
+# Image with Netflix Asgard available in us-west-1 region
+# https://github.com/Answers4AWS/netflixoss-ansible/wiki/AMIs-for-NetflixOSS
+AMI_ID = 'ami-c8052d8d'
+
+SIZE_ID = 't1.micro'
+
+# 'us-west-1' region is available in Libcloud under EC2_US_WEST provider
+# constant
+cls = get_driver(Provider.EC2_US_WEST)
+driver = cls(ACCESS_ID, SECRET_KEY)
+
+# Here we select
+sizes = driver.list_sizes()
+size = [s for s in sizes if s.id == 't1.micro'][0]
+image = NodeImage(id=AMI_ID, name=None, driver=driver)
+
+node = driver.create_node(name='test-node', image=image, size=size)