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

oneview_server_profile TypeError: sequence item 0: expected str instance, NoneType found #219

Closed
dobey-xx opened this issue Oct 17, 2022 · 10 comments
Assignees

Comments

@dobey-xx
Copy link

Getting the follow error when trying to create a profile:

"/tmp/ansible_hpe.oneview.oneview_server_profile_payload___kih52j/ansible_hpe.oneview.oneview_server_profile_payload.zip/ansible_collections/hpe/oneview/plugins/modules/oneview_server_profile.py", line 337, in __present\n File "/tmp/ansible_hpe.oneview.oneview_server_profile_payload___kih52j/ansible_hpe.oneview.oneview_server_profile_payload.zip/ansible_collections/hpe/oneview/plugins/modules/oneview_server_profile.py", line 467, in __create_profile\n File "/tmp/ansible_hpe.oneview.oneview_server_profile_payload___kih52j/ansible_hpe.oneview.oneview_server_profile_payload.zip/ansible_collections/hpe/oneview/plugins/modules/oneview_server_profile.py", line 702, in _auto_assign_server_profile\n File "/tmp/ansible_hpe.oneview.oneview_server_profile_payload___kih52j/ansible_hpe.oneview.oneview_server_profile_payload.zip/ansible_collections/hpe/oneview/plugins/modules/oneview_server_profile.py", line 556, in __get_available_server_hardware_uri\nTypeError: sequence item 0: expected str instance, NoneType found\n",

It's in a test environment so the user is Infrastructure admin.

I followed the example as described here: https://github.com/HewlettPackard/oneview-ansible-collection/blob/master/roles/oneview_server_profile/tasks/main.yml

@alisha-k-kalladassery alisha-k-kalladassery self-assigned this Oct 17, 2022
@alisha-k-kalladassery
Copy link
Collaborator

Hi
Could you please confirm if you are creating server profile within a scope? If not could you please try the same.

Thanks

@dobey-xx
Copy link
Author

Hi,

According to this example, there is no need to set an scope uri.

  • name: Create Server Profile without specifying a template
    oneview_server_profile:
    config: "{{ config }}"
    sessionID: "{{ session.ansible_facts.session }}"
    data:
    name: "{{ contents.server_profile.inventory_hostname }}"
    serverHardwareTypeName: "{{ contents.server_profile.server_hardware_type_name }}"
    enclosureGroupName: "{{ contents.server_profile.enclosure_group_name }}"
    description: "{{ contents.server_profile.server_profile_description }}"
    delegate_to: localhost

And if I try to use the parameter "InitialScopeUris", it throws the following error:

File "/var/lib/awx/venv/env/lib/python3.6/site-packages/hpeOneView/connection.py", line 413, in __do_rest_call\n raise HPEOneViewException(body)\nhpeOneView.exceptions.HPEOneViewException: ('Unrecognized JSON field.', {'errorCode': 'UNRECOGNIZED_JSON_FIELD', 'message': 'Unrecognized JSON field.', 'details': 'The field named ServerHardwareTypeName near line 1, column 175 is not a valid field in this JSON object.', 'messageParameters': [], 'recommendedActions': ['Check the valid fields for this JSON object and remove or correct the unrecognized field.'], 'errorSource': None, 'nestedErrors': [], 'data': {}})\n",

@alisha-k-kalladassery
Copy link
Collaborator

Hi,

Please confirm the username which you are using.

@dobey-xx
Copy link
Author

dobey-xx commented Oct 18, 2022

Hi,

I'm using this username: awxacc, this user has the role: infrastructure administrator

Strange thing is, if I removed the parameter: ServerHardwareTypeName, it gives the following error:
HPEOneViewTaskError(msg, error_code)\nhpeOneView.exceptions.HPEOneViewTaskError: The server hardware type null is not valid or not supported.\n

But when I add it again it gives:
'The field named ServerHardwareTypeName near line 1, column 175 is not a valid field in this JSON object.', 'messageParameters': [], 'recommendedActions': ['Check the valid fields for this JSON object and remove or correct the unrecognized field.']

Small update:
When I use a template to create a server profile it seems to work, but the example without a server template doesn't work.

@alisha-k-kalladassery
Copy link
Collaborator

Hi,

We understood the issue and have pushed the changes to branch sp_issue_219. Please confirm if it works fine for you.

@dobey-xx
Copy link
Author

dobey-xx commented Oct 18, 2022

I've changed the python file in my locally pulled collection. The error is still the same, this is the stderr output:

"exception": "Traceback (most recent call last):\n File "/var/lib/awx/.ansible/tmp/ansible-tmp-1666083337.685405-476-235430583536718/AnsiballZ_oneview_server_profile.py", line 102, in \n _ansiballz_main()\n File "/var/lib/awx/.ansible/tmp/ansible-tmp-1666083337.685405-476-235430583536718/AnsiballZ_oneview_server_profile.py", line 94, in _ansiballz_main\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n File "/var/lib/awx/.ansible/tmp/ansible-tmp-1666083337.685405-476-235430583536718/AnsiballZ_oneview_server_profile.py", line 40, in invoke_module\n runpy.run_module(mod_name='ansible_collections.hpe.oneview.plugins.modules.oneview_server_profile', init_globals=None, run_name='main', alter_sys=True)\n File "/usr/lib64/python3.6/runpy.py", line 205, in run_module\n return _run_module_code(code, init_globals, run_name, mod_spec)\n File "/usr/lib64/python3.6/runpy.py", line 96, in _run_module_code\n mod_name, mod_spec, pkg_name, script_name)\n File "/usr/lib64/python3.6/runpy.py", line 85, in _run_code\n exec(code, run_globals)\n File "/tmp/ansible_hpe.oneview.oneview_server_profile_payload_f8aembed/ansible_hpe.oneview.oneview_server_profile_payload.zip/ansible_collections/hpe/oneview/plugins/modules/oneview_server_profile.py", line 712, in \n File "/tmp/ansible_hpe.oneview.oneview_server_profile_payload_f8aembed/ansible_hpe.oneview.oneview_server_profile_payload.zip/ansible_collections/hpe/oneview/plugins/modules/oneview_server_profile.py", line 708, in main\n File "/tmp/ansible_hpe.oneview.oneview_server_profile_payload_f8aembed/ansible_hpe.oneview.oneview_server_profile_payload.zip/ansible_collections/hpe/oneview/plugins/module_utils/oneview.py", line 685, in run\n File "/tmp/ansible_hpe.oneview.oneview_server_profile_payload_f8aembed/ansible_hpe.oneview.oneview_server_profile_payload.zip/ansible_collections/hpe/oneview/plugins/modules/oneview_server_profile.py", line 297, in execute_module\n File "/tmp/ansible_hpe.oneview.oneview_server_profile_payload_f8aembed/ansible_hpe.oneview.oneview_server_profile_payload.zip/ansible_collections/hpe/oneview/plugins/modules/oneview_server_profile.py", line 337, in __present\n File "/tmp/ansible_hpe.oneview.oneview_server_profile_payload_f8aembed/ansible_hpe.oneview.oneview_server_profile_payload.zip/ansible_collections/hpe/oneview/plugins/modules/oneview_server_profile.py", line 477, in __create_profile\n File "/var/lib/awx/venv/venv/lib/python3.6/site-packages/hpeOneView/resources/servers/server_profiles.py", line 74, in create\n resource_data = self._helper.create(data, timeout=timeout, force=force)\n File "/var/lib/awx/venv/venv/lib/python3.6/site-packages/hpeOneView/resources/resource.py", line 465, in create\n return self.do_post(uri, data, timeout, custom_headers)\n File "/var/lib/awx/venv/venv/lib/python3.6/site-packages/hpeOneView/resources/resource.py", line 811, in do_post\n task, entity = self._connection.post(uri, resource, custom_headers=custom_headers)\n File "/var/lib/awx/venv/venv/lib/python3.6/site-packages/hpeOneView/connection.py", line 386, in post\n return self.__do_rest_call('POST', uri, body, custom_headers=custom_headers)\n File "/var/lib/awx/venv/venv/lib/python3.6/site-packages/hpeOneView/connection.py", line 413, in __do_rest_call\n raise HPEOneViewException(body)\nhpeOneView.exceptions.HPEOneViewException: ('Unrecognized JSON field.', {'errorCode': 'UNRECOGNIZED_JSON_FIELD', 'message': 'Unrecognized JSON field.', 'details': 'The field named ServerHardwareName near line 1, column 1,968 is not a valid field in this JSON object.', 'messageParameters': [], 'recommendedActions': ['Check the valid fields for this JSON object and remove or correct the unrecognized field.'], 'errorSource': None, 'nestedErrors': [], 'data': {}})\n",

@alisha-k-kalladassery
Copy link
Collaborator

Hi,

Please follow the example file without any changes and kindly share the exact task which you are getting this error. It will help me to debug your issue further.

Thanks

@dobey-xx
Copy link
Author

Hi,

I've did some reverse engineering and it seems the provided example isn't correct.

The error states that there are unrecognized JSON fields,

  • name: Create Server Profile without specifying a template
    oneview_server_profile:
    config: "{{ config }}"
    sessionID: "{{ session.ansible_facts.session }}"
    data:
    name: "{{ contents.server_profile.inventory_hostname }}"
    serverHardwareTypeName: "{{ contents.server_profile.server_hardware_type_name }}"
    enclosureGroupName: "{{ contents.server_profile.enclosure_group_name }}"
    description: "{{ contents.server_profile.server_profile_description }}"
    delegate_to: localhost

I've changed that to:

  • name: Create Server Profile without specifying a template
    oneview_server_profile:
    config: "{{ config }}"
    sessionID: "{{ session.ansible_facts.session }}"
    data:
    name: "{{ contents.server_profile.inventory_hostname }}"
    serverHardwareName: "enclosure, bay"
    serialNumberType: "Phyiscal"
    description: "{{ contents.server_profile.server_profile_description }}"
    delegate_to: localhost

And the profile is created,

@alisha-k-kalladassery
Copy link
Collaborator

From the above discussion, it seems you are trying multiple ways to create server profiles.

For server profile creation, either serverHardwareTypeName/serverHardwareName can be passed as input.

In case of serverHardwareName, it will search for server hardware of that name to assign it to the profile. And in case of serverHardwareTypeName it will use this type to fetch available server of that type for auto assignment of server hardware.

Field enclosureGroupName depends on the environment which you are trying, enclosureGroupName is valid for synergy and not available for rack servers.

we do feel our examples are not correctly explaining all the scenarios...we will work on it.

Thanks

@dobey-xx
Copy link
Author

From my experience so far, i'm unable to use serverHardwareTypename without the use of a serverProfileTemplate. It just doesn't accept the json format.

This example worked for me:

name: Create Server Profile without specifying a template
oneview_server_profile:
config: "{{ config }}"
sessionID: "{{ session.ansible_facts.session }}"
data:
name: "{{ contents.server_profile.inventory_hostname }}"
serverHardwareName: "enclosure, bay"
serialNumberType: "Phyiscal"
description: "{{ contents.server_profile.server_profile_description }}"
delegate_to: localhost

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

2 participants