Skip to content

Commit 7626172

Browse files
Merge pull request #53 from danielmellado/fix_netconf_var
Fix error due to netconf var not being defined Reviewed-by: Bradley A. Thornton https://github.com/cidrblock
2 parents 6629ecf + 51317f3 commit 7626172

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

roles/scaffold_rm_facts/templates/module_utils/network_os/config/resource/resource.py.j2

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ created
1313
from ansible.module_utils.network.common.cfg.base import ConfigBase
1414
from ansible.module_utils.network.common.utils import to_list
1515
from {{ import_path }}.{{ network_os }}.facts.facts import Facts
16-
{% if transport.netconf %}
16+
{% if transport == 'netconf' %}
1717
from ansible.module_utils.network.netconf.netconf import locked_config
1818
from ansible.module_utils.network.common.netconf import (build_root_xml_node,
1919
build_child_xml_node)
@@ -56,7 +56,7 @@ class {{ resource|capitalize }}(ConfigBase):
5656
:returns: The result from module execution
5757
"""
5858
result = {'changed': False}
59-
{% if transport.netconf %}
59+
{% if transport == 'netconf' %}
6060
existing_{{ resource }}_facts = self.get_{{ resource }}_facts()
6161
config_xmls = self.set_config(existing_{{ resource }}_facts)
6262

@@ -120,7 +120,7 @@ class {{ resource|capitalize }}(ConfigBase):
120120
:returns: the commands necessary to migrate the current configuration
121121
to the desired configuration
122122
"""
123-
{% if transport.netconf %}
123+
{% if transport == 'netconf' %}
124124
root = build_root_xml_node('{{ resource }}')
125125
state = self._module.params['state']
126126
if state == 'overridden':
@@ -152,7 +152,7 @@ class {{ resource|capitalize }}(ConfigBase):
152152
commands = self._state_replaced(**kwargs)
153153
return commands
154154
{% endif %}
155-
{% if transport.netconf %}
155+
{% if transport == 'netconf' %}
156156
def _state_replaced(self, want, have):
157157
""" The command generator when state is replaced
158158

roles/scaffold_rm_facts/templates/module_utils/network_os/facts/resource/resource.py.j2

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@ It is in this file the configuration is collected from the device
99
for a given resource, parsed, and the facts tree is populated
1010
based on the configuration.
1111
"""
12-
{% if not transport.netconf %}
12+
{% if not transport=='netconf' %}
1313
import re
1414
{% endif %}
1515
from copy import deepcopy
1616

17-
{% if transport.netconf %}
17+
{% if transport=='netconf' %}
1818
from ansible.module_utils._text import to_bytes
1919
{% endif %}
2020
from ansible.module_utils.network.common import utils
2121
from {{ import_path }}.{{ network_os }}.argspec.{{ resource }}.{{ resource }} import {{ resource|capitalize }}Args
22-
{% if transport.netconf %}
22+
{% if transport=='netconf' %}
2323
from ansible.module.utils.six import string_types
2424
try:
2525
from lxml import etree
@@ -55,7 +55,7 @@ class {{ resource|capitalize }}Facts(object):
5555
:rtype: dictionary
5656
:returns: facts
5757
"""
58-
{% if transport.netconf %}
58+
{% if transport=='netconf' %}
5959
if not HAS_LXML:
6060
self._module.fail_json(msg='lxml is not installed.')
6161

@@ -105,7 +105,7 @@ class {{ resource|capitalize }}Facts(object):
105105
if obj:
106106
objs.append(obj)
107107

108-
{% if transport.netconf %}
108+
{% if transport=='netconf' %}
109109
facts = {}
110110
if objs:
111111
facts['resource'] = []
@@ -135,7 +135,7 @@ class {{ resource|capitalize }}Facts(object):
135135
:returns: The generated config
136136
"""
137137
config = deepcopy(spec)
138-
{% if transport.netconf %}
138+
{% if transport=='netconf' %}
139139
config['name'] = utils.get_xml_conf_arg(conf, 'name')
140140
config['some_value'] = utils.get_xml_conf_arg(conf, 'some_value')
141141
{% else %}

roles/scaffold_rm_facts/vars/main.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
network_os: "{{ rm['NETWORK_OS'] }}"
33
resource: "{{ rm['RESOURCE'] }}"
44

5+
# set transport to network_cli unless overridden in cli
6+
transport: network_cli
7+
58
# set the directory for modules based on the structure
69
module_directories:
710
role: library

0 commit comments

Comments
 (0)