Skip to content

Commit e0540df

Browse files
author
Boris Filippov
committed
blueprint lvm-disk-images
Add ability to use LVM volumes for VM disks. Implements LVM disks support for libvirt driver. VM disks will be stored on LVM volumes in volume group specified by `libvirt_images_volume_group` option. Another option `libvirt_local_images_type` specify which storage type will be used. Supported values are `raw`, `lvm`, `qcow2`, `default`. If `libvirt_local_images_type` = `default`, usual logic with `use_cow_images` flag is used. Boolean option `libvirt_sparse_logical_volumes` controls which type of logical volumes will be created (sparsed with virtualsize or usual logical volumes with full space allocation). Default value for this option is `False`. Commit introduce three classes: `Raw`, `Qcow2` and `Lvm`. They contain image creation logic, that was stored in `LibvirtConnection._cache_image` and `libvirt_info` methods, that produce right `LibvirtGuestConfigDisk` configurations for libvirt. `Backend` class choose which image type to use. Change-Id: I0d01cb7d2fd67de2565b8d45d34f7846ad4112c2
1 parent 6555c5a commit e0540df

File tree

11 files changed

+900
-182
lines changed

11 files changed

+900
-182
lines changed

Authors

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Asbjørn Sannes <asbjorn.sannes@interhost.no>
2323
Ben McGraw <ben@pistoncloud.com>
2424
Ben Swartzlander <bswartz@netapp.com>
2525
Bilal Akhtar <bilalakhtar@ubuntu.com>
26+
Boris Filippov <bfilippov@griddynamics.com>
2627
Brad Hall <brad@nicira.com>
2728
Brad McConnell <bmcconne@rackspace.com>
2829
Brendan Maguire <B_Maguire@Dell.com>

nova/rootwrap/compute.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,4 +188,13 @@
188188
# nova/virt/libvirt/connection.py:
189189
filters.ReadFileFilter("/etc/iscsi/initiatorname.iscsi"),
190190

191+
# nova/virt/libvirt/connection.py:
192+
filters.CommandFilter("/sbin/lvremove", "root"),
193+
194+
# nova/virt/libvirt/utils.py:
195+
filters.CommandFilter("/sbin/lvcreate", "root"),
196+
197+
# nova/virt/libvirt/utils.py:
198+
filters.CommandFilter("/sbin/vgs", "root")
199+
191200
]

nova/tests/fake_imagebackend.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# vim: tabstop=4 shiftwidth=4 softtabstop=4
2+
3+
# Copyright 2012 Grid Dynamics
4+
# All Rights Reserved.
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
7+
# not use this file except in compliance with the License. You may obtain
8+
# a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15+
# License for the specific language governing permissions and limitations
16+
# under the License.
17+
18+
import os
19+
20+
from nova.virt.libvirt import config
21+
from nova.virt.libvirt import imagebackend
22+
23+
24+
class Backend(object):
25+
def __init__(self, use_cow):
26+
pass
27+
28+
def image(self, instance, name, suffix='', image_type=''):
29+
class FakeImage(imagebackend.Image):
30+
def __init__(self, instance, name, suffix=''):
31+
self.path = os.path.join(instance, name + suffix)
32+
33+
def create_image(self, prepare_template, base,
34+
size, *args, **kwargs):
35+
pass
36+
37+
def cache(self, fn, fname, size=None, *args, **kwargs):
38+
pass
39+
40+
def libvirt_info(self, device_type):
41+
info = config.LibvirtConfigGuestDisk()
42+
info.source_type = 'file'
43+
info.source_device = device_type
44+
info.driver_format = 'raw'
45+
info.source_path = self.path
46+
return info
47+
48+
return FakeImage(instance, name, suffix)

nova/tests/fake_libvirt_utils.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,22 @@ def mkfs(fs, path):
5050
pass
5151

5252

53+
def resize2fs(path):
54+
pass
55+
56+
57+
def create_lvm_image(vg, lv, size, sparse=False):
58+
pass
59+
60+
61+
def volume_group_free_space(vg):
62+
pass
63+
64+
65+
def remove_logical_volumes(*paths):
66+
pass
67+
68+
5369
def ensure_tree(path):
5470
pass
5571

0 commit comments

Comments
 (0)