Commit cff640d7 authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

Test Ryu OpenFlow:

- Renamed folder and files
- Added composition of Ryu docker image
parent 719df434
Loading
Loading
Loading
Loading
+0 −61
Original line number Diff line number Diff line
{
    "links": [
        {    
    "link_id": {"link_uuid": {"uuid": "h1/h1-eth0==0000000000000002/s2-eth3"}},
    "link_endpoint_ids": [
        {"device_id": {"device_uuid": {"uuid": "h1"}}, "endpoint_uuid": {"uuid": "h1-eth0"}},
        {"device_id": {"device_uuid": {"uuid": "0000000000000002"}}, "endpoint_uuid": {"uuid": "s2-eth3"}}
    ]
},
{
    "link_id": {"link_uuid": {"uuid": "0000000000000002/s2-eth3==h1/h1-eth0"}},
    "link_endpoint_ids": [
        {"device_id": {"device_uuid": {"uuid": "0000000000000002"}}, "endpoint_uuid": {"uuid": "s2-eth3"}},
        {"device_id": {"device_uuid": {"uuid": "h1"}}, "endpoint_uuid": {"uuid": "h1-eth0"}}
            ]
        },
        {    
    "link_id": {"link_uuid": {"uuid": "h2/h2-eth0==0000000000000002/s2-eth4"}},
    "link_endpoint_ids": [
        {"device_id": {"device_uuid": {"uuid": "h2"}}, "endpoint_uuid": {"uuid": "h2-eth0"}},
        {"device_id": {"device_uuid": {"uuid": "0000000000000002"}}, "endpoint_uuid": {"uuid": "s2-eth4"}}
    ]
},
{
    "link_id": {"link_uuid": {"uuid": "0000000000000002/s2-eth4==h2/h2-eth0"}},
    "link_endpoint_ids": [
        {"device_id": {"device_uuid": {"uuid": "0000000000000002"}}, "endpoint_uuid": {"uuid": "s2-eth4"}},
        {"device_id": {"device_uuid": {"uuid": "h2"}}, "endpoint_uuid": {"uuid": "h2-eth0"}}
            ]
        },
        {    
    "link_id": {"link_uuid": {"uuid": "h3/h3-eth0==0000000000000005/s5-eth3"}},
    "link_endpoint_ids": [
        {"device_id": {"device_uuid": {"uuid": "h3"}}, "endpoint_uuid": {"uuid": "h3-eth0"}},
        {"device_id": {"device_uuid": {"uuid": "0000000000000005"}}, "endpoint_uuid": {"uuid": "s5-eth3"}}
    ]
},
{
    "link_id": {"link_uuid": {"uuid": "0000000000000005/s5-eth3==h3/h3-eth0"}},
    "link_endpoint_ids": [
        {"device_id": {"device_uuid": {"uuid": "0000000000000005"}}, "endpoint_uuid": {"uuid": "s5-eth3"}},
        {"device_id": {"device_uuid": {"uuid": "h3"}}, "endpoint_uuid": {"uuid": "h3-eth0"}}
            ]
        },
        {    
    "link_id": {"link_uuid": {"uuid": "h4/h4-eth0==0000000000000005/s5-eth4"}},
    "link_endpoint_ids": [
        {"device_id": {"device_uuid": {"uuid": "h4"}}, "endpoint_uuid": {"uuid": "h4-eth0"}},
        {"device_id": {"device_uuid": {"uuid": "0000000000000005"}}, "endpoint_uuid": {"uuid": "s5-eth4"}}
    ]
},
{
    "link_id": {"link_uuid": {"uuid": "0000000000000005/s5-eth4==h4/h4-eth0"}},
    "link_endpoint_ids": [
        {"device_id": {"device_uuid": {"uuid": "0000000000000005"}}, "endpoint_uuid": {"uuid": "s5-eth4"}},
        {"device_id": {"device_uuid": {"uuid": "h4"}}, "endpoint_uuid": {"uuid": "h4-eth0"}}
            ]
        }
    ]
}
+0 −71
Original line number Diff line number Diff line
{
    "contexts": [
        {"context_id": {"context_uuid": {"uuid": "admin"}}}
    ],
    "topologies": [
        {
            "topology_id": {
                "context_id": {"context_uuid": {"uuid": "admin"}},
                "topology_uuid": {"uuid": "admin"}
            }
        }
    ],
    "devices": [
        {
            "device_id": {"device_uuid": {"uuid": "RYU"}}, "device_type": "openflow-ryu-controller",
            "device_config": {"config_rules": [
                {"action": 1, "custom": {"resource_key": "_connect/address", "resource_value": "10.1.7.197"}},
                {"action": 1, "custom": {"resource_key": "_connect/port", "resource_value": "8080"}},
                {"action": 1, "custom": {"resource_key": "_connect/settings", "resource_value": {"timeout": 120}}}
            ]},
            "device_drivers": ["DEVICEDRIVER_RYU"]
        },
    {
        "device_id": {"device_uuid": {"uuid": "h1"}}, "device_type": "emu-client", "device_drivers": [0],
        "device_config": {"config_rules": [
            {"action": 1, "custom": {"resource_key": "_connect/address", "resource_value": "127.0.0.1"}},
            {"action": 1, "custom": {"resource_key": "_connect/port", "resource_value": "0"}},
            {"action": 1, "custom": {"resource_key": "_connect/settings", "resource_value": {"endpoints": [
                {"uuid": "h1-eth0", "type": "copper/internal","mac_address":"00:00:00:00:00:01"},
                {"uuid": "int", "type": "copper/internal"}
            ]}}}
        ]}
    },
    {
        "device_id": {"device_uuid": {"uuid": "h2"}}, "device_type": "emu-client", "device_drivers": [0],
        "device_config": {"config_rules": [
            {"action": 1, "custom": {"resource_key": "_connect/address", "resource_value": "127.0.0.1"}},
            {"action": 1, "custom": {"resource_key": "_connect/port", "resource_value": "0"}},
            {"action": 1, "custom": {"resource_key": "_connect/settings", "resource_value": {"endpoints": [
                {"uuid": "h2-eth0", "type": "copper/internal"},
                {"uuid": "int", "type": "copper/internal"}
            ]}}}
        ]}
    },
    {
        "device_id": {"device_uuid": {"uuid": "h3"}}, "device_type": "emu-client", "device_drivers": [0],
        "device_config": {"config_rules": [
            {"action": 1, "custom": {"resource_key": "_connect/address", "resource_value": "127.0.0.1"}},
            {"action": 1, "custom": {"resource_key": "_connect/port", "resource_value": "0"}},
            {"action": 1, "custom": {"resource_key": "_connect/settings", "resource_value": {"endpoints": [
                {"uuid": "h3-eth0", "type": "copper/internal"},
                {"uuid": "int", "type": "copper/internal"}
            ]}}}
        ]}
    },
    {
        "device_id": {"device_uuid": {"uuid": "h4"}}, "device_type": "emu-client", "device_drivers": [0],
        "device_config": {"config_rules": [
            {"action": 1, "custom": {"resource_key": "_connect/address", "resource_value": "127.0.0.1"}},
            {"action": 1, "custom": {"resource_key": "_connect/port", "resource_value": "0"}},
            {"action": 1, "custom": {"resource_key": "_connect/settings", "resource_value": {"endpoints": [
                {"uuid": "h4-eth0", "type": "copper/internal"},
                {"uuid": "int", "type": "copper/internal"}
            ]}}}
        ]}
    }
    ]
}


+0 −3
Original line number Diff line number Diff line
sudo mn -c
ryu-manager --observe-links ryu.app.ofctl_rest ryu.app.gui_topology.gui_topology
sudo python3 ~/mininet/custom_pentagon_topology.py
 No newline at end of file
+31 −0
Original line number Diff line number Diff line
# Copyright 2022-2024 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

FROM python:3.9-slim

RUN apt-get update && apt-get install -y --no-install-recommends iproute2 tree git && rm -rf /var/lib/apt/lists/*

RUN pip install --no-cache-dir --upgrade pip
# NOTE: Ryu 4.34 expects eventlet.wsgi.ALREADY_HANDLED, which disappears in Eventlet ≥ 0.30.3.
RUN pip install --no-cache-dir "setuptools" "wheel" "git+https://github.com/faucetsdn/ryu.git@v4.34" "eventlet<0.30.3"

#COPY apps/ /opt/ryu-apps/  # Copy Ryu Apps, if any
WORKDIR /opt/ryu-apps

# --- OpenFlow & Ryu REST API ports ---
EXPOSE 6653/tcp 8080/tcp

RUN tree -a /usr/local/lib/python3.9/site-packages/ryu/app/gui_topology/

CMD ["ryu-manager", "--verbose", "--observe-links", "ryu.app.ofctl_rest", "ryu.app.gui_topology.gui_topology"]
+28 −0
Original line number Diff line number Diff line
sudo mn -c
ryu-manager --observe-links ryu.app.ofctl_rest ryu.app.gui_topology.gui_topology
sudo python3 ~/tfs-ctrl/src/tests/ryu-openflow/custom_pentagon_topology.py

curl -X POST \
    --header "Content-Type: application/json" \
    --data @ietf-l3vpn-service.json \
    --user "admin:admin" \
    http://127.0.0.1/restconf/data/ietf-l3vpn-svc:l3vpn-svc/vpn-services



4. Build and run
# from ryu-docker/
docker compose build         # or: docker build -t ryu-local .
docker compose up -d         # or: docker run -d --network host ryu-local
You should now see the usual Ryu banner in docker compose logs -f.

5. Start Mininet on the host
sudo mn --topo single,3 \
        --controller remote,ip=127.0.0.1,port=6653 \
        --switch ovs,protocols=OpenFlow13
127.0.0.1 works because the container is in host network mode.
If you prefer normal bridge networking, publish the port instead:

docker run -d -p 6653:6653 -p 8080:8080 ryu-local
# …then tell Mininet ip=<host-IP>
Verify the switch talks OpenFlow 1.3 (protocols=OpenFlow13) unless your app requires 1.0.
Loading