question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

oneview_server_profile doesn't appear to be idempotent

See original GitHub issue

When rerunning the following playbook receive an exception that “The error was: KeyError: ‘id’”

- name: Create a Server Profile
  oneview_server_profile:
    config: "{{ login }}"
    state: "present"
    data:
        name: "{{ blade_item.name }}"
        server_hardware: "{{ blade_item.hardware }}"
        connections:
          - name: 'side-a'
            networkUri: "{{ network_sets.0.uri }}"
          - name: 'side-b'
            networkUri: "{{ network_sets.0.uri }}"

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: KeyError: ‘id’ fatal: [10.200.220.50]: FAILED! => {“changed”: false, “failed”: true, “module_stderr”: “Traceback (most recent call last):\n File "/tmp/ansible_lFY_NH/ansible_module_oneview_server_profile.py", line 544, in <module>\n main()\n File "/tmp/ansible_lFY_NH/ansible_module_oneview_server_profile.py", line 540, in main\n ServerProfileModule().run()\n File "/tmp/ansible_lFY_NH/ansible_module_oneview_server_profile.py", line 269, in run\n created, changed, msg, server_profile = self.__present(data, server_profile)\n File "/tmp/ansible_lFY_NH/ansible_module_oneview_server_profile.py", line 318, in __present\n merged_data = ServerProfileMerger().merge_data(resource, data)\n File "/usr/lib/python2.7/site-packages/hpOneView/extras/server_profile_utils.py", line 65, in merge_data\n merged_data = self._merge_connections(merged_data, resource, data)\n File "/usr/lib/python2.7/site-packages/hpOneView/extras/server_profile_utils.py", line 85, in _merge_connections\n merged_data[Keys.CONNECTIONS] = merge_list_by_key(existing_connections, params_connections, key=Keys.ID)\n File "/usr/lib/python2.7/site-packages/hpOneView/extras/mergers.py", line 63, in merge_list_by_key\n item_key = item[key]\nKeyError: ‘id’\n”, “module_stdout”: “”, “msg”: “MODULE FAILURE”}

When removing the server profile and running the playbook the server profile is created successfully. Library module should fit standards for Ansible to be idempotent.

Thanks.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
marikrgcommented, Mar 3, 2017

The oneview_server_profile module should be idempotent, but looks like there is an issue when you don’t set an ID to the connection.

I suggest you change the connection list until we fix this issue, adding IDs to the items. For example:

connections:
     - id: 1
       name: 'side-a'
       networkUri: "{{ network_sets.0.uri }}"
     - id: 2
       name: 'side-b'
       networkUri: "{{ network_sets.0.uri }}"

Please let me know if this temporary fix has solved the issue.

0reactions
yuviranicommented, Apr 29, 2020

We are looking into our server_profile module and we will update you once it is fixed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Idempotent - MDN Web Docs Glossary: Definitions of ... - Mozilla
An HTTP method is idempotent if the intended effect on the server of making a single request is the same as the effect...
Read more >
What is an idempotent operation? - Stack Overflow
This answer doesn't seem right. Idempotence is about calling an operation that you expect to change some state, given the input parameters, which...
Read more >
Idempotent REST APIs
Idempotency essentially means that the effect of a successfully performed request on a server resource is independent of the number of times it...
Read more >
Making retries safe with idempotent APIs - Amazon AWS
One possible response to this request is to return a ResourceAlreadyExists return code. This meets the basic tenets for idempotency because there is...
Read more >
Idempotent Requests - Stripe API reference
An idempotency key is a unique value generated by the client which the server uses to recognize subsequent retries of the same request....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found