Revision 362adf50 kamaki/cli/commands/__init__.py
b/kamaki/cli/commands/__init__.py | ||
---|---|---|
34 | 34 |
from kamaki.cli.logger import get_logger |
35 | 35 |
from kamaki.cli.utils import print_json, print_items |
36 | 36 |
from kamaki.cli.argument import FlagArgument |
37 |
from kamaki.cli.errors import CLIError |
|
38 |
from kamaki.clients import Client |
|
37 | 39 |
|
38 | 40 |
log = get_logger(__name__) |
39 | 41 |
|
40 | 42 |
|
41 | 43 |
class _command_init(object): |
42 | 44 |
|
43 |
def __init__(self, arguments={}, auth_base=None): |
|
45 |
def __init__(self, arguments={}, auth_base_or_remote=None):
|
|
44 | 46 |
if hasattr(self, 'arguments'): |
45 | 47 |
arguments.update(self.arguments) |
46 | 48 |
if isinstance(self, _optional_output_cmd): |
... | ... | |
52 | 54 |
self.config = self['config'] |
53 | 55 |
except KeyError: |
54 | 56 |
pass |
55 |
self.auth_base = auth_base or getattr(self, 'auth_base', None) |
|
57 |
if isinstance(auth_base_or_remote, Client): |
|
58 |
self.auth_base = auth_base_or_remote |
|
59 |
elif not getattr(self, 'auth_base', None): |
|
60 |
self.remote = auth_base_or_remote |
|
61 |
if not self.remote: |
|
62 |
raise CLIError('CRITICAL: No cloud specified', 3) |
|
56 | 63 |
|
57 | 64 |
def _set_log_params(self): |
58 | 65 |
try: |
59 | 66 |
self.client.LOG_TOKEN, self.client.LOG_DATA = ( |
60 |
self['config'].get('global', 'log_token') == 'on',
|
|
61 |
self['config'].get('global', 'log_data') == 'on')
|
|
67 |
self['config'].get_global('log_token').lower() == 'on',
|
|
68 |
self['config'].get_global('log_data').lower() == 'on')
|
|
62 | 69 |
except Exception as e: |
63 | 70 |
log.warning('Failed to read custom log settings:' |
64 | 71 |
'%s\n defaults for token and data logging are off' % e) |
65 | 72 |
|
66 | 73 |
def _update_max_threads(self): |
67 | 74 |
try: |
68 |
max_threads = int(self['config'].get('global', 'max_threads'))
|
|
75 |
max_threads = int(self['config'].get_global('max_threads'))
|
|
69 | 76 |
assert max_threads > 0 |
70 | 77 |
self.client.MAX_THREADS = max_threads |
71 | 78 |
except Exception as e: |
Also available in: Unified diff