summaryrefslogtreecommitdiff
path: root/nova/virt/libvirt/imagebackend.py
diff options
context:
space:
mode:
authorMichael Still <mikal@stillhq.com>2014-11-25 15:42:47 +0300
committerYaguang Tang <ytang@mirantis.com>2015-08-01 23:19:34 +0800
commitadecf780d3ed4315e4ce305cb1821d493650494b (patch)
treeaf81e5ee1c1c015175756a68b31bc742878401cc /nova/virt/libvirt/imagebackend.py
parent2cd6485efe923657b01a7977b53817dce2d37977 (diff)
downloadnova-adecf780d3ed4315e4ce305cb1821d493650494b.tar.gz
Handle config drives being stored on rbd
rbd is the only example of a currently supported image storage backend where it makes sense to put the config drive in the configured storage backend instead of local hypervisor disk. I don't think this makes sense for LVM, where we would be creating a LV for a tens of megabytes file, which seems like overkill to me. The other storage backends use local disk for their data already. This use case was covered by the now reverted changes: 228d0221763b12f11ecbacde4db38b1151f96e31 0b01e846d40f3b343da9ebe1dae89cca8bc2ac66 ecce888c469c62374a3cc43e3cede11d8aa1e799 Support this special case by moving the image to rbd once it has been created in the local instance directory on the hypervisor. I've tested this change in devstack and it works. Related-bug: #1369627 Related-bug: #1361840 Related-bug: #1246201 Co-Authored-By: Mehdi Abaakouk <sileht@redhat.com> Co-Authored-By: Dan Smith <dms@danplanet.com> Change-Id: Ia3ca5a18c79d62b71b9c042a612d12dd074b245e
Diffstat (limited to 'nova/virt/libvirt/imagebackend.py')
-rw-r--r--nova/virt/libvirt/imagebackend.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/nova/virt/libvirt/imagebackend.py b/nova/virt/libvirt/imagebackend.py
index 8708d29651..61b02cbdef 100644
--- a/nova/virt/libvirt/imagebackend.py
+++ b/nova/virt/libvirt/imagebackend.py
@@ -386,6 +386,23 @@ class Image(object):
"""
raise NotImplementedError()
+ def import_file(self, instance, local_file, remote_name):
+ """Import an image from local storage into this backend.
+
+ Import a local file into the store used by this image type. Note that
+ this is a noop for stores using local disk (the local file is
+ considered "in the store").
+
+ If the image already exists it will be overridden by the new file
+
+ :param local_file: path to the file to import
+ :param remote_name: the name for the file in the store
+ """
+
+ # NOTE(mikal): this is a noop for now for all stores except RBD, but
+ # we should talk about if we want this functionality for everything.
+ pass
+
class Raw(Image):
def __init__(self, instance=None, disk_name=None, path=None):
@@ -808,6 +825,12 @@ class Rbd(Image):
secret,
servers)
+ def import_file(self, instance, local_file, remote_name):
+ name = '%s_%s' % (instance.uuid, remote_name)
+ if self.check_image_exists():
+ self.driver.remove_image(name)
+ self.driver.import_image(local_file, name)
+
class Ploop(Image):
def __init__(self, instance=None, disk_name=None, path=None):