Skip to content
Permalink
Browse files
Merge branch 'master' of github.com:imduffy15/ec2stack
  • Loading branch information
brogand93 committed Mar 8, 2014
2 parents 712d335 + 7435459 commit b780c8e48073018aee211bb2480584cbc517f20f
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 31 deletions.
@@ -7,12 +7,13 @@

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

def _describe_specific_item(args, keyname, not_found, prefix):
"""
Describe a specific item based on args['id'] or args['name']
@param args:
@param keyname:
@param not_found:
@param prefix:
@return:
@param args: Arguments involved in the request.
@param keyname: Keyname of the cloudstack response.
@param not_found: Function to call if the item is not found.
@param prefix: Parameter prefix.
@return: Response.
"""
keys = helpers.get_request_parameter_keys(prefix)

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

def describe_item_request(args, keyname, not_found):
"""
Executes the request and searches the Cloudstack response for the item.
@param args:
@param keyname:
@param not_found:
@return:
@param args: Arguments involved in the request.
@param keyname: Keyname of the cloudstack response.
@param not_found: Function to call if the item is not found.
@return: Response.
"""
request = describe_items_request(args, not_found)
request = request[keyname]
@@ -71,10 +74,11 @@ def describe_item_request(args, keyname, not_found):

def describe_items_request(args, not_found):
"""
Executes the request.
@param args:
@param not_found:
@return:
@param args: Request payload.
@param not_found: Function to call on empty response from Cloudstack.
@return: Response.
"""
args['listAll'] = 'true'
response = requester.make_request(args)
@@ -11,9 +11,9 @@
@helpers.authentication_required
def describe_instance_attribute():
"""
Describes an instance attribute
@return:
@return: Response.
"""
instance_id = helpers.get('InstanceId')
attribute = helpers.get('Attribute')
@@ -36,11 +36,12 @@ def describe_instance_attribute():

def _describe_instance_attribute_response(response, attribute, attr_map):
"""
Generates a response for a describe instance attribute request.
@param response:
@param attribute:
@param attr_map:
@return:
@param response: Response from Cloudstack.
@param attribute: Attribute to Describe.
@param attr_map: Map of attributes from EC2 to Cloudstack.
@return: Response.
"""
response = {
'template_name_or_list': 'instance_attribute.xml',
@@ -56,9 +57,9 @@ def _describe_instance_attribute_response(response, attribute, attr_map):
@helpers.authentication_required
def describe_instances():
"""
Describe a specific instance or all instances.
@return:
@return: Response.
"""
args = {'command': 'listVirtualMachines'}
response = cloudstack.describe_item(
@@ -72,9 +73,10 @@ def describe_instances():

def describe_instance_by_id(instance_id):
"""
Describe an instance by Id.
@param instance_id:
@return:
@param instance_id: Id of the instance.
@return: Response.
"""
args = {'id': instance_id, 'command': 'listVirtualMachines'}
response = cloudstack.describe_item_request(
@@ -84,6 +86,12 @@ def describe_instance_by_id(instance_id):


def _describe_instances_response(response):
"""
Generates a response for a describe instance request
@param response: Response from Cloudstack.
@return: Response.
"""
return {
'template_name_or_list': 'instances.xml',
'response_type': 'DescribeInstancesResponse',
@@ -94,9 +102,9 @@ def _describe_instances_response(response):
@helpers.authentication_required
def run_instance():
"""
Run a instance.
@return:
@return: Response.
"""
helpers.require_parameters(
['ImageId', 'MinCount', 'MaxCount'])
@@ -106,9 +114,9 @@ def run_instance():

def _run_instance_request():
"""
Request to bring up an instance
@return:
@return: Response.
"""
args = {}

0 comments on commit b780c8e

Please sign in to comment.