heat clients : make --host option error for heat-boto

The --host option cannot work for heat-boto, so print a helpful
error if the user tries to use it.

ref bug 1102101

Change-Id: I63129b314eabd7bc84647efb96e9f10b1963b8b2
This commit is contained in:
Steven Hardy 2013-03-07 12:11:16 +00:00
parent 180430fa32
commit 2e000a6d28

View File

@ -411,6 +411,8 @@ def get_client(options):
Returns a new client object to a heat server
specified by the --host and --port options
supplied to the CLI
Note options.host is ignored for heat-boto, host must be
set in your boto config via the cfn_region_endpoint option
"""
return heat_client.get_client(host=options.host,
port=options.port,
@ -438,7 +440,7 @@ def create_options(parser):
parser.add_option('-y', '--yes', default=False, action="store_true",
help="Don't prompt for user input; assume the answer to "
"every question is 'yes'.")
parser.add_option('-H', '--host', metavar="ADDRESS", default="0.0.0.0",
parser.add_option('-H', '--host', metavar="ADDRESS", default=None,
help="Address of heat API host. "
"Default: %default")
parser.add_option('-p', '--port', dest="port", metavar="PORT",
@ -527,6 +529,14 @@ def parse_options(parser, cli_args):
if not getattr(options, option):
setattr(options, option, env_val)
if scriptname == 'heat-boto':
if options.host is not None:
logging.error("Use boto.cfg or ~/.boto cfn_region_endpoint")
raise ValueError("--host option not supported by heat-boto")
if options.url is not None:
logging.error("Use boto.cfg or ~/.boto cfn_region_endpoint")
raise ValueError("--url option not supported by heat-boto")
if options.url is not None:
u = urlparse(options.url)
options.port = u.port
@ -648,7 +658,11 @@ Commands:
oparser = optparse.OptionParser(version=version_string,
usage=usage.strip())
create_options(oparser)
(opts, cmd, args) = parse_options(oparser, sys.argv[1:])
try:
(opts, cmd, args) = parse_options(oparser, sys.argv[1:])
except ValueError as ex:
logging.error("Error parsing options : %s" % str(ex))
sys.exit(1)
try:
start_time = time.time()