Contributor
Contributor

vRA 8 Set static IP assignment for selectable number of networks

Jump to solution

Hi All,

I am trying to create a blueprint with selectable number of networks and I use  networks: ${map_to_object(resource.Cloud_Network_1[*].id + resource.Cloud_Network_2[*].id,"network")} for that.

It works fine, but by default we have dynamic IP assignment for all neworks, but I need static. I do not know how to change it nither through bluprint syntax nor through subscriptions.

Some details:

I suspect that for subscription Network Configure event should be used. But there are only one similar shema element SkipIPAllocations. I create it but it does not help.

Also I try to catch a difference between these two bluprints in inputProperties but I can't find any:

   1)

    networks: '${map_to_object(resource.Cloud_Network_1[*].id + resource.Cloud_Network_2[*].id,"network")}'

2)

    networks:

        - network: '${resource.Cloud_Network_1.id}'

          assignment: static

        - network: '${resource.Cloud_Network_2.id}'

          assignment: dynamic

Finally I try to set up in bluprint all networks and delete some of them during deployment using subscriptions. But if I delete some element from networkSelectionIds array I get an error:

Invalid network selection response for resource [com.vmware.photon.controller.model.resources.ComputeService$ComputeState@10778798]. The number of network selections do not match.

Regards,

Roman

1 Solution

Accepted Solutions
Enthusiast
Enthusiast

I think you want the the map_by() function instead - at least that's what I found for a somewhat similar need (VRA 8.1 - Adding/Removing NICs Before Provisioning ).

Something like this probably:

networks: '${map_by(resource.Main_Network[*] + resource.Add_Net_01[*],nic => {"network":nic.id, "assignment":"static"})}'

View solution in original post

0 Kudos
6 Replies
Commander
Commander

Hey PavelGudkov​,

To understand well the scenario you are trying to accomplish, the expected result should be dynamic assignment for some networks and static assignment for some others?

How are you populating these networks inside the blueprint? Are they being chosen based on Tags?

0 Kudos
Contributor
Contributor

I expect static assignment for all networks, but number of networks can be different. Example of blueprint that demonstrate this approach:

formatVersion: 1

inputs:

  SecondSubnetSelected:

    type: boolean

    default: false

resources:

  vSphere_VM:

    type: Cloud.vSphere.Machine

    properties:

      image: 'Ubuntu'

      cpuCount: 1

      totalMemoryMB: 1024

      networks: '${map_to_object(resource.Main_Network[*].id + resource.Add_Net_01[*].id,"network")}'

  Main_Network:

    type: Cloud.vSphere.Network

    properties:

      networkType: existing

      constraints:

        - tag: 'subnet-cidr:192.168.1.0/24'

      count: 1

  Add_Net_01:

    type: Cloud.vSphere.Network

    properties:

      networkType: existing

      constraints:

        - tag: 'subnet-cidr:192.168.2.0/24'

      count: '${input.SecondSubnetSelected == false ? 0 : 1}'

This works fine. I can order one or two networks, but both will have dynamic type. I need static. It shoud look like I select between these two parts of blueprint:

    networks:

        - network: ${resource.Main_Network.id}

          assignment: static

or

   networks:

        - network: ${resource.Main_Network.id}

          assignment: static

        - network: ${resource.Add_Net_01.id}

          assignment: static

0 Kudos
Commander
Commander

If you want to use static as assignment then you should use:

  • assignment: static

This needs to be configured inside the vSphere VM properties. And how are you going to assign the IPs? I am asking this because if you want you can use the internal IPAM that vRA has.

0 Kudos
Contributor
Contributor

Yes, I use internal IPAM. There is network profile with configured IP Range. And yes I use assignment: static.

But how to set static assignment for selectable number of network. Number of network that will finally be used detected dynamicaly after user selection.

blueprint syntax

networks: '${map_to_object(resource.Main_Network[*].id + resource.Add_Net_01[*].id,"network")}'

works for variable number of networks, but set dynamic assignment for networks

blueprint syntax

  networks:

        - network: ${resource.Main_Network.id}

          assignment: static

        - network: ${resource.Add_Net_01.id}

          assignment: static

sets static assignment but does not work with variable number of networks.

I need both: variable number of static networks

))

0 Kudos
Enthusiast
Enthusiast

I think you want the the map_by() function instead - at least that's what I found for a somewhat similar need (VRA 8.1 - Adding/Removing NICs Before Provisioning ).

Something like this probably:

networks: '${map_by(resource.Main_Network[*] + resource.Add_Net_01[*],nic => {"network":nic.id, "assignment":"static"})}'

View solution in original post

0 Kudos
Contributor
Contributor

Hi Emacintosh,

It works! You made my day ))

Thanks a lot!