# Templating and Property Toolkit

> Use OneFuse Templating and Property Toolkit features with the OneFuse XUI

---

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

---

To learn more about this OneFuse feature, refer to [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 configuration sprawl with dynamic property 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 OneFuse Template Engine

## 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)

## Best practices

### OneFuse Property Sets for Property Toolkit consumption

The OneFuse Property Toolkit is a very powerful tool with the ability to look up data against a standard set of properties.

An example would be a Property Sets for: `Environment` that defines known values for different integrations or services for provisioning:

- You may have a Property Set for the **production** environment that effects the name, network selection, DNS registration, template to be used, etc.
- You may also have a Property Set for the **development** environment that differently effects the name, network selection, DNS registration, template to be used, etc.

**It is a best practice to have all of your Property Set management within dedicated in OneFuse Property Set(s).** This allows a single location where you can review and manage the OneFuse Property Sets and the resultant property associations versus having them scattered throughout CloudBolt Parameters.

## Prerequisites

1. Configure OneFuse [Property Set(s)](/docs/onefuse/templating/property-sets/) and OneFuse Module Policies.
1. [Install OneFuse XUI](/docs/onefuse/consume/onefuse-xui/getting-started/#install-onefuse-xui) per CloudBolt CMP.
1. Review an overview on [OneFuse Modules](/docs/onefuse/consume/onefuse-xui/modules/) with CloudBolt CMP.
1. Create a new **Blueprint** (if none exist) or determine which existing Blueprint(s) will utilize this OneFuse Module. Resource: [Blueprints](/docs/cmp/use/blueprints/).

## Use OneFuse Property Toolkit

### Configure the Blueprint

1. **Know the name of the OneFuse Connection Info** created via [OneFuse XUI initial setup](/docs/onefuse/consume/onefuse-xui/getting-started/#initial-setup).
1. **Determine _which_ OneFuse Property Sets** are needed for this Blueprint.
1. **Determine _which_ custom properties/parameters** needed for this Blueprint.
1. **Update the Blueprint** to add in necessary parameters to influence other properties in OneFuse Policies.
1. **Deploy the Blueprint** to provision a deployment with dynamic configurations.

### Update the Blueprint

1. Log in to **CloudBolt CMP**.
1. If not already on the **Catalog** page, select **Catalog** from the main menu.
1. Search and find the desired CloudBolt Blueprint.
1. **Edit the Blueprint** by selecting the gear icon on the bottom-right of the Catalog Item.

#### Add in necessary Parameters

The following Parameters need exist on the Blueprint.

Learn more about [CloudBolt Parameters](/docs/cmp/configure/order-forms-and-pricing/parameters/) for: [Blueprints](/docs/cmp/use/blueprints/customize-order-form/blueprint-level-parameters/), [Environments](/docs/cmp/use/blueprints/customize-order-form/group-and-environment-parameters/), and [Groups](/docs/cmp/configure/order-forms-and-pricing/parameters/).

**1. Trigger Property Toolkit:**

| Parameter Name Format | Parameter Value Format |
| --- | --- |
| `OneFuse_PropertyToolkit` | `<OneFuse Connection Info Name>`:true |

**2. Add in additional Parameters:**

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

| Parameter Name Format | Parameter Value Format |
| --- | --- |
| `OneFuse_SPS_`\<CustomID\> _(Replace `<CustomID>` with a unique, user-defined friendly label.)_ | `<OneFuse Property Set Name>` |

**2b. Method to dynamically add in Parameter properties:**

| Parameter Name Format | Parameter Value Format |
| --- | --- |
| `OneFuse_CreateProperties_`\<CustomID\> _(Replace `<CustomID>` with a unique, user-defined friendly label.)_ | `<JSON key:value pairs of Properties>` |

**Example Parameter:**

```yaml
# Parameter Name (in blue) is separated from the Parameter value (in black) with the first colon (:)

# Method A Example - Add in properties from OneFuse Property Set(s)

# -- Parameter Name
# <CustomID> is App and Env

# -- Parameter Value
# <Property Set Names>: linux and prod
OneFuse_PropertyToolkit: onefuse:true
OneFuse_SPS_App: linux
OneFuse_SPS_Env: prod


# Method B Example - Create Parameters

# -- Parameter Name
# <CustomID> is 001Backup

# -- Parameter Value
# <Property Name>  is Backup-VM
# <Property Value> is the provisioned resource hostname
OneFuse_PropertyToolkit: onefuse:true
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 Trigger Point.

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 Trigger Point Execution Strings for the OneFuse Module on the specific resource for the Blueprint.
- Is reusable either between different VM components of the same Blueprint or between different Blueprints.

```yaml
# Example CustomID

Apache
BackupClient
WebApp
```

**Specify Sorting with CustomID:**

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

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

```yaml
# Example CustomID with sorting

001Apache
002WebApp
003BackupClient
```

##### Additional helpful properties passed to OneFuse Module

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

| Property and Parameter | 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 Parameter** 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>` | See examples below |

Replace `<#>` with a number from `0` to `9`, one for each NIC.

Replace `<value>` with an appropriate key: `assignment`, `dnsServers`, `dnsSuffix`, `fqdn`, `gateway`, `hostname`, `ipAddress`, `label`, `mac`, `network`, `nicLabel`, `target`

<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>


Examples:

- `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).

**Purpose: Reference VM hardware information: cpu, memory, etc.**

| Property Format | Example |
| --- | --- |
| `OneFuse_VmHardware.<value>` | See examples below |

Replace `<value>` with an appropriate key: `cpuCount`, `memoryGB`, `memoryMB`, `platformUuid`, `powerState`, `totalStorageGB`

Examples:

- `OneFuse_VmHardware.cpuCount`
- `OneFuse_VmHardware.memoryGB`
- `OneFuse_VmHardware.platformUuid`
- `OneFuse_VmHardware.powerState`
- `OneFuse_VmHardware.totalStorageGB`

### 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 Parameters will exist the deployment.

## Trigger Points

| Job / Process | Trigger Point Name | Run Sequence | Plugin Action Name |
| --- | --- | --- | --- |
| Provision Server | Generated Hostname Overwrite | 1000 | OneFuse - Property Toolkit |
| Provision Server | Pre-Create Resource | 1000 | OneFuse - Property Toolkit |
| Provision Server | Pre-Application Installation | 1000 | OneFuse - Property Toolkit |
| Provision Server | Post-Provision | 1000 | OneFuse - Property Toolkit |
