Revision 5eae854d kamaki/cli/commands/cyclades_cli.py
b/kamaki/cli/commands/cyclades_cli.py | ||
---|---|---|
41 | 41 |
from kamaki.cli.errors import CLIError, raiseCLIError |
42 | 42 |
from kamaki.clients.cyclades import CycladesClient, ClientError |
43 | 43 |
from kamaki.cli.argument import FlagArgument, ValueArgument |
44 |
from . import _command_init |
|
45 |
|
|
44 | 46 |
from base64 import b64encode |
45 | 47 |
from os.path import abspath, exists |
46 | 48 |
|
47 |
class _init_cyclades(object): |
|
48 |
def __init__(self, arguments={}): |
|
49 |
self.arguments=arguments |
|
50 |
try: |
|
51 |
self.config = self.get_argument('config') |
|
52 |
except KeyError: |
|
53 |
pass |
|
54 |
|
|
55 |
def get_argument(self, argterm): |
|
56 |
return self.arguments[argterm].value |
|
57 |
|
|
49 |
class _init_cyclades(_command_init): |
|
58 | 50 |
def main(self, service='compute'): |
59 | 51 |
token = self.config.get(service, 'token') or self.config.get('global', 'token') |
60 | 52 |
base_url = self.config.get(service, 'url') or self.config.get('global', 'url') |
61 | 53 |
self.client = CycladesClient(base_url=base_url, token=token) |
62 | 54 |
|
63 |
class _init_server(_init_cyclades): |
|
64 |
def main(self): |
|
65 |
super(_init_server, self).main('server') |
|
66 |
|
|
67 | 55 |
@command() |
68 | 56 |
class server_list(_init_cyclades): |
69 | 57 |
"""List servers""" |
Also available in: Unified diff