Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

Navigation
Guide That Contains This Content
[+] Expand All
[-] Collapse All

    Building Your First JET Application

    This tutorial leads you through building a JET application that has no dependency on C or C++ modules and does not have to be signed. In this tutorial, we will set up JET request response session and then add and delete an interface. For the complete application example, see the JET Interfaces Application.

    To develop JET applications, see the following workflows in the Juniper Extension Toolkit Developer Guide:

    Note: Before you start writing code, you need to download the JET API package from juniper.net.

    To code the following example application, use your favorite IDE. Substitute your IP addresses for the ones used in the example.

    To develop your first JET application:

    1. Import the Python modules for this application.
      from jnpr.jet.JetHandler import *
      
    2. Create the client handler to connect to the server.
      try:
          client = JetHandler()
      
    3. Open a session with the server.
          client.OpenRequestResponseSession(device='127.0.0.1, port=9090, user='foo',password='bar',client_id=’myapp’)
      
      
    4. Create the client handler for interface service.
      intf_handle = client.GetInterfaceService()
      
    5. Create a new interface.
      int_ip = InterfaceAddressConfig('ge-0/0/0',0,InetFamilyType.INTF_AF_INET,'192.1.1.1/32')
      
      result = intf_handle.InterfaceAddressCreate(int_ip)
      print 'InterfaceAddressCreate : Invoked, return = ', result
      
    6. Delete the interface we just added.
      result = intf_handle.InterfaceAddressDelete(int_ip)
      print 'InterfaceAddressDelete : Invoked, return = ', result
      
    7. Close the session.
          client.CloseRequestResponseSession()
      
    8. Handle errors that might occur in the code.
      except Exception as tx:
          print '%s' % (tx.message)
    9. Use the Python packaging tool to create an unsigned package.
    10. Deploy the application on a Junos OS device.

    For the complete example application, see JET Interfaces Application.

    Modified: 2016-06-30