# ServiceNow CMDB

> Configure and use the OneFuse ServiceNow CMDB module with VMware Aria Automation 8x/Cloud

---

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

---

To learn more about this OneFuse module, refer to [ServiceNow CMDB](/docs/onefuse/configure/modules/servicenow-cmdb/).

## 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 ServiceNow CMDB Policies to run** for this Cloud Template.
3. **Update the Cloud Template** to add in necessary vRA Properties and/or add in the Custom Resource to invoke OneFuse ServiceNow CMDB Policies.
4. **Deploy the Cloud Template** to provision a vRA Deployment and create ServiceNow CMDB Configuration Item(s) and run the Provision IRE Template.
5. **Performing specific Day2 actions on the vRA Deployment** will update the ServiceNow CMDB CI(s) accordingly and run the Update IRE Template.
6. **Destroy the vRA Deployment** to update the ServiceNow CMDB CI(s) with the specified deprovision status and IRE Template.

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

| Property Name Format | Property Value Format |
| --- | --- |
| **Call a ServiceNow CMDB Policy** | |
| `OneFuse_ServiceNowCmdbPolicy` *(Required vRA Property for ServiceNow CMDB)* | `'<OneFuse Endpoint Name>:<ServiceNow CMDB Policy Name>'` |
| *Optionally, call additional ServiceNow CMDB Policies* | |
| `OneFuse_ServiceNowCmdbPolicy_<CustomID>`: Replace `<CustomID>` with a unique, user-defined friendly label. | `'<OneFuse Endpoint Name>:<ServiceNow CMDB Policy Name>'` |

**Example YAML:**

```yaml
# -- Property Name
# <CustomID> is replaced with 001Apache

# -- Property Value
# <OneFuse Endpoint Name>  is onefuse
# <ServiceNow CMDB Policy Name> is prod and linux_Apache

name: Simple Example
resources:
  Cloud_Machine_1:
    type: Cloud.Machine
    properties:
      image: CentOS7
      flavor: small
      count: 1
      OneFuse_ServiceNowCmdbPolicy: 'onefuse:prod'
      OneFuse_ServiceNowCmdbPolicy_001Apache: 'onefuse:linux_Apache'
```

##### 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 the `<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
# -- Property Name
# <CustomID> is replaced with 001Apache

# -- Property Value
# <OneFuse Endpoint Name>  is onefuse
# <ServiceNow CMDB Policy Name> is prod and linux_Apache

name: Simple Example
resources:
  Cloud_Machine_1:
    type: Cloud.Machine
    properties:
      image: CentOS7
      flavor: small
      count: 1
      OneFuse_ServiceNowCmdbPolicy: 'onefuse:prod'
      OneFuse_ServiceNowCmdbPolicy_001Apache: 'onefuse:linux_Apache'
```

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

```yaml
# -- Property Value
# <OneFuse Endpoint Name>  is onefuse
# <ServiceNow CMDB Policy Name> is prod
# <Name> is the Hostname

formatVersion: 1
inputs: {}
resources:
  Custom_onefuse_servicenowcmdb:
    type: Custom.onefuse.servicenowcmdb
    properties:
      name: {{ OneFuse_VmNic0.hostname }}
      policyName: 'prod'
      endpointName: 'onefuse'
```

#### Option 2: Add in Custom Resource for OneFuse ServiceNow CMDB

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


- From the **Resource Types** navigation, expand **Custom Resources**
- Drag-and-drop `OneFuse:ServiceNowCMDB_v1` to the 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). |
| `policyName` | Required | OneFuse Module Policy Name (string). |
| `templateProperties` | Optional | Additional properties that are referenced within the Policy. JSON format. |
| `trackingId` | Optional | Tracking ID (string) to link multiple OneFuse Policy Executions and resulting OneFuse Managed Objects together. If none is passed, one gets generated by OneFuse for that specific Policy Execution. |

### Provision

Deploy a Cloud Template with OneFuse ServiceNow CMDB Policy configured. ServiceNow CMDB CI(s) will be created in ServiceNow.

#### Outputs

The following vRA Property will have the generated OneFuse ServiceNow CMDB Managed Object as a JSON string on the Deployment.

| Property Name | Property Value Format |
| --- | --- |
| `OneFuse_ServiceNowCmdb` | *JSON string of OneFuse ServiceNow CMDB Managed Object* |
| `OneFuse_ServiceNowCmdb_<CustomID>` (if additional ServiceNow CMDB Policies) | *JSON string of OneFuse ServiceNow CMDB Managed Object* |

### Deprovision

Destroy an existing deployment with OneFuse ServiceNow CMDB Policy configured. ServiceNow CMDB CI(s) will be updated with the specified deprovision status in ServiceNow.

## vRA EBS

| EBS Execution | Subscription State | EBS Priority | EBS Name |
| --- | --- | --- | --- |
| **Provision** | | | |
| ComputeProvisionPost | Early | 1600 | OneFuse_Provision_ServiceNow_CMDB |
| **Day2** | | | |
| DeploymentResourceActionPost | - | 1100 | OneFuse_Update_ServiceNow_CMDB |
| **Deprovision** | | | |
| ComputePostRemoval | - | 1100 | OneFuse_De-Provision_ServiceNow_CMDB |

## 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:
   1. Select **Library** > **Workflows** from the left menu
   2. Go to: **OneFuse** > **ServiceNow CMDB** > **vRA8** to find corresponding workflow runs and view logs
   3. 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)
