Override subprocess environment for dpkg
Whenever we subprocess out from the charm, it is most likely because we are running tools provided by the payload to mange it. We should take care to set an appropriate environment whenever there is a chance for external python tools to be directly or indirectly involved. Change-Id: Icce4e4a8475b6ad3dc9bf60e59ff2a8ee60d9d1c Closes-Bug: #1840257
This commit is contained in:
parent
5503c63ffe
commit
88480fdae0
|
@ -139,7 +139,8 @@ class OpenStackCharm(BaseOpenStackCharm,
|
||||||
"""
|
"""
|
||||||
# No attempt is made to deal with dependancies. These should be
|
# No attempt is made to deal with dependancies. These should be
|
||||||
# handled by the charms 'packages' list.
|
# handled by the charms 'packages' list.
|
||||||
subprocess.check_call(['dpkg', '-i', deb])
|
subprocess.check_call(['dpkg', '-i', deb],
|
||||||
|
env=fetch.get_apt_dpkg_env())
|
||||||
|
|
||||||
def install_resources(self):
|
def install_resources(self):
|
||||||
"""Install Juju application resources
|
"""Install Juju application resources
|
||||||
|
|
|
@ -211,8 +211,11 @@ class TestOpenStackCharm(BaseOpenStackCharmTest):
|
||||||
|
|
||||||
def test_install_deb(self):
|
def test_install_deb(self):
|
||||||
self.patch_object(chm.subprocess, 'check_call')
|
self.patch_object(chm.subprocess, 'check_call')
|
||||||
|
self.patch_object(chm.fetch, 'get_apt_dpkg_env', return_value={})
|
||||||
self.target.install_deb('mydeb')
|
self.target.install_deb('mydeb')
|
||||||
self.check_call.assert_called_once_with(['dpkg', '-i', 'mydeb'])
|
self.check_call.assert_called_once_with(
|
||||||
|
['dpkg', '-i', 'mydeb'],
|
||||||
|
env={})
|
||||||
|
|
||||||
def test_install_resources(self):
|
def test_install_resources(self):
|
||||||
self.patch_target('install_deb')
|
self.patch_target('install_deb')
|
||||||
|
|
Loading…
Reference in New Issue