Network Automation using YANG Models across XE, XR, & NX

Installing The Bundle We Created


Install the Bundle

Having successfully generated a Python package using ydk-gen, it is now time to install so we can use it from a Python script. In the prior exercise, ydk-gen will have told you where your generated code was created. You need to use that location to pip install the package from.

Run the following while inside the ydk-gen directory.

    
    pip3.6 install gen-api/python/openconfig_interfaces_lab-bundle/dist/ydk-models-openconfig-interfaces-lab-0.1.0.tar.gz
    

The output should look as follows:

    
        [root@e135e13e734d ydk-gen]# pip3.6 install gen-api/python/openconfig_interfaces_lab-bundle/dist/ydk-models-openconfig-interfaces-lab-0.1.0.tar.gz
        Processing ./gen-api/python/openconfig_interfaces_lab-bundle/dist/ydk-models-openconfig-interfaces-lab-0.1.0.tar.gz
        Installing collected packages: ydk-models-openconfig-interfaces-lab
        Running setup.py install for ydk-models-openconfig-interfaces-lab ... done
        Successfully installed ydk-models-openconfig-interfaces-lab-0.1.0
        You are using pip version 9.0.3, however version 10.0.0 is available.
        You should consider upgrading via the 'pip install --upgrade pip' command.
    

At this point your Docker container will have your custom-built openconfig_interfaces_lab package installed.

Verify Bundle Installation

To truly verify that the package has been installed, lets take a look at pip freeze.

    
    pip3.6 freeze | grep ydk-models-openconfig-interfaces-lab
    

The output should look as follows:

    
        [root@e135e13e734d ydk-gen]# pip3.6 freeze | grep ydk-models-openconfig-interfaces-lab
        ydk-models-openconfig-interfaces-lab==0.1.0
        [root@e135e13e734d ydk-gen]#
    

Perfect! We see that ydk-models-openconfig-interfaces-lab==0.1.0 has been installed and is listed as a package visible to Python. Next we would like to import classes from this generated package to verify that we can actually use it in Python.