Skip to content

Commit

Permalink
Merge pull request #20 from amatamalas/moduleutils
Browse files Browse the repository at this point in the history
Moved pythonlibs to module_utils to avoid usage of ENV vars
  • Loading branch information
zahodi authored Dec 7, 2017
2 parents 38ccf5f + da30f52 commit c23500d
Show file tree
Hide file tree
Showing 24 changed files with 31 additions and 30 deletions.
4 changes: 2 additions & 2 deletions library/mt_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
password: 123
'''

import mt_api
from mt_common import clean_params
from ansible.module_utils import mt_api
from ansible.module_utils.mt_common import clean_params
from ansible.module_utils.basic import AnsibleModule


Expand Down
2 changes: 1 addition & 1 deletion library/mt_dhcp_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
dns: 192.168.1.20
'''

from mt_common import clean_params, MikrotikIdempotent
from ansible.module_utils.mt_common import clean_params, MikrotikIdempotent
from ansible.module_utils.basic import AnsibleModule


Expand Down
2 changes: 1 addition & 1 deletion library/mt_hotspot.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
use-radius: yes
'''

from mt_common import clean_params, MikrotikIdempotent
from ansible.module_utils.mt_common import clean_params, MikrotikIdempotent
from ansible.module_utils.basic import AnsibleModule


Expand Down
4 changes: 2 additions & 2 deletions library/mt_interface_bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@
comment: ansible_test
'''

import mt_api
from mt_common import clean_params
from ansible.module_utils import mt_api
from ansible.module_utils.mt_common import clean_params
from ansible.module_utils.basic import AnsibleModule


Expand Down
4 changes: 2 additions & 2 deletions library/mt_interface_bridge_port.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@
comment: ansible_test
'''

import mt_api
from mt_common import clean_params
from ansible.module_utils import mt_api
from ansible.module_utils.mt_common import clean_params
from ansible.module_utils.basic import AnsibleModule


Expand Down
2 changes: 1 addition & 1 deletion library/mt_interface_wireless.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
'''

from ansible.module_utils.basic import AnsibleModule
from mt_common import clean_params, MikrotikIdempotent
from ansible.module_utils.mt_common import clean_params, MikrotikIdempotent


def main():
Expand Down
2 changes: 1 addition & 1 deletion library/mt_interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
mtu: 1501
'''

from mt_common import clean_params, MikrotikIdempotent
from ansible.module_utils.mt_common import clean_params, MikrotikIdempotent
from ansible.module_utils.basic import AnsibleModule


Expand Down
2 changes: 1 addition & 1 deletion library/mt_ip.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
'''

from ansible.module_utils.basic import AnsibleModule
from mt_common import clean_params, MikrotikIdempotent
from ansible.module_utils.mt_common import clean_params, MikrotikIdempotent


def main():
Expand Down
2 changes: 1 addition & 1 deletion library/mt_ip_address.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
comment: "link 3"
'''

import mt_api
from ansible.module_utils import mt_api
import socket

#import mt_action #TODO: get this working
Expand Down
4 changes: 2 additions & 2 deletions library/mt_ip_firewall.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@
password: "{{ mt_pass }}"
state: present
parameter: filter
settings:
rule:
action: accept
chain: forward
comment: controlled by ansible
place-before: "2"
'''

from ansible.module_utils.basic import AnsibleModule
import mt_api
from ansible.module_utils import mt_api
import re
from copy import copy

Expand Down
2 changes: 1 addition & 1 deletion library/mt_ip_firewall_addresslist.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
- 19.134.52.23/23
'''

import mt_api
from ansible.module_utils import mt_api
from ansible.module_utils.basic import AnsibleModule


Expand Down
2 changes: 1 addition & 1 deletion library/mt_login_test.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#! /usr/bin/python

import json
import mt_api
from ansible.module_utils import mt_api

from ansible.module_utils.basic import AnsibleModule

Expand Down
2 changes: 1 addition & 1 deletion library/mt_neighbor.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
discover: "yes"
'''

from mt_common import clean_params, MikrotikIdempotent
from ansible.module_utils.mt_common import clean_params, MikrotikIdempotent
from ansible.module_utils.basic import AnsibleModule


Expand Down
2 changes: 1 addition & 1 deletion library/mt_radius.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
'''

from ansible.module_utils.basic import AnsibleModule
from mt_common import MikrotikIdempotent
from ansible.module_utils.mt_common import MikrotikIdempotent


def main():
Expand Down
2 changes: 1 addition & 1 deletion library/mt_radius_backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
timeout: '2s500ms'
'''

import mt_api
from ansible.module_utils import mt_api
from ansible.module_utils.basic import AnsibleModule


Expand Down
2 changes: 1 addition & 1 deletion library/mt_snmp.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
name: ansible_managed
'''

from mt_common import clean_params, MikrotikIdempotent
from ansible.module_utils.mt_common import clean_params, MikrotikIdempotent
from ansible.module_utils.basic import AnsibleModule


Expand Down
2 changes: 1 addition & 1 deletion library/mt_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
name: test_ansible
'''

from mt_common import clean_params, MikrotikIdempotent
from ansible.module_utils.mt_common import clean_params, MikrotikIdempotent
from ansible.module_utils.basic import AnsibleModule


Expand Down
4 changes: 2 additions & 2 deletions library/mt_system_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@
on_event: put "hello"
'''

import mt_api
from mt_common import clean_params
from ansible.module_utils import mt_api
from ansible.module_utils.mt_common import clean_params
from ansible.module_utils.basic import AnsibleModule


Expand Down
2 changes: 1 addition & 1 deletion library/mt_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
from: [email protected]
'''

from mt_common import clean_params, MikrotikIdempotent
from ansible.module_utils.mt_common import clean_params, MikrotikIdempotent
from ansible.module_utils.basic import AnsibleModule


Expand Down
2 changes: 1 addition & 1 deletion library/mt_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
group: read
'''

from mt_common import clean_params, MikrotikIdempotent
from ansible.module_utils.mt_common import clean_params, MikrotikIdempotent
from ansible.module_utils.basic import AnsibleModule


Expand Down
6 changes: 3 additions & 3 deletions pythonlibs/mt_api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
import ssl
import sys

from .retryloop import RetryError
from .retryloop import retryloop
from .socket_utils import set_keepalive
from ansible.module_utils.mt_api.retryloop import RetryError
from ansible.module_utils.mt_api.retryloop import retryloop
from ansible.module_utils.mt_api.socket_utils import set_keepalive

PY2 = sys.version_info[0] < 3
logger = logging.getLogger(__name__)
Expand Down
2 changes: 1 addition & 1 deletion pythonlibs/mt_common.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python
import mt_api
from ansible.module_utils import mt_api
import re
import sys

Expand Down
2 changes: 2 additions & 0 deletions tests/integration/ansible.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[defaults]
module_utils = ./pythonlibs/
1 change: 0 additions & 1 deletion tests/integration/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ ABSOLUTE_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
pushd .

cd "$ABSOLUTE_PATH"
export PYTHONPATH=./pythonlibs/
ansible-playbook tests.yml --diff -i 127.0.0.1, $@

popd >/dev/null

0 comments on commit c23500d

Please sign in to comment.