From 966a514821738caf7835e7781037a04454e3299d Mon Sep 17 00:00:00 2001 From: John Griffith Date: Fri, 20 Sep 2013 21:30:36 +0000 Subject: [PATCH] Add extend to reference LVM driver Somwhere along the way we somehow dropped or missed implementing the extend functionality in the reference LVM driver. Add it. Change-Id: Ib3efe16252b5efacce253688767df426117b2a44 Closes-Bug: #1228358 --- cinder/brick/local_dev/lvm.py | 15 +++++++++++++++ cinder/volume/drivers/lvm.py | 4 ++++ etc/cinder/rootwrap.d/volume.filters | 5 ++++- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/cinder/brick/local_dev/lvm.py b/cinder/brick/local_dev/lvm.py index bee80ba20..fa7548c23 100644 --- a/cinder/brick/local_dev/lvm.py +++ b/cinder/brick/local_dev/lvm.py @@ -434,3 +434,18 @@ class LVM(executor.Executor): if (out[0] == 'o') or (out[0] == 'O'): return True return False + + def extend_volume(self, lv_name, new_size): + """Extend the size of an existing volume.""" + + try: + self._execute('lvextend', '-L', new_size, + '%s/%s' % (self.vg_name, lv_name), + root_helper=self._root_helper, + run_as_root=True) + except putils.ProcessExecutionError as err: + LOG.exception(_('Error extending Volume')) + LOG.error(_('Cmd :%s') % err.cmd) + LOG.error(_('StdOut :%s') % err.stdout) + LOG.error(_('StdErr :%s') % err.stderr) + raise diff --git a/cinder/volume/drivers/lvm.py b/cinder/volume/drivers/lvm.py index fc3b10ccb..afd460272 100644 --- a/cinder/volume/drivers/lvm.py +++ b/cinder/volume/drivers/lvm.py @@ -371,6 +371,10 @@ class LVMVolumeDriver(driver.VolumeDriver): self._stats = data + def extend_volume(self, volume, new_size): + """Extend an existing voumes size.""" + self.vg.extend_volume(volume['name'], new_size) + class LVMISCSIDriver(LVMVolumeDriver, driver.ISCSIDriver): """Executes commands relating to ISCSI volumes. diff --git a/etc/cinder/rootwrap.d/volume.filters b/etc/cinder/rootwrap.d/volume.filters index 99f75ed6c..aa533269d 100644 --- a/etc/cinder/rootwrap.d/volume.filters +++ b/etc/cinder/rootwrap.d/volume.filters @@ -27,6 +27,9 @@ lvdisplay: CommandFilter, lvdisplay, root # cinder/volume/driver.py: 'lvrename', '%(vg)s', '%(orig)s' '(new)s'... lvrename: CommandFilter, lvrename, root +# cinder/volume/driver.py: 'lvextend', '-L' '%(new_size)s', '%(lv_name)s' ... +lvextend: CommandFilter, lvextend, root + # cinder/volume/driver.py: 'iscsiadm', '-m', 'discovery', '-t',... # cinder/volume/driver.py: 'iscsiadm', '-m', 'node', '-T', ... iscsiadm: CommandFilter, iscsiadm, root @@ -61,7 +64,7 @@ find: CommandFilter, find, root # cinder/volume/drivers/glusterfs.py mv: CommandFilter, mv, root -# cinder/volumes/drivers/hds/hds.py: +# cinder/volumes/drivers/hds/hds.py: hus-cmd: CommandFilter, hus-cmd, root # cinder/brick/initiator/connector.py: -- 2.45.2