DX NetOps Manager

 View Only

Free script to set interface custom attributes 

Apr 19, 2018 05:30 AM

Attached is a Perl script to set interface custom attributes in batch from a CSV file.

 

Use Case

Customer needs to be able to sort and filter tabular views of interfaces in CA PC by custom criteria such as region or business line. With OpenAPI, he created a couple of CSV files with the interfaces to update and added the custom attribute settings. These updates need to be uploaded to the CA PM system.

 

Approach

Perl script setInterfaceCustAttr.pl sets interface custom attributes from CSV file in CA PM Data Aggregator
CSV file format:
ID; Name; DeviceID; DeviceName; CA1; CA2\n
first line is the column header and has the name of the custom attributes to be set
first column is the interface item ID, columns 2, 3 and 4 are ignored

e.g. file interfaces.csv
ID;Name;device/ID;device/Name;Region;Business
7027;eth0;6;deviceA;EMEA;Power

 

Usage

perl setInterfaceCustAttr.pl DA_host_and_port (e.g. PMDA:8581) inputfilename (without csv suffix)

e.g.

perl setInterfaceCustAttr.pl PMDA:8581 interfaces


Prerequisites

  • CA PM 3.2+
  • custom attributes have been created
  • Perl 5.18+, with REST::Client

 

 

Your feedback is appreciated so please post any comments in this thread.  As with all free Infrastructure Management Field Developed Utility postings, inquiries should be made through questions or comments in this thread, and the author, Lutz_Holzbecher, will provide a response.

All information downloaded or accessed (including field packs, customized solutions, patches etc.) are provided AS IS and no warranties are provided or made.  For more information you may click here.

Statistics
0 Favorited
3 Views
1 Files
0 Shares
4 Downloads
Attachment(s)
zip file
setInterfaceCustAttr.zip   1 KB   1 version
Uploaded - May 29, 2019

Tags and Keywords

Comments

Aug 24, 2018 12:00 PM

Hi Fernando,

yes you can override the interface speed in/out. You can do the following:

  • use OpenAPI to create a csv file with the IDs of the interfaces you need to update
  • add the speed in/out to the file
  • create script that reads the file and makes for each record the subsequent REST request with corresponding ID and newValues. You can use the script from this community post as a template.
  • once updated on the DA, the changes will be synched to CA PC.

 

PUT http://DA:8581/rest/ports/ID

body:

<Port version="1.0.0">
<SpeedOutOverride>newValue</SpeedOutOverride>
<SpeedInOverride>newValue</SpeedInOverride>
</Port>

 

Hth

Lutz.

Aug 24, 2018 10:52 AM

Hello Lutz,
Thank you very much for the spectrim, it is very useful.

I wanted to ask if it is possible to modify existing values.
For example, the speed of the interface (In and out) positions 9 and 10
I have to modify 1300 interfaces and looking to get here.

 

I leave an example of the device 130

http://performance:8181/pc/center/webservice/devices/deviceItemId/130/interfaces 

 

<interface>

<itemId>2030</itemId>
<name>Gi0/0/0</name>
<nameAlias>Interface 1</nameAlias>
<description>GigabitEthernet0/0/0</description>
<domainId>3</domainId>
<subType>physical</subType>
<ifIndex>1</ifIndex>
<ifType>ethernetCsmacd (6)</ifType>
<ifSpeedIn>1000000000</ifSpeedIn>
<ifSpeedOut>1000000000</ifSpeedOut>
<ifAlias>## MPLS TASA ##</ifAlias>
<flowEnabled>off</flowEnabled>
<lifeCycleState>ACTIVE</lifeCycleState>
<lastLifeCycleStateChangeOn>1533733268</lastLifeCycleStateChangeOn>
<Polling>Enabled</Polling>
</interface>
Thank you very much!

Related Entries and Links

No Related Resource entered.