Setup LVM_SYSTEM_DIR earlier in LVM.__init()
When using a Cinder specific lvm.conf file, we need to setup the
LVM_SYSTEM_DIR setting in the LVM.LVM_CMD_PREFIX before issuing
any LVM commands to ensure that the correct lvm.conf is used.
The issue was uncovered when testing on a Cinder Volume host setup
as follows:
* Cinder is configured to use an LVM backend, backed by the
cinder-volumes VG, which already exists.
* /etc/lvm/lvm.conf rejects all devices other than those on which
the operating system is installed.
* /etc/cinder/lvm.conf accepts only the devices backing the
cinder-volumes LVM VG
The cinder-volume service would fail to initialise the specified LVM
backend because the cinder.brick.local_dev.lvm.LVM.__init__() call
checks for the existence of the specified VG before
LVM_SYSTEM_DIR=/etc/cinder
has been added to the LVM.LVM_CMD_PREFIX, and thus fails to find the
VG, and raises an exception.
By moving the setup of the LVM_SYSTEM_DIR environment variable in
LVM.LVM_CMD_PREFIX to happen before any LVM commands are issued we
ensure that all subsequent LVM commands are run against the correct
lvm.conf file.
Change-Id: I6551b045ab48ee60c3ee4cd15c13058635c144c2
Closes-Bug: #
1498480