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

Update nios_member.py #54419

Open
wants to merge 1 commit into
base: devel
from

Conversation

Projects
None yet
3 participants
@krisvasudevan
Copy link
Contributor

commented Mar 26, 2019

SUMMARY
ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME
ADDITIONAL INFORMATION

licenses=dict(type='list'),
)

ib_spec = dict(
host_name=dict(required=True, aliases=['name'], ib_req=True),
vip_setting=dict(type='dict', elements='dict', options=ipv4_spec),

This comment has been minimized.

Copy link
@justjais

justjais Mar 27, 2019

Contributor

@krisvasudevan removing elements is not the solution to the issue faced, please check the implementation of nios_network option parameter and verify if the nios_member parameters need to be defined as elements type/not and if yes then follow option parameter implementation and implement in the same way for nios_member elements parameter types.

This comment has been minimized.

Copy link
@krisvasudevan

krisvasudevan Apr 9, 2019

Author Contributor

@justjais I tried your recommendation, I'm still hitting the same error when it is trying to verify the elements.

This comment has been minimized.

Copy link
@justjais

justjais Apr 10, 2019

Contributor

@krisvasudevan plz paste in the play, I'll try to check from my end.

This comment has been minimized.

Copy link
@krisvasudevan

krisvasudevan Apr 10, 2019

Author Contributor

This is what i tried:
Option 1:
ib_spec = dict(
host_name=dict(required=True, aliases=['name'], ib_req=True),
vip_setting=dict(type='dict', elements='dict', options=ipv4_spec),
ipv6_setting=dict(type='dict', elements='dict', options=ipv6_spec),
config_addr_type=dict(default='IPV4'),
comment=dict(),
enable_ha=dict(type='bool', default=False),
router_id=dict(type='int'),
lan2_enabled=dict(type='bool', default=False),
lan2_port_setting=dict(type='dict', elements='dict', options=lan2_port_spec),
platform=dict(default='INFOBLOX'),
node_info=dict(type='list', elements='list', options=node_spec),
mgmt_port_setting=dict(type='dict', elements='dict', options=mgmt_port_spec),
upgrade_group=dict(default='Default'),
use_syslog_proxy_setting=dict(type='bool'),
external_syslog_server_enable=dict(type='bool'),
syslog_servers=dict(type='list', elements='list', options=syslog_spec),
pre_provisioning=dict(type='dict', elements='dict', options=pre_prov_spec),
extattrs=dict(type='dict'),
create_token=dict(type='bool', default=False),
)

Option 2:
ib_spec = dict(
host_name=dict(required=True, aliases=['name'], ib_req=True),
vip_setting=dict(type='dict', elements='list'', options=ipv4_spec),
ipv6_setting=dict(type='dict', elements='list'', options=ipv6_spec),
config_addr_type=dict(default='IPV4'),
comment=dict(),
enable_ha=dict(type='bool', default=False),
router_id=dict(type='int'),
lan2_enabled=dict(type='bool', default=False),
lan2_port_setting=dict(type='dict', elements='list'', options=lan2_port_spec),
platform=dict(default='INFOBLOX'),
node_info=dict(type='list', elements='list', options=node_spec),
mgmt_port_setting=dict(type='dict', elements='list'', options=mgmt_port_spec),
upgrade_group=dict(default='Default'),
use_syslog_proxy_setting=dict(type='bool'),
external_syslog_server_enable=dict(type='bool'),
syslog_servers=dict(type='list', elements='list', options=syslog_spec),
pre_provisioning=dict(type='dict', elements='list'', options=pre_prov_spec),
extattrs=dict(type='dict'),
create_token=dict(type='bool', default=False),
)

This comment has been minimized.

Copy link
@justjais

justjais Apr 23, 2019

Contributor

@krisvasudevan plz paste in the ansible play with which you are facing the error while keeping the element param.

This comment has been minimized.

Copy link
@krisvasudevan

krisvasudevan Apr 23, 2019

Author Contributor

Here is the playbook.

  • hosts: localhost
    vars:
    nios_provider:
    host: 127.0.0.1
    username: cloud-admin
    password: password
    wapi_version: 2.9

    connection: local
    tasks:

    • name: Create Infoblox member
      nios_member:
      host_name: member.ansible-qa.com
      vip_setting:
      - address: 192.168.1.6
      subnet_mask: 255.255.255.0
      gateway: 192.168.1.1
      config_addr_type: IPV4
      platform: VNIOS
      comment: Created with Ansible
      state: present
      provider: "{{ nios_provider }}"

This comment has been minimized.

Copy link
@justjais

justjais Apr 23, 2019

Contributor

@krisvasudevan from your ib_spec I can see you have defined it as vip_setting=dict(type='dict', elements='dict', options=ipv4_spec)/vip_setting=dict(type='dict', elements='list'', options=ipv4_spec)tells you that its dictionary of dictionary type/dictionary of list type but you are actually passing vip_setting as:

vip_setting:
- address: 192.168.1.6
  subnet_mask: 255.255.255.0
  gateway: 192.168.1.1

Which actually means u are passing list of dictionary in your vip_setting param, so have you tried keeping it as: vip_setting=dict(type='list', elements='dict', options=ipv4_spec) as this actually means that you are passing list of dictionary under vip_setting param. Please try this way and lemme know if it fixes the issue you are having.

This comment has been minimized.

Copy link
@krisvasudevan

krisvasudevan Apr 23, 2019

Author Contributor

@justjais I already tried that as well. I get an error:
The error was: AttributeError: 'unicode' object has no attribute 'items'
fatal: [localhost]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n File "/root/.ansible/tmp/ansible-tmp-1555999726.63-43892135149165/AnsiballZ_nios_member.py", line 114, in \n _ansiballz_main()\n File "/root/.ansible/tmp/ansible-tmp-1555999726.63-43892135149165/AnsiballZ_nios_member.py", line 106, in _ansiballz_main\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n File "/root/.ansible/tmp/ansible-tmp-1555999726.63-43892135149165/AnsiballZ_nios_member.py", line 49, in invoke_module\n imp.load_module('main', mod, module, MOD_DESC)\n File "/tmp/ansible_nios_member_payload_HjKZZz/main.py", line 492, in \n File "/tmp/ansible_nios_member_payload_HjKZZz/main.py", line 487, in main\n File "/tmp/ansible_nios_member_payload_HjKZZz/ansible_nios_member_payload.zip/ansible/module_utils/net_tools/nios/api.py", line 279, in run\n File "/tmp/ansible_nios_member_payload_HjKZZz/ansible_nios_member_payload.zip/ansible/module_utils/net_tools/nios/api.py", line 383, in compare_objects\n File "/tmp/ansible_nios_member_payload_HjKZZz/ansible_nios_member_payload.zip/ansible/module_utils/net_tools/nios/api.py", line 366, in issubset\n File "/tmp/ansible_nios_member_payload_HjKZZz/ansible_nios_member_payload.zip/ansible/module_utils/net_tools/nios/api.py", line 366, in \nAttributeError: 'unicode' object has no attribute 'items'\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}

This comment has been minimized.

Copy link
@justjais

justjais Apr 23, 2019

Contributor

@krisvasudevan you didn't mentioned the same in ib_spec argument that's why I told you to check with the suggestion I made, also for above issue you need to triage from your end via debugging the module that from where exactly the particular unicode issue is been thrown as this is not the error you mentioned earlier, also use -vvvv to get the complete ansible verbose output.

This comment has been minimized.

Copy link
@krisvasudevan

krisvasudevan Apr 23, 2019

Author Contributor

Apologies, I must have been clearer. I did already try your suggestion:
vip_setting=dict(type='list', elements='dict', options=ipv4_spec),
Below is the full traceback of the error.
The full traceback is:
Traceback (most recent call last):
File "/root/.ansible/tmp/ansible-tmp-1555999621.84-256750679493464/AnsiballZ_nios_member.py", line 114, in
_ansiballz_main()
File "/root/.ansible/tmp/ansible-tmp-1555999621.84-256750679493464/AnsiballZ_nios_member.py", line 106, in _ansiballz_main
invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
File "/root/.ansible/tmp/ansible-tmp-1555999621.84-256750679493464/AnsiballZ_nios_member.py", line 49, in invoke_module
imp.load_module('main', mod, module, MOD_DESC)
File "/tmp/ansible_nios_member_payload__Tjisz/main.py", line 492, in
File "/tmp/ansible_nios_member_payload__Tjisz/main.py", line 487, in main
File "/tmp/ansible_nios_member_payload__Tjisz/ansible_nios_member_payload.zip/ansible/module_utils/net_tools/nios/api.py", line 279, in run
File "/tmp/ansible_nios_member_payload__Tjisz/ansible_nios_member_payload.zip/ansible/module_utils/net_tools/nios/api.py", line 383, in compare_objects
File "/tmp/ansible_nios_member_payload__Tjisz/ansible_nios_member_payload.zip/ansible/module_utils/net_tools/nios/api.py", line 366, in issubset
File "/tmp/ansible_nios_member_payload__Tjisz/ansible_nios_member_payload.zip/ansible/module_utils/net_tools/nios/api.py", line 366, in
AttributeError: 'unicode' object has no attribute 'items'

fatal: [localhost]: FAILED! => {
"changed": false,
"module_stderr": "Traceback (most recent call last):\n File "/root/.ansible/tmp/ansible-tmp-1555999621.84-256750679493464/AnsiballZ_nios_member.py", line 114, in \n _ansiballz_main()\n File "/root/.ansible/tmp/ansible-tmp-1555999621.84-256750679493464/AnsiballZ_nios_member.py", line 106, in _ansiballz_main\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n File "/root/.ansible/tmp/ansible-tmp-1555999621.84-256750679493464/AnsiballZ_nios_member.py", line 49, in invoke_module\n imp.load_module('main', mod, module, MOD_DESC)\n File "/tmp/ansible_nios_member_payload__Tjisz/main.py", line 492, in \n File "/tmp/ansible_nios_member_payload__Tjisz/main.py", line 487, in main\n File "/tmp/ansible_nios_member_payload__Tjisz/ansible_nios_member_payload.zip/ansible/module_utils/net_tools/nios/api.py", line 279, in run\n File "/tmp/ansible_nios_member_payload__Tjisz/ansible_nios_member_payload.zip/ansible/module_utils/net_tools/nios/api.py", line 383, in compare_objects\n File "/tmp/ansible_nios_member_payload__Tjisz/ansible_nios_member_payload.zip/ansible/module_utils/net_tools/nios/api.py", line 366, in issubset\n File "/tmp/ansible_nios_member_payload__Tjisz/ansible_nios_member_payload.zip/ansible/module_utils/net_tools/nios/api.py", line 366, in \nAttributeError: 'unicode' object has no attribute 'items'\n",
"module_stdout": "",
"msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
"rc": 1
}

@justjais

This comment has been minimized.

Copy link
Contributor

commented Apr 8, 2019

@krisvasudevan you'll have to keep element definition as is in ib_spec arguments and from others sub-options arguments you can remove the element definition.

@justjais

This comment has been minimized.

Copy link
Contributor

commented Apr 10, 2019

@krisvasudevan

This comment has been minimized.

Copy link
Contributor Author

commented Apr 11, 2019

cc @s-giri

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.