
Currently there is no way to get data onto a volume through the dashboard without taking manual steps in a guest. It's possible to create a volume from a snapshot, but there's no way to get data onto a volume to create the snapshot in the first place. Creating a volume from an image is particularly useful when booting from a volume. This was implemented in cinder and nova-volume in Folsom. Expose this to dashboard users as well. Create a new action for this on the images panel, reusing the 'Create Volume' form. Also make this possible from the volumes panel, by adding a 'source type' field to the 'Create Volume' form. This lets users choose among no source (the default), snapshot, and image, hiding the lists of snapshots and images when the corresponding source type is not selected, similar to the 'image type' field in the 'Launch Instance' workflow. Use the same infrastructure as creating from a snapshot to update the size and name based on the image size and name. Extract the image listing code out of the instance panel, into a generic utility module. Also add a size conversion function, since image sizes are reported by glance in bytes, while volumes are specified in gigabytes. Change-Id: I8314ab011734d80d5f611b338ed6e2538e6bab7e Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
18 lines
480 B
Python
18 lines
480 B
Python
import math
|
|
|
|
from django.utils.encoding import force_unicode
|
|
from django.utils.functional import lazy
|
|
|
|
|
|
def _lazy_join(separator, strings):
|
|
return separator.join([force_unicode(s)
|
|
for s in strings])
|
|
|
|
lazy_join = lazy(_lazy_join, unicode)
|
|
|
|
|
|
def bytes_to_gigabytes(bytes):
|
|
# Converts the number of bytes to the next highest number of Gigabytes
|
|
# For example 5000000 (5 Meg) would return '1'
|
|
return int(math.ceil(float(bytes) / 1024 ** 3))
|