1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

minor bug fixes found in netcfg

* fixes issue with converting config to lines
* fixes issue with returning text config with single line
This commit is contained in:
Peter Sprygada 2016-07-05 20:25:53 -04:00
parent c5d4151234
commit 3002965af0

View file

@ -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