Introduction

What is OpenPnPy?

OpenPnPy is a python package implementing Cisco’s Network PnP protocol. It provides a server class, as well as utility functions to easily build PnP XML service messages.

To understand what Cisco Network PnP is all about, see https://developer.cisco.com/docs/network-plug-n-play/

Basic Usage

A PnP server with custom behavior can be defined by subclassing the openpnpy.server.PnpServer class, and implementing the handler methods.

Service messages to be returned by the handler methods can be built using functions provided by the openpnpy.messages module.

A very basic server implementation could look like this:

# myserver.py

#!/usr/bin/env python3

from openpnpy.server import PnpServer
from openpnpy.messages import device_info, backoff, bye


class MyServer(PnpServer):

    def handle_work_request(self, work_request):
        return device_info(type='all')

    def handle_work_response(self, work_response):
        if work_response.success:
            return bye()
        else:
            return backoff(seconds=30)


server = MyServer(__name__)


if __name__ == '__main__':
    server.run(host='0.0.0.0', port='1234')

Which can then be run like so:

python3 myserver.py