Revision a29d2f88

b/kamaki/cli/commands/astakos.py
1
# Copyright 2011-2012 GRNET S.A. All rights reserved.
2
#
3
# Redistribution and use in source and binary forms, with or
4
# without modification, are permitted provided that the following
5
# conditions are met:
6
#
7
#   1. Redistributions of source code must retain the above
8
#      copyright notice, this list of conditions and the following
9
#      disclaimer.
10
#
11
#   2. Redistributions in binary form must reproduce the above
12
#      copyright notice, this list of conditions and the following
13
#      disclaimer in the documentation and/or other materials
14
#      provided with the distribution.
15
#
16
# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
17
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
20
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
23
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
24
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
26
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27
# POSSIBILITY OF SUCH DAMAGE.
28
#
29
# The views and conclusions contained in the software and
30
# documentation are those of the authors and should not be
31
# interpreted as representing official policies, either expressed
32
# or implied, of GRNET S.A.command
33

  
34
from kamaki.cli import command
35
from kamaki.clients.astakos import AstakosClient
36
from kamaki.cli.utils import print_dict
37
from kamaki.cli.commands import _command_init, errors
38
from kamaki.cli.command_tree import CommandTree
39

  
40
user_cmds = CommandTree('user', 'Astakos API commands')
41
_commands = [user_cmds]
42

  
43

  
44
class _user_init(_command_init):
45

  
46
    @errors.generic.all
47
    @errors.user.load
48
    def _run(self):
49
        token = self.config.get('user', 'token')\
50
            or self.config.get('global', 'token')
51
        base_url = self.config.get('user', 'url')\
52
            or self.config.get('global', 'url')
53
        self.client = AstakosClient(base_url=base_url, token=token)
54
        self._set_log_params()
55
        self._update_max_threads()
56

  
57
    def main(self):
58
        self._run()
59

  
60

  
61
@command(user_cmds)
62
class user_authenticate(_user_init):
63
    """Authenticate a user
64
    Get user information (e.g. unique account name) from token
65
    Token should be set in settings:
66
    *  check if a token is set    /config get token
67
    *  permanently set a token    /config set token <token>
68
    Token can also be provided as a parameter
69
    """
70

  
71
    @errors.generic.all
72
    @errors.user.authenticate
73
    def _run(self, custom_token=None):
74
        super(self.__class__, self)._run()
75
        reply = self.client.authenticate(custom_token)
76
        print_dict(reply)
77

  
78
    def main(self, custom_token=None):
79
        self._run(custom_token)
b/kamaki/cli/commands/config.py
36 36
from kamaki.cli.commands import _command_init, errors
37 37
from kamaki.cli.command_tree import CommandTree
38 38

  
39
config_cmds = CommandTree('config', 'Configuration commands')
39
config_cmds = CommandTree('config', 'Kamaki configurations')
40 40
_commands = [config_cmds]
41 41

  
42 42
about_options = '\nAbout options:\
b/kamaki/cli/commands/cyclades.py
44 44
from os.path import exists
45 45

  
46 46

  
47
server_cmds = CommandTree('server', 'Compute/Cyclades API server commands')
48
flavor_cmds = CommandTree('flavor', 'Compute/Cyclades API flavor commands')
49
network_cmds = CommandTree('network', 'Compute/Cyclades API network commands')
47
server_cmds = CommandTree('server', 'Cyclades/Compute API server commands')
48
flavor_cmds = CommandTree('flavor', 'Cyclades/Compute API flavor commands')
49
network_cmds = CommandTree('network', 'Cyclades/Compute API network commands')
50 50
_commands = [server_cmds, flavor_cmds, network_cmds]
51 51

  
52 52

  
b/kamaki/cli/commands/history.py
45 45
from kamaki.clients import ClientError
46 46

  
47 47

  
48
history_cmds = CommandTree('history', 'Command history')
48
history_cmds = CommandTree('history', 'Kamaki command history')
49 49
_commands = [history_cmds]
50 50

  
51 51

  
b/kamaki/cli/commands/image.py
41 41
from kamaki.cli.commands import _command_init, errors
42 42

  
43 43

  
44
image_cmds = CommandTree('image', 'Plankton (and Compute) Image API commands')
44
image_cmds = CommandTree(
45
    'image',
46
    'Cyclades/Plankton API image commands\n'
47
    'image compute:\tCyclades/Compute API image commands')
45 48
_commands = [image_cmds]
46 49

  
47 50

  
......
291 294

  
292 295
@command(image_cmds)
293 296
class image_compute(_init_cyclades):
294
    """Compute Image API commands"""
297
    """Cyclades/Compute API image commands"""
295 298

  
296 299

  
297 300
@command(image_cmds)
b/kamaki/cli/commands/livetest.py
38 38
from kamaki.clients import livetest
39 39
from kamaki.cli.errors import raiseCLIError
40 40

  
41
livetest_cmds = CommandTree('livetest', 'Test clients on live servers')
41
livetest_cmds = CommandTree('livetest', 'Client func. tests on live servers')
42 42
_commands = [livetest_cmds]
43 43

  
44 44

  
b/kamaki/cli/commands/pithos.py
58 58

  
59 59
kloger = getLogger('kamaki')
60 60

  
61
pithos_cmds = CommandTree('file', 'Pithos+ storage commands')
61
pithos_cmds = CommandTree('file', 'Pithos+/Storage API commands')
62 62
_commands = [pithos_cmds]
63 63

  
64 64

  
/dev/null
1
# Copyright 2012 GRNET S.A. All rights reserved.
2
#
3
# Redistribution and use in source and binary forms, with or
4
# without modification, are permitted provided that the following
5
# conditions are met:
6
#
7
#   1. Redistributions of source code must retain the above
8
#      copyright notice, this list of conditions and the following
9
#      disclaimer.
10
#
11
#   2. Redistributions in binary form must reproduce the above
12
#      copyright notice, this list of conditions and the following
13
#      disclaimer in the documentation and/or other materials
14
#      provided with the distribution.
15
#
16
# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
17
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
20
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
23
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
24
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
26
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27
# POSSIBILITY OF SUCH DAMAGE.
28
#
29
# The views and conclusions contained in the software and
30
# documentation are those of the authors and should not be
31
# interpreted as representing official policies, either expressed
32
# or implied, of GRNET S.A.
33

  
34
from kamaki.cli.commissioning import commissioning_cli
35
from kamaki.clients.quotaholder import QuotaholderClient
36

  
37

  
38
class quotaholder(commissioning_cli):
39

  
40
    def __init__(self):
41
        self.client = QuotaholderClient
42
        self.add_context = True
43
        self.description = 'Quotaholder description'
44
        super(self.__class__, self).__init__()
45

  
46
cli = quotaholder()
47
cli.generate_all()
48
_commands = [cli.ctree]
/dev/null
1
# Copyright 2011-2012 GRNET S.A. All rights reserved.
2
#
3
# Redistribution and use in source and binary forms, with or
4
# without modification, are permitted provided that the following
5
# conditions are met:
6
#
7
#   1. Redistributions of source code must retain the above
8
#      copyright notice, this list of conditions and the following
9
#      disclaimer.
10
#
11
#   2. Redistributions in binary form must reproduce the above
12
#      copyright notice, this list of conditions and the following
13
#      disclaimer in the documentation and/or other materials
14
#      provided with the distribution.
15
#
16
# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
17
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
20
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
23
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
24
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
26
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27
# POSSIBILITY OF SUCH DAMAGE.
28
#
29
# The views and conclusions contained in the software and
30
# documentation are those of the authors and should not be
31
# interpreted as representing official policies, either expressed
32
# or implied, of GRNET S.A.command
33

  
34
from kamaki.cli import command
35
from kamaki.clients.astakos import AstakosClient
36
from kamaki.cli.utils import print_dict
37
from kamaki.cli.commands import _command_init, errors
38
from kamaki.cli.command_tree import CommandTree
39

  
40
user_cmds = CommandTree('user', 'Astakos API commands')
41
_commands = [user_cmds]
42

  
43

  
44
class _user_init(_command_init):
45

  
46
    @errors.generic.all
47
    @errors.user.load
48
    def _run(self):
49
        token = self.config.get('user', 'token')\
50
            or self.config.get('global', 'token')
51
        base_url = self.config.get('user', 'url')\
52
            or self.config.get('global', 'url')
53
        self.client = AstakosClient(base_url=base_url, token=token)
54
        self._set_log_params()
55
        self._update_max_threads()
56

  
57
    def main(self):
58
        self._run()
59

  
60

  
61
@command(user_cmds)
62
class user_authenticate(_user_init):
63
    """Authenticate a user
64
    Get user information (e.g. unique account name) from token
65
    Token should be set in settings:
66
    *  check if a token is set    /config get token
67
    *  permanently set a token    /config set token <token>
68
    Token can also be provided as a parameter
69
    """
70

  
71
    @errors.generic.all
72
    @errors.user.authenticate
73
    def _run(self, custom_token=None):
74
        super(self.__class__, self)._run()
75
        reply = self.client.authenticate(custom_token)
76
        print_dict(reply)
77

  
78
    def main(self, custom_token=None):
79
        self._run(custom_token)
b/kamaki/cli/config.py
91 91
        'url': 'https://cyclades.okeanos.grnet.gr/plankton'
92 92
    },
93 93
    'user': {
94
        'cli': 'user',
94
        'cli': 'astakos',
95 95
        'url': 'https://accounts.okeanos.grnet.gr'
96 96
    }
97 97
}

Also available in: Unified diff