From: Eric Harney Date: Thu, 14 Nov 2013 18:29:42 +0000 (-0500) Subject: Check only our VG name when testing if VG exists X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=ccc4cca6e1d220a140dfa647aeff36bcae4f79dc;p=openstack-build%2Fcinder-build.git Check only our VG name when testing if VG exists Rather than calling "vgs" we should just call "vgs " which returns only information about the VG we are querying. Also hardens test command string matching to error on unexpected calls. Change-Id: I25580e34b6589e161a51274f22dbb9ed922e43ed --- diff --git a/cinder/brick/local_dev/lvm.py b/cinder/brick/local_dev/lvm.py index 4b3066c6a..47e6d5b9f 100644 --- a/cinder/brick/local_dev/lvm.py +++ b/cinder/brick/local_dev/lvm.py @@ -95,7 +95,7 @@ class LVM(executor.Executor): """ exists = False - cmd = ['vgs', '--noheadings', '-o', 'name'] + cmd = ['vgs', '--noheadings', '-o', 'name', self.vg_name] (out, err) = self._execute(*cmd, root_helper=self._root_helper, run_as_root=True) diff --git a/cinder/tests/brick/test_brick_lvm.py b/cinder/tests/brick/test_brick_lvm.py index 16df44b5b..83183b59e 100644 --- a/cinder/tests/brick/test_brick_lvm.py +++ b/cinder/tests/brick/test_brick_lvm.py @@ -67,9 +67,10 @@ class BrickLvmTestCase(test.TestCase): if 'vgs, --noheadings, --unit=g, -o, name' == cmd_string: data = " fake-volumes\n" - elif 'vgs, --noheadings, -o, name' == cmd_string: + data += " some-other-vg\n" + elif 'vgs, --noheadings, -o, name, fake-volumes' == cmd_string: data = " fake-volumes\n" - if 'vgs, --version' in cmd_string: + elif 'vgs, --version' in cmd_string: data = " LVM version: 2.02.95(2) (2012-03-06)\n" elif 'vgs, --noheadings, -o uuid, fake-volumes' in cmd_string: data = " kVxztV-dKpG-Rz7E-xtKY-jeju-QsYU-SLG6Z1\n" @@ -99,7 +100,7 @@ class BrickLvmTestCase(test.TestCase): data += " fake-volumes-2:/dev/sdb:10.00g:8.99g\n" data += " fake-volumes-3:/dev/sdc:10.00g:8.99g\n" else: - pass + raise AssertionError('unexpected command called: %s' % cmd_string) return (data, "")