Commit ec31129c authored by Christos Stavrakakis's avatar Christos Stavrakakis
Browse files

cyclades: Various fixes to plankton and volumes

Fix various issues after rebasing branch.
parent 099005a6
......@@ -83,7 +83,7 @@ log = getLogger('synnefo.plankton')
API_STATUS_FROM_IMAGE_STATUS = {
"CREATING": "SAVING",
"AVAILABLE": "ACTIVE",
"AVAILABLE": "AVAILABLE",
"DELETED": "DELETED"}
......
......@@ -33,17 +33,17 @@
from optparse import make_option
from django.core.management.base import BaseCommand, CommandError
from snf_django.management.commands import SynnefoCommand, CommandError
from synnefo.management import common
#from snf_django.management.utils import parse_bool
from synnefo.volume import snapshots
class Command(BaseCommand):
class Command(SynnefoCommand):
args = "<volume ID>"
help = "Create a snapshot from the specified volume"
option_list = BaseCommand.option_list + (
option_list = SynnefoCommand.option_list + (
make_option(
'--wait',
dest='wait',
......
# Copyright 2011-2012 GRNET S.A. All rights reserved.
# Copyright 2013-2014 GRNET S.A. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
......@@ -28,16 +28,16 @@
# policies, either expressed or implied, of GRNET S.A.
#
from django.core.management.base import BaseCommand
from snf_django.management.commands import SynnefoCommand
from optparse import make_option
from snf_django.management.utils import pprint_table
from synnefo.plankton.utils import image_backend
from synnefo.plankton.backend import PlanktonBackend
class Command(BaseCommand):
class Command(SynnefoCommand):
help = "List public snapshots or snapshots available to a user."
option_list = BaseCommand.option_list + (
option_list = SynnefoCommand.option_list + (
make_option(
'--user-id',
dest='userid',
......@@ -50,7 +50,7 @@ class Command(BaseCommand):
def handle(self, **options):
user = options['userid']
with image_backend(user) as backend:
with PlanktonBackend(user) as backend:
snapshots = backend.list_snapshots(user)
headers = ("id", "name", "volume_id", "size", "mapfile", "status")
......
......@@ -28,18 +28,18 @@
# policies, either expressed or implied, of GRNET S.A.
#
from django.core.management.base import BaseCommand, CommandError
from snf_django.management.commands import SynnefoCommand, CommandError
from optparse import make_option
from synnefo.management import common
from synnefo.plankton.utils import image_backend
from synnefo.plankton.backend import PlanktonBackend
from snf_django.management import utils
class Command(BaseCommand):
class Command(SynnefoCommand):
args = "<snapshot_id>"
help = "Display available information about a snapshot"
option_list = BaseCommand.option_list + (
option_list = SynnefoCommand.option_list + (
make_option(
'--user-id',
dest='userid',
......@@ -55,9 +55,9 @@ class Command(BaseCommand):
raise CommandError("Please provide a snapshot ID")
snapshot_id = args[0]
user_id = options["userid"]
userid = options["userid"]
with image_backend(userid) as backend:
with PlanktonBackend(userid) as backend:
snapshot = backend.get_snapshot(userid, snapshot_id)
utils.pprint_table(out=self.stdout, table=[snapshot.values()],
headers=snapshot.keys(), vertical=True)
......@@ -33,7 +33,7 @@
from optparse import make_option
from django.core.management.base import BaseCommand, CommandError
from snf_django.management.commands import SynnefoCommand, CommandError
from snf_django.management.utils import parse_bool
from synnefo.management import common, pprint
......@@ -42,10 +42,10 @@ from synnefo.volume import volumes
HELP_MSG = """Create a new volume."""
class Command(BaseCommand):
class Command(SynnefoCommand):
help = HELP_MSG
option_list = BaseCommand.option_list + (
option_list = SynnefoCommand.option_list + (
make_option(
"--name",
dest="name",
......
......@@ -32,17 +32,17 @@
# or implied, of GRNET S.A.
from optparse import make_option
from django.core.management.base import BaseCommand, CommandError
from snf_django.management.commands import SynnefoCommand, CommandError
from synnefo.management.common import convert_api_faults
from synnefo.management import pprint, common
class Command(BaseCommand):
class Command(SynnefoCommand):
help = "Inspect a Volume on DB and Ganeti"
args = "<volume ID>"
option_list = BaseCommand.option_list + (
option_list = SynnefoCommand.option_list + (
make_option(
'--displayname',
action='store_true',
......
......@@ -32,7 +32,7 @@
# or implied, of GRNET S.A.
from optparse import make_option
from django.core.management.base import BaseCommand, CommandError
from snf_django.management.commands import SynnefoCommand, CommandError
from snf_django.management.utils import parse_bool
from synnefo.management.common import convert_api_faults
......@@ -40,11 +40,11 @@ from synnefo.management import pprint, common
from synnefo.volume import volumes
class Command(BaseCommand):
class Command(SynnefoCommand):
help = "Modify a volume"
args = "<volume ID>"
option_list = BaseCommand.option_list + (
option_list = SynnefoCommand.option_list + (
make_option(
'--name',
dest='name',
......
......@@ -32,17 +32,17 @@
# or implied, of GRNET S.A.
from optparse import make_option
from django.core.management.base import BaseCommand, CommandError
from snf_django.management.commands import SynnefoCommand, CommandError
from synnefo.management.common import convert_api_faults
from synnefo.management import pprint, common
class Command(BaseCommand):
class Command(SynnefoCommand):
help = "Show Volume information"
args = "<volume ID>"
option_list = BaseCommand.option_list + (
option_list = SynnefoCommand.option_list + (
make_option(
'--displayname',
action='store_true',
......
import logging
from django.db import transaction
from snf_django.lib.api import faults
from synnefo.plankton.utils import image_backend
from synnefo.plankton.backend import PlanktonBackend
from synnefo.logic import backend
from synnefo.volume import util
......@@ -87,7 +87,7 @@ def create(user_id, volume, name, description, metadata, force=False):
# Convert size from Gbytes to bytes
size = volume.size << 30
with image_backend(user_id) as pithos_backend:
with PlanktonBackend(user_id) as pithos_backend:
# move this to plankton backend
snapshot_id = pithos_backend.backend.register_object_map(
user=user_id,
......@@ -127,7 +127,7 @@ def delete(snapshot):
"""
user_id = snapshot["owner"]
log.info("Deleting snapshot '%s'", snapshot["location"])
with image_backend(user_id) as pithos_backend:
with PlanktonBackend(user_id) as pithos_backend:
pithos_backend.delete_snapshot(snapshot["id"])
return snapshot
......@@ -145,5 +145,5 @@ def update(snapshot, name=None, description=None):
if not metadata:
return
user_id = snapshot["owner"]
with image_backend(user_id) as b:
with PlanktonBackend(user_id) as b:
return b.update_metadata(snapshot["id"], metadata)
from synnefo.db import models
from snf_django.lib.api import faults
from synnefo.api.util import get_image_dict, get_vm, image_backend
from synnefo.api.util import get_image_dict, get_vm
from synnefo.plankton.backend import PlanktonBackend
from synnefo.cyclades_settings import cyclades_services, BASE_HOST
from synnefo.lib import join_urls
from synnefo.lib.services import get_service_path
......@@ -23,7 +24,7 @@ def get_volume(user_id, volume_id, for_update=False,
def get_snapshot(user_id, snapshot_id, exception=faults.ItemNotFound):
try:
with image_backend(user_id) as b:
with PlanktonBackend(user_id) as b:
return b.get_snapshot(user_id, snapshot_id)
except faults.ItemNotFound:
raise exception("Snapshot %s not found" % snapshot_id)
......@@ -82,5 +83,5 @@ def get_disk_template_provider(disk_template):
def update_snapshot_status(snapshot_id, user_id, status):
with image_backend(user_id) as b:
with PlanktonBackend(user_id) as b:
return b.update_status(snapshot_id, status=status)
......@@ -44,7 +44,8 @@ from snf_django.lib.api import faults, utils
from synnefo.volume import volumes, snapshots, util
from synnefo.db.models import Volume
from synnefo.plankton.utils import image_backend
from synnefo.plankton.backend import PlanktonBackend
log = getLogger('synnefo.volume')
......@@ -287,7 +288,7 @@ def create_snapshot(request):
def list_snapshots(request, detail=False):
log.debug('list_snapshots detail=%s', detail)
since = utils.isoparse(request.GET.get('changes-since'))
with image_backend(request.user_uniq) as backend:
with PlanktonBackend(request.user_uniq) as backend:
snapshots = backend.list_snapshots()
if since:
updated_since = lambda snap:\
......
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