Introduction to SDN OpenDayLight

This topic is to discuss the following lesson:

WOW Rene!!!
Nice and clear explanation.
God Bless you!

Hello Rene,
can you please explain to us more about RESTCONF and NETCONF and what is the difference? also can we integrate ODL controller with regular Cisco devices in GNS3 ?

thanks

Hi @ammar.eng100

There’s not really a quick answer to this but to get an idea what NETCONF and RESTCONF are about, let me show you an example. This is done on an CSR1000V router running IOS XE.

## RESTCONF

Here’s an example of NETCONF on a Cisco IOS router. It’s an alternative to the CLI where you can use XML to retrieve information or to configure the device. It uses RPC for transport and can be used through SSH:

R1(config)#netconf ssh

Let’s log in:

$ ssh admin@192.168.1.1 -s netconf

The router will respond with a hello like this:

<?xml version="1.0" encoding="UTF-8"?>
<hello
	xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
	<capabilities>
		<capability>urn:ietf:params:netconf:base:1.0</capability>
		<capability>urn:ietf:params:netconf:capability:writeable-running:1.0</capability>
		<capability>urn:ietf:params:netconf:capability:startup:1.0</capability>
		<capability>urn:ietf:params:netconf:capability:url:1.0</capability>
		<capability>urn:cisco:params:netconf:capability:pi-data-model:1.0</capability>
		<capability>urn:cisco:params:netconf:capability:notification:1.0</capability>
	</capabilities>
	<session-id>2035438880</session-id></hello>]]>]]>

We need to send a hello to the router:

<?xml version="1.0" encoding="UTF-8"?>
<hello xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
    <capabilities>
        <capability>urn:ietf:params:netconf:base:1.0</capability>
    </capabilities>
</hello>]]>]]>

Now we can send commands, for example, request the configuration of an interface:

<?xml version="1.0"?>
<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"xmlns:cpi="http://www.cisco.com/cpi_10/schema"
message-id="101">
   <get-config>
        <source>
             <running/>
         </source>
          <filter>
              <config-format-text-cmd>
               <text-filter-spec>
        interface GigabitEthernet2
                 </text-filter-spec>
              </config-format-text-cmd>
          </filter>
      </get-config>

This is what the router will send:

<?xml version="1.0" encoding="UTF-8"?><rpc-reply message-id="101" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"><data><cli-c</cmd>data><cmd>!
</cmd>nterface GigabitEthernet2
</cmd>ip address dhcp
</cmd>negotiation auto
</cmd></cli-config-data></data></rpc-reply>]]>]]>

We get the configuration of the GigabitEthernet2 interface in XML format. The advantage of these XML outputs is that they can easily be parsed by scripts, making it easier to automate things.

## RESTCONF

A bit similar as NETCONF but it uses an API through HTTP:

R1(config)#restconf
R1(config)#virtual-service csr_mgmt
R1(config-virt-serv)#ip shared host-interface GigabitEthernet 2
R1(config-virt-serv)#activate

Now we do an HTTP REQUEST for this URL:

http://192.168.1.1/restconf/api/config/native/interface/GigabitEthernet/2/ip/address

And we receive an XML object in return:

<address
	xmlns="http://cisco.com/ns/yang/ned/ios"
	xmlns:y="http://tail-f.com/ns/rest"
	xmlns:ios="http://cisco.com/ns/yang/ned/ios">
	<dhcp/>
</address>

Above you can see that the IP address was assigned by DHCP.

Since IOS XE supports NETCONF / RESTCONF, you could use it with a controller that configures these devices. I believe ODL does have support for IOS XE. In my SDN example, the control plane is only in the controller…not in the devices anymore.

Hope this helps!

Forgot to mention, APIC-EM does have support for most Cisco routers/switches.

Hi,
In the SDN topic you have explained , do we need to run mininet and sdn controller both on single machine as two seperate virtual machines?

Hi @veera.krn

Both options are possible, whatever you prefer. It’s possible to create a single virtual machine that includes mininet and multiple SDN controllers.

Personally, I like to use the VM images that are offered. Mininet also has a pre-installed image:

http://mininet.org/download/

OpenDayLight has a VM image that includes their SDN controller and mininet:

https://wiki.opendaylight.org/view/CrossProject:Integration_Group:Test_VMs

Using these images usually saves you a lot of time compared to installing everything from source yourself.

Hi Rene,

I have difficulties understanding this step. sorry, not so familiar with Linux commands:

Open the following file in your favorite text editor:

$ vim ~/.bashrc
And add the following line to set the JAVA_HOME variable:

export JAVA_HOME=/usr/lib/jvm/default-java
Save the file and execute the bashrc file:

$ source ~/.bashrc

Hello Hany

vim is a CLI text editor in Linux. You can find out more about vim and getting started with quick commands here.

Secondly, the command $ vim ~/.bashrc means open the “.bashrc” file (yes the full stop “.” is part of the file name) in the vim CLI text editor. The “~/” is just an indication of the user’s home directory. The $ just shows the prompt belongs to a normal user account.

So, the command $ vim ~/.bashrc essentially says a user wants to open the .bashrc file which is in the user’s home directory using the vim CLI text editor.

Now once you have it open, you should see its contents. Go to the end of the file (using the command keys indicated in the link provided above) and add the text “export JAVA_HOME=/usr/lib/jvm/default-java”

Finally, save and close the file (again using the commands from the link). Issue the final command. The source command essentially tells the operating system to run the .bashrc file. It executes the commands implemented in there including the additional export command you added.

I hope this has been helpful!

Laz

hello guys,

do you have any idea why get this issue ;

mininet@mininet-vm:~/distribution-karaf-0.6.4-Carbon$ ./bin/karaf
karaf: JAVA_HOME is not valid: /usr/lib/jvm/default-java

Hi Ali,

Looking at these posts:

https://ask.opendaylight.org/question/7019/java_home-not-avalid/

This error seems to occur when it can’t find Java. Did you install it? Otherwise, it seems you can fix it by setting the environment variable with the correct java folder.

You can try some of the docker containers out there. This saves quite some time. For example:

https://hub.docker.com/r/glefevre/opendaylight/

Rene

In case anyone wants to know more about NETCONF, RESTCONF, and gRPC…I just published a lesson that covers these three protocols:

Hi Rene,

I am trying to get OpenDaylight to work but I’m having some difficulty. I have installed your VM but now when i open ./bin/karaf… how do i get to the web GUI of Opendaylight? this is where im stuck.

Hello Edgar

In order to access the web GUI, you will have to input the URL in the web browser of your PC. You don’t access the interface from the actual VM itself. You will have to use the IP address that ens160 has obtained via DHCP to gain network access to the interface.

I hope this has been helpful!

Laz

1 Like

Thank you… I think thats where i got confused.

1 Like

Dear Rene,
I was able to follow all the lab except the part where I am supposed to run the script in python. I get the following syntax error:


Can you please tell me the mistake?


Regards,
–Gaby :slight_smile:

Btw, my python is operational:


Regards,
–Gaby

Hi Gaby,

Are you using python 3? The syntax for the print command is different for python 2 or 3.

Python 2:

ip_address = "1.2.3.4"
mac_address = "FC-77-74-EA-F2-FE"
print "Found host with MAC address %s and IP address %s" % (mac_address, ip_address)
Found host with MAC address FC-77-74-EA-F2-FE and IP address 1.2.3.4

Python 3:

ip_address = "1.2.3.4"
mac_address = "FC-77-74-EA-F2-FE"
print "Found host with MAC address %s and IP address %s" % (mac_address, ip_address)
SyntaxError: invalid syntax

In python 3 you have to use parenthesis for the print command like this:

print("hello")

Or in our example:

print("Found host with MAC address %s and IP address %s" % (mac_address, ip_address))
Found host with MAC address FC-77-74-EA-F2-FE and IP address 1.2.3.4

Python 2 is still the most popular version but will retire on 1-1-2020. When you use Python, it’s best to use version 3 now. I’ll update my material so it works on Python 3.

Hope this helps!

Rene

Hello Rene,
Yes, I am using Python 3. I will use the parenthesis as per your suggetion. I will let you know if it works.
Thanks!
MGO

Hello Rene,
Just letting you know that this worked. Thank you!!!