Commit 149a9aa0 authored by Vangelis Koukis's avatar Vangelis Koukis
Browse files

Merge branch 'plankton'

parents db782692 3dc658a1
......@@ -241,7 +241,8 @@ class ImageBackend(object):
location = get_location(account, container, object)
return self._get_image(location)
def iter_public(self, filters):
def iter_public(self, filters=None):
filters = filters or {}
backend = self.backend
keys = [PLANKTON_PREFIX + 'name']
......@@ -122,8 +122,11 @@ class Command(object):
def execute(self):
except TypeError:
except TypeError as e:
if e.args and e.args[0].startswith('main()'):
# Server commands
......@@ -315,9 +318,9 @@ class ListImages(Command):
def main_pithos(self, image_id=None):
backend = ImageBackend(self.user)
if image_id:
images = [backend.get_meta(image_id)]
images = [backend.get_image(image_id)]
images = backend.iter_shared()
images = backend.iter_public()
for image in images:
print image['id'], image['name']
......@@ -401,59 +404,6 @@ class RegisterImage(Command):
class UploadImage(Command):
group = 'image'
name = 'upload'
syntax = '<name> <path>'
description = 'upload an image'
def add_options(self, parser):
container_formats = ', '.join(settings.ALLOWED_CONTAINER_FORMATS)
disk_formats = ', '.join(settings.ALLOWED_DISK_FORMATS)
parser.add_option('--container-format', dest='container_format',
help='set container format (%s)' % container_formats)
parser.add_option('--disk-format', dest='disk_format',
help='set disk format (%s)' % disk_formats)
parser.add_option('--meta', dest='meta', action='append',
help='add metadata (can be used multiple times)')
parser.add_option('--owner', dest='owner',
help='set owner to USER')
parser.add_option('--public', action='store_true', dest='public',
help='make image public')
def main(self, name, path):
backend = ImageBackend(self.owner)
params = {
'container_format': self.container_format,
'disk_format': self.disk_format,
'is_public': self.public,
'filename': basename(path),
'properties': {}}
if self.meta:
for m in self.meta:
key, sep, val = m.partition('=')
if key and val:
params['properties'][key] = val
print 'WARNING: Ignoring meta', m
with open(path) as f:
backend.put(name, f, params)
class UpdateImage(Command):
group = 'image'
name = 'update'
......@@ -485,7 +435,7 @@ class UpdateImage(Command):
def main(self, image_id):
backend = ImageBackend(self.user)
image = backend.get_meta(image_id)
image = backend.get_image(image_id)
if not image:
print 'Image not found'
......@@ -803,6 +753,7 @@ def print_usage(exe, groups, group=None, shortcut=False):
def main():
groups = defaultdict(dict)
module = sys.modules[__name__]
for name, cls in inspect.getmembers(module, inspect.isclass):
......@@ -836,5 +787,4 @@ def main():
if __name__ == '__main__':
......@@ -7,11 +7,15 @@ Configure kamaki
To upload, register or modify an image you will need the **kamaki** tool.
Before proceeding make sure that it is configured properly. Verify that
*image_url*, *storage_url*, *storage_account*, *storage_container* and
*token* are set as needed::
*token* are set as needed:
.. code-block:: console
kamaki config list
To chage a setting use ``kamaki config set``::
To chage a setting use ``kamaki config set``:
.. code-block:: console
kamaki config set storage_account okeanos
kamaki config set storage_container images
......@@ -22,7 +26,9 @@ Upload an image
You are now ready to upload an image. You can upload it with a Pithos client
or use kamaki directly::
or use kamaki directly:
.. code-block:: console
kamaki store upload ubuntu.iso
......@@ -33,16 +39,22 @@ Register the image
To register an image you will need to use the full Pithos URL. To register as
a public image the one from the previous example use::
a public image the one from the previous example use:
.. code-block:: console
kamaki glance register Ubuntu pithos://okeanos/images/ubuntu.iso --public
Use ``kamaki glance register`` with no arguments to see a list of available
options. A more complete example would be the following::
options. A more complete example would be the following:
.. code-block:: console
kamaki glance register Ubuntu pithos://okeanos/images/ubuntu.iso --public \
--disk-format diskdump --property kernel=3.1.2
To verify that the image was registered successfully use::
To verify that the image was registered successfully use:
.. code-block:: console
kamaki glance list -l
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