mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
nxos integration fix part 1 (#27069)
* Assorted Python 3 fixes * Fix `testcase` definition in integration tests * Fix nxos_acl_interface * clean up nxapi after nxos_nxapi
This commit is contained in:
parent
b8337ee9d3
commit
56a0b988a9
12 changed files with 29 additions and 11 deletions
|
@ -27,7 +27,7 @@
|
||||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||||
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#
|
#
|
||||||
import re
|
|
||||||
import collections
|
import collections
|
||||||
|
|
||||||
from ansible.module_utils._text import to_text
|
from ansible.module_utils._text import to_text
|
||||||
|
|
|
@ -88,7 +88,10 @@ from ansible.module_utils.basic import AnsibleModule
|
||||||
def check_for_acl_int_present(module, name, intf, direction):
|
def check_for_acl_int_present(module, name, intf, direction):
|
||||||
# Need to Captitalize the interface name as the nxos
|
# Need to Captitalize the interface name as the nxos
|
||||||
# output has capitalization
|
# output has capitalization
|
||||||
command = ['show running-config aclmgr | section {0}'.format(intf.title())]
|
command = [{
|
||||||
|
'command': 'show running-config aclmgr | section {0}'.format(intf.title()),
|
||||||
|
'output': 'text',
|
||||||
|
}]
|
||||||
body = run_commands(module, command)
|
body = run_commands(module, command)
|
||||||
|
|
||||||
if direction == 'ingress':
|
if direction == 'ingress':
|
||||||
|
|
|
@ -41,7 +41,7 @@ class ActionModule(_ActionModule):
|
||||||
try:
|
try:
|
||||||
self._handle_template()
|
self._handle_template()
|
||||||
except ValueError as exc:
|
except ValueError as exc:
|
||||||
return dict(failed=True, msg=exc.message)
|
return dict(failed=True, msg=str(exc))
|
||||||
|
|
||||||
result = super(ActionModule, self).run(tmp, task_vars)
|
result = super(ActionModule, self).run(tmp, task_vars)
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ class ActionModule(_ActionModule):
|
||||||
|
|
||||||
# strip out any keys that have two leading and two trailing
|
# strip out any keys that have two leading and two trailing
|
||||||
# underscore characters
|
# underscore characters
|
||||||
for key in result.keys():
|
for key in list(result.keys()):
|
||||||
if PRIVATE_KEYS_RE.match(key):
|
if PRIVATE_KEYS_RE.match(key):
|
||||||
del result[key]
|
del result[key]
|
||||||
|
|
||||||
|
|
|
@ -22,9 +22,9 @@ __metaclass__ = type
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
import glob
|
import glob
|
||||||
import urlparse
|
|
||||||
|
|
||||||
from ansible.module_utils._text import to_text
|
from ansible.module_utils._text import to_text
|
||||||
|
from ansible.module_utils.six.moves.urllib.parse import urlsplit
|
||||||
from ansible.plugins.action.nxos import ActionModule as _ActionModule
|
from ansible.plugins.action.nxos import ActionModule as _ActionModule
|
||||||
|
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ class ActionModule(_ActionModule):
|
||||||
try:
|
try:
|
||||||
self._handle_template()
|
self._handle_template()
|
||||||
except (ValueError, AttributeError) as exc:
|
except (ValueError, AttributeError) as exc:
|
||||||
return dict(failed=True, msg=exc.message)
|
return dict(failed=True, msg=str(exc))
|
||||||
|
|
||||||
result = super(ActionModule, self).run(tmp, task_vars)
|
result = super(ActionModule, self).run(tmp, task_vars)
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ class ActionModule(_ActionModule):
|
||||||
|
|
||||||
working_path = self._get_working_path()
|
working_path = self._get_working_path()
|
||||||
|
|
||||||
if os.path.isabs(src) or urlparse.urlsplit(src).scheme:
|
if os.path.isabs(src) or urlsplit(src).scheme:
|
||||||
source = src
|
source = src
|
||||||
else:
|
else:
|
||||||
source = self._loader.path_dwim_relative(working_path, 'templates', src)
|
source = self._loader.path_dwim_relative(working_path, 'templates', src)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
- debug: msg="START cli/lesstahnorequal.yaml"
|
- debug: msg="START cli/lessthanorequal.yaml"
|
||||||
|
|
||||||
- name: test le operator
|
- name: test le operator
|
||||||
nxos_command:
|
nxos_command:
|
||||||
|
@ -29,4 +29,4 @@
|
||||||
that:
|
that:
|
||||||
- "result.changed == false"
|
- "result.changed == false"
|
||||||
|
|
||||||
- debug: msg="END cli/lesstahnorequal.yaml"
|
- debug: msg="END cli/lessthanorequal.yaml"
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
---
|
||||||
|
testcase: "*"
|
2
test/integration/targets/nxos_feature/defaults/main.yaml
Normal file
2
test/integration/targets/nxos_feature/defaults/main.yaml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
---
|
||||||
|
testcase: "*"
|
|
@ -0,0 +1,2 @@
|
||||||
|
---
|
||||||
|
testcase: "*"
|
2
test/integration/targets/nxos_mtu/defaults/main.yaml
Normal file
2
test/integration/targets/nxos_mtu/defaults/main.yaml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
---
|
||||||
|
testcase: "*"
|
|
@ -13,3 +13,9 @@
|
||||||
with_items: "{{ test_items }}"
|
with_items: "{{ test_items }}"
|
||||||
loop_control:
|
loop_control:
|
||||||
loop_var: test_case_to_run
|
loop_var: test_case_to_run
|
||||||
|
|
||||||
|
- name: disable nxapi
|
||||||
|
nxos_config:
|
||||||
|
lines:
|
||||||
|
- no feature nxapi
|
||||||
|
provider: "{{ cli }}"
|
||||||
|
|
2
test/integration/targets/nxos_system/defaults/main.yaml
Normal file
2
test/integration/targets/nxos_system/defaults/main.yaml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
---
|
||||||
|
testcase: "*"
|
|
@ -48,8 +48,7 @@ class TestNxosAclInterfaceModule(TestNxosModule):
|
||||||
|
|
||||||
for item in commands:
|
for item in commands:
|
||||||
try:
|
try:
|
||||||
obj = json.loads(item)
|
command = item['command']
|
||||||
command = obj['command']
|
|
||||||
except ValueError:
|
except ValueError:
|
||||||
command = item
|
command = item
|
||||||
filename = '%s.txt' % str(command).split(' | ')[0].replace(' ', '_')
|
filename = '%s.txt' % str(command).split(' | ')[0].replace(' ', '_')
|
||||||
|
|
Loading…
Reference in a new issue