1+ """
2+ Deis cloud provider implementation for Amazon EC2.
3+ """
14
25from __future__ import unicode_literals
36
2629
2730
2831def seed_flavors ():
29- """Seed the database with default Flavors for each EC2 region.
32+ """Seed the database with default flavors for each EC2 region.
3033
31- :rtype: list of dicts containing Flavor data
34+ :rtype: list of dicts containing flavor data
3235 """
3336 flavors = []
3437 for r in ('us-east-1' , 'us-west-1' , 'us-west-2' , 'eu-west-1' ,
@@ -45,6 +48,11 @@ def seed_flavors():
4548
4649
4750def build_layer (layer ):
51+ """
52+ Build a layer.
53+
54+ :param layer: a dict containing formation, id, params, and creds info
55+ """
4856 region = layer ['params' ].get ('region' , 'us-east-1' )
4957 conn = _create_ec2_connection (layer ['creds' ], region )
5058 # create a new sg and authorize all ports
@@ -68,6 +76,11 @@ def build_layer(layer):
6876
6977
7078def destroy_layer (layer ):
79+ """
80+ Destroy a layer.
81+
82+ :param layer: a dict containing formation, id, params, and creds info
83+ """
7184 region = layer ['params' ].get ('region' , 'us-east-1' )
7285 name = "{formation}-{id}" .format (** layer )
7386 conn = _create_ec2_connection (layer ['creds' ], region )
@@ -84,6 +97,12 @@ def destroy_layer(layer):
8497
8598
8699def build_node (node ):
100+ """
101+ Build a node.
102+
103+ :param node: a dict containing formation, layer, params, and creds info.
104+ :rtype: a tuple of (provider_id, fully_qualified_domain_name, metadata)
105+ """
87106 params , creds = node ['params' ], node ['creds' ]
88107 region = params .setdefault ('region' , 'us-east-1' )
89108 conn = _create_ec2_connection (creds , region )
@@ -119,6 +138,11 @@ def build_node(node):
119138
120139
121140def destroy_node (node ):
141+ """
142+ Destroy a node.
143+
144+ :param node: a dict containing a node's provider_id, params, and creds
145+ """
122146 provider_id = node ['provider_id' ]
123147 region = node ['params' ].get ('region' , 'us-east-1' )
124148 conn = _create_ec2_connection (node ['creds' ], region )
@@ -133,6 +157,14 @@ def destroy_node(node):
133157
134158
135159def _create_ec2_connection (creds , region ):
160+ """
161+ Connect to an EC2 region with the given credentials.
162+
163+ :param creds: a dict containing an EC2 access_key and secret_key
164+ :region: the name of an EC2 region, such as "us-west-2"
165+ :rtype: a connected :class:`~boto.ec2.connection.EC2Connection`
166+ :raises EnvironmentError: if no credentials are provided
167+ """
136168 if not creds :
137169 raise EnvironmentError ('No credentials provided' )
138170 return ec2 .connect_to_region (region ,
0 commit comments