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 22:02:21 UTC
[1/2] git commit: Update EC2 docstring to correctly indicate
ex_securitygroup type and description.
Updated Branches:
refs/heads/trunk d7e08d340 -> a3c0479ca
Update EC2 docstring to correctly indicate ex_securitygroup type and
description.
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/adfbce14
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/adfbce14
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/adfbce14
Branch: refs/heads/trunk
Commit: adfbce1456898fa05a83594218bcfb5a8b34864d
Parents: d7e08d3
Author: Tomaz Muraus <to...@apache.org>
Authored: Thu Aug 15 21:48:38 2013 +0200
Committer: Tomaz Muraus <to...@apache.org>
Committed: Thu Aug 15 21:48:38 2013 +0200
----------------------------------------------------------------------
libcloud/compute/drivers/ec2.py | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/adfbce14/libcloud/compute/drivers/ec2.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/ec2.py b/libcloud/compute/drivers/ec2.py
index f2b1109..5d18469 100644
--- a/libcloud/compute/drivers/ec2.py
+++ b/libcloud/compute/drivers/ec2.py
@@ -1325,8 +1325,9 @@ class BaseEC2NodeDriver(NodeDriver):
@keyword ex_maxcount: Maximum number of instances to launch
@type ex_maxcount: C{int}
- @keyword ex_securitygroup: Name of security group
- @type ex_securitygroup: C{str}
+ @keyword ex_securitygroup: Name of security group or a list of names
+ for multiple security groups.
+ @type ex_securitygroup: C{str} or C{list}
@keyword ex_keyname: The name of the key pair
@type ex_keyname: C{str}
[2/2] git commit: docs: Add another ec2 example.
Posted by to...@apache.org.
docs: Add another ec2 example.
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/a3c0479c
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/a3c0479c
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/a3c0479c
Branch: refs/heads/trunk
Commit: a3c0479cae45b033d64755da65658d4f7abece3a
Parents: adfbce1
Author: Tomaz Muraus <to...@apache.org>
Authored: Thu Aug 15 22:02:09 2013 +0200
Committer: Tomaz Muraus <to...@apache.org>
Committed: Thu Aug 15 22:02:09 2013 +0200
----------------------------------------------------------------------
docs/compute/examples.rst | 18 ++++++++++++++
.../create_ec2_node_keypair_and_to_secgroup.py | 25 ++++++++++++++++++++
2 files changed, 43 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/a3c0479c/docs/compute/examples.rst
----------------------------------------------------------------------
diff --git a/docs/compute/examples.rst b/docs/compute/examples.rst
index 47167af..719fac4 100644
--- a/docs/compute/examples.rst
+++ b/docs/compute/examples.rst
@@ -56,6 +56,24 @@ generic provider such as a test lab
.. literalinclude:: /examples/compute/vmware_vcloud_1.5.py
:language: python
+Create EC2 node using a provided key pair and security groups
+-------------------------------------------------------------
+
+.. note::
+
+ This example assumes the provided key pair already exists. If the key pair
+ doesn't exist yet, you can create it using AWS dashboard, or
+ :func:`ex_import_keypair` driver method.
+
+This example demonstrates how to create an EC2 node using an existing key pair.
+Created node also gets added to the provided security groups.
+
+.. literalinclude:: /examples/compute/create_ec2_node_keypair_and_to_secgroup.py
+ :language: python
+
+As noted in the example, you use `ex_keyname` argument to specify key pair name
+and `ex_securitygroup` to specify a name of a single (``str``) or multiple
+groups (``list``) you want this node to be added to.
Create EC2 node using a custom AMI
----------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/a3c0479c/docs/examples/compute/create_ec2_node_keypair_and_to_secgroup.py
----------------------------------------------------------------------
diff --git a/docs/examples/compute/create_ec2_node_keypair_and_to_secgroup.py b/docs/examples/compute/create_ec2_node_keypair_and_to_secgroup.py
new file mode 100644
index 0000000..40f96a4
--- /dev/null
+++ b/docs/examples/compute/create_ec2_node_keypair_and_to_secgroup.py
@@ -0,0 +1,25 @@
+from libcloud.compute.types import Provider
+from libcloud.compute.providers import get_driver
+
+ACCESS_ID = 'your access id'
+SECRET_KEY = 'your secret key'
+
+SIZE_ID = 't1.micro'
+
+# Name of the existing keypair you want to use
+KEYPAIR_NAME = 'keypairname'
+
+# A list of security groups you want this node to be added to
+SECURITY_GROUP_NAMES = ['secgroup1', 'secgroup2']
+
+cls = get_driver(Provider.EC2)
+driver = cls(ACCESS_ID, SECRET_KEY)
+
+sizes = driver.list_sizes()
+images = driver.list_images()
+size = [s for s in sizes if s.id == 't1.micro'][0]
+image = images[0]
+
+node = driver.create_node(name='test-node-1', image=image, size=size,
+ ex_keyname=KEYPAIR_NAME,
+ ex_securitygroup=SECURITY_GROUP_NAMES)