# IPAM network selection support

> How to derive OneFuse IPAM Policy inputs from Aria Automation 8 Network Selection IDs to let vRA constraints drive IP address reservations

---

Site [llms.txt](/llms.txt)

---

To learn more about this OneFuse Module, refer to [IPAM](/docs/onefuse/configure/modules/ipam/).

## Introduction

This feature allows you to derive the inputs for the OneFuse IPAM policy from a Network in vRA8. This simplifies implementation of IPAM in OneFuse, allowing you to defer to the Constraints in vRA8 to determine the network to be used for the IPAM reservation instead of mirroring that business logic within OneFuse templating or Static Property Sets.

Using this setup enables **vRA Selected Network Mode** for OneFuse IPAM.

- In **"normal" mode**, OneFuse IPAM looks only to the fixed and/or templated values supplied in the IPAM Policy fields to determine the destination for the IP reservation.
- In **"vRA Selected Network" mode**, OneFuse will query the network profile in vRA8 to obtain the information needed for the IP assignment instead of looking to internal OneFuse properties. A special property called `OneFuse_VraSelectedNetwork` is stored with these values, which you consume from your IPAM Policy.

## Prerequisites

1. Configure OneFuse [Property Set(s)](/docs/onefuse/templating/property-sets/) and OneFuse Module Policies.
2. Run [OneFuse Configuration](/docs/onefuse/consume/vmware-aria-automation/aria-automation-8x/installation-and-setup/#run-the-onefuse-configuration-workflow) per Cloud Assembly Organization.
3. Review an overview on [OneFuse modules](/docs/onefuse/consume/vmware-aria-automation/aria-automation-8x/modules/) with Aria Automation 8.1+/Cloud.
4. Create a new **Cloud Template** (if none exist) or determine which existing Cloud Template(s) will utilize this OneFuse Module.
   - Resource: [Designing your vRealize Automation Cloud Assembly deployments](https://docs.vmware.com/en/vRealize-Automation/8.1/Using-and-Managing-Cloud-Assembly/GUID-BFD33C28-ADCC-43F4-BE43-CC92B62FBE2E.html)

## Steps

1. **Configure a vRA Network Profile** and associated network(s). You will also need to configure your Constraints appropriately.
2. **Create/Update the OneFuse IPAM Policy** in OneFuse to use the vRA Selected Network Properties.
3. **Update the Cloud Template** to add in the necessary vRA Properties to invoke a OneFuse IPAM Policy and enable vRA Selected Network mode.
4. **Deploy** the vRA Cloud Template to provision resources with IPAM Network Selection support.

---

### Configure a vRA network profile

1. **Configure Network Profiles** in Aria Automation 8.1+/Cloud.
   - **Resource:** [How to add network profiles in Aria Automation](https://docs.vmware.com/en/vRealize-Automation/8.5/Using-and-Managing-Cloud-Assembly/GUID-5E3523F9-3995-46E1-9C72-04F81CD02AAF.html)
2. **Test Constraints** prior to attempting this setup to ensure Aria Automation 8 can allocate a resource based on the configured Constraints.
   - **Resource:** [Using constraint tags in Aria Automation Cloud Assembly](https://docs.vmware.com/en/vRealize-Automation/8.5/Using-and-Managing-Cloud-Assembly/GUID-C8C335F4-9623-401C-825E-6F5B2B3C6507.html)

---

### Create/update the OneFuse IPAM Policy to use vRA Selected Network properties

1. Log in to the OneFuse UI.
2. Go to **Modules** > **IPAM** on the left navigation menu.
3. **Create or update an IPAM Policy:**
   - In the **Subnet(s)** tab, configure the following:

     | Field name | Field value |
     | --- | --- |
     | Subnet (CIDR) | `{{ OneFuse_VraSelectedNetwork.subnet }}` |
     | Gateway | `{{ OneFuse_VraSelectedNetwork.gateway }}` |
     | Network Name | `{{ OneFuse_VraSelectedNetwork.name }}` |
     | Network Mask Override | *(Optional)* |

   - In the **DNS** tab, configure the following:

     | Field name | Field value |
     | --- | --- |
     | Primary DNS (optional) | `{{ OneFuse_VraSelectedNetwork.primaryDns }}` |
     | Secondary DNS (optional) | `{{ OneFuse_VraSelectedNetwork.secondaryDns }}` |
     | DNS Suffix (optional) | `{{ OneFuse_VraSelectedNetwork.dnsSuffix }}` |
     | DNS Search Suffix(es) (optional) | `{{ OneFuse_VraSelectedNetwork.dnsSearchSuffixes }}` |

The `OneFuse_VraSelectedNetwork` vRA property contains the following sub-properties:

```jinja2
{# The OneFuse_VraSelectedNetwork vRA Property contains the following sub-properties #}
{{ OneFuse_VraSelectedNetwork.id }}
{{ OneFuse_VraSelectedNetwork.name }}
{{ OneFuse_VraSelectedNetwork.externalId }}
{{ OneFuse_VraSelectedNetwork.dnsSuffix }}
{{ OneFuse_VraSelectedNetwork.subnet }}
{{ OneFuse_VraSelectedNetwork.gateway }}
{{ OneFuse_VraSelectedNetwork.primaryDns }}
{{ OneFuse_VraSelectedNetwork.dnsSearchSuffix }}
```

---

![IPAM policy using vRA selected network properties](/img/onefuse/consume/vmware-aria-automation/aria-automation-8x/modules/ipam/ipam-network-selection-support/ipam-network-selection-support-2021-01-27-3.png)

![IPAM policy template preview with vRA selected network properties](/img/onefuse/consume/vmware-aria-automation/aria-automation-8x/modules/ipam/ipam-network-selection-support/ipam-network-selection-support-2021-01-27-4.png)

### Update blueprints

#### 1. Add vRA Properties for OneFuse IPAM

1. Refer to [OneFuse + Aria Automation 8 IPAM](/docs/onefuse/consume/vmware-aria-automation/aria-automation-8x/modules/ipam/) to add in the necessary vRA Properties.
2. **Verify** the OneFuse IPAM Policy name specified has the vRA Selected Network Properties.

#### 2. Add vRA properties for vRA Network Selection Try Count

When the following Custom Property is added to the Cloud Template, vRA will look up the first `NetworkSelectionID` and create special vRA properties for Subnet CIDR, Gateway, Network Name, Network Mask, as well as Primary/Secondary DNS, DNS Suffix, and DNS Search Suffix(es).

Select how many `NetworkSelectionID` to try against per NIC with the following property.

| Property name format | Property value |
| --- | --- |
| `OneFuse_VraNetworkSelectionTryCountNic<#>` | `#` |

- Replace `<#>` with a number from `0` to `9`, one for each NIC. Default is `0`.
- Enter the numerical maximum number of retries. If a network fails, vRA requests the next network from NetworkSelectionIDs and continues until the retry count is reached.
- Required to enable **vRA Selected Network Mode** for a NIC; allows customization per individual network interface.

<div class="alert alert-info" role="alert">


For best performance, the recommended max number of retries is `10`. If the Try Count number is high enough, it will try all the networks in the network profile, which could lead to performance issues if your profile has many networks. We recommend limiting the number of networks in the network profile you are assigning that NIC in the Cloud Template.
</div>


#### 3. Add vRA properties for vRA Network Selection Order By Name (optional)

When the following Custom Property is added to the Cloud Template, vRO will order the Network Selection IDs passed to OneFuse by Name instead of the default ordering which is done on the IDs.

| Property name format | Property value |
| --- | --- |
| `OneFuse_VraNetworkSelectionOrderByNameNic<#>` | `true` or `"true"` |

- Replace `<#>` with a number from `0` to `9`, one for each NIC. Default is `0`.
- Set the value to either `true` (boolean format) or `"true"` (string format).

#### Example Cloud Template

![Example Cloud Template using the vRA selected network](/img/onefuse/consume/vmware-aria-automation/aria-automation-8x/modules/ipam/ipam-network-selection-support/ipam-network-selection-support-2021-01-27-6.png)

**Example Cloud Template YAML:**

```yaml
# Execute OneFuse IPAM Policy with vRA Selected Network

# -- Property Value
# <OneFuse Endpoint Name>  is onefuse
# <IPAM Policy Name> is prod

name: Simple Example
resources:
  Cloud_Machine_1:
    type: Cloud.Machine
    properties:
      image: CentOS7
      flavor: small
      count: 1
      OneFuse_IpamPolicy_Nic0: 'onefuse:prod'
      OneFuse_VraNetworkSelectionTryCountNic0: 2
      OneFuse_VraNetworkSelectionOrderByNameNic0: true
      constraints:
        - tag: Cluster1
      networks:
        - network: '${resource.Cloud_Network_1.id}'
          deviceIndex: 0
  Cloud_Network_1:
    type: Cloud.Network
    properties:
      networkType: existing
      constraints:
        - tag: my-network
```

## Provisioning

The next step is to deploy the Cloud Template, now that the OneFuse IPAM Policy is configured with the special vRA Network Selection properties and will select the correct Network based on vRA constraints.

1. In the OneFuse UI, you will see the Job for **Reserve IP Address**.
2. Select the eye icon under **Actions** to see the `VraSelectedNetwork` properties in the **Resolved Properties** tab.

   ```json
   {
     ...
     "OneFuse_VraSelectedNetwork": {
       "id": "<Network GUID>",
       "name": "<Network Name>",
       "externalId": "<Network External ID>",
       "dnsSuffix": "<DNS Suffix>",
       "subnet": "<Subnet CIDR>",
       "gateway": "<Gateway>",
       "primaryDns": "<Primary DNS>",
       "secondaryDns": "<Secondary DNS>",
       "dnsSearchSuffixes": "<DNS Search Suffix(es)>"
     }
   }
   ```
