Using show to set a single variable

Posts: 29
2286     0


I'm trying to use the show method assign a single variable... Is something like this possible?


my $devName  = $client->broker->Device->DeviceName({DeviceID=>$ifaddr->DeviceID});



I'm looking for a quick way to set the get the DeviceName when I have the DeviceID.










Re: Using show to set a single variable

Posts: 470
2286     0

If you are using PERL in NetMRI it's $name


External API for what you are trying to do:


use strict;
use warnings;
use NetMRI::API;
#use Data::Dumper;

# Connet to the NetMRI.
my $netmri = new NetMRI::API({
        api_version => '2.8'

        #print header
        print "DeviceName,DeviceIPAddress,InterfaceName,InterfaceDescription,Layer3IPaddress,Layer3SubnetMask,Speed,Duplex,InterfaceMAC\n";

        my @pt1 = $netmri->broker->device->index({

        #print $line;

        # for every device ID that matches filter up top
foreach my $initial (@pt1) {
        my $IP = $initial->DeviceIPDotted;
        my $name = $initial->DeviceName;
        my $device_id = $initial->DeviceID;

#print "$name \t $IP\n";

                my @pt2 = $netmri->broker->interface->find({

         # parse this device's physical compents
        op_DeviceID        => '=',
        val_c_DeviceID     => $initial->DeviceID,
        op_ifType        => '=',
        val_c_ifType     => 'ethernet-csmacd',
         select              => [qw( ifName ifDescr ifSpeed ifDuplex InterfaceID ifMAC )],


                 #my $arraySize = @pt2;
                        foreach my $snum (@pt2) {

                         my $intName = $snum->ifName;
                        my $intDescr = $snum->ifDescr;
                        my $intSpeed = $snum->ifSpeed;
                        my $intDuplex = $snum->ifDuplex;
                        my $intMAC = $snum->ifMAC;

                        my @pt3 = $netmri->broker->if_addr->find({

                 op_InterfaceID          => '=',
                val_c_InterfaceID     => $snum->InterfaceID,

                 select              => [qw( ifIPDotted ifNetMaskDotted )],


                                my $count = 0;
                                foreach my $snum2 (@pt3) {

                                 my $intIP = $snum2->ifIPDotted;
                                my $intSubnet = $snum2->ifNetMaskDotted;

                                 print "\n$name,$IP,$intName,$intDescr,$intIP,$intSubnet,$intSpeed,$intDuplex,$intMAC";

                                #print "\n===$count==="


                 #print "\n***$count***";
                if ($count ==0){
                print "\n$name,$IP,$intName,$intDescr,,,$intSpeed,$intDuplex,$intMAC";



         print "\n";
Follow me on LinkedIn:
Showing results for 
Search instead for 
Did you mean: 

Recommended for You