dell / dellemc-openmanage-ansible-modules

Dell OpenManage Ansible Modules
GNU General Public License v3.0
336 stars 163 forks source link

idrac_network.py fails with `AttributeError: 'NoneType' object has no attribute 'iDRAC'` #266

Closed grantcurell closed 3 years ago

grantcurell commented 3 years ago

When attempting to update the idrac IP with input:

{
    "ANSIBLE_MODULE_ARGS": {
        "idrac_ip": "192.168.1.63",
        "idrac_user": "root",
        "idrac_password": "mypassword",
        "share_name": "\\\\192.168.1.156\\sambashare",
        "share_user": "grant",
        "share_password": "mypassword",
        "ip_address": "192.168.1.64"
    }
}

I receive:

  File "/home/grant/programs/dellemc-openmanage-ansible-modules/plugins/modules/idrac_network.py", line 399, in main
    msg = run_idrac_network_config(idrac, module)
  File "/home/grant/programs/dellemc-openmanage-ansible-modules/plugins/modules/idrac_network.py", line 309, in run_idrac_network_config
    idrac.config_mgr.configure_ipv4(
  File "/home/grant/.local/lib/python3.8/site-packages/omdrivers/lifecycle/iDRAC/iDRACConfig.py", line 4230, in configure_ipv4
    self.iDRAC_IPv4.Address_IPv4.set_value(ip_address)
  File "/home/grant/.local/lib/python3.8/site-packages/omdrivers/lifecycle/iDRAC/iDRACConfig.py", line 4176, in iDRAC_IPv4
    return self._sysconfig.iDRAC.IPv4
AttributeError: 'NoneType' object has no attribute 'iDRAC'

I've run the error down and it occurs because my instance of omdrivers.lifecycle.iDRAC.iDRACConfig.iDRACConfig has no value _sysconfig in:

@property
def iDRAC_IPv4(self):
    return self._sysconfig.iDRAC.IPv4
grantcurell commented 3 years ago

This happens because the liason share is required but there is no error handling in the event that a connection to the share fails. Since this is not handled it eventually results in the nonetype object. Specifically _load_scp in iDRACConfig.py fails but that failure is never accounted for.