HewlettPackard / oneview-ansible-collection

Ansible Collection and Sample Playbooks for HPE OneView
Apache License 2.0
26 stars 22 forks source link

Unable to append a network to an existing network set #241

Closed dobey-xx closed 1 year ago

dobey-xx commented 1 year ago

It seems that when i loop through the list it doesn't append the different networks to the network_set, it just adds them after eachother, overwriting the previous network.

This is what my tasks looks like

Lets say that my list is:

I would expect the network set to have 3 networks, but i only see the last one in the list. However i see that it loops through the list, so i think it just overwrites the previous entry.

alisha-k-kalladassery commented 1 year ago

Hi @dobey-xx We will check on this and get back to you.

alisha-k-kalladassery commented 1 year ago

Hi @dobey-xx

If you are creating a network set, you need to provide all the network uris/network names at once. Because when you try to loop through a list of network uris, SDK dont know whether you are appending to the existing list or are you adding a new one irrespective of the existing values. From the SDK perspective, each of your iteration would be new call and it will update the network set with the new set of networkUri values. Please let us know if you have any further queries.

Thanks

dobey-xx commented 1 year ago

Hi @alisha-k-kalladassery ,

But it's an already existing networkset, I want to add a couple of new VLANs to that networkset, but that would mean i have to create a list with the previous 100 VLANs, just to add 3?

Regards,

alisha-k-kalladassery commented 1 year ago

Hi @dobey-xx ,

We have added this issue to our backlog and will be fixing this as per our priority. But it may not be quick fix. Meanwhile you can use below playbook as a workaround for the same. Here existing networkUris of a networkSet are prefetched and added it along with the new networkUri list.

- name: Gather facts about all Network Sets
  oneview_network_set_facts:
    config: '{{ config }}'
    sessionID: "{{ session.ansible_facts.session }}"
  delegate_to: localhost

- set_fact:
    network_list: "{{ network_sets[0]['networkUris'] }}"

- set_fact:
    new_network_list: ["/rest/ethernet-networks/fbfe8fc7-2e99-49bf-a533-08ffabc4bfc4", "/rest/ethernet-networks/3d76a080-1d1e-4313-877b-0f9ee6bbbc35"]

- name: Create a Network Set
  oneview_network_set:
    config: '{{ config }}'
    sessionID: "{{ session.ansible_facts.session }}"
    state: present
    data:
      name: 'OneViewSDK Test Network Set'
      networkUris: "{{ network_list + new_network_list}}"
      bandwidth:
        maximumBandwidth: 15000
        typicalBandwidth: 3000
  delegate_to: localhost
alisha-k-kalladassery commented 1 year ago

Hi @dobey-xx ,

We have added this issue to our backlog and will be fixing it per priority. We are closing this issue as we have not heard back from you.

Thanks

dobey-xx commented 1 year ago

Sorry for the late response, but that seems to work as a workaround. So thanks for that.