This options can be used to get the authentication URL and token
from a saved cloud section in the kamaki configuration file
default=None, help="use this authentication URL when "
"uploading/registering images")
default=None, help="use this authentication URL when "
"uploading/registering images")
+ parser.add_option("-c", "--cloud", dest="cloud", type="string",
+ default=None, help="use this saved cloud account to "
+ "authenticate against a cloud when "
+ "uploading/registering images")
+
parser.add_option("--print-sysprep", dest="print_sysprep", default=False,
help="print the enabled and disabled system preparation "
"operations for this input media", action="store_true")
parser.add_option("--print-sysprep", dest="print_sysprep", default=False,
help="print the enabled and disabled system preparation "
"operations for this input media", action="store_true")
if options.register and not options.upload:
raise FatalError("You also need to set -u when -r option is set")
if options.register and not options.upload:
raise FatalError("You also need to set -u when -r option is set")
- if options.upload and (options.token is None or options.url is None):
- if options.url is None:
- err = "No authentication URL is specified. Use -a to set a URL"
- else:
- err = "No autentication token is specified. Use -t to set a token"
+ if options.upload and (options.token is None or options.url is None) and \
+ options.cloud is None:
+
+ err = "You need to either specify an authentication URL and token " \
+ "pair or an available cloud name."
raise FatalError("Image uploading cannot be performed. %s" % err)
raise FatalError("Image uploading cannot be performed. %s" % err)
raise FatalError("Output file `%s' exists "
"(use --force to overwrite it)." % filename)
raise FatalError("Output file `%s' exists "
"(use --force to overwrite it)." % filename)
- # Check if the authentication token is valid. The earlier the better
+ # Check if the authentication info is valid. The earlier the better
if options.token is not None and options.url is not None:
try:
account = Kamaki.create_account(options.url, options.token)
if options.token is not None and options.url is not None:
try:
account = Kamaki.create_account(options.url, options.token)
kamaki = Kamaki(account, out)
except ClientError as e:
raise FatalError("Astakos client: %d %s" % (e.status, e.message))
kamaki = Kamaki(account, out)
except ClientError as e:
raise FatalError("Astakos client: %d %s" % (e.status, e.message))
+ elif options.cloud:
+ avail_clouds = Kamaki.get_clouds()
+ if options.cloud not in avail_clouds.keys():
+ raise FatalError(
+ "Cloud: `%s' does not exist.\n\nAvailable clouds:\n\n\t%s\n"
+ % (options.cloud, "\n\t".join(avail_clouds.keys())))
+ try:
+ account = Kamaki.get_account(options.cloud)
+ if account is None:
+ raise FatalError(
+ "Cloud: `$s' exists but is not valid!" % options.cloud)
+ else:
+ kamaki = Kamaki(account, out)
+ except ClientError as e:
+ raise FatalError("Astakos client: %d %s" % (e.status, e.message))
if options.upload and not options.force:
if kamaki.object_exists(options.upload):
if options.upload and not options.force:
if kamaki.object_exists(options.upload):