Automatisierung von Netzwerkdiensten oder Aufbau eines virtuellen Labors mit OpenDaylight, Postman und Vrnetlab



In diesem Artikel werde ich Ihnen erklären , wie Sie OpenDaylight für die Arbeit mit Netzwerkgeräten konfigurieren und wie Sie diese Geräte mithilfe von Postman und einfachen RESTCONF- Anforderungen steuern können. Wir werden nicht mit Hardware arbeiten, sondern stattdessen kleine virtuelle Labore mit einem einzigen Router unter Verwendung von Vrnetlab auf Ubuntu 20.04 LTS bereitstellen .



Ich werde die detaillierte Konfiguration zuerst am Beispiel eines Juniper vMX 20.1R1.11-Routers zeigen und sie dann mit der Cisco xRV9000 7.0.2- Konfiguration vergleichen .



Inhalt



  • Erforderliche Kenntnisse
  • 1: OpenDaylight ( ODL), Postman Vrnetlab
  • 2:
  • 3: OpenDaylight
  • 4: Vrnetlab
  • 5: Postman (Juniper vMX) ODL
  • 6: Postman ODL
  • 7: Cisco xRV9000
  • P.S.




, , ( , ).



, , ( ) :





1:





  • SDN , Linux Foundation
  • Java inside
  • Model-Driven Service Abstraction Level (MD-SAL)
  • YANG RESTCONF API


. . API.



OpenDaylight .





  • API


REST API OpenDaylight'. , , , Postman .



: ().





  • Docker'
  • : Cisco XRv, Juniper vMX, Arista vEOS, Nokia VSR .
  • Open Source


, . Juniper vMX Cisco xRV9000 Ubuntu 20.04 LTS.



.



2:



:







  • Juniper vMX Docker ( Vrnetlab) .
  • ODL .
  • Postman ODL: / , .




Juniper vMX ODL . vMX 6 Gb 4 . "" (Heulett Packard Enterprise MicroServer ProLiant Gen8, Ubuntu 20.04 LTS). , , "", .



3: OpenDaylight





ODL — Magnesium SR1



1) Java OpenJDK 11 ( )



ubuntu:~$ sudo apt install default-jdk


2) ODL

3)

4)

5) ./bin/karaf



ODL ( 8181, ).



ODL Features, NETCONF RESTCONF. ODL :



opendaylight-user@root> feature:install odl-netconf-topology odl-restconf-all


ODL . ( ).



4: Vrnetlab







Vrnetlab . Docker, git, sshpass:



ubuntu:~$ sudo apt update
ubuntu:~$ sudo apt -y install python3-bs4 sshpass make
ubuntu:~$ sudo apt -y install git
ubuntu:~$ sudo apt install -y \
    apt-transport-https ca-certificates \
    curl gnupg-agent software-properties-common
ubuntu:~$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
ubuntu:~$ sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"
ubuntu:~$ sudo apt update
ubuntu:~$ sudo apt install -y docker-ce docker-ce-cli containerd.io


Vrnetlab



Vrnetlab github:



ubuntu:~$ cd ~
ubuntu:~$ git clone https://github.com/plajjan/vrnetlab.git


vrnetlab:



ubuntu:~$ cd ~/vrnetlab


, . , :



ubuntu:~/vrnetlab$ ls
CODE_OF_CONDUCT.md  config-engine-lite        openwrt           vr-bgp
CONTRIBUTING.md     csr                       routeros          vr-xcon
LICENSE             git-lfs-repo.sh           sros              vrnetlab.sh
Makefile            makefile-install.include  topology-machine  vrp
README.md           makefile-sanity.include   veos              vsr1000
ci-builder-image    makefile.include          vmx               xrv
common              nxos                      vqfx              xrv9k


image



, Vrnetlab, . Juniper vMX .tgz ( ) vmx make:



ubuntu:~$ cd ~/vrnetlab/vmx
ubuntu:~$ #     .tgz   
ubuntu:~$ sudo make


vMX 10-20 . !



, ?

:



" , VCP (Control Plane) , , VRR VCP vMX. Docker, , VCP , , ( 5 ). VCP Docker, Docker --privileged, , qemu KVM , , . , , , , . , , , ."



image Docker:



ubuntu:~$ sudo docker image list
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
vrnetlab/vr-vmx     20.1R1.11           b1b2369b453c        3 weeks ago         4.43GB
debian              stretch             614bb74b620e        7 weeks ago         101MB


vr-vmx



:



ubuntu:~$ sudo docker run -d --privileged --name jun01 b1b2369b453c


:



ubuntu:~$ sudo docker container list
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                     PORTS                                                 NAMES
120f882c8712        b1b2369b453c        "/launch.py"        2 minutes ago       Up 2 minutes (unhealthy)   22/tcp, 830/tcp, 5000/tcp, 10000-10099/tcp, 161/udp   jun01




IP- :



ubuntu:~$ sudo docker inspect --format '{{.NetworkSettings.IPAddress}}' jun01
172.17.0.2


, Vrnetlab vrnetlab/VR-netlab9.

ssh:



ubuntu:~$ ssh vrnetlab@172.17.0.2
The authenticity of host '172.17.0.2 (172.17.0.2)' can't be established.
ECDSA key fingerprint is SHA256:g9Sfg/k5qGBTOX96WiCWyoJJO9FxjzXYspRoDPv+C0Y.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '172.17.0.2' (ECDSA) to the list of known hosts.
Password:
--- JUNOS 20.1R1.11 Kernel 64-bit  JNPR-11.0-20200219.fb120e7_buil
vrnetlab> show version
Model: vmx
Junos: 20.1R1.11


.



github .



5: Postman — OpenDaylight



Postman



.



ODL



PUT :





  1. :

    PUT http://10.132.1.202:8181/restconf/config/network-topology:network-topology/topology/topology-netconf/node/jun01
  2. ( Body):

    <node xmlns="urn:TBD:params:xml:ns:yang:network-topology">
    <node-id>jun01</node-id>
    <host xmlns="urn:opendaylight:netconf-node-topology">172.17.0.2</host>
    <port xmlns="urn:opendaylight:netconf-node-topology">22</port>
    <username xmlns="urn:opendaylight:netconf-node-topology">vrnetlab</username>
    <password xmlns="urn:opendaylight:netconf-node-topology">VR-netlab9</password>
    <tcp-only xmlns="urn:opendaylight:netconf-node-topology">false</tcp-only>
    <schema-cache-directory xmlns="urn:opendaylight:netconf-node-topology">jun01_cache</schema-cache-directory>
    </node>
  3. Authorization Basic Auth /: admin/admin. ODL:

  4. Headers :

    • Accept application/xml
    • Content-Type application/xml


. . , "201 Created":





?

node ODL , .



xmlns="urn:TBD:params:xml:ns:yang:network-topology"
xmlns="urn:opendaylight:netconf-node-topology"


XML (XML namespace) ODL node.



, , — node-id, — host .



— . Schema-cache-directory , YANG Schema . $ODL_ROOT/cache/jun01_cache.





GET :



  1. :

    GET http://10.132.1.202:8181/restconf/operational/network-topology:network-topology/topology/topology-netconf/
  2. Authorization Basic Auth /: admin/admin.


. "200 OK" YANG Schema:





: , 10 PUT, YANG shema ODL. GET :







DELETE :



  1. :

    DELETE http://10.132.1.202:8181/restconf/config/network-topology:network-topology/topology/topology-netconf/node/jun01
  2. Authorization Basic Auth /: admin/admin.


6:





GET :



  1. :

    GET http://10.132.1.202:8181/restconf/config/network-topology:network-topology/topology/topology-netconf/node/jun01/yang-ext:mount/
  2. Authorization Basic Auth /: admin/admin.


. "200 OK" :







:



protocols {
    bgp {
        disable;
        shutdown;
    }
}


POST :



  1. :

    POST http://10.132.1.202:8181/restconf/config/network-topology:network-topology/topology/topology-netconf/node/jun01/yang-ext:mount/junos-conf-root:configuration/junos-conf-protocols:protocols
  2. ( Body):

    <bgp xmlns="http://yang.juniper.net/junos/conf/protocols">
    <disable/>
    <shutdown>
    </shutdown>
    </bgp>
  3. Authorization Basic Auth /: admin/admin.
  4. Headers :

    • Accept application/xml
    • Content-Type application/xml


"204 No Content"



, , . , .



GET :



  1. :

    GET http://10.132.1.202:8181/restconf/config/network-topology:network-topology/topology/topology-netconf/node/jun01/yang-ext:mount/junos-conf-root:configuration/junos-conf-protocols:protocols
  2. Authorization Basic Auth /: admin/admin.


:







BGP. :



protocols {
    bgp {
        disable;
    }
}


PUT :



  1. :

    PUT http://10.132.1.202:8181/restconf/config/network-topology:network-topology/topology/topology-netconf/node/jun01/yang-ext:mount/junos-conf-root:configuration/junos-conf-protocols:protocols
  2. ( Body):

    <protocols xmlns="http://yang.juniper.net/junos/conf/protocols">
    <bgp>
        <disable/>
    </bgp>
    </protocols>
  3. Authorization Basic Auth /: admin/admin.
  4. Headers :

    • Accept application/xml
    • Content-Type application/xml


GET , :







DELETE :



  1. :

    DELETE http://10.132.1.202:8181/restconf/config/network-topology:network-topology/topology/topology-netconf/node/jun01/yang-ext:mount/junos-conf-root:configuration/junos-conf-protocols:protocols
  2. Authorization Basic Auth /: admin/admin.


GET :





:



, , XML. JSON.



, , PUT :



{
    "junos-conf-protocols:protocols": {
        "bgp": {
            "description" : "Changed in postman" 
        }
    }
}


Headers :



  • Accept application/json
  • Content-Type application/json


( GET ):





7: Cisco xRV9000



, ? Cisco !

xRV9000 7.0.2 (, 8Gb RAM 4 . , Cisco) — .





Docker Juniper. , .qcow2 , , ( xrv9k) make docker-image.



, :



ubuntu:~$ sudo docker image ls
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
vrnetlab/vr-xrv9k   7.0.2               54debc7973fc        4 hours ago         1.7GB
vrnetlab/vr-vmx     20.1R1.11           b1b2369b453c        4 weeks ago         4.43GB
debian              stretch             614bb74b620e        7 weeks ago         101MB


:



ubuntu:~$ sudo docker run -d --privileged --name xrv01 54debc7973fc


, :



ubuntu:~$ sudo docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                 PORTS                                                      NAMES
058c5ecddae3        54debc7973fc        "/launch.py"        4 hours ago         Up 4 hours (healthy)   22/tcp, 830/tcp, 5000-5003/tcp, 10000-10099/tcp, 161/udp   xrv01


ssh:



ubuntu@ubuntu:~$ ssh vrnetlab@172.17.0.2
Password:

RP/0/RP0/CPU0:ios#show version
Mon Jul  6 12:19:28.036 UTC
Cisco IOS XR Software, Version 7.0.2
Copyright (c) 2013-2020 by Cisco Systems, Inc.

Build Information:
 Built By     : ahoang
 Built On     : Fri Mar 13 22:27:54 PDT 2020
 Built Host   : iox-ucs-029
 Workspace    : /auto/srcarchive15/prod/7.0.2/xrv9k/ws
 Version      : 7.0.2
 Location     : /opt/cisco/XR/packages/
 Label        : 7.0.2

cisco IOS-XRv 9000 () processor
System uptime is 3 hours 22 minutes


OpenDaylight



vMX . .

PUT :



GET , , :





:



!
router ospf LAB
 mpls ldp auto-config
!


POST :



  1. :

    POST http://10.132.1.202:8181/restconf/config/network-topology:network-topology/topology/topology-netconf/node/xrv01/yang-ext:mount/Cisco-IOS-XR-ipv4-ospf-cfg:ospf
  2. ( Body):

    {
        "processes": {
            "process": [
                {
                    "process-name": "LAB",
                    "default-vrf": {
                        "process-scope": {
                            "ldp-auto-config": [
                                null
                            ]
                        }
                    }
                }
            ]
        }
    }
  3. Authorization Basic Auth /: admin/admin.
  4. Headers :

    • Accept application/json
    • Content-Type application/json


"204 No Content".



, .

GET :



  1. :

    GET http://10.132.1.202:8181/restconf/config/network-topology:network-topology/topology/topology-netconf/node/xrv01/yang-ext:mount/Cisco-IOS-XR-ipv4-ospf-cfg:ospf
  2. Authorization Basic Auth /: admin/admin.


:





DELETE:



  1. :

    DELETE http://10.132.1.202:8181/restconf/config/network-topology:network-topology/topology/topology-netconf/node/xrv01/yang-ext:mount/Cisco-IOS-XR-ipv4-ospf-cfg:ospf
  2. Authorization Basic Auth /: admin/admin.




, , Cisco Juniper OpenDaylight — . .

, OpenDaylight. , — *



...



P.S.



, , ODL, ODL. .



!





  1. Vrnetlab: Emulate networks using KVM and Docker / Brian Linkletter
  2. OpenDaylight Cookbook / Mathieu Lemay, Alexis de Talhouet, Et al
  3. Network Programmability with YANG / Benoît Claise, Loe Clarke, Jan Lindblad
  4. Learning XML, Second Edition / Erik T. Ray
  5. Effective DevOps / Jennifer Davis, Ryn Daniels



All Articles