storage/lvm: force default locale for lvm command cont.
Few more places where lvm commands are called. Fixes QubesOS/qubes-issues#3753
This commit is contained in:
parent
faca89875b
commit
2c13ba9c48
@ -170,8 +170,10 @@ def init_cache(log=logging.getLogger('qubes.storage.lvm')):
|
|||||||
'--units', 'b', '--separator', ';']
|
'--units', 'b', '--separator', ';']
|
||||||
if os.getuid() != 0:
|
if os.getuid() != 0:
|
||||||
cmd.insert(0, 'sudo')
|
cmd.insert(0, 'sudo')
|
||||||
|
environ = os.environ.copy()
|
||||||
|
environ['LC_ALL'] = 'C.utf8'
|
||||||
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
|
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
|
||||||
close_fds=True)
|
close_fds=True, env=environ)
|
||||||
out, err = p.communicate()
|
out, err = p.communicate()
|
||||||
return_code = p.returncode
|
return_code = p.returncode
|
||||||
if return_code == 0 and err:
|
if return_code == 0 and err:
|
||||||
|
@ -164,17 +164,23 @@ class TC_00_ThinPool(ThinPoolBase):
|
|||||||
def test_004_size(self):
|
def test_004_size(self):
|
||||||
with self.assertNotRaises(NotImplementedError):
|
with self.assertNotRaises(NotImplementedError):
|
||||||
size = self.pool.size
|
size = self.pool.size
|
||||||
|
environ = os.environ.copy()
|
||||||
|
environ['LC_ALL'] = 'C.utf8'
|
||||||
pool_size = subprocess.check_output(['sudo', 'lvs', '--noheadings',
|
pool_size = subprocess.check_output(['sudo', 'lvs', '--noheadings',
|
||||||
'-o', 'lv_size',
|
'-o', 'lv_size',
|
||||||
'--units', 'b', self.pool.volume_group + '/' + self.pool.thin_pool])
|
'--units', 'b', self.pool.volume_group + '/' + self.pool.thin_pool],
|
||||||
|
env=environ)
|
||||||
self.assertEqual(size, int(pool_size.strip()[:-1]))
|
self.assertEqual(size, int(pool_size.strip()[:-1]))
|
||||||
|
|
||||||
def test_005_usage(self):
|
def test_005_usage(self):
|
||||||
with self.assertNotRaises(NotImplementedError):
|
with self.assertNotRaises(NotImplementedError):
|
||||||
usage = self.pool.usage
|
usage = self.pool.usage
|
||||||
|
environ = os.environ.copy()
|
||||||
|
environ['LC_ALL'] = 'C.utf8'
|
||||||
pool_info = subprocess.check_output(['sudo', 'lvs', '--noheadings',
|
pool_info = subprocess.check_output(['sudo', 'lvs', '--noheadings',
|
||||||
'-o', 'lv_size,data_percent',
|
'-o', 'lv_size,data_percent',
|
||||||
'--units', 'b', self.pool.volume_group + '/' + self.pool.thin_pool])
|
'--units', 'b', self.pool.volume_group + '/' + self.pool.thin_pool],
|
||||||
|
env=environ)
|
||||||
pool_size, pool_usage = pool_info.strip().split()
|
pool_size, pool_usage = pool_info.strip().split()
|
||||||
pool_size = int(pool_size[:-1])
|
pool_size = int(pool_size[:-1])
|
||||||
pool_usage = float(pool_usage)
|
pool_usage = float(pool_usage)
|
||||||
|
Loading…
Reference in New Issue
Block a user