# Templating and Property Toolkit

> Configure and use the OneFuse Property Toolkit in VMware Aria Automation 8x to apply dynamic Property Sets and create vRA properties via Cloud Templates and Event Broker Subscriptions

---

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

---

To learn more, refer to the [Templating guide and Property Toolkit features](/docs/onefuse/templating/best-practices/).

## Introduction

**The OneFuse Property Toolkit (PTK) is the Swiss army knife of the OneFuse Platform.**

PTK can be used to simplify configurations, define business logic as configuration, build simple logic or tackle the most complex problems. At face value, the PTK is meta-data that can be called upon offering simple name value pairs that can be used as a reference for decision making. In its most powerful form, it can contain logic, decision trees, platform abstractions, and much more.

## Feature highlights

- Minimize automation inputs by presenting simple meaningful inputs, and leveraging policy-driven decisioning
- Reduce blueprint and configuration sprawl with dynamic blueprints and configurations
- Reduce custom code/technical debt in the areas of configurations and business logic
- Cross-platform/tool standardization
- Use OneFuse Property Sets to drive property assignment and rendering
  - Supports nested Property Sets
- Supports OneFuse Template Engine for both `key:value` pair.
- Supports ordering sets/groupings of properties by alphabetizing the after the Property Key prefix.

## Resources

- [Property Sets for Property Toolkit features](/docs/onefuse/templating/property-sets/#property-sets-for-property-toolkit-features)
- [Property Sets for Upstream Providers](/docs/onefuse/templating/property-sets/#property-sets-for-upstream-providers)

## Prerequisites

1. Configure OneFuse [Property Set(s)](/docs/onefuse/templating/property-sets/) and OneFuse Module Policies.
2. Run OneFuse Configuration per Cloud Assembly Organization.
3. Review an overview on OneFuse 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. **Know the name of the OneFuse Endpoint** created via [OneFuse Configuration](/docs/onefuse/consume/vmware-aria-automation/aria-automation-8x/installation-and-setup/#run-the-onefuse-configuration-workflow).
2. **Determine _which_ OneFuse Property Sets** are needed for this Cloud Template.
3. **Determine _which_ custom vRA Properties** are needed for this Cloud Template.
4. **Update the Cloud Template** to add in necessary vRA Properties to influence other vRA Properties and OneFuse Policies.
5. **Deploy the Cloud Template** to provision a vRA Deployment with dynamic configurations.

### Update the Cloud Template

1. Log in to vRA > **Cloud Assembly**
2. Select the **Design** tab from the top menu bar
3. Select the **Cloud Templates** tab from the left menu
4. **Edit the Cloud Template** and perform the below:

#### Option 1: Add in necessary vRA properties

The following vRA Properties need to be added to the Cloud Template's **Code** section under the **Resource(s)** of interest.

**1. Trigger Property Toolkit and/or VM Tagging:**

| Property Name Format | Property Value Format |
| --- | --- |
| `OneFuse_PropertyToolkit` | `'<OneFuse Endpoint Name>:true'` |

**Example YAML:**

```yaml
# OneFuse Property Toolkit - Simple Example

# -- Property Name
# <CustomID> is replaced with App, Env and 001Backup

# -- Property Value
# <OneFuse Endpoint Name>  is onefuse
# <OneFuse Property Set Name> is linux and prod
# <Property Name>  is Backup-VM
# <Property Value> is the provisioned resource hostname

name: Simple Example
resources:
  Cloud_Machine_1:
    type: Cloud.Machine
    properties:
      image: CentOS7
      flavor: small
      count: 1
      OneFuse_PropertyToolkit: 'onefuse:true'
      OneFuse_SPS_App: 'linux'
      OneFuse_SPS_Env: 'prod'
      OneFuse_CreateProperties_001Backup: '{"key":"Backup-VM", "value":"{{ OneFuse_VmNic0.hostname }}"}'
```

**2. Add in additional vRA Properties:**

**2a. Method to add in properties from a OneFuse Property Set:**

| Property Name Format | Property Value Format |
| --- | --- |
| `OneFuse_SPS_<CustomID>`: Replace `<CustomID>` with a unique, user-defined friendly label. | `'<OneFuse Property Set Name>'` |

**2b. Method to dynamically add in vRA Properties:**

| Property Name Format | Property Value Format |
| --- | --- |
| `OneFuse_CreateProperties_<CustomID>`: Replace `<CustomID>` with a unique, user-defined friendly label. | `'<JSON key:value pairs of Properties>'` |

**Example YAML:**

```yaml
# Method A Example - Add in properties from OneFuse Property Set(s)
# !!Note: Starting in OneFuse v1.4, Static Property Sets was renamed to Property Sets. Backwards compatibility exists.

# -- Property Name Format
# <CustomID> is App and Env

# -- Property Value Format
# <Property Set Names>: linux and prod
OneFuse_SPS_App: 'linux'
OneFuse_SPS_Env: 'prod'


# Method B Example - Create vRA Properties

# -- Property Name Format
# <CustomID> is 001Backup

# -- Property Value Format
# <Property Name>  is Backup-VM
# <Property Value> is the provisioned resource hostname
OneFuse_CreateProperties_001Backup: '{"key":"Backup-VM", "value":"{{ OneFuse_VmNic0.hostname }}"}'
```

##### CustomID

**CustomID** refers to a user specified text string to identify and can set an order of precedence for execution when calling multiple Policies for the OneFuse Module in the same vRA EBS State.

Replace `<CustomID>` variable with a unique custom identifier:

- Format is alphanumeric characters only `A-Z, a-z, 0-9`. No spaces, underscores, hyphens nor special characters.
- Must be unique across all EBS Execution Strings for the OneFuse Module on the specific VM for the Blueprint/Cloud Template.
- Is reusable either between different VM components of the Blueprint/Cloud Template canvas or between different Blueprints/Cloud Templates.

```yaml
# OneFuse Property Toolkit - Simple Example

# -- Property Name
# <CustomID> is replaced with App, Env and 001Backup

# -- Property Value
# <OneFuse Endpoint Name>  is onefuse
# <OneFuse Property Set Name> is linux and prod
# <Property Name>  is Backup-VM
# <Property Value> is the provisioned resource hostname

name: Simple Example
resources:
  Cloud_Machine_1:
    type: Cloud.Machine
    properties:
      image: CentOS7
      flavor: small
      count: 1
      OneFuse_PropertyToolkit: 'onefuse:true'
      OneFuse_SPS_App: 'linux'
      OneFuse_SPS_Env: 'prod'
      OneFuse_CreateProperties_001Backup: '{"key":"Backup-VM", "value":"{{ OneFuse_VmNic0.hostname }}"}'
```

**Specify sorting with CustomID:**

When executing multiple different OneFuse Module's Policies in the same EBS State, prefix the `<CustomID>` with a numeric value (for example, 001, 002, etc).

The `<CustomID>` is sorted prior to executing the OneFuse module's policies.

##### Additional helpful vRA properties

**Purpose: Relate OneFuse Policy executions from different OneFuse Modules together with a Tracking ID.**

| Property | Value Format |
| --- | --- |
| `OneFuse_Tracking_Id` | A GUID (globally unique identifier) that links OneFuse Policy Executions and the resulting Managed Objects together for a given resource on a deployment. The first OneFuse Module Policy execution will populate this vRA property and it will be passed into other OneFuse Modules automatically. Learn more about OneFuse [Tracking ID](/docs/onefuse/concepts/tracking-id/). |

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


When a Tracking ID is not provided, a Tracking ID gets generated for the Policy execution.
</div>


**Purpose: Reference a specific NIC's values to get hostname, IP Address, etc.**

| Property Format | Example |
| --- | --- |
| `OneFuse_VmNic<#>.<value>`: Replace `<#>` with a number from `0` to `9`, one for each NIC. Replace `<value>` with an appropriate key: `dnsSuffix`, `fqdn`, `gateway`, `hostname`, `ipAddress`, `macAddress`, `netmask`, `network`, `subnet`, `target` | `OneFuse_VmNic0.dnsSuffix`, `OneFuse_VmNic0.fqdn`, `OneFuse_VmNic0.hostname`, `OneFuse_VmNic0.ipAddress`, `OneFuse_VmNic0.target` (when DNS Suffix is provided, will be the FQDN; otherwise, will be the hostname without domain) |

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


For most use cases, NIC 0 is the primary network interface and the target hostname is a Fully Qualified Domain Name (FQDN).
</div>


##### Example Cloud Template YAML code

```yaml
# OneFuse Property Toolkit - Simple Example

# -- Property Name
# <CustomID> is replaced with App, Env and 001Backup

# -- Property Value
# <OneFuse Endpoint Name>  is onefuse
# <OneFuse Property Set Name> is linux and prod
# <Property Name>  is Backup-VM
# <Property Value> is the provisioned resource hostname

name: Simple Example
resources:
  Cloud_Machine_1:
    type: Cloud.Machine
    properties:
      image: CentOS7
      flavor: small
      count: 1
      OneFuse_PropertyToolkit: 'onefuse:true'
      OneFuse_SPS_App: 'linux'
      OneFuse_SPS_Env: 'prod'
      OneFuse_CreateProperties_001Backup: '{"key":"Backup-VM", "value":"{{ OneFuse_VmNic0.hostname }}"}'
```

## Using Property Toolkit with Custom Resources

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


Review [OneFuse custom resources](/docs/onefuse/consume/vmware-aria-automation/aria-automation-8x/modules/custom-resources/) before using this method.
</div>


Both of the `OneFuse_SPS_<CustomID>` and `OneFuse_CreateProperties_<CustomID>` methods of invoking the Property Toolkit are available to OneFuse Custom Resources.

Business logic and configuration information surrounding how a particular Custom Resource should be deployed should be contained in Property Sets and invoked when creating a Custom Resource.

![Using the Property Toolkit to standardize information passed to the Naming Custom Resource](/img/onefuse/consume/vmware-aria-automation/aria-automation-8x/modules/templating-property-toolkit/bpd_onefuse-custom-resources-example3.png)

**Add a Custom Resource to get an existing OneFuse Property Set:**

- From the **Resource Types** navigation, expand **Custom Resources**
- Drag-and-drop `OneFuse:ExistingSPS_v1` to the Cloud Template canvas
- In the **Code** tab, provide values for the following properties:

| Parameter Name | Required? | Notes |
| --- | --- | --- |
| `endpointName` | Required | OneFuse Endpoint Name in vRA. Refer to [Managing endpoints](/docs/onefuse/consume/vmware-aria-automation/aria-automation-8x/installation-and-setup/#managing-endpoints). |
| `name` | Required | OneFuse Property Set name |

**Add a Custom Resource to create a new OneFuse Property Set:**

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


Once the vRA Deployment is destroyed, the correlated OneFuse Property Set will also get deleted.
</div>


- From the **Resource Types** navigation, expand **Custom Resources**
- Drag-and-drop `OneFuse:SPS_v1` to the Cloud Template canvas
- In the **Code** tab, provide values for the following properties:

| Parameter Name | Required? | Notes |
| --- | --- | --- |
| `endpointName` | Required | OneFuse Endpoint Name in vRA. Refer to [Managing endpoints](/docs/onefuse/consume/vmware-aria-automation/aria-automation-8x/installation-and-setup/#managing-endpoints). |
| `workspaceName` | Optional | OneFuse Workspace Name. Will use `Default` if not specified. |
| `name` | Required | OneFuse Property Set name. |
| `description` | Optional | OneFuse Property Set description. |
| `templateProperties` | Optional | Property Set Properties. JSON format. |

### Provision

Deploy a Cloud Template with OneFuse Property Sets configured and/or Create Properties dynamically. The resource will be dynamically created.

#### Outputs

The user specified vRA Properties will exist on the deployment.

## vRA EBS

| EBS Execution | Subscription State | EBS Priority | EBS Name |
| --- | --- | --- | --- |
| **Provision** | | | |
| ComputeAllocationPre | Early | 1000 | OneFuse_PropertyToolkit_ComputeAllocate |
| NetworkConfigure | Early | 1000 | OneFuse_PropertyToolkit_NetworkConfigure |
| ComputeProvisionPre | Early | 15 | OneFuse_PropertyToolkit_ComputeProvision |
| ComputeProvisionPost | Early | 1000 | OneFuse_PropertyToolkit_ComputePostProvision |

## Troubleshooting

Troubleshoot in vRealize Orchestrator.

1. Log in to **vRealize Orchestrator**.
2. Turn on [Verbose Logging](/docs/onefuse/consume/vmware-aria-automation/aria-automation-8x/modules/#troubleshooting-verbose-logging) and try again to see additional log messages in vRO Workflows:
   - Select **Library** > **Workflows** from the left menu
   - Go to: **OneFuse** > **Property Toolkit** > **vRA8** to find corresponding workflow runs and view logs
   - Optionally, run the workflows in the **Manual** folder to manually test
3. Optionally, [configure timeouts for EBS](/docs/onefuse/consume/vmware-aria-automation/aria-automation-8x/modules/event-broker-subscriptions/#configure-ebs-timeouts) and/or [Configure timeouts for OneFuse modules](/docs/onefuse/consume/vmware-aria-automation/aria-automation-8x/installation-and-setup/#configure-timeouts-for-onefuse-modules).

**Additional resources:**

- Review [Troubleshooting in OneFuse](/docs/onefuse/getting-started/troubleshooting/)
- Review [VMware troubleshooting resources](/docs/onefuse/consume/vmware-aria-automation/aria-automation-8x/getting-started/#troubleshooting)
