Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ADD Ea definition support #234

Closed
wants to merge 10 commits into from
48 changes: 24 additions & 24 deletions .github/workflows/ansible-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ jobs:
- name: Check out code
uses: actions/checkout@v2

- name: Set up Python 3.10
- name: Set up Python 3.11
uses: actions/setup-python@v1
with:
python-version: '3.10'
python-version: '3.11'

- name: Install ansible (${{ matrix.ansible-version }})
run: pip install pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible-version }}.tar.gz --disable-pip-version-check
Expand All @@ -48,21 +48,21 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11']
ansible-version: [stable-2.14, stable-2.15, stable-2.16, devel]
python-version: ['3.9', '3.10', '3.11', '3.12']
ansible-version: [stable-2.15, stable-2.16, stable-2.17, devel]
exclude:
- ansible-version: devel
python-version: '3.8'
python-version: '3.11'
- ansible-version: devel
python-version: '3.10'
- ansible-version: devel
python-version: '3.9'
- ansible-version: stable-2.16
python-version: '3.8'
- ansible-version: stable-2.17
python-version: '3.9'
- ansible-version: stable-2.16
python-version: '3.9'
- ansible-version: stable-2.15
python-version: '3.8'
- ansible-version: stable-2.14
python-version: '3.8'
python-version: '3.12'

steps:
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -83,7 +83,7 @@ jobs:
run: |
ansible-galaxy collection install .cache/collection-tarballs/*.tar.gz
git clone https://github.com/ansible/ansible.git -b ${{ matrix.ansible-version }}
if [ "${{ matrix.ansible-version }}" != "devel" ]; then cp -rf ansible/test/units/compat /home/runner/.ansible/collections/ansible_collections/infoblox/nios_modules/tests/unit/; fi
if [ "${{ matrix.ansible-version }}" != "devel" ] && [ "${{ matrix.ansible-version }}" != "stable-2.17" ]; then cp -rf ansible/test/units/compat /home/runner/.ansible/collections/ansible_collections/infoblox/nios_modules/tests/unit/; fi
cp -rf ansible/test/units/modules/utils.py /home/runner/.ansible/collections/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/
sed -i 's/units/ansible_collections.infoblox.nios_modules.tests.unit/' /home/runner/.ansible/collections/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/utils.py
if [ -f /home/runner/.ansible/collections/ansible_collections/infoblox/nios_modules/tests/unit/requirements.txt ]; then pip install -r /home/runner/.ansible/collections/ansible_collections/infoblox/nios_modules/tests/unit/requirements.txt; fi
Expand All @@ -93,8 +93,8 @@ jobs:

- name: Generate coverage report
run: |
if [ "${{ matrix.ansible-version }}" == "stable-2.14" ]; then
pip install coverage==6.5.0;
if [ "${{ matrix.ansible-version }}" == "devel" ]; then
pip install coverage==7.5.3;
elif [ "${{ matrix.ansible-version }}" == "stable-2.15" ]; then
pip install coverage==6.5.0;
fi
Expand All @@ -114,21 +114,21 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11']
ansible-version: [stable-2.14, stable-2.15, stable-2.16, devel]
python-version: ['3.9', '3.10', '3.11', '3.12']
ansible-version: [stable-2.15, stable-2.16, stable-2.17, devel]
exclude:
- ansible-version: devel
python-version: '3.8'
python-version: '3.11'
- ansible-version: devel
python-version: '3.10'
- ansible-version: devel
python-version: '3.9'
- ansible-version: stable-2.16
python-version: '3.8'
- ansible-version: stable-2.17
python-version: '3.9'
- ansible-version: stable-2.16
python-version: '3.9'
- ansible-version: stable-2.15
python-version: '3.8'
- ansible-version: stable-2.14
python-version: '3.8'
python-version: '3.12'
steps:
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
Expand Down Expand Up @@ -186,15 +186,15 @@ jobs:
strategy:
fail-fast: false
matrix:
ansible-version: [stable-2.14, stable-2.15, stable-2.16, devel]
ansible-version: [stable-2.15, stable-2.16, stable-2.17, devel]

steps:
- name: Set up Python 3.10
- name: Set up Python 3.11
uses: actions/setup-python@v1
with:
# it is just required to run that once as "ansible-test sanity" in the docker image
# will run on all python versions it supports.
python-version: '3.10'
python-version: 3.11

- name: Install ansible (${{ matrix.ansible-version }}) version
run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible-version }}.tar.gz --disable-pip-version-check
Expand Down
Empty file added MANIFEST.in
Empty file.
16 changes: 11 additions & 5 deletions plugins/lookup/nios_next_ip.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,22 @@
EXAMPLES = """
- name: return next available IP address for network 192.168.10.0/24
ansible.builtin.set_fact:
ipaddr: "{{ lookup('infoblox.nios_modules.nios_next_ip', '192.168.10.0/24', provider={'host': 'nios01', 'username': 'admin', 'password': 'password'}) }}"
ipaddr: "{{ lookup('infoblox.nios_modules.nios_next_ip', '192.168.10.0/24',
provider={'host': 'nios01', 'username': 'admin', 'password': 'password'}) }}"

- name: return next available IP address for network 192.168.10.0/24 in a non-default network view
ansible.builtin.set_fact:
ipaddr: "{{ lookup('infoblox.nios_modules.nios_next_ip', '192.168.10.0/24', network_view='ansible', \
ipaddr: "{{ lookup('infoblox.nios_modules.nios_next_ip', '192.168.10.0/24', network_view='ansible',
provider={'host': 'nios01', 'username': 'admin', 'password': 'password'}) }}"

- name: return the next 3 available IP addresses for network 192.168.10.0/24
ansible.builtin.set_fact:
ipaddr: "{{ lookup('infoblox.nios_modules.nios_next_ip', '192.168.10.0/24', num=3,
provider={'host': 'nios01', 'username': 'admin', 'password': 'password'}) }}"
ipaddr: "{{ lookup('infoblox.nios_modules.nios_next_ip',
'192.168.10.0/24',
num=3,
provider={'host': 'nios01',
'username': 'admin',
'password': 'password'}) }}"

- name: return the next 3 available IP addresses for network 192.168.10.0/24 excluding ip addresses - ['192.168.10.1', '192.168.10.2']
ansible.builtin.set_fact:
Expand All @@ -62,7 +67,8 @@

- name: return next available IP address for network fd30:f52:2:12::/64
ansible.builtin.set_fact:
ipaddr: "{{ lookup('infoblox.nios_modules.nios_next_ip', 'fd30:f52:2:12::/64', provider={'host': 'nios01', 'username': 'admin', 'password': 'password'}) }}"
ipaddr: "{{ lookup('infoblox.nios_modules.nios_next_ip', 'fd30:f52:2:12::/64',
provider={'host': 'nios01', 'username': 'admin', 'password': 'password'}) }}"
"""

RETURN = """
Expand Down
12 changes: 12 additions & 0 deletions plugins/module_utils/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
NIOS_DTC_MONITOR_SNMP = 'dtc:monitor:snmp'
NIOS_DTC_MONITOR_TCP = 'dtc:monitor:tcp'
NIOS_DTC_TOPOLOGY = 'dtc:topology'
NIOS_EXTENSIBLE_ATTRIBUTE = 'extensibleattributedef'

NIOS_PROVIDER_SPEC = {
'host': dict(fallback=(env_fallback, ['INFOBLOX_HOST'])),
Expand Down Expand Up @@ -214,6 +215,14 @@ def convert_members_to_struct(member_spec):
return member_spec


def convert_ea_list_to_struct(member_spec):
''' Transforms the list of the values into a valid WAPI struct.
'''
if 'list_values' in member_spec.keys():
member_spec['list_values'] = [{'_struct': 'extensibleattributedef:listvalues', 'value': v} for v in member_spec['list_values']]
return member_spec


def normalize_ib_spec(ib_spec):
result = {}
for arg in ib_spec:
Expand Down Expand Up @@ -381,6 +390,9 @@ def run(self, ib_obj_type, ib_spec):
proposed_object['end_addr'] = proposed_object.get('new_end_addr')
del proposed_object['new_end_addr']

if (ib_obj_type == NIOS_EXTENSIBLE_ATTRIBUTE):
proposed_object = convert_ea_list_to_struct(proposed_object)

# checks if the 'text' field has to be updated for the TXT Record
if (ib_obj_type == NIOS_TXT_RECORD):
text_obj = proposed_object["text"]
Expand Down
Loading
Loading