Commit 60e32198 authored by Mohamad Rahhal's avatar Mohamad Rahhal
Browse files

Device component - gNMI Nokia SR Linux Driver:

- Added support test files
parent 9370a067
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
#!/bin/bash

# address for our topology example here in cttc test
TOPOLOGY_FILE="evpn01.clab.yml"

# Ensure you get elevated privileges
sudo true

# Check if the topology exists and destroy it to build our new topology again
sudo containerlab destroy --topo $TOPOLOGY_FILE
echo "Topology destroyed successfully."

sudo rm -rf clab-evpn01 .evpn01.clab.yml.bak

# Build the new topology
sudo containerlab deploy --topo $TOPOLOGY_FILE
echo "Topology deployed successfully."
+46 −0
Original line number Diff line number Diff line
name: evpn01

topology:
  kinds:
    srl:
      image: ghcr.io/nokia/srlinux:23.10.1
    linux:
      image: ghcr.io/hellt/network-multitool

  nodes:
    spine1:
      kind: srl
      type: ixrd3
      mgmt-ipv4: 172.20.20.101

    leaf1:
      kind: srl
      type: ixrd2
      mgmt-ipv4: 172.20.20.102

    leaf2:
      kind: srl
      type: ixrd2
      mgmt-ipv4: 172.20.20.103

    srv1:
      kind: linux
      exec:
        - ip link set address 00:c1:ab:00:00:01 dev eth1
        - ip addr add 192.168.0.1/24 dev eth1
    srv2:
      kind: linux
      exec:
        - ip link set address 00:c1:ab:00:00:02 dev eth1
        - ip addr add 192.168.0.2/24 dev eth1


  links:
    # inter-switch links
    - endpoints: ["leaf1:e1-49", "spine1:e1-1"]
    - endpoints: ["leaf2:e1-49", "spine1:e1-2"]
    # server links
    - endpoints: ["srv1:eth1", "leaf1:e1-1"]
    - endpoints: ["srv2:eth1", "leaf2:e1-1"]

  
 No newline at end of file
+201 −0
Original line number Diff line number Diff line
# Ref: https://github.com/aristanetworks/openmgmt/blob/main/src/pygnmi/update.py
# Ref: https://github.com/aristanetworks/openmgmt/blob/main/src/pygnmi/delete.py
# Ref: https://yang.srlinux.dev/release/v23.3.2/

from pygnmi.client import gNMIclient

host = {
    "ip_address": "172.20.20.102",
    "port": 57400,
    "username": "admin",
    "password": "NokiaSrl1!"
}

if __name__ == "__main__":
    with gNMIclient(
        target=(host["ip_address"], host["port"]), username=host["username"], password=host["password"],
        insecure=False, debug=True
    ) as gc:
        updates = [
     ('/interface[name=ethernet-1/49]',
             {
                 "admin-state": "enable",
                 "subinterface": [
                     {
                         "index": 0,
                         "ipv4": {
                             "admin-state": "enable",
                             "address": [
                                 {
                                     "ip-prefix": "192.168.11.1/30"
                                 }
                             ]
                         }
                     }
                 ]
             }
        ),
     ('/network-instance[name=default]',
             {
                 "interface": [
                     {"name": "ethernet-1/49.0"},
                     {"name": "system0.0"}
                 ],
                 "name": "default",
                 "protocols": {
                     "bgp": {
                         "afi-safi": [
                             {
                                 "admin-state": "enable",
                                 "afi-safi-name": "ipv4-unicast"
                             }
                         ],
                         "autonomous-system": 101,
                         "group": [
                             {
                                 "export-policy": "all",
                                 "group-name": "eBGP-underlay",
                                 "import-policy": "all",
                                 "peer-as": 201
                             },
                             {
                                 "afi-safi": [
                                     {
                                         "admin-state": "enable",
                                         "afi-safi-name": "evpn"
                                     },
                                     {
                                         "admin-state": "disable",
                                         "afi-safi-name": "ipv4-unicast"
                                     }
                                 ],
                            "export-policy": "all",
                            "group-name": "iBGP-overlay",
                            "import-policy": "all",
                            "local-as": {
                                     "as-number": 100
                                 },
                            "peer-as": 100,
                            "timers": {
                                     "minimum-advertisement-interval": 1
                                 }
                             }
                         ],
                         "neighbor": [
                             {
                                 "admin-state": "enable",
                                 "peer-address": "10.0.0.2",
                                 "peer-group": "iBGP-overlay",
                                 "transport": {
                                     "local-address": "10.0.0.1"
                                 }
                             },
                             {
                                 "peer-address": "192.168.11.2",
                                 "peer-group": "eBGP-underlay"
                             }
                         ],
                         "router-id": "10.0.0.1"
                     }
                 },
             }
        ),
     ('/routing-policy',
             {
                 "policy": [
                     {
                         "name": "all",
                         "default-action": {
                             "policy-result": "accept"
                         }
                     }
                 ]
             }
        ),
        ('/interface[name=system0]',
             {
                 "name": "system0",
                 "admin-state": "enable",
                 "subinterface": [
                     {
                         "index": 0,
                         "ipv4": {
                             "admin-state": "enable",
                             "address": [
                                 {
                                     "ip-prefix": "10.0.0.1/32"
                                 }
                             ]
                         }
                     }
                 ]
             }
        ),
        ('/interface[name=ethernet-1/1]',
             {
                 "vlan-tagging": True,
                 "subinterface": [ {
                     "index": 0,
                     "type": "bridged",
                     "admin-state": "enable",
                     "vlan": {
                         "encap": {
                             "untagged": {}
                         }
                     }
                 }
              ]
             } 
             ),        
        ('/network-instance[name=vrf-1]',
             {
                 "name": "vrf-1",
                 "type": "mac-vrf",
                 "admin-state": "enable",
                 "interface": [
                     {"name": "ethernet-1/1.0"}
                 ],
                 "vxlan-interface": [
                     {"name": "vxlan1.1"}
                 ],
                 "protocols": {
                     "bgp-evpn": {
                         "bgp-instance": [
                             {
                                 "id": 1,
                                 "admin-state": "enable",
                                 "vxlan-interface": "vxlan1.1",
                                 "evi": 111
                             }
                         ]
                     },
                     "bgp-vpn": {
                         "bgp-instance": [
                             {
                                 "id": 1,
                                 "route-target": {
                                     "export-rt": "target:100:111",
                                     "import-rt": "target:100:111"
                                 }
                             }
                         ]
                     }
                 }
             }
             ),
         ('/tunnel-interface[name=vxlan1]',
             {"vxlan-interface": [
                 {
                     "index": "1",
                     "type": "bridged",
                     "ingress": {
                         "vni": 1
                     }
                 }
             ]
           }
        ) 
        ]

        result = gc.set(update=updates, encoding='json_ietf')
        print(result)        
 No newline at end of file
+200 −0
Original line number Diff line number Diff line
# Ref: https://github.com/aristanetworks/openmgmt/blob/main/src/pygnmi/update.py
# Ref: https://github.com/aristanetworks/openmgmt/blob/main/src/pygnmi/delete.py
# Ref: https://yang.srlinux.dev/release/v23.3.2/

from pygnmi.client import gNMIclient

host = {
    "ip_address": "172.20.20.103",
    "port": 57400,
    "username": "admin",
    "password": "NokiaSrl1!"
}

if __name__ == "__main__":
    with gNMIclient(
        target=(host["ip_address"], host["port"]), username=host["username"], password=host["password"],
        insecure=False
    ) as gc:
        updates = [
            ('/interface[name=ethernet-1/49]',
             {
                 "admin-state": "enable",
                 "subinterface": [
                     {
                         "index": 0,
                         "ipv4": {
                             "admin-state": "enable",
                             "address": [
                                 {
                                     "ip-prefix": "192.168.12.1/30"
                                 }
                             ]
                         }
                     }
                 ]
             }
        ),
        ('/network-instance[name=default]',       
             {
                 "interface": [
                     {"name": "ethernet-1/49.0"},
                     {"name": "system0.0"}
                 ],
                 "name": "default",
                 "protocols": {
                     "bgp": {
                         "afi-safi": [
                             {
                                 "admin-state": "enable",
                                 "afi-safi-name": "ipv4-unicast"
                             }
                         ],
                         "autonomous-system": 102,
                         "group": [
                             {
                                 "export-policy": "all",
                                 "group-name": "eBGP-underlay",
                                 "import-policy": "all",
                                 "peer-as": 201
                             },
                             {
                                 "afi-safi": [
                                     {
                                         "admin-state": "enable",
                                         "afi-safi-name": "evpn"
                                     },
                                     {
                                         "admin-state": "disable",
                                         "afi-safi-name": "ipv4-unicast"
                                     }
                                 ],
                                 "export-policy": "all",
                                 "group-name": "iBGP-overlay",
                                 "import-policy": "all",
                                 "local-as": {
                                     "as-number": 100
                                 },
                                 "peer-as": 100,
                                 "timers": {
                                     "minimum-advertisement-interval": 1
                                 }
                             }
                         ],
                         "neighbor": [
                             {
                                 "admin-state": "enable",
                                 "peer-address": "10.0.0.1",
                                 "peer-group": "iBGP-overlay",
                                 "transport": {
                                     "local-address": "10.0.0.2"
                                 }
                             },
                             {
                                 "peer-address": "192.168.12.2",
                                 "peer-group": "eBGP-underlay"
                             }
                         ],
                         "router-id": "10.0.0.2"
                     }
                 },
             }
             ),
            ('/routing-policy',
             {
                 "policy": [
                     {
                         "name": "all",
                         "default-action": {
                             "policy-result": "accept"
                         }
                     }
                 ]
             }
        ),    
            ('/interface[name=system0]',
             {
                 "name": "system0",
                 "admin-state": "enable",
                 "subinterface": [
                     {
                         "index": 0,
                         "ipv4": {
                             "admin-state": "enable",
                             "address": [
                                 {
                                     "ip-prefix": "10.0.0.2/32"
                                 }
                             ]
                         }
                     }
                 ]
             }
        ),      
           ('/interface[name=ethernet-1/1]',
             {
                 "vlan-tagging": True,
                 "subinterface": {
                     "index": 0,
                     "type": "bridged",
                     "admin-state": "enable",
                     "vlan": {
                         "encap": {
                             "untagged": {}
                         }
                     }
                 }
             }
        ),  
            ('/network-instance[name=vrf-1]',
             {
                 "name": "vrf-1",
                 "type": "mac-vrf",
                 "admin-state": "enable",
                 "interface": [
                     {"name": "ethernet-1/1.0"}
                 ],
                 "vxlan-interface": [
                     {"name": "vxlan1.1"}
                 ],
                 "protocols": {
                     "bgp-evpn": {
                         "bgp-instance": [
                             {
                                 "id": 1,
                                 "admin-state": "enable",
                                 "vxlan-interface": "vxlan1.1",
                                 "evi": 111
                             }
                         ]
                     },
                     "bgp-vpn": {
                         "bgp-instance": [
                             {
                                 "id": 1,
                                 "route-target": {
                                     "export-rt": "target:100:111",
                                     "import-rt": "target:100:111"
                                 }
                             }
                         ]
                     }
                 }
             }
             ),
            ('/tunnel-interface[name=vxlan1]',
             {"vxlan-interface": [
                 {
                     "index": "1",
                     "type": "bridged",
                     "ingress": {
                         "vni": 1
                        }
                     }
                ]
            }
         )
    ]

        result = gc.set(update=updates, encoding='json_ietf')
        print(result)    
 No newline at end of file
+118 −0
Original line number Diff line number Diff line
from pygnmi.client import gNMIclient

host1 = {"ip_address": "172.20.20.101", "port": 57400, "username": "admin", "password": "NokiaSrl1!"}

if __name__ == "__main__":
    with gNMIclient(
        target=(host1["ip_address"], host1["port"]), username=host1["username"], password=host1["password"],
        insecure=False
    ) as gc:
        updates = [
             ('/interface[name=ethernet-1/1]', { #interfaces
                "admin-state": "enable",
                "subinterface": [
                    {
                        "index": 0,
                        "ipv4": {
                            "admin-state": "enable",
                            "address": [
                                {
                                    "ip-prefix": "192.168.11.2/30"
                                }
                            ]
                        }
                    }
                ]
            }),

            ('/interface[name=ethernet-1/2]', {
                "admin-state": "enable",
                "subinterface": [
                    {
                        "index": 0,
                        "ipv4": {
                            "admin-state": "enable",
                            "address": [
                                {
                                    "ip-prefix": "192.168.12.2/30"
                                }
                            ]
                        }
                    }
                ]
            }),
            ('/network-instance[name=default]', { #default network instance
                 "interface": [
                    {"name": "ethernet-1/1.0"},
                    {"name": "ethernet-1/2.0"},
                    {"name": "system0.0"}
                ],
                 "name": "default",
                    "protocols": {
                        "bgp": {
                            "afi-safi": [
                             {
                                 "admin-state": "enable",
                                 "afi-safi-name": "ipv4-unicast"
                             }
                         ],
                        "autonomous-system": 201,
                            "group": [
                                {
                                 "export-policy": "all",
                                 "group-name": "eBGP-underlay",
                                 "import-policy": "all",
                                }
                             ],
                         "neighbor": [
                             {
                                "peer-address": "192.168.11.1",
                                "peer-as": 101,
                                "peer-group": "eBGP-underlay",
                             },
                             {
                                "peer-address": "192.168.12.1",
                                "peer-as": 102,
                                "peer-group": "eBGP-underlay",
                                }
                            ],
                        "router-id": "10.0.1.1"
                     }
                 },
                      
                 }),
            
            ('/interface[name=system0]', {
                    "name": "system0",
                     "admin-state": "enable",
                     "subinterface": [
                        {
                             "index": 0,
                             "ipv4": {
                             "admin-state": "enable",
                             "address": [
                                {
                                    "ip-prefix": "10.0.1.1/32"
                                }
                            ]
                        }
                    }
                ]
            }
        ),

            ('/routing-policy', {  #routing policy 
                "policy": {
                    "name": "all", 
                    "default-action": {
                        "policy-result": "accept"
                    }
                }
            }
        ),


        ]

        result = gc.set(update=updates, encoding='json_ietf')
        print(result)