Skip to content
This repository was archived by the owner on Apr 24, 2024. It is now read-only.

Commit b780c8e

Browse files
committed
Merge branch 'master' of github.com:imduffy15/ec2stack
2 parents 712d335 + 7435459 commit b780c8e

2 files changed

Lines changed: 43 additions & 31 deletions

File tree

‎ec2stack/providers/cloudstack/__init__.py‎

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@
77

88
def describe_item(args, keyname, not_found, prefix):
99
"""
10+
Describe a specific item or all items.
1011
11-
@param args:
12-
@param keyname:
13-
@param not_found:
14-
@param prefix:
15-
@return:
12+
@param args: Arguments involved in the request.
13+
@param keyname: Keyname of the cloudstack response.
14+
@param not_found: Function to if the item is not found.
15+
@param prefix: Parameter prefix.
16+
@return: Response.
1617
"""
1718
if helpers.contains_parameter_with_keyword(prefix):
1819
response = _describe_specific_item(args, keyname, not_found, prefix)
@@ -24,12 +25,13 @@ def describe_item(args, keyname, not_found, prefix):
2425

2526
def _describe_specific_item(args, keyname, not_found, prefix):
2627
"""
28+
Describe a specific item based on args['id'] or args['name']
2729
28-
@param args:
29-
@param keyname:
30-
@param not_found:
31-
@param prefix:
32-
@return:
30+
@param args: Arguments involved in the request.
31+
@param keyname: Keyname of the cloudstack response.
32+
@param not_found: Function to call if the item is not found.
33+
@param prefix: Parameter prefix.
34+
@return: Response.
3335
"""
3436
keys = helpers.get_request_parameter_keys(prefix)
3537

@@ -51,11 +53,12 @@ def _describe_specific_item(args, keyname, not_found, prefix):
5153

5254
def describe_item_request(args, keyname, not_found):
5355
"""
56+
Executes the request and searches the Cloudstack response for the item.
5457
55-
@param args:
56-
@param keyname:
57-
@param not_found:
58-
@return:
58+
@param args: Arguments involved in the request.
59+
@param keyname: Keyname of the cloudstack response.
60+
@param not_found: Function to call if the item is not found.
61+
@return: Response.
5962
"""
6063
request = describe_items_request(args, not_found)
6164
request = request[keyname]
@@ -71,10 +74,11 @@ def describe_item_request(args, keyname, not_found):
7174

7275
def describe_items_request(args, not_found):
7376
"""
77+
Executes the request.
7478
75-
@param args:
76-
@param not_found:
77-
@return:
79+
@param args: Request payload.
80+
@param not_found: Function to call on empty response from Cloudstack.
81+
@return: Response.
7882
"""
7983
args['listAll'] = 'true'
8084
response = requester.make_request(args)

‎ec2stack/providers/cloudstack/instances.py‎

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
@helpers.authentication_required
1212
def describe_instance_attribute():
1313
"""
14+
Describes an instance attribute
1415
15-
16-
@return:
16+
@return: Response.
1717
"""
1818
instance_id = helpers.get('InstanceId')
1919
attribute = helpers.get('Attribute')
@@ -36,11 +36,12 @@ def describe_instance_attribute():
3636

3737
def _describe_instance_attribute_response(response, attribute, attr_map):
3838
"""
39+
Generates a response for a describe instance attribute request.
3940
40-
@param response:
41-
@param attribute:
42-
@param attr_map:
43-
@return:
41+
@param response: Response from Cloudstack.
42+
@param attribute: Attribute to Describe.
43+
@param attr_map: Map of attributes from EC2 to Cloudstack.
44+
@return: Response.
4445
"""
4546
response = {
4647
'template_name_or_list': 'instance_attribute.xml',
@@ -56,9 +57,9 @@ def _describe_instance_attribute_response(response, attribute, attr_map):
5657
@helpers.authentication_required
5758
def describe_instances():
5859
"""
60+
Describe a specific instance or all instances.
5961
60-
61-
@return:
62+
@return: Response.
6263
"""
6364
args = {'command': 'listVirtualMachines'}
6465
response = cloudstack.describe_item(
@@ -72,9 +73,10 @@ def describe_instances():
7273

7374
def describe_instance_by_id(instance_id):
7475
"""
76+
Describe an instance by Id.
7577
76-
@param instance_id:
77-
@return:
78+
@param instance_id: Id of the instance.
79+
@return: Response.
7880
"""
7981
args = {'id': instance_id, 'command': 'listVirtualMachines'}
8082
response = cloudstack.describe_item_request(
@@ -84,6 +86,12 @@ def describe_instance_by_id(instance_id):
8486

8587

8688
def _describe_instances_response(response):
89+
"""
90+
Generates a response for a describe instance request
91+
92+
@param response: Response from Cloudstack.
93+
@return: Response.
94+
"""
8795
return {
8896
'template_name_or_list': 'instances.xml',
8997
'response_type': 'DescribeInstancesResponse',
@@ -94,9 +102,9 @@ def _describe_instances_response(response):
94102
@helpers.authentication_required
95103
def run_instance():
96104
"""
105+
Run a instance.
97106
98-
99-
@return:
107+
@return: Response.
100108
"""
101109
helpers.require_parameters(
102110
['ImageId', 'MinCount', 'MaxCount'])
@@ -106,9 +114,9 @@ def run_instance():
106114

107115
def _run_instance_request():
108116
"""
117+
Request to bring up an instance
109118
110-
111-
@return:
119+
@return: Response.
112120
"""
113121
args = {}
114122

0 commit comments

Comments
 (0)