Learn How We Can Help You Keep Teleworkers Protected During the COVID-19 Crisis

Network Change & Configuration Management

Reply
Highlighted

Perl script using "get_list_value"

Techie
Posts: 2
3237     0

Hi,

 

Is it possible to use get_list_value in a perl script ? I don't find the correct syntax to use it :-/ I'm a beginner in perl scripting ^^'

 

I defined a list called HW_EOS with this format :

Row1                             Row2                          Row3

Cisco_Model                 NetMRI_Model           HW_EOS

WS-C2960+24PC-L      WsC2960P24PcL      None Annouced

WS-C2960-24LT-L        catalyst296024LT      31/10/2019

 

The purpose of my script is to determine the device model, compare it with the list and set a components custom field with name "HW_EOS"

 

#!/usr/bin/perl -w
# BEGIN-SCRIPT-BLOCK
# Script-Filter: $Vendor == "Cisco"
#
# END-SCRIPT-BLOCK

#################################

use strict;
use warnings;
use NetMRI_Easy;
# Connect to the NetMRI
my $easy = new NetMRI_Easy;
# get the device id from the job engine.
my $device_id = $easy->device_id;
# retrieve the device
my $device = $easy->device;
my $model = $device->DeviceModel;
#
# Create the custom Device field called HW_EOS if it does not already exist
#
$easy->broker->custom_fields->create_field({
  model => 'Component',
  name  => 'HW_EOS',
  type  => 'date',
});
my $EOS->get_list_value(EOS,$model,HW_EOS,NULL);

#Log if needed
#$easy->log_message('info', "$EOS");
$easy->device->set_custom_field(HW_EOS => $EOS);

exit(1);

###################
##       End of Script        ##
##################

 

 

 

Many thanks for your help !

Highlighted

Re: Perl script using "get_list_value"

Adviser
Posts: 353
3238     0
It is possible, but I think you are better off using the ”Config List” API directly rather than get_list_value. Take a look at the docs for that and I think it will be easier to understand.
Highlighted

Re: Perl script using "get_list_value"

Adviser
Posts: 417
3238     0

Here is an example:

# Example: : my $enable_password = get_list_value(
# "Enable Passwords",
# "IP Address",
# $ipaddress,
# "Password",
# "NOT FOUND"
# );
#my $sif_name;
my $my_location;
our $device_devicename;

my $my_location = get_list_value("sif_test", "name", $device_devicename,"location", "null");
$easy->log_message('info', , "Device location is $my_location for device $device_devicename");
$easy->device->set_custom_field(location => $my_location);

Follow me on LinkedIn: https://www.linkedin.com/in/sifbaksh
Twitter: https://twitter.com/sifbaksh
Highlighted

Re: Perl script using "get_list_value"

Techie
Posts: 2
3238     0

Thanks for your example but this error is returned when trying to execute :-/

 

*** Error / Undefined subroutine &main::get_list_value called at /mnt/host/script/752834987043799037.ccs line 43

Showing results for 
Search instead for 
Do you mean 

Recommended for You