HewlettPackard / oneview-ansible-collection

Ansible Collection and Sample Playbooks for HPE OneView

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to append a network to an existing network set

dobey-xx opened this issue · comments

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

  • name: Add the rest of the networks
    hpe.oneview.oneview_network_set:
    hostname: "{{ oneview_appl }}"
    username: "{{ ONEVIEW_USR }}"
    password: "{{ ONEVIEW_PASSWD }}"
    auth_login_domain: "Local"
    api_version: 3200
    state: present
    data:
    name: "{{ ntwkset_name }}"
    networkUris:
    - "{{ networks }}"
    when: " ntwk_check.ansible_facts.network_sets == [] and networklist|length != 1 "
    loop: "{{ networklist[1:] }}"
    delegate_to: localhost

Lets say that my list is:

  • vlan002
  • vlan003
  • vlan004

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.

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

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

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,

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

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

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