Revision a868c831
b/snf-cyclades-app/synnefo/logic/backend.py | ||
---|---|---|
1146 | 1146 |
"name": volume.backend_volume_uuid, |
1147 | 1147 |
"volume_name": volume.backend_volume_uuid} |
1148 | 1148 |
|
1149 |
disk_provider = volume.disk_provider
|
|
1149 |
disk_provider = volume.provider |
|
1150 | 1150 |
if disk_provider is not None: |
1151 | 1151 |
disk["provider"] = disk_provider |
1152 | 1152 |
|
b/snf-cyclades-app/synnefo/management/pprint.py | ||
---|---|---|
397 | 397 |
volume_dict = OrderedDict([ |
398 | 398 |
("id", volume.id), |
399 | 399 |
("size", volume.size), |
400 |
("disk_template", volume.disk_template),
|
|
401 |
("disk_provider", volume.disk_provider),
|
|
400 |
("disk_template", volume.template), |
|
401 |
("disk_provider", volume.provider), |
|
402 | 402 |
("server_id", volume.machine_id), |
403 | 403 |
("userid", volume.userid), |
404 | 404 |
("username", ucache.get_name(userid) if display_mails else None), |
405 | 405 |
("index", volume.index), |
406 | 406 |
("name", volume.name), |
407 | 407 |
("state", volume.status), |
408 |
("delete_on_termination", volume.delete_on_termination), |
|
408 | 409 |
("deleted", volume.deleted), |
409 | 410 |
("backendjobid", volume.backendjobid), |
410 | 411 |
]) |
b/snf-cyclades-app/synnefo/volume/management/commands/volume-list.py | ||
---|---|---|
56 | 56 |
"id": ("id", "ID of the server"), |
57 | 57 |
"name": ("name", "Name of the server"), |
58 | 58 |
"user.uuid": ("userid", "The UUID of the server's owner"), |
59 |
"server_id": ("machine_id", ""), |
|
60 |
"source": ("source", ""), |
|
61 |
"status": ("status", ""), |
|
59 |
"server_id": ("machine_id", "The UUID of the server that the volume" |
|
60 |
" is currently attached"), |
|
61 |
"source": ("source", "The source of the volume"), |
|
62 |
"status": ("status", "The status of the volume"), |
|
62 | 63 |
"created": ("created", "The date the server was created"), |
63 | 64 |
"deleted": ("deleted", "Whether the server is deleted or not"), |
65 |
"disk_template": ("disk_template", "The disk template of the volume") |
|
64 | 66 |
} |
65 | 67 |
|
66 |
fields = ["id", "name", "user.uuid", "status", "source", "server_id"] |
|
68 |
fields = ["id", "user.uuid", "status", "source", "disk_template", |
|
69 |
"server_id"] |
b/snf-cyclades-app/synnefo/volume/management/commands/volume-modify.py | ||
---|---|---|
1 |
# Copyright 2013 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 optparse import make_option |
|
35 |
from django.core.management.base import BaseCommand, CommandError |
|
36 |
|
|
37 |
from snf_django.management.utils import parse_bool |
|
38 |
from synnefo.management.common import convert_api_faults |
|
39 |
from synnefo.management import pprint, common |
|
40 |
from synnefo.volume import volumes |
|
41 |
|
|
42 |
|
|
43 |
class Command(BaseCommand): |
|
44 |
help = "Modify a volume" |
|
45 |
args = "<volume ID>" |
|
46 |
|
|
47 |
option_list = BaseCommand.option_list + ( |
|
48 |
make_option( |
|
49 |
'--name', |
|
50 |
dest='name', |
|
51 |
help="Modify a volume's display name"), |
|
52 |
make_option( |
|
53 |
'--description', |
|
54 |
dest='description', |
|
55 |
help="Modify a volume's display description"), |
|
56 |
make_option( |
|
57 |
'--delete-on-termination', |
|
58 |
dest='delete_on_termination', |
|
59 |
default="True", |
|
60 |
choices=["True", "False"], |
|
61 |
metavar="True|False", |
|
62 |
help="Set whether volume will be preserved when the server" |
|
63 |
" the volume is attached will be deleted"), |
|
64 |
) |
|
65 |
|
|
66 |
@convert_api_faults |
|
67 |
def handle(self, *args, **options): |
|
68 |
if len(args) != 1: |
|
69 |
raise CommandError("Please provide a volume ID") |
|
70 |
|
|
71 |
volume = common.get_volume(args[0]) |
|
72 |
|
|
73 |
name = options.get("name") |
|
74 |
description = options.get("description") |
|
75 |
delete_on_termination = options.get("delete_on_termination") |
|
76 |
if delete_on_termination is not None: |
|
77 |
delete_on_termination = parse_bool(delete_on_termination) |
|
78 |
|
|
79 |
volume = volumes.update(volume, name, description, |
|
80 |
delete_on_termination) |
|
81 |
|
|
82 |
pprint.pprint_volume(volume, stdout=self.stdout) |
|
83 |
self.stdout.write('\n\n') |
b/snf-cyclades-app/synnefo/volume/views.py | ||
---|---|---|
202 | 202 |
|
203 | 203 |
new_name = req.get("display_name") |
204 | 204 |
description = req.get("display_description") |
205 |
delete_on_termination = req.get("delete_on_termination") |
|
205 | 206 |
|
206 |
if new_name is None and description is None: |
|
207 |
if new_name is None and description is None and\ |
|
208 |
delete_on_termination is None: |
|
207 | 209 |
raise faults.BadRequest("Nothing to update.") |
210 |
else: |
|
211 |
volume = volumes.update(volume, new_name, description, |
|
212 |
delete_on_termination) |
|
208 | 213 |
|
209 |
if new_name is not None: |
|
210 |
volume = volumes.rename(volume, new_name) |
|
211 |
if description is not None: |
|
212 |
volume = volumes.update_description(volume, description) |
|
213 | 214 |
data = json.dumps({'volume': volume_to_dict(volume, detail=True)}) |
214 | 215 |
return HttpResponse(data, content_type="application/json", status=200) |
215 | 216 |
|
b/snf-cyclades-app/synnefo/volume/volumes.py | ||
---|---|---|
37 | 37 |
source_type = "image" |
38 | 38 |
source_uuid = source_image_id |
39 | 39 |
else: |
40 |
source_type = source_uuid = None |
|
40 |
source_type = "blank" |
|
41 |
source_uuid = None |
|
41 | 42 |
|
42 | 43 |
volume = _create_volume(server, user_id, size, source_type, source_uuid, |
43 | 44 |
name, description, index=None) |
... | ... | |
142 | 143 |
|
143 | 144 |
|
144 | 145 |
@transaction.commit_on_success |
145 |
def rename(volume, new_name): |
|
146 |
volume.name = new_name |
|
147 |
volume.save() |
|
148 |
return volume |
|
146 |
def update(volume, name=None, description=None, delete_on_termination=None): |
|
147 |
if name is not None: |
|
148 |
volume.name = name |
|
149 |
if description is not None: |
|
150 |
volume.description = description |
|
151 |
if delete_on_termination is not None: |
|
152 |
volume.delete_on_termination = delete_on_termination |
|
149 | 153 |
|
150 |
|
|
151 |
@transaction.commit_on_success |
|
152 |
def update_description(volume, new_description): |
|
153 |
volume.description = new_description |
|
154 | 154 |
volume.save() |
155 | 155 |
return volume |
Also available in: Unified diff