'Implements ListStacks API action.
Lists summary information for all stacks.'

def list(self, req):

    self._enforce(req, 'ListStacks')
    def format_stack_summary(s):
        'Reformat    engine    output    into    the    AWS    "StackSummary"    format.'
        keymap = {rpc_api.STACK_CREATION_TIME: 'CreationTime', rpc_api.STACK_UPDATED_TIME: 'LastUpdatedTime', rpc_api.STACK_ID: 'StackId', rpc_api.STACK_NAME: 'StackName', rpc_api.STACK_STATUS_DATA: 'StackStatusReason', rpc_api.STACK_TMPL_DESCRIPTION: 'TemplateDescription'}
        result = api_utils.reformat_dict_keys(keymap, s)
        action = s[rpc_api.STACK_ACTION]
        status = s[rpc_api.STACK_STATUS]
        result['StackStatus'] = '_'.join((action, status))
        if (rpc_api.STACK_DELETION_TIME in s):
            result['DeletionTime'] = s[rpc_api.STACK_DELETION_TIME]
        return self._id_format(result)
    con = req.context
    try:
        stack_list = self.rpc_client.list_stacks(con)
    except Exception as ex:
        return exception.map_remote_error(ex)
    res = {'StackSummaries': [format_stack_summary(s) for s in stack_list]}
    return api_utils.format_response('ListStacks', res)
