Network Change & Configuration Management

Reply

How to access Netmri API :: Remote :: DevicePhysical

falakoss
Techie
Posts: 3
2747     0

Hello,

Someone know how to access Device Physical Attribute and methode on netmri? i would like to retrieve for example PhysicalModelNamePhysicalClass ... of cisco switch

Below the script i' ve tried but it doesn't work!  (Error / Can't locate object method "PhysicalModelName" via package "NetMRI::API::Remote::V3_2_0:Smiley Very Happyevice")

It's point to "NetMRI::API::Remote::V3_2_0:Smiley Very Happyevice" but not "NetMRI::API::Remote::V3_2_0:Smiley Very HappyevicePhysical"

 

#

use strict;
use warnings;
use NetMRI_Easy;

# Connect to the Network Automation
my $easy = new NetMRI_Easy;

my $physicalModelName = $easy->device->PhysicalModelName;
print $physicalModelName;

 

Thanks

Re: How to access Netmri API :: Remote :: DevicePhysical

Adviser
Posts: 357
2748     0
There may be a method ”device_physicals” on the device object - try perldoc. Alternatively you can create a broker for the DevicePhysical objects and query it directly.

Re: How to access Netmri API :: Remote :: DevicePhysical

Adviser
Posts: 423
2748     0

$model is a well-known variable in NetMRI Smiley Happy

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

Re: How to access Netmri API :: Remote :: DevicePhysical

falakoss
Techie
Posts: 3
2748     0

Hello,

Thank you for your answer,

 

I have tried your suggestion, 

1 - The device object have not a method: Error / Can't locate object method "device_physicals" via package "NetMRI::API::Remote::V3_2_0:Smiley Very Happyevice" 

 

2 - I created a broker and query it directly but it doesn' to workError / Can't locate object method "PhysicalModelName" via package "NetMRI::API::Broker::V3_2_0:Smiley Very HappyevicePhysical" 

 

NOTE: The Attribute/Methode is located at NetMRI::API::Remote::V3_2_0:Smiley Very HappyevicePhysical

 

Please see below the script:

 

use NetMRI::API;
my $client = NetMRI::API->new({ api_version => '3.2.0' });

my $broker = $client->broker->device_physical;
my $physicalModelName = $broker->PhysicalModelName;
print $physicalModelName;

 

Thanks

Re: How to access Netmri API :: Remote :: DevicePhysical

falakoss
Techie
Posts: 3
2748     0

@

 

Thank you for your answer, I would like to get something like below on PhysicalDevice but not on Device

The script below work on Device but the result is not what i want: 

The model return by netmri is catalyst356012PCS but i want the PhysicalModelName: WS-C3560-12PC-S which is the real cisco model

 

use strict;
use warnings;
use NetMRI_Easy;
my $easy = new NetMRI_Easy;


my $device = $easy->device;
my $model= $device->DeviceModel;
print $model;

 

Thanks

Re: How to access Netmri API :: Remote :: DevicePhysical

Authority
Posts: 29
2748     0

This should give you the phyical model (and serial number) of each chassis:

 

my $client = new NetMRI::API({
api_version => '3.0',
});

 


my @devices = $client->broker->device->find({

 

# find all devices where Vendor = Cisco
op_DeviceVendor => '=', val_c_DeviceVendor => 'Cisco',

});

 

foreach my $device (@devices) {

  my @chassis = $client->broker->DevicePhysical->find({

 

  # find all components where DeviceID = Current Device
  op_DeviceID => '=', val_c_DeviceID => $device->DeviceID,


  # find all components where Physical Class = Chassis
  op_PhysicalClass => '=', val_c_PhysicalClass => 'chassis',

  });

 

  foreach my $chassis (@chassis) {

    print $chassis->PhysicalModelName, "/t",

    $chassis->PhysicalSerialNum, "/r/n";
  }
}

Showing results for 
Search instead for 
Do you mean 

Recommended for You