Skip to content

OF Config Demo

shivarammysore edited this page Apr 3, 2013 · 11 revisions

OF-Config demonstration

1. Init

Start LINC without any controllers

LINC has to be started with root priviledges, because by default NETCONF is using port 830.

root% cd $LINC_ROOT
root% make
root$ ./rel/linc/bin/linc console

Start the controller

Right now the controller has to be started before adding it to LINC.

user% cd $LINC_ROOT/scripts
user% ./of_controller.sh
Erlang R15B02 (erts-5.9.2) [source] [64-bit] [smp:4:4] [async-threads:0] [kernel-poll:false]

Eshell V5.9.2  (abort with ^G)
1>

Connect with enetconf_client

user% cd $LINC_ROOT/deps/enetconf
user% erl -pa ebin
1> {ok, C} = enetconf_client:connect("localhost", [{user, "linc"}, {password, "linc"}]).
{ok, <0.XXX.0>}

Connect with Yuma

After building and installing Yuma few different applications become available via command line. One of them is yangcli, which is interactive client for Netconf.

Create a bash script file which will run yangcli. Running this script will connect to the enetconf or other Netconf server, exchange packets and wait for interactive input. You can read about yangcli commands and syntax here: http://doc.yumaworks.com/manuals/v2/html/yangcli/yuma-yangcli-manual3.xhtml

#!/bin/bash
yangcli --server=localhost --ncport=830 --user=guest --password=guest

2. Check there are no controllers configured

We can check that no controllers are configured with OF-Config:

Using enetconf_client

2> {ok, X} = enetconf_client:get_config(C, running).
{ok, <<"<?xml ... ">>}
3> io:format("~p~n", [X]).
<<"<?xml ... <rpc-reply ... <controllers/> ... ">>

Using Yuma

Connect to yangcli as described above. Type in yangcli:

get-config source=running

Directly on LINC

We can also check directly on the LINC switch:

1> rr(of_config).
[capabilities, capable_switch ...]
2> supervisor:which_children(ofs_receiver_sup).
[]
3> mnesia:dirty_read(linc_ofconfig, running).
[{ofconfig, running, #capable_switch{... controllers = [], ...

3. Add a controller via OF-Config

We now add a new controller to the LINC configuration using the edit-config operation.

Using enetconf_client

4> IP = "127.0.0.1",
   Port = "6633",
   Controller = {controller, [{id, ["Controller0"]}, {role, ["master"]},
                              {'ip-address', [IP]}, {port, [Port]}, {protocol, ["tcp"]}]},
   Attributes = [{'xmlns:xsi', "http://www.w3.org/2001/XMLSchema-instance"},
                 {'xsi:schemaLocation', "urn:onf:of111:config:yang ../priv/of-config-1.1.1.xsd"},
                 {xmlns, "urn:onf:of111:config:yang"},
                 {'xmlns:ds', "http://www.w3.org/2000/09/xmldsig#"}],
   Config = {'capable-switch', Attributes,
             [{id, ["CapableSwitch0"]}, {'logical-switches',
              [{'switch', [{id, ["LogicalSwitch0"]}, {'datapath-id', ["11:11:11:11:11:11:11:11"]},
               {enabled, ["true"]}, {controllers, [Controller]}]}]}]}.
{'capable-switch', ...
5> {ok, Y} = enetconf_client:edit_config(C, running, {xml, Config}).
{ok, <<"<?xml ... <rpc-reply ...

Using Yuma

Yuma is capable of complex commands involving calling get/edit-config and operations on XML subtrees. Simplest operation without manually picking up subtrees and keys is edit-config: replace whole config with file contents.

Prepare a configuration in XML file, say config1.xml. Run:

edit-config target=running [email protected]

or more complex example

edit-config target=candidate default-operation=merge test-option=test error-option=stop-on-error\
            [email protected]

4. Check that a new controller was added

We can see that LINC connected to the controller on the controller side:

XX:XX:XX.XXX [info] Accepted connection from #Port<0.XXXX> {{127,0,0,1}, XXXXX}

We can confirm that using get-config operation:

Using enetconf_client

6> {ok, Z} = enetconf_client:get_config(C, running).
{ok, <<"<?xml ... ">>}
7> io:format("~p~n", [Z]).
<<"<?xml ... <rpc-reply ... <controllers><controller ... </controllers> ... ">>

Using Yuma

Same as above, execute command in yangcli console:

get-config source=running

Directly on LINC

4> supervisor:which_children(ofs_receiver_sup).
[{'127.0.0.1_6633', <0.XXX.0>, worker, [ofs_receiver]}]
5> mnesia:dirty_read(linc_ofconfig, running).
[{ofconfig, running, #capable_switch{... controllers = [#controller{ ... }], ...

Clone this wiki locally