* ce_netstream_template: update to fix a bug. (#59690)
* update to fix a bug.
* Update ce_netstream_template.py
* Update ce_netstream_template.py
* Update ce_netstream_template.py
(cherry picked from commit adfbd04b3a
)
* add a changelog fragment.
This commit is contained in:
parent
adc494a9e1
commit
777395ec18
2 changed files with 40 additions and 2 deletions
|
@ -0,0 +1,2 @@
|
||||||
|
bugfixes:
|
||||||
|
- ce_netstream_global - The 'get_config', which is from 'ansible.module_utils.network.cloudengine.ce', try to return the result from cache,however the configure has changed. (https://github.com/ansible/ansible/pull/59690)
|
|
@ -138,10 +138,43 @@ updates:
|
||||||
|
|
||||||
import re
|
import re
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.network.cloudengine.ce import get_config, load_config
|
from ansible.module_utils.network.cloudengine.ce import load_config
|
||||||
|
from ansible.module_utils.network.cloudengine.ce import get_connection, rm_config_prefix
|
||||||
from ansible.module_utils.network.cloudengine.ce import ce_argument_spec
|
from ansible.module_utils.network.cloudengine.ce import ce_argument_spec
|
||||||
|
|
||||||
|
|
||||||
|
def get_config(module, flags):
|
||||||
|
|
||||||
|
"""Retrieves the current config from the device or cache
|
||||||
|
"""
|
||||||
|
flags = [] if flags is None else flags
|
||||||
|
if isinstance(flags, str):
|
||||||
|
flags = [flags]
|
||||||
|
elif not isinstance(flags, list):
|
||||||
|
flags = []
|
||||||
|
|
||||||
|
cmd = 'display current-configuration '
|
||||||
|
cmd += ' '.join(flags)
|
||||||
|
cmd = cmd.strip()
|
||||||
|
conn = get_connection(module)
|
||||||
|
rc, out, err = conn.exec_command(cmd)
|
||||||
|
if rc != 0:
|
||||||
|
module.fail_json(msg=err)
|
||||||
|
cfg = str(out).strip()
|
||||||
|
# remove default configuration prefix '~'
|
||||||
|
for flag in flags:
|
||||||
|
if "include-default" in flag:
|
||||||
|
cfg = rm_config_prefix(cfg)
|
||||||
|
break
|
||||||
|
if cfg.startswith('display'):
|
||||||
|
lines = cfg.split('\n')
|
||||||
|
if len(lines) > 1:
|
||||||
|
return '\n'.join(lines[1:])
|
||||||
|
else:
|
||||||
|
return ''
|
||||||
|
return cfg
|
||||||
|
|
||||||
|
|
||||||
class NetstreamTemplate(object):
|
class NetstreamTemplate(object):
|
||||||
""" Manages netstream template configuration """
|
""" Manages netstream template configuration """
|
||||||
|
|
||||||
|
@ -291,6 +324,9 @@ class NetstreamTemplate(object):
|
||||||
tmp_value = re.findall(r'collect interface (.*)', self.netstream_cfg)
|
tmp_value = re.findall(r'collect interface (.*)', self.netstream_cfg)
|
||||||
if tmp_value:
|
if tmp_value:
|
||||||
self.end_state["collect_interface"] = tmp_value
|
self.end_state["collect_interface"] = tmp_value
|
||||||
|
if self.end_state == self.existing:
|
||||||
|
self.changed = False
|
||||||
|
self.updates_cmd = list()
|
||||||
|
|
||||||
def present_netstream(self):
|
def present_netstream(self):
|
||||||
""" Present netstream configuration """
|
""" Present netstream configuration """
|
||||||
|
@ -309,7 +345,7 @@ class NetstreamTemplate(object):
|
||||||
need_create_record = True
|
need_create_record = True
|
||||||
|
|
||||||
if self.description:
|
if self.description:
|
||||||
cmd = "description %s" % self.description
|
cmd = "description %s" % self.description.strip()
|
||||||
if not self.netstream_cfg or cmd not in self.netstream_cfg:
|
if not self.netstream_cfg or cmd not in self.netstream_cfg:
|
||||||
cmds.append(cmd)
|
cmds.append(cmd)
|
||||||
self.updates_cmd.append(cmd)
|
self.updates_cmd.append(cmd)
|
||||||
|
|
Loading…
Add table
Reference in a new issue