From 3002965af0e8d46d2d33e77f905365330b4f429a Mon Sep 17 00:00:00 2001 From: Peter Sprygada Date: Tue, 5 Jul 2016 20:25:53 -0400 Subject: [PATCH] minor bug fixes found in netcfg * fixes issue with converting config to lines * fixes issue with returning text config with single line --- lib/ansible/module_utils/netcfg.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/ansible/module_utils/netcfg.py b/lib/ansible/module_utils/netcfg.py index c84baed3c72..f916956105b 100644 --- a/lib/ansible/module_utils/netcfg.py +++ b/lib/ansible/module_utils/netcfg.py @@ -133,7 +133,8 @@ class NetworkConfig(object): def __str__(self): if self._device_os == 'junos': - return self.to_lines(self.expand(self.items)) + lines = self.to_lines(self.expand(self.items)) + return '\n'.join(lines) return self.to_block(self.expand(self.items)) def load(self, contents): @@ -188,12 +189,12 @@ class NetworkConfig(object): visited.add(o) return expanded - def to_lines(self, section): + def to_lines(self, objects): lines = list() - for entry in section[1:]: - line = ['set'] - line.extend([p.text for p in entry.parents]) - line.append(entry.text) + for obj in objects: + line = list() + line.extend([p.text for p in obj.parents]) + line.append(obj.text) lines.append(' '.join(line)) return lines