Add debug information of the dhclient process

Log the standard output/error of the dhclient process which provides
more information of the execution of the DHCP client script.

Change-Id: I6a057d089ee21ea2898078fb7b11dce00a570ec0
This commit is contained in:
Hongbin Lu 2018-12-13 21:42:58 +00:00
parent 462b510c50
commit 02dabd6f10
1 changed files with 8 additions and 0 deletions

View File

@ -16,6 +16,7 @@ from distutils import spawn
import itertools import itertools
import netaddr import netaddr
from oslo_log import log as logging
from neutron_lib.api.definitions import portbindings as pbs from neutron_lib.api.definitions import portbindings as pbs
from neutron_lib import constants from neutron_lib import constants
@ -27,6 +28,7 @@ from neutron.tests.common import machine_fixtures
from neutron.tests.common import net_helpers from neutron.tests.common import net_helpers
FULLSTACK_DHCLIENT_SCRIPT = 'fullstack-dhclient-script' FULLSTACK_DHCLIENT_SCRIPT = 'fullstack-dhclient-script'
LOG = logging.getLogger(__name__)
class FakeFullstackMachinesList(list): class FakeFullstackMachinesList(list):
@ -146,6 +148,12 @@ class FakeFullstackMachine(machine_fixtures.FakeMachineBase):
return return
try: try:
self.dhclient_async.stop() self.dhclient_async.stop()
cmd = self.dhclient_async.cmd
stdout = list(self.dhclient_async.iter_stdout())
stderr = list(self.dhclient_async.iter_stderr())
LOG.debug('Stopping async dhclient [%(cmd)s]. stdout: '
'[%(stdout)s] - stderr: [%(stderr)s]',
{'cmd': cmd, 'stdout': stdout, 'stderr': stderr})
except async_process.AsyncProcessException: except async_process.AsyncProcessException:
# If it was already stopped than we don't care about it # If it was already stopped than we don't care about it
pass pass