Revision 43ca98ee kamaki/cli.py

b/kamaki/cli.py
1 1
#!/usr/bin/env python
2 2

  
3
# Copyright 2011 GRNET S.A. All rights reserved.
3
# Copyright 2011-2012 GRNET S.A. All rights reserved.
4 4
#
5 5
# Redistribution and use in source and binary forms, with or
6 6
# without modification, are permitted provided that the following
......
106 106
    'image': "Compute API image commands",
107 107
    'network': "Compute API network commands (Cyclades extension)",
108 108
    'glance': "Image API commands",
109
    'store': "Storage API commands"}
109
    'store': "Storage API commands",
110
    'astakos': "Astakos API commands"}
110 111

  
111 112

  
112 113
def command(api=None, group=None, name=None, syntax=None):
......
796 797
        self.client.delete_object(path)
797 798

  
798 799

  
800
@command(api='astakos')
801
class astakos_authenticate(object):
802
    """Authenticate a user"""
803
    
804
    def main(self):
805
        reply = self.client.authenticate()
806
        print_dict(reply)
807

  
808

  
799 809
def print_groups():
800 810
    puts('\nGroups:')
801 811
    with indent(2):
......
812 822
    puts('\nCommands:')
813 823
    with indent(2):
814 824
        for name, cls in _commands[group].items():
815
            puts(columns([name, 12], [cls.description, 60]))
825
            puts(columns([name, 14], [cls.description, 60]))
816 826

  
817 827

  
818 828
def add_handler(name, level, prefix=''):
......
875 885
        config.override(section.strip(), key.strip(), val.strip())
876 886
    
877 887
    apis = set(['config'])
878
    for api in ('compute', 'image', 'storage'):
888
    for api in ('compute', 'image', 'storage', 'astakos'):
879 889
        if config.getboolean(api, 'enable'):
880 890
            apis.add(api)
881 891
    if config.getboolean('compute', 'cyclades_extensions'):
......
968 978
        url = config.get('image', 'url')
969 979
        token = config.get('image', 'token') or config.get('global', 'token')
970 980
        cmd.client = clients.image(url, token)
981
    elif api == 'astakos':
982
        url = config.get('astakos', 'url')
983
        token = config.get('astakos', 'token') or config.get('global', 'token')
984
        cmd.client = clients.astakos(url, token)
971 985
    
972 986
    cmd.options = options
973 987
    cmd.config = config

Also available in: Unified diff