Posted on January 30, 2020 1:52 am
 |  Asked by Armando Reyes
 |  193 views
RESOLVED
0
0
Print Friendly, PDF & Email

Hello,

does anyone already tried the locateMac.py scrip? I’m not able to run it from any switch.

Thanks!

3
Posted by Sreelekha
Answered on January 30, 2020 4:37 pm

Hi Armando,

Thanks for writing to the forum.

I have tried the script locally in my lab switch and it worked fine.

mt701...16:07:49(config)#findmac 000a
Searching....

MAC Address Hostname Interface VLAN Status
------------------ --------- ---------- --------- ---------
00:0a:00:0a:00:0a mt701 Ethernet1/1 1 Found

This works based on the eAPI request to the switch, did you happen to configure the following user on the switch?

username arista privilege 15 role network-admin secret arista

the above configuration is mandatory as the script uses these credentials to pull the data.

In addition, do you have the management interface in the default VRF? If not, you will have to configure the following as well:

Arista#config
Arista(config)#management api http-commands
Arista(config)#no shut
Arista(config)#vrf MGMT
Arista(config)#no shut
Arista(config)#end

Arista#config
Arista(config)#alias findmac bash sudo ip netns exec ns-MGMT /mnt/flash/locateMac.py %1
Arista(config)#end
Arista#write

Cheers,
Sreelekha

0
Posted by Armando Reyes
Answered on January 30, 2020 11:30 pm

Hello Sreelekha,
Thanks a lot for your quick reply. I changed the user and pass for the one with those privileges that is already in the switch. I dont think is the script itself since now Im getting this:

BRLAB-L1(config)#findmac c52a
sudo: unable to execute /mnt/flash/locateMac.py: No such file or directory
% 'sudo /mnt/flash/locateMac.py c52a' returned error code: 1

however, is supposed the user should have access to the directory, correct?

Thanks!

0
Posted by Armando Reyes
Answered on January 30, 2020 11:44 pm

I'm not sure if my last answer got deleted since I dont see it..

I'm getting this:

BRLAB-L1(config)#findmac c52a
exec of "/mnt/flash/locateMac.py" failed: No such file or directory
% 'sudo ip netns exec ns-management /mnt/flash/locateMac.py c52a' returned error code: 1

thanks a gain !

1
Posted by Armando Reyes
Answered on February 4, 2020 12:09 am

FYI,

I found the problem. Apparently I need to create the script using the vi editor inside of the switch itself instead of transfer it from a windows machine, other wise the switch (or Linux) wont recognize it as a valid script file.

I hope someone find it useful.

0
Posted by Sreelekha
Answered on February 4, 2020 4:11 am

Hi Armando,

Thanks for the response.

The switch is not able to find the file in /mnt/flash.

Can you confirm if you had copied the script to /mnt/flash?

Regards,
Sreelekha

Post your Answer

You must be logged in to post an answer.