Revision c825ddc9 kamaki/cli/__init__.py
b/kamaki/cli/__init__.py | ||
---|---|---|
194 | 194 |
|
195 | 195 |
def _check_config_version(cnf): |
196 | 196 |
guess = cnf.guess_version() |
197 |
if guess < 3.0:
|
|
198 |
print('Config file format version >= 3.0 is required')
|
|
197 |
if guess < 0.9:
|
|
198 |
print('Config file format version >= 9.0 is required')
|
|
199 | 199 |
print('Configuration file "%s" format is not up to date' % ( |
200 | 200 |
cnf.path)) |
201 | 201 |
print('but kamaki can fix this:') |
... | ... | |
247 | 247 |
if _help or is_non_API: |
248 | 248 |
return None, None |
249 | 249 |
|
250 |
cloud = arguments['cloud'].value or 'default' |
|
250 |
cloud = arguments['cloud'].value or _cnf.value.get( |
|
251 |
'global', 'default_cloud') |
|
252 |
if not cloud: |
|
253 |
num_of_clouds = len(_cnf.value.keys('cloud')) |
|
254 |
if num_of_clouds == 1: |
|
255 |
cloud = _cnf.value.keys('cloud')[0] |
|
256 |
else: |
|
257 |
raise CLIError( |
|
258 |
'Found %s clouds but none of them is set as default', |
|
259 |
importance=2, details=[ |
|
260 |
'Please, choose one of the following cloud names:', |
|
261 |
', '.join(_cnf.value.keys('cloud')), |
|
262 |
'To set a default cloud:', |
|
263 |
' kamaki config set default_cloud <cloud name>', |
|
264 |
'To pick a cloud for the current session, use --cloud:', |
|
265 |
' kamaki --cloud=<cloud name> ...']) |
|
251 | 266 |
if not cloud in _cnf.value.keys('cloud'): |
252 | 267 |
raise CLIError( |
253 | 268 |
'No cloud "%s" is configured' % cloud, |
... | ... | |
258 | 273 |
' kamaki config set cloud.%s.token <t0k3n>' % cloud]) |
259 | 274 |
auth_args = dict() |
260 | 275 |
for term in ('url', 'token'): |
261 |
auth_args[term] = _cnf.get_cloud(cloud, term) |
|
276 |
try: |
|
277 |
auth_args[term] = _cnf.get_cloud(cloud, term) |
|
278 |
except KeyError: |
|
279 |
auth_args[term] = '' |
|
262 | 280 |
if not auth_args[term]: |
263 | 281 |
raise CLIError( |
264 |
'No authentication %s provided for %s cloud' % (term, cloud),
|
|
282 |
'No authentication %s provided for cloud "%s"' % (term, cloud),
|
|
265 | 283 |
importance=3, details=[ |
266 |
'Get and set a %s for %s cloud:' % (term, cloud), |
|
267 |
' kamaki config set cloud.%s.%s <t0k3n>' % (term, cloud) |
|
268 |
]) |
|
284 |
'Set a %s for cloud %s:' % (term, cloud), |
|
285 |
' kamaki config set cloud.%s.%s <t0k3n>' % (cloud, term)]) |
|
269 | 286 |
|
270 | 287 |
from kamaki.clients.astakos import AstakosClient as AuthCachedClient |
271 | 288 |
try: |
Also available in: Unified diff