diff --git a/bin/heat-boto b/bin/heat-boto new file mode 100755 index 0000000000..8c6e85bdce --- /dev/null +++ b/bin/heat-boto @@ -0,0 +1,711 @@ +#!/usr/bin/env python +# vim: tabstop=4 shiftwidth=4 softtabstop=4 +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +""" +This is the administration program for heat. It is simply a command-line +interface for adding, modifying, and retrieving information about the stacks +belonging to a user. It is a convenience application that talks to the heat +API server. +""" + +import gettext +import optparse +import os +import os.path +import sys +import time +import json +import logging + +from urlparse import urlparse + +# If ../heat/__init__.py exists, add ../ to Python search path, so that +# it will override what happens to be installed in /usr/(local/)lib/python... +possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), + os.pardir, + os.pardir)) +if os.path.exists(os.path.join(possible_topdir, 'heat', '__init__.py')): + sys.path.insert(0, possible_topdir) + +gettext.install('heat', unicode=1) + +import boto +from heat import version +from heat.common import config +from heat.common import exception +from heat import utils + + +# FIXME : would be better if each of the boto response classes +# implemented __str__ or a print method, so we could just print +# them, avoiding all these print functions, boto patch TODO + + +def print_stack_event(event): + ''' + Print contents of a boto.cloudformation.stack.StackEvent object + ''' + print "EventId : %s" % event.event_id + print "LogicalResourceId : %s" % event.logical_resource_id + print "PhysicalResourceId : %s" % event.physical_resource_id + print "ResourceProperties : %s" % event.resource_properties + print "ResourceStatus : %s" % event.resource_status + print "ResourceStatusReason : %s" % event.resource_status_reason + print "ResourceType : %s" % event.resource_type + print "StackId : %s" % event.stack_id + print "StackName : %s" % event.stack_name + print "Timestamp : %s" % event.timestamp + print "--" + + +def print_stack(s): + ''' + Print contents of a boto.cloudformation.stack.Stack object + ''' + print "Capabilities : %s" % s.capabilities + print "CreationTime : %s" % s.creation_time + print "Description : %s" % s.description + print "DisableRollback : %s" % s.disable_rollback + # FIXME : boto doesn't populate this field, but AWS defines it. + # bit unclear because the docs say LastUpdatedTime, where all + # other response structures define LastUpdatedTimestamp + # need confirmation of real AWS format, probably a documentation bug.. +# print "LastUpdatedTime : %s" % s.last_updated_time + print "NotificationARNs : %s" % s.notification_arns + print "Outputs : %s" % s.outputs + print "Parameters : %s" % s.parameters + print "StackId : %s" % s.stack_id + print "StackName : %s" % s.stack_name + print "StackStatus : %s" % s.stack_status + print "StackStatusReason : %s" % s.stack_status_reason + print "TimeoutInMinutes : %s" % s.timeout_in_minutes + print "--" + + +def print_stack_resource(res): + ''' + Print contents of a boto.cloudformation.stack.StackResource object + ''' + print "LogicalResourceId : %s" % res.logical_resource_id + print "PhysicalResourceId : %s" % res.physical_resource_id + print "ResourceStatus : %s" % res.resource_status + print "ResourceStatusReason : %s" % res.resource_status_reason + print "ResourceType : %s" % res.resource_type + print "StackId : %s" % res.stack_id + print "StackName : %s" % res.stack_name + print "Timestamp : %s" % res.timestamp + print "--" + + +def print_stack_resource_summary(res): + ''' + Print contents of a boto.cloudformation.stack.StackResourceSummary object + ''' + print "LastUpdatedTimestamp : %s" % res.last_updated_timestamp + print "LogicalResourceId : %s" % res.logical_resource_id + print "PhysicalResourceId : %s" % res.physical_resource_id + print "ResourceStatus : %s" % res.resource_status + print "ResourceStatusReason : %s" % res.resource_status_reason + print "ResourceType : %s" % res.resource_type + print "--" + + +def print_stack_summary(s): + ''' + Print contents of a boto.cloudformation.stack.StackSummary object + ''' + print "StackId : %s" % s.stack_id + print "StackName : %s" % s.stack_name + print "CreationTime : %s" % s.creation_time + print "StackStatus : %s" % s.stack_status + print "TemplateDescription : %s" % s.template_description + print "--" + + +@utils.catch_error('validate') +def template_validate(options, arguments): + ''' + Validate a template. This command parses a template and verifies that + it is in the correct format. + + Usage: heat validate \\ + [--template-file=