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

UCS managed object can't create SAN objects #28

Open
sgcse01 opened this issue Jul 25, 2021 · 0 comments
Open

UCS managed object can't create SAN objects #28

sgcse01 opened this issue Jul 25, 2021 · 0 comments

Comments

@sgcse01
Copy link

sgcse01 commented Jul 25, 2021

Hi, I am trying to use managed object module to create boot policy and SAN objects in the boot policy it fails with the below ansible error.

-----------snip---------------
The full traceback is:
Traceback (most recent call last):
File "/root/.ansible/tmp/ansible-tmp-1627154514.4361196-113843015789001/AnsiballZ_ucs_managed_objects.py", line 102, in
_ansiballz_main()
File "/root/.ansible/tmp/ansible-tmp-1627154514.4361196-113843015789001/AnsiballZ_ucs_managed_objects.py", line 94, in _ansiballz_main
invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
File "/root/.ansible/tmp/ansible-tmp-1627154514.4361196-113843015789001/AnsiballZ_ucs_managed_objects.py", line 40, in invoke_module
runpy.run_module(mod_name='ansible_collections.cisco.ucs.plugins.modules.ucs_managed_objects', init_globals=None, run_name='main', alter_sys=True)
File "/usr/lib/python3.8/runpy.py", line 207, in run_module
return _run_module_code(code, init_globals, run_name, mod_spec)
File "/usr/lib/python3.8/runpy.py", line 97, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/tmp/ansible_cisco.ucs.ucs_managed_objects_payload_2v6r84ow/ansible_cisco.ucs.ucs_managed_objects_payload.zip/ansible_collections/cisco/ucs/plugins/modules/ucs_managed_objects.py", line 256, in
File "/tmp/ansible_cisco.ucs.ucs_managed_objects_payload_2v6r84ow/ansible_cisco.ucs.ucs_managed_objects_payload.zip/ansible_collections/cisco/ucs/plugins/modules/ucs_managed_objects.py", line 242, in main
File "/tmp/ansible_cisco.ucs.ucs_managed_objects_payload_2v6r84ow/ansible_cisco.ucs.ucs_managed_objects_payload.zip/ansible_collections/cisco/ucs/plugins/modules/ucs_managed_objects.py", line 213, in traverse_objects
File "/tmp/ansible_cisco.ucs.ucs_managed_objects_payload_2v6r84ow/ansible_cisco.ucs.ucs_managed_objects_payload.zip/ansible_collections/cisco/ucs/plugins/modules/ucs_managed_objects.py", line 183, in traverse_objects
File "/usr/local/lib/python3.8/dist-packages/ucsmsdk/mometa/lsboot/LsbootSan.py", line 65, in init
ManagedObject.init(self, "LsbootSan", parent_mo_or_dn, **kwargs)
File "/usr/local/lib/python3.8/dist-packages/ucsmsdk/ucsmo.py", line 82, in init
self._set_mo_prop_value(kwargs)
File "/usr/local/lib/python3.8/dist-packages/ucsmsdk/ucsmo.py", line 106, in _set_mo_prop_value
self.__set_prop(prop_name, prop_value)
File "/usr/local/lib/python3.8/dist-packages/ucsmsdk/ucsmo.py", line 220, in __set_prop
raise ValueError("%s is not a read-write property." % name)
ValueError: access is not a read-write property.
fatal: [localhost]: FAILED! => {
"changed": false,
"module_stderr": "Traceback (most recent call last):\n File "/root/.ansible/tmp/ansible-tmp-1627154514.4361196-113843015789001/AnsiballZ_ucs_managed_objects.py", line 102, in \n _ansiballz_main()\n File "/root/.ansible/tmp/ansible-tmp-1627154514.4361196-113843015789001/AnsiballZ_ucs_managed_objects.py", line 94, in _ansiballz_main\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n File "/root/.ansible/tmp/ansible-tmp-1627154514.4361196-113843015789001/AnsiballZ_ucs_managed_objects.py", line 40, in invoke_module\n runpy.run_module(mod_name='ansible_collections.cisco.ucs.plugins.modules.ucs_managed_objects', init_globals=None, run_name='main', alter_sys=True)\n File "/usr/lib/python3.8/runpy.py", line 207, in run_module\n return _run_module_code(code, init_globals, run_name, mod_spec)\n File "/usr/lib/python3.8/runpy.py", line 97, in _run_module_code\n _run_code(code, mod_globals, init_globals,\n File "/usr/lib/python3.8/runpy.py", line 87, in _run_code\n exec(code, run_globals)\n File "/tmp/ansible_cisco.ucs.ucs_managed_objects_payload_2v6r84ow/ansible_cisco.ucs.ucs_managed_objects_payload.zip/ansible_collections/cisco/ucs/plugins/modules/ucs_managed_objects.py", line 256, in \n File "/tmp/ansible_cisco.ucs.ucs_managed_objects_payload_2v6r84ow/ansible_cisco.ucs.ucs_managed_objects_payload.zip/ansible_collections/cisco/ucs/plugins/modules/ucs_managed_objects.py", line 242, in main\n File "/tmp/ansible_cisco.ucs.ucs_managed_objects_payload_2v6r84ow/ansible_cisco.ucs.ucs_managed_objects_payload.zip/ansible_collections/cisco/ucs/plugins/modules/ucs_managed_objects.py", line 213, in traverse_objects\n File "/tmp/ansible_cisco.ucs.ucs_managed_objects_payload_2v6r84ow/ansible_cisco.ucs.ucs_managed_objects_payload.zip/ansible_collections/cisco/ucs/plugins/modules/ucs_managed_objects.py", line 183, in traverse_objects\n File "/usr/local/lib/python3.8/dist-packages/ucsmsdk/mometa/lsboot/LsbootSan.py", line 65, in init\n ManagedObject.init(self, "LsbootSan", parent_mo_or_dn, **kwargs)\n File "/usr/local/lib/python3.8/dist-packages/ucsmsdk/ucsmo.py", line 82, in init\n self._set_mo_prop_value(kwargs)\n File "/usr/local/lib/python3.8/dist-packages/ucsmsdk/ucsmo.py", line 106, in _set_mo_prop_value\n self.__set_prop(prop_name, prop_value)\n File "/usr/local/lib/python3.8/dist-packages/ucsmsdk/ucsmo.py", line 220, in __set_prop\n raise ValueError("%s is not a read-write property." % name)\nValueError: access is not a read-write property.\n",
"module_stdout": "",
"msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
"rc": 1
}

PLAY RECAP ***************************************************************************************************************************************************************************
localhost : ok=2 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
--------------------snip------------------------------

The error is misleading as it will come for any access method, read-only, read-write, read-only-local. The bug is in code

/usr/local/lib/python3.8/dist-packages/ucsmsdk/ucsmo.py

-------snip--------------

ef __set_prop(self, name, value, mark_dirty=True, forced=False):
"""
Internal method to set the properties after validation

Args:
    name (str): property name
    value (str): property value
    mark_dirty (bool): if True, property will be part of xml request
    forced (bool): if True, set the value without validation

Returns:
    None
"""

if not forced:
    prop_meta = self.prop_meta[name]
    if prop_meta.access != ucscoremeta.MoPropertyMeta.READ_WRITE:
        if getattr(self, name) is not None or \
                prop_meta.access != \
                ucscoremeta.MoPropertyMeta.CREATE_ONLY:
            raise ValueError("%s is not a read-write property." % name)
    if value and not prop_meta.validate_property_value(value):
        raise ValueError("Invalid Value Exception - "
                         "[%s]: Prop <%s>, Value<%s>. "
                         % (self.__class__.__name__,
                            name,
                            value))
        # return False
    if prop_meta.mask and mark_dirty:
        self._dirty_mask |= prop_meta.mask
object.__setattr__(self, name, value)

--------------snip-------------------------------

Can you guys fix this? I have raised the same in ciscoucs/ucsm-ansible but looks like that repo is not active.

Thanks
Sunil

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant