Reply

How to establish a connection with in the job by using IPAddress by using Python - NetMRI easy?

New Member
Posts: 3
3866     0

Hi Infoblox team,

 

I'm working on IOS device upgrades by using NetMRI along with Python. As part of this initiative i have to upgrade "Cisco ASA-X-Series" switches, which has failover mechanisam. By using the command "show failover" we will get primary and secondary device IP address. 

 

Can you please help me or guide me to built some sample to establish the connection by using IPAddress from Python job by using NetMRI easy? 

When we run the job we will selct primary host ip or hostname from the device list, however on the script we will get IP of secondary device which is tagged with the selected primary device. I need to establish connection(custom way) from the script with secondary device and invoke some commands on it.

 

In case there is any sample script to show how to establish custom connection by using netmri easy then please provide, i will use it as areference to build my upgrade job.

 

Thanks,

Ramu

Re: How to establish a connection with in the job by using IPAddress by using Python - NetMRI easy?

Adviser
Posts: 65
3866     0

If you run a python script as a job from the UI you specify which device to connect to at runtime.

 

Outside of the GUI there are 2 ways how to create a connection: as an object and as a context manager. The last option if more preferable cause it will close session after the script will complete and also will close connection if something inside script causes exception.

 

    from infoblox_netmri.easy import NetMRIEasy

    # variables will be provided by NetMRI
    defaults = {
        "api_url": api_url,
        "http_username": http_username,
        "http_password": http_password,
        "job_id": job_id,
        "device_id": device_id,
        "batch_id": batch_id
    }

    easy = NetMRIEasy(**defaults)
    easy.device_id

    #this option is more preferable
    with NetMRIEasy(**defaults) as easy:
        easy.device_id

For your usecase you can connect to a device, get version and the output for primary or secondary. Then validate if the device is running old code and is secondary, if so upgrade the device. After the upgrade failover and upgrade the other.

 

Re: How to establish a connection with in the job by using IPAddress by using Python - NetMRI easy?

New Member
Posts: 3
3866     0

Thanks for your reply Ingmar.

 

As per the code snippet it seems like details to defaults will be provided by NetMRI based on our device selection on the UI side(run time).

So the device id will be provided by NetMRI and then it will connect to device without any IP or hostname. Whle running the Job on UI side we will select the primary device, so it will automatically connect to promary device, with in the sane script is there any way to connect to secondary device by using its IP?

 

If i understand it correctly on lines how to upgrade primary and secondary, your suggestion is to do the upgrade on pri first and verify boot sequence on pri, failover it to secondary before reload the pri. and then perform the same steps with secondary device(select the device from UI while launching the job). Correct me if my understanding is wrong.

 

Thanks,

Ramu

Showing results for 
Search instead for 
Did you mean: 

Recommended for You