From 32d4f14c9ecaf56767a4a4c3fd7fba2e85935d98 Mon Sep 17 00:00:00 2001
From: Dirk Mueller <dirk@dmllr.de>
Date: Thu, 12 Dec 2013 00:49:27 +0100
Subject: [PATCH] Remove LANG=C from rootwrap invocations

For more than a decade already, systems support LC_ALL=C,
which overwrites LANG=C, so setting both is only confusing.

Change-Id: I5640b9cb747892162a856315ea7331cfea7cba5a
---
 cinder/brick/local_dev/lvm.py    |  7 +++----
 cinder/image/image_utils.py      |  4 ++--
 cinder/tests/test_image_utils.py | 19 +++++++++----------
 3 files changed, 14 insertions(+), 16 deletions(-)

diff --git a/cinder/brick/local_dev/lvm.py b/cinder/brick/local_dev/lvm.py
index 79af81a89..b8a952623 100644
--- a/cinder/brick/local_dev/lvm.py
+++ b/cinder/brick/local_dev/lvm.py
@@ -130,7 +130,7 @@ class LVM(executor.Executor):
         :returns: Free space, calculated after the data_percent value
 
         """
-        cmd = ['env', 'LC_ALL=C', 'LANG=C', 'lvs', '--noheadings', '--unit=g',
+        cmd = ['env', 'LC_ALL=C', 'lvs', '--noheadings', '--unit=g',
                '-o', 'size,data_percent', '--separator', ':', '--nosuffix']
 
         # NOTE(gfidente): data_percent only applies to some types of LV so we
@@ -295,8 +295,7 @@ class LVM(executor.Executor):
         :returns: List of Dictionaries with PV info
 
         """
-        cmd = ['env', 'LC_ALL=C', 'LANG=C',
-               'pvs', '--noheadings',
+        cmd = ['env', 'LC_ALL=C', 'pvs', '--noheadings',
                '--unit=g',
                '-o', 'vg_name,name,size,free',
                '--separator', ':']
@@ -342,7 +341,7 @@ class LVM(executor.Executor):
         :returns: List of Dictionaries with VG info
 
         """
-        cmd = ['env', 'LC_ALL=C', 'LANG=C', 'vgs', '--noheadings', '--unit=g',
+        cmd = ['env', 'LC_ALL=C', 'vgs', '--noheadings', '--unit=g',
                '-o', 'name,size,free,lv_count,uuid', '--separator', ':']
 
         if no_suffix:
diff --git a/cinder/image/image_utils.py b/cinder/image/image_utils.py
index f853f75be..2b870468d 100644
--- a/cinder/image/image_utils.py
+++ b/cinder/image/image_utils.py
@@ -54,9 +54,9 @@ CONF.register_opts(image_helper_opt)
 
 def qemu_img_info(path):
     """Return a object containing the parsed output from qemu-img info."""
-    cmd = ('env', 'LC_ALL=C', 'LANG=C', 'qemu-img', 'info', path)
+    cmd = ('env', 'LC_ALL=C', 'qemu-img', 'info', path)
     if os.name == 'nt':
-        cmd = cmd[3:]
+        cmd = cmd[2:]
     out, err = utils.execute(*cmd, run_as_root=True)
     return imageutils.QemuImgInfo(out)
 
diff --git a/cinder/tests/test_image_utils.py b/cinder/tests/test_image_utils.py
index 4ff5a5214..a4fec3e18 100644
--- a/cinder/tests/test_image_utils.py
+++ b/cinder/tests/test_image_utils.py
@@ -115,7 +115,7 @@ class TestUtils(test.TestCase):
         mox.StubOutWithMock(utils, 'execute')
 
         utils.execute(
-            'env', 'LC_ALL=C', 'LANG=C', 'qemu-img', 'info',
+            'env', 'LC_ALL=C', 'qemu-img', 'info',
             TEST_PATH, run_as_root=True).AndReturn(
                 (TEST_RETURN, 'ignored')
             )
@@ -168,8 +168,7 @@ class TestUtils(test.TestCase):
         mox = self._mox
         mox.StubOutWithMock(utils, 'execute')
 
-        cmd = ['env', 'LC_ALL=C', 'LANG=C',
-               'qemu-img', 'info', TEST_PATH]
+        cmd = ['env', 'LC_ALL=C', 'qemu-img', 'info', TEST_PATH]
         utils.execute(*cmd, run_as_root=True).AndReturn(
             (TEST_RETURN, 'ignored'))
 
@@ -207,8 +206,8 @@ class TestUtils(test.TestCase):
         image_utils.create_temporary_file().AndReturn(self.TEST_DEV_PATH)
 
         test_qemu_img = utils.execute(
-            'env', 'LC_ALL=C', 'LANG=C', 'qemu-img', 'info',
-            self.TEST_DEV_PATH, run_as_root=True)
+            'env', 'LC_ALL=C', 'qemu-img', 'info', self.TEST_DEV_PATH,
+            run_as_root=True)
 
         if has_qemu:
             test_qemu_img.AndReturn((TEST_INFO, 'ignored'))
@@ -219,7 +218,7 @@ class TestUtils(test.TestCase):
 
         if has_qemu and src_inf:
             utils.execute(
-                'env', 'LC_ALL=C', 'LANG=C', 'qemu-img', 'info',
+                'env', 'LC_ALL=C', 'qemu-img', 'info',
                 self.TEST_DEV_PATH, run_as_root=True).AndReturn(
                     (src_inf, 'ignored')
                 )
@@ -230,7 +229,7 @@ class TestUtils(test.TestCase):
                 self.TEST_DEV_PATH, self.TEST_DEV_PATH, run_as_root=True)
 
             utils.execute(
-                'env', 'LC_ALL=C', 'LANG=C', 'qemu-img', 'info',
+                'env', 'LC_ALL=C', 'qemu-img', 'info',
                 self.TEST_DEV_PATH, run_as_root=True).AndReturn(
                     (dest_inf, 'ignored')
                 )
@@ -334,7 +333,7 @@ class TestUtils(test.TestCase):
                           self.TEST_IMAGE_ID, self.TEST_DEV_PATH, None, None)
 
         utils.execute(
-            'env', 'LC_ALL=C', 'LANG=C', 'qemu-img', 'info',
+            'env', 'LC_ALL=C', 'qemu-img', 'info',
             self.TEST_DEV_PATH, run_as_root=True).AndReturn(
                 (qemu_info, 'ignored')
             )
@@ -396,7 +395,7 @@ class TestUtils(test.TestCase):
         utils.execute('qemu-img', 'convert', '-O', 'qcow2',
                       mox.IgnoreArg(), mox.IgnoreArg(), run_as_root=True)
         utils.execute(
-            'env', 'LC_ALL=C', 'LANG=C', 'qemu-img', 'info',
+            'env', 'LC_ALL=C', 'qemu-img', 'info',
             mox.IgnoreArg(), run_as_root=True).AndReturn(
                 (TEST_RET, 'ignored')
             )
@@ -434,7 +433,7 @@ class TestUtils(test.TestCase):
         utils.execute('qemu-img', 'convert', '-O', 'qcow2',
                       mox.IgnoreArg(), mox.IgnoreArg(), run_as_root=True)
         utils.execute(
-            'env', 'LC_ALL=C', 'LANG=C', 'qemu-img', 'info',
+            'env', 'LC_ALL=C', 'qemu-img', 'info',
             mox.IgnoreArg(), run_as_root=True).AndReturn(
                 (TEST_RET, 'ignored')
             )
-- 
2.45.2