Commit 8741c407 authored by Stavros Sachtouris's avatar Stavros Sachtouris
Browse files

Create an image compute cmd group, make it work

- image compute group contains all Compute Image API commands, as oposed to
Plankton API commands.

- definition of a kamaki cli command slightly changed: a command with
subcommands can have a class without being a command itself, as long as it has
subcommands! Thus a subcommand group can be defined with docs and everything.

- image public is not image list (docs not updated yet)
parent 47ccc132
......@@ -118,7 +118,7 @@ To see the command groups, use -h or --help like in example 1.3.1. In the same w
config : Configuration commands
flavor : Compute/Cyclades API flavor commands
history: Command history
image : Compute/Cyclades or Plankton API image commands
image : Plankton Image API commands
network: Compute/Cyclades API network commands
server : Compute/Cyclades API server commands
store : Pithos+ storage commands
......
......@@ -254,7 +254,7 @@ class Shell(Cmd):
except IndexError:
break
print('Syntax: %s %s' % (' '.join(clist[upto:]), cls.syntax))
else:
if cmd.subcommands:
print_subcommands_help(cmd)
self._register_method(help_method, 'help_%s' % cmd.name)
......
......@@ -70,7 +70,7 @@ class Command(object):
@property
def is_command(self):
return self.cmd_class is not None
return self.cmd_class is not None and len(self.subcommands) == 0
@property
def has_description(self):
......@@ -153,7 +153,7 @@ class CommandTree(object):
self._all_commands[path] = new_cmd
cmd.add_subcmd(new_cmd)
cmd = new_cmd
if cmd_class is not None:
if cmd_class:
cmd.set_class(cmd_class)
if description is not None:
cmd.help = description
......
......@@ -46,9 +46,8 @@ from os.path import exists
server_cmds = CommandTree('server', 'Compute/Cyclades API server commands')
flavor_cmds = CommandTree('flavor', 'Compute/Cyclades API flavor commands')
image_cmds = CommandTree('image', 'Cyclades/Plankton API image commands')
network_cmds = CommandTree('network', 'Compute/Cyclades API network commands')
_commands = [server_cmds, flavor_cmds, image_cmds, network_cmds]
_commands = [server_cmds, flavor_cmds, network_cmds]
about_authentication = '\nUser Authentication:\
......
......@@ -41,9 +41,7 @@ from kamaki.cli.commands.cyclades_cli import _init_cyclades
from kamaki.cli.commands import _command_init, errors
image_cmds = CommandTree(
'image',
'Compute/Cyclades or Glance API image commands')
image_cmds = CommandTree('image', 'Plankton Image API commands')
_commands = [image_cmds]
......@@ -174,6 +172,7 @@ class image_register(_init_image):
if not location.startswith('pithos://'):
account = self.config.get('store', 'account') \
or self.config.get('global', 'account')
assert account, 'No user account provided'
if account[-1] == '/':
account = account[:-1]
container = self.config.get('store', 'container') \
......@@ -282,7 +281,12 @@ class image_setmembers(_init_image):
@command(image_cmds)
class image_list(_init_cyclades):
class image_compute(_init_cyclades):
"""Compute Image API commands"""
@command(image_cmds)
class image_compute_list(_init_cyclades):
"""List images"""
arguments = dict(
......@@ -315,7 +319,7 @@ class image_list(_init_cyclades):
@command(image_cmds)
class image_info(_init_cyclades):
class image_compute_info(_init_cyclades):
"""Get detailed information on an image"""
@errors.generic.all
......@@ -333,7 +337,7 @@ class image_info(_init_cyclades):
@command(image_cmds)
class image_delete(_init_cyclades):
class image_compute_delete(_init_cyclades):
"""Delete an image (WARNING: image file is also removed)"""
@errors.generic.all
......@@ -348,7 +352,7 @@ class image_delete(_init_cyclades):
@command(image_cmds)
class image_properties(_init_cyclades):
class image_compute_properties(_init_cyclades):
"""Get properties related to OS installation in an image"""
@errors.generic.all
......@@ -382,7 +386,7 @@ class image_addproperty(_init_cyclades):
@command(image_cmds)
class image_setproperty(_init_cyclades):
class image_compute_setproperty(_init_cyclades):
"""Update an existing property in an image"""
@errors.generic.all
......@@ -400,7 +404,7 @@ class image_setproperty(_init_cyclades):
@command(image_cmds)
class image_delproperty(_init_cyclades):
class image_compute_delproperty(_init_cyclades):
"""Delete a property of an image"""
@errors.generic.all
......
......@@ -1021,7 +1021,7 @@ class store_upload(_store_container_command):
poolsize=IntArgument('set pool size', '--with-pool-size'),
progress_bar=ProgressBarArgument(
'do not show progress bar',
('N', '--no-progress-bar'),
('-N', '--no-progress-bar'),
default=False),
overwrite=FlagArgument('Force (over)write', ('-f', '--force'))
)
......
......@@ -41,6 +41,17 @@ class ImageClient(Client):
def __init__(self, base_url, token):
super(ImageClient, self).__init__(base_url, token)
def test(self):
"""
:param image_id: (str)
:param member: (str) user to allow access to current user's images
"""
path = path4url('images')
data = dict(stuff='stuff')
r = self.put(path, json=data, async_headers={'x-image-meta-name': 'lalakis'})
r.release()
def list_public(self, detail=False, filters={}, order=''):
"""
:param detail: (bool)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment