ServiceNow
vScope’s Discovery not only gathers and structures data but also correlates resources from multiple technologies into a virtual map showing your complete datacenter setup. Integrate vScope with ServiceNow using vScope’s REST API to automate the import of Configuration Items (CIs) like virtual machines, virtualization hosts, and their relationships.
Overview
This setup fully integrates vScope and ServiceNow for automated discovery, transforming, and relationship mapping, offering a unified view of your IT infrastructure within ServiceNow’s CMDB.
Steps in vScope
- Create an API token for ServiceNow.
- Create a table listing the virtual machines to import.
- Create a table listing the virtualization hosts to import.
Steps in ServiceNow
- Create Data Sources for virtual machines and virtualization hosts.
- Set up Transformation Maps to create CIs in ServiceNow.
- Create Data Sources and Transformation Maps for host/VM relationships.
Create an API Token in vScope
In vScope:
- Navigate to Settings > API Tokens.
- Create a token, assigning it to a user with READ access to the tables.
- Note the expiry date and ensure that the token has access to all tables used in ServiceNow.
Create Tables in vScope
Table for Virtual Machines
- In Tables, create a new table for Virtual Machines.
- Add essential columns, including
UUID
(required). - Include additional columns like
RAM
andCPU Total
as needed. - Save the table with a recognizable name, ensuring the assigned user has READ access.
- After saving, click Collaborators to get the table ID from the permalink, which will be used in ServiceNow.
Table for Virtualization Hosts
Follow the same steps as above to create a table for Virtualization Hosts and add UUID
. Use Collaborators to note the table ID.
Set Up Data Sources in ServiceNow
Data Source for Virtual Machines
-
In ServiceNow, navigate to Data Sources and create a new entry.
-
Configure:
- Name: vScope-CS
- Label: vScope
- Import set table name:
u_vscope_cs
- Type: File
- Format: JSON
- Path for each row:
/rows/rows
- File retrieval method: HTTP/HTTPS
- Server:
{your vScope server address}
- File path:
/rest/v1/tables/{tableId}/data/json?token={API_TOKEN}
-
Replace
{tableId}
and{API_TOKEN}
with the actual table ID and API token created earlier. -
Test the data import by clicking Load All Records.
Data Source for Virtualization Hosts
Follow similar steps to create a Data Source for Virtualization Hosts, using the appropriate table ID from the vScope Hosts table.
Create a Transform Map in ServiceNow for Virtual Machines
- After importing the Virtual Machines data into the import table (
u_vscope_cs
), navigate to Transform Maps and click New. - Configure the Transform Map as follows:
- Name: vScope-CS
- Source table: vScope-CS (
u_vscope_cs
) - Target table: Computer (
cmdb_ci_computer
)
- Click Submit to save the new Transform Map.
- Under Related Links, click Mapping Assist to set up field mappings.
Suggested Field Mappings for Virtual Machines
In Mapping Assist:
- Name -> Name
- UUID -> Correlation ID (this is essential for maintaining consistency on each import)
- CPU Cores -> CPU core count
- CPU Sockets -> CPU count
-
Ensure Coalesce is enabled for UUID -> Correlation ID. This treats UUID as a unique key, enabling ServiceNow to update existing records rather than creating duplicates.
-
Click Transform under Related Links to start the transformation, selecting the import set and corresponding transform map.
Create a Transform Map in ServiceNow for Virtualization Hosts
- After importing the Virtualization Hosts data into the import table (
u_vscope_host
), go to Transform Maps and create a new entry. - Configure the Transform Map:
- Name: vScope-Host
- Source table: vScope-Host (
u_vscope_host
) - Target table: ESX Server (
cmdb_ci_esx_server
) or Hyper-V Host (cmdb_ci_hyper_v_server
for Hyper-V)
- Click Submit to save the new Transform Map, then use Mapping Assist for field mapping.
Suggested Field Mappings for Virtualization Hosts
- Name -> Name
- UUID -> Correlation ID
- CPU Cores -> CPU core count
- CPU Sockets -> CPU count
- Enable Coalesce for UUID -> Correlation ID to ensure unique mapping. Then, click Transform under Related Links.
Create a Data Source in ServiceNow for Host/VM Relationships
-
In ServiceNow, create a Data Source for the Host/VM Relationship:
- Name: vScope-Host-VM-Rel
- Import set table label: vScope
- Import set table name:
u_vscope_host_vm_rel
- Type: File
- Format: JSON
- Path for each row:
/rows/rows
- File retrieval method: HTTP/HTTPS
- Server:
{your vScope server address}
- File path:
/rest/v1/tables/{tableId}/hops/hostToVM?hopName=Hosted on::Hosts&token={API_TOKEN}
-
Replace
{tableId}
with the table ID of the Virtualization Hosts table and{API_TOKEN}
with your API token. -
Test the Data Source by selecting Load All Records. Confirm successful import in the u_vscope_host_vm_rel import table.
Create a Transform Map in ServiceNow for Host/VM Relationships
-
In ServiceNow, create a new Transform Map for the Host/VM relationship:
- Name: vScope-Host-VM-Rel
- Source table: vScope-Host-VM-Rel (
u_vscope_host_vm_rel
) - Target table: CI Relationship (
cmdb_rel_ci
)
-
Configure field mappings in Mapping Assist:
- u_sourceuuid -> parent
- u_targetuuid -> child
- u_hopname -> type
-
Add a Transform Script under the Transform Scripts tab, using onBefore to run the script:
Verify Successful Transformation of Relationships
-
Check Transformation History: After running the transformation, go to Transform History to review the results. Here, you’ll see the number of relationships created, updated, or any errors encountered.
-
Common Errors:
- If you encounter entries like
"Skipped: Failed to map endpoints"
, it usually indicates that the u_sourceuuid or u_targetuuid fields could not be matched to existing CI records. - Make sure the UUID fields in both vScope and ServiceNow match and that your API token has the correct permissions.
- If necessary, re-run the import to ensure data integrity.
- If you encounter entries like
-
Verify Relationships in ServiceNow:
- Navigate to CI Relationships by entering cmdb_rel_ci in the ServiceNow filter navigator.
- You should see entries that represent relationships between virtual machines and virtualization hosts, with parent and child fields populated by the
sys_id
values from cmdb_ci_computer and cmdb_ci_esx_server tables.
Viewing Relationships in ServiceNow
-
Visualize CI Relationships:
- To view relationships in a graphical format, go to an imported ESX server or virtual machine in the Configuration Item table.
- Under Related Items, click the graph icon to bring up a visualization of relationships.
-
Check Relationship Details:
- Relationships will show connections between hosts and their hosted virtual machines.
- Verify the Relationship Type (e.g., “Hosted on::Hosts”) is correctly displayed for each entry.
Schedule Regular Imports in ServiceNow
Automating the import process is essential to maintain up-to-date data in ServiceNow. Follow these steps to set up scheduled imports:
-
Navigate to Scheduled Imports:
- In ServiceNow, go to System Import Sets > Scheduled Import.
- Click New to create a scheduled import for each data source (Virtual Machines, Virtualization Hosts, and Host/VM Relationships).
-
Configure Each Import Schedule:
-
Virtual Machines:
- Name: vScope-CS Import
- Data Source: vScope-CS
- Run as User: Choose a user with API access permissions.
- Schedule: Set the preferred interval (e.g., Daily at 3:00 AM).
- Click Submit and Execute Now to test the import.
-
Virtualization Hosts:
- Name: vScope-Host Import
- Data Source: vScope-Host
- Set the schedule to run after the Virtual Machines import is complete.
-
Host/VM Relationships:
- Name: vScope-Host-VM-Rel Import
- Data Source: vScope-Host-VM-Rel
- Schedule this import to run after the Virtual Machines and Hosts imports (e.g., at 3:30 AM) to ensure all CI records are in place.
-
-
Validate Scheduled Imports:
- After setting up, run each scheduled import manually via Execute Now to confirm functionality.
- Review the Transform History for each import to ensure successful transformations and troubleshoot any issues as needed.
Important Notes and Tips
- Always Coalesce on UUID: For accurate synchronization, always map UUID from vScope to Correlation ID in ServiceNow and enable Coalesce on this field to maintain consistent identifiers across imports.
- Relationship Transformations: Ensure that Host/VM Relationships transformations only run after Virtual Machines and Virtualization Hosts transformations. This sequencing ensures that CI references are established before relationships are created.
- Check API Token Permissions: Verify that your API token has sufficient permissions to access all relevant tables and CI records in vScope.
- Monitor Storage Limits: If import tables (
u_vscope_cs
,u_vscope_host
, etc.) reach maximum field character limits (often 40 characters), you may need to delete and recreate them as noted earlier.
Troubleshooting Common Issues
-
Data Not Importing:
- Check that the vScope API endpoint and API token are correct.
- Verify network connectivity between ServiceNow and vScope.
-
Field Truncation:
- If UUIDs are truncated in import tables, clear and recreate the table structure by deleting import tables under System Import Sets > Cleanup and re-running the import.
-
Duplicate Records:
- Ensure Coalesce is enabled on the UUID to Correlation ID field mapping to prevent duplicate CI entries.
- Confirm that scheduled imports do not overlap or run concurrently.