Category Archives: On Programming

Really cool (and useful) programming stanzas for Network Engineers

Using Junos PyEZ with Xcode 5.1.1

 

Python has become a sponsored language for automation and scripting for their products by two of the largest vendors: Cisco and Juniper – Kudos to Python! – it is definitely a clear, uncomplicated language to get your programming work done.

However, there is no consensus among Python programmers on what the most convenient Integrated Development Environments (IDE) for your Python needs. Tthere are plenty of of IDE options available – including the very effective option of writing your Python code in a text file, name the file with the .py extension and run it from your terminal using the command: python <filename>.py.

My preference is to leverage Apple’s Xcode as my Python IDE and to use it in my MacAir under MacOS 10.10.3 (Yosemite). So, this post’s purpose is to provide an example of how Xcode can be leverage for Python programming to remotely access a network device, in this case a Juniper Networks’ SRX210.

First, you need to have your Xcode environment installed. I have Xcode 5.1.1 installed in my MacAir. For a URL where the instructions to install Xcode in your Mac Air can be found, click here.

Once your Xcode version is installed, you need to setup Xcode to run Python. This procedure is often convoluted as presented by many sites, but I found the instructions found in this link very clear.

Once you are ready for your Python code, it is required to setup the network device (the SRX210 in this case), to accept remote python scripting. In the Juniper SRX we are using, this is done by activating the Netconf over ssh protocol as shown below:

yardiel@srx-210h-mint# set netconf ssh

[edit system services]

yardiel@srx-210h-mint# commit and-quit

commit complete

Exiting configuration mode

yardiel@srx-210h-mint>

At this point, your Xcode IDE should be ready to run your xcode python code.  Enjoy it.

Yardiel