How to get relationship values available under network interface instance page.

Vinay2509
Tera Contributor

Hi Team,

 

I am trying to achieve physical connection naming convention.

 

Naming format would be : A-end equipmentname/slot/card/port-Z-end equipmentname/slot/card/port-Linktype

 

Naming convention rule has to be implemented when user creates an instance using change model/change request (Create physical connection)

 

Vinay2509_0-1708410896545.png

Question here, at A-end interface and Z end interface we can only select port but will not come to know to which card and slot the selected port is associated. How to resolve this.

 

please help with logic and implementation.

 

Thanks

Vinay

1 ACCEPTED SOLUTION

Hi @Vinay2509 ,

 

I dont think you need business rule. You can achieve this in below ways:

1) Update the sn_ni_core.TNIDefaultCINameUtils script or
2) Update/create extension points for sn_ni_core.TNIDefaultCINameUtils.

 

Option 2 is the best practice.

Here is how you can do that.
(these steps are provided assuming you dont have any customization on this script and you are using the OOB version of the script)
- search for Extension points in navigator. click on Scripted Extension Points

AneeshD_0-1708727954791.png

 

search for sn_ni_core.TNIDefaultCINameUtils

AneeshD_1-1708728030757.png

Open this record and update the code: here is the changes I have made to achieve what you wanted.

AneeshD_3-1708728317974.png

AneeshD_2-1708728266430.png

attaching the complete file for your reference.

Once the code is added, save the code and "create implementation"

AneeshD_4-1708728648216.png

 

Once that is done, you are good to test your changes.

Here is what mine looks like:

AneeshD_5-1708728935577.png

 

 

Let me know if this was helpful. Please mark this as resolved or let me know if any further help needed.

 

Thanks,

Aneesh D

View solution in original post

5 REPLIES 5

Hi @Vinay2509 ,

 

Port ->Card

Car->Slot

relationship will be maintained in CMDB_REL_CI (not just these two, all related CI's in general).

AneeshD_0-1708990719612.png

ie: Port(child) -> is related to Card(parent) with Type  contains::contained by.

similarly 

Car(child) -> Slot(parent).

 

So you can write a function in the extension code to retrieve the parent details and use their names to generate the Physical connection name.

Here is a sample script for your reference. (You will need to make appropriate changes and include in the extension file)

/*
* Method to get the parent CI record from the CI relatioship
*use port ci sys id to get the card ci sys id
*use card ci sys id to get the slot ci sys id
* @method getParentCi
* @param {childCi} childCI sys id. eg: port_a  
*
*/

function getParentCi(childCi) {
  var _parentCi = "";
  var _parentCiGr =  new GlideRecordSecure('cmdb_rel_ci');
  _parentCiGr.addQuery("child",childCi);
  _parentCiGr.query();
   while (_parentCiGr.next()) {
        _parentCi = _parentCiGr.parent.getRefRecord();
   }
   return _parentCi;
}

// calling this function by passing port_a to get the Card C
var _aEndCardCi = getParentCi(ciGr.port_a);

gs.info("A END Card Name: {0}",_aEndCardCi.name);

 

the same function can be used to get the Slot details by passing card sys id.

 

Hope this is helpful.

 

Thanks,

Aneesh D