Revision 49c07ce3 image_creator/main.py
b/image_creator/main.py | ||
---|---|---|
98 | 98 |
default=None, help="use this authentication token when " |
99 | 99 |
"uploading/registering images") |
100 | 100 |
|
101 |
parser.add_option("-a", "--authentication-url", dest="url", type="string", |
|
102 |
default=None, help="use this authentication URL when " |
|
103 |
"uploading/registering images") |
|
104 |
|
|
101 | 105 |
parser.add_option("--print-sysprep", dest="print_sysprep", default=False, |
102 | 106 |
help="print the enabled and disabled system preparation " |
103 | 107 |
"operations for this input media", action="store_true") |
... | ... | |
138 | 142 |
if options.register and not options.upload: |
139 | 143 |
raise FatalError("You also need to set -u when -r option is set") |
140 | 144 |
|
141 |
if options.upload and options.token is None: |
|
142 |
raise FatalError( |
|
143 |
"Image uploading cannot be performed. " |
|
144 |
"No authentication token is specified. Use -t to set a token") |
|
145 |
if options.upload and (options.token is None or options.url is None): |
|
146 |
if options.url is None: |
|
147 |
err = "No authentication URL is specified. Use -a to set a URL" |
|
148 |
else: |
|
149 |
err = "No autentication token is specified. Use -t to set a token" |
|
150 |
|
|
151 |
raise FatalError("Image uploading cannot be performed. %s" % err) |
|
145 | 152 |
|
146 | 153 |
if options.tmp is not None and not os.path.isdir(options.tmp): |
147 | 154 |
raise FatalError("The directory `%s' specified with --tmpdir is not " |
... | ... | |
190 | 197 |
"(use --force to overwrite it)." % filename) |
191 | 198 |
|
192 | 199 |
# Check if the authentication token is valid. The earlier the better |
193 |
if options.token is not None: |
|
200 |
if options.token is not None and options.url is not None:
|
|
194 | 201 |
try: |
195 |
account = Kamaki.get_account(options.token)
|
|
202 |
account = Kamaki.create_account(options.url, options.token)
|
|
196 | 203 |
if account is None: |
197 |
raise FatalError("The authentication token you provided is not"
|
|
198 |
" valid!") |
|
204 |
raise FatalError("The authentication token and/or URL you "
|
|
205 |
"provided is not valid!")
|
|
199 | 206 |
else: |
200 | 207 |
kamaki = Kamaki(account, out) |
201 | 208 |
except ClientError as e: |
Also available in: Unified diff