Merge "Handle utf-8 when running python commands"
This commit is contained in:
commit
d8ecf364e5
|
@ -1112,10 +1112,10 @@ class TestPostConfig(base.BaseTestCase):
|
|||
mock_heat = mock.Mock()
|
||||
mock_heat.stacks.list.return_value = stacks
|
||||
undercloud._migrate_to_convergence(mock_heat)
|
||||
self.assertEqual([mock.call(['sudo', 'heat-manage',
|
||||
self.assertEqual([mock.call(['sudo', '-E', 'heat-manage',
|
||||
'migrate_convergence_1', '1'],
|
||||
name='heat-manage'),
|
||||
mock.call(['sudo', 'heat-manage',
|
||||
mock.call(['sudo', '-E', 'heat-manage',
|
||||
'migrate_convergence_1', '2'],
|
||||
name='heat-manage')],
|
||||
mock_run_command.mock_calls)
|
||||
|
|
|
@ -561,6 +561,15 @@ def _run_command(args, env=None, name=None):
|
|||
"""
|
||||
if name is None:
|
||||
name = args[0]
|
||||
|
||||
if env is None:
|
||||
env = os.environ
|
||||
env = env.copy()
|
||||
|
||||
# When running a localized python script, we need to tell it that we're
|
||||
# using utf-8 for stdout, otherwise it can't tell because of the pipe.
|
||||
env['PYTHONIOENCODING'] = 'utf8'
|
||||
|
||||
try:
|
||||
return subprocess.check_output(args,
|
||||
stderr=subprocess.STDOUT,
|
||||
|
@ -579,6 +588,15 @@ def _run_live_command(args, env=None, name=None):
|
|||
"""
|
||||
if name is None:
|
||||
name = args[0]
|
||||
|
||||
if env is None:
|
||||
env = os.environ
|
||||
env = env.copy()
|
||||
|
||||
# When running a localized python script, we need to tell it that we're
|
||||
# using utf-8 for stdout, otherwise it can't tell because of the pipe.
|
||||
env['PYTHONIOENCODING'] = 'utf8'
|
||||
|
||||
process = subprocess.Popen(args, env=env,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.STDOUT)
|
||||
|
@ -1657,7 +1675,7 @@ def _migrate_to_convergence(heat):
|
|||
"""
|
||||
for stack in heat.stacks.list():
|
||||
LOG.info('Migrating stack "%s" to convergence engine', stack.id)
|
||||
args = ['sudo', 'heat-manage', 'migrate_convergence_1', stack.id]
|
||||
args = ['sudo', '-E', 'heat-manage', 'migrate_convergence_1', stack.id]
|
||||
_run_command(args, name='heat-manage')
|
||||
LOG.info('Finished migrating stack "%s"', stack.id)
|
||||
|
||||
|
@ -1772,7 +1790,7 @@ def install(instack_root, upgrade=False):
|
|||
# `nova-manage db online_data_migrations` command before. This
|
||||
# could cause the post-upgrade db sync to fail. Better be safe
|
||||
# than sorry and run it before package upgrade.
|
||||
_run_command(['sudo', '/usr/bin/nova-manage', 'db',
|
||||
_run_command(['sudo', '-E', '/usr/bin/nova-manage', 'db',
|
||||
'online_data_migrations'])
|
||||
# Even if we backport https://review.openstack.org/#/c/457478/
|
||||
# into stable branches of puppet-ironic, we still need a way
|
||||
|
|
Loading…
Reference in New Issue