Highlighted
Trusted Contributor.
Trusted Contributor.
555 views

(UCMDB Support Tip) - how to map a custom attribute from a scan file to a node ci custom attribute

This document is demonstrating how to :

  • map the custom attribute "hwsmbiosEmbeddedControllerFirmwareRelease" appearing in the smbios of a scan file
  • to the custom attribute "biosfmversion" of the "node" ci-type.

As prerequisite, the attribute "biosfmversion" has to be created on the node ci-type. It won't function if you don't create it or don't edit the script below.

How to locate the proper script :

  1. Login into ucmdb with an "admin" user.
  2. In the dataflow management panel, section adapter management
  3. locate the "InventoryDiscovery" package, and unfold it.
  4. Select : scripts => ParseEnrichedScanFile.py
  5. Open the script, and keep a secure copy of it.

Locate the following text :

    #Uncomment this code to map the selected asset data fields detected by the inventory scanners to UCMDB
    #mapAssetData(root, nodeOsh)
    oshvresults.add(nodeOsh)
    mapScanFile(oshvresults, root, nodeOsh, nodeOsh)
    return nodeOsh
 
# Example code illustrating how to map selected asset data fields from the scan file to
# UCMDB CI attributes, for example, map the hwAssetDescription field to the Node CI 'description' attribute.
#def mapAssetData(root, hostOsh):
#mapStringAttribute(hostOsh, "description", "hwAssetDescription", root)
 
and replace it with :
 
    #Uncomment this code to map the selected asset data fields detected by the inventory scanners to UCMDB
    mapAssetData(root, nodeOsh)
    oshvresults.add(nodeOsh)
    mapScanFile(oshvresults, root, nodeOsh, nodeOsh)
    return nodeOsh
 
# Example code illustrating how to map selected asset data fields from the scan file to
# UCMDB CI attributes, for example, map the hwAssetDescription field to the Node CI 'description' attribute.
def mapAssetData(root, hostOsh):
mapStringAttribute(hostOsh, "biosfmversion", " hwsmbiosEmbeddedControllerFirmwareRelease", root)
 
Take care to the fact that in Python/Jython the indentation level is a crucial thing. IE, the tabulation before the mapstringattribute is signifiant.
 
Restart the scanner job.
0 Likes
2 Replies
Highlighted
Honored Contributor.
Honored Contributor.

Re: (UCMDB Support Tip) - how to map a custom attribute from a scan file to a node ci custom attribu

Hi Xavier,

I tried what you mention but i am getting an error on the UI as 

<< Progress message, Severity: Error>>
XML Enricher failed to parse scanning file local variable 'mapAssetData' referenced before assignment

 Checked the com log and the error i got 

<log start="16:58:48" severity="error">Failed parsing scan file...</log>
<log start="16:58:48" severity="debug">local variable 'mapAssetData' referenced before assignment
Traceback (most recent call last):
File "ParseEnrichedScanFile", line 221, in domParse
File "ParseEnrichedScanFile", line 519, in createNodeOSH
UnboundLocalError: local variable 'mapAssetData' referenced before assignment

0 Likes
Highlighted
Trusted Contributor.
Trusted Contributor.

Re: (UCMDB Support Tip) - how to map a custom attribute from a scan file to a node ci custom attribu

Hi Ayush,

May you share an extract of your changes ?

I'd like to look for this specific part :

def mapAssetData(root, hostOsh):
    mapStringAttribute(hostOsh, "biosfmversion", "hwsmbiosEmbeddedControllerFirmwareRelease", root)

as python complains about it not being defined.

 

Important point to mention, is that python is particularly picky about the indentation (spaces and tabs are the start of a line), as it's a structural element.

Regards.

Xavier

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.