Configuring ONS SDN Controllers for Single Device Connection using Two Protocols
ONS SDN (Open Network Software-Defined Networking) controllers are network devices that can be configured to manage and control network functions. In this article, we will discuss how to configure ONS SDN controllers for single device connection using two protocols: NETCONF and RESTCONF.
What is NETCONF and RESTCONF?
NETCONF (Network Configuration Protocol) is a network management protocol that provides a secure and standard way of configuring network devices. It uses a simple text-based protocol to communicate with the device and supports both XML and YANG data models.
RESTCONF (Representational State Transfer Configuration Protocol) is a network management protocol that provides a RESTful interface to network devices. It uses HTTP(S) as the transport protocol and supports JSON and XML data models. RESTCONF is built on top of the YANG data model and provides a more flexible and scalable way of configuring network devices compared to NETCONF.
Configuring ONS SDN Controllers using NETCONF
To configure ONS SDN controllers using NETCONF, we need to establish a connection to the device using the NETCONF protocol. The following is an example of how to do this:
import ncclient
# Connect to the device using NETCONF
conn = ncclient.connect(host='192.168.8.220', port=830, username='admin', password='password')
# Get the device's capabilities
capabilities = conn.server_capabilities
# Create a session with the device
session = conn.session
# Load the YANG data model for configuration
schema = session.get_schema('ietf-interfaces:interfaces')
# Create a new interface configuration
interface = {
'name': 'ethernet1',
'description': 'New Ethernet Interface',
'type': 'iana-if-type:ethernetCsmacd',
'enabled': True,
'ip': {
'address': {
'ip': '192.168.1.1',
'netmask': '255.255.255.0'
}
}
}
# Create a new interface using the YANG data model
new_interface = schema.get_module('ietf-interfaces').get_node('interfaces').add(interface)
# Commit the configuration changes
session.commit()
In the above example, we first connect to the device using the ncclient.connect() function, which establishes a NETCONF connection to the device. We then get the device's capabilities using the conn.server_capabilities property, which returns a list of the device's supported capabilities. We then create a session with the device using the conn.session property, which allows us to communicate with the device using the NETCONF protocol.
Next, we load the YANG data model for configuration using the session.get_schema() function, which returns a YANG data model object that we can use to create new configurations. We then create a new interface configuration using the YANG data model object, which we can add to the device using the schema.get_node().add() method.
Finally, we commit the configuration changes using the session.commit() method, which applies the changes to the device. Note that the configuration changes are not applied to the device until the session.commit() method is called.
Configuring ONS SDN Controllers using RESTCONF
To configure ONS SDN controllers using RESTCONF, we need to establish a connection to the device using the RESTCONF protocol. The following is an example of how to do this:
import requests
#
In the above example, we first establish a RESTCONF connection to the device using the requests.get() function, which sends a GET request to the device's RESTCONF endpoint. We then authenticate the request using the Authorization header, which contains the username and password for the device. We then retrieve the device's capabilities using the GET /restconf/capabilities endpoint, which returns a list of the device's supported capabilities.
Next, we create a new interface configuration using the YANG data model object, which we can add to the device using the POST /restconf/config/ietf-interfaces:interfaces endpoint. We then commit the configuration changes using the PUT /restconf/data/ietf-interfaces:interfaces endpoint, which applies the changes to the device.
- ONS SDN controllers can be configured for single device connection using two protocols: NETCONF and RESTCONF.
- NETCONF is a network management protocol that provides a secure and standard way of configuring network devices using a simple text-based protocol.
- RESTCONF is a network management protocol that provides a RESTful interface to network devices using HTTP(S) as the transport protocol.
- NETCONF and RESTCONF both support the YANG data model, which provides a flexible and scalable way of configuring network devices compared to traditional CLI-based methods.