containerlab icon indicating copy to clipboard operation
containerlab copied to clipboard

Sonic docs refresh and introduction of sonic-vm

Open hellt opened this issue 1 year ago • 3 comments

hellt avatar Jul 02 '24 10:07 hellt

@adam-kulagowski do you have an example how ports are mapped in Sonic? A tiny lab with IP connectivity would be great

something based on this

name: sonic
topology:
  nodes:
    sonic:
      kind: sonic-vm
      image: vrnetlab/vr-sonic:202405
    linux:
      kind: linux
      image: alpine:3

  links:
    - endpoints: [sonic:eth1, linux:eth1]

hellt avatar Jul 03 '24 10:07 hellt

name: clab
prefix: __lab-name

topology:
  nodes:
    sonic-vm:
      kind: vr-sonic
      startup-config: config/sonic-vm/sonic-vm-ok.json
      image: vrnetlab/vr-sonic:202305
    frr1:
      kind: linux
      image: quay.io/frrouting/frr:9.1.0
      binds:
        - config/frr1/daemons:/etc/frr/daemons
        - config/frr1/frr.conf:/etc/frr/frr.conf
    frr2:
      kind: linux
      image: quay.io/frrouting/frr:9.1.0
      binds:
        - config/frr2/daemons:/etc/frr/daemons
        - config/frr2/frr.conf:/etc/frr/frr.conf
    PC1:
      kind: linux
      image: praqma/network-multitool:latest
      exec:
        - ip addr add 192.168.1.10/24 dev eth1
        - ip route add 192.168.0.0/16 via 192.168.1.1
        - ip route add 10.0.0.0/8 via 192.168.1.1
    PC2:
      kind: linux
      image: praqma/network-multitool:latest
      exec:
        - ip addr add 192.168.2.10/24 dev eth1
        - ip route add 192.168.0.0/16 via 192.168.2.1
        - ip route add 10.0.0.0/8 via 192.168.2.1

  links:
    - endpoints: ["sonic-vm:eth1", "frr1:eth1"]
    - endpoints: ["sonic-vm:eth2", "frr2:eth1"]
    - endpoints: ["PC1:eth1", "frr1:eth2"]
    - endpoints: ["PC2:eth1", "frr2:eth2"]

This will create a PC - FRR - SONIC - FRR - PC topology. The only issue here is (and I'm not sure if that's important) that SONiC maps eth1 to Ethernet0, eth2 to Ethernet4 , eth3 to Ethernet8 and so on.

Update: the non continuity in SONiC naming is OK. In VM, SONiC assumes that each interface has 4 lanes, and leaves space for potential cable-breakout :)

adam-kulagowski avatar Jul 03 '24 10:07 adam-kulagowski

@adam-kulagowski can you please drop here a quick memo on how save the configuration that will be suitable for startup-config?

hellt avatar Jul 03 '24 12:07 hellt

@adam-kulagowski can you please drop here a quick memo on how save the configuration that will be suitable for startup-config?

Could You please elaborate? I'm not sure what do You expect.

An example configuration that we use looks like this:

{

    "BGP_DEVICE_GLOBAL": {
        "STATE": {
            "tsa_enabled": "false"
        }
    },
    "DEVICE_METADATA": {
        "localhost": {
            "bgp_asn": "65000",
            "buffer_model": "traditional",
            "default_bgp_status": "up",
            "default_pfcwd_status": "disable",
            "hostname": "sonic1-vs",
            "hwsku": "Force10-S6000",
            "mac": "52:54:00:db:58:04",
            "platform": "x86_64-kvm_x86_64-r0",
            "synchronous_mode": "enable",
            "type": "LeafRouter"
        }
    },

    "INTERFACE": {
        "Ethernet0": {},
        "Ethernet0|10.10.1.1/30": {},
        "Ethernet4": {},
        "Ethernet4|10.10.2.1/30": {}
    },
    "LOOPBACK_INTERFACE": {
        "Loopback0": {},
        "Loopback0|10.1.0.1/32": {}
    },
    "BGP_NEIGHBOR": {
        "10.10.1.2": {
            "rrclient": 0,
            "name": "FRR1",
            "local_addr": "10.10.1.1",
            "nhopself": 1,
            "holdtime": "180",
            "asn": "65001",
            "keepalive": "60"
        },
        "10.10.2.2": {
            "rrclient": 0,
            "name": "FRR2",
            "local_addr": "10.10.2.1",
            "nhopself": 1,
            "holdtime": "180",
            "asn": "65002",
            "keepalive": "60"
        }
    },
    "PORT": {
        "Ethernet0": {
            "admin_status": "up",
            "alias": "GigE0/0",
            "index": "0",
            "lanes": "25,26,27,28",
            "mtu": "9100",
            "speed": "1000"
        },
        "Ethernet4": {
            "admin_status": "up",
            "alias": "GigE0/4",
            "index": "1",
            "lanes": "29,30,31,32",
            "mtu": "9100",
            "speed": "1000"
        }
    },

    "VERSIONS": {
        "DATABASE": {
            "VERSION": "version_3_0_5"
        }
    }
}

And is 1:1 copy from /etc/sonic/config_db.json of running VM. Its a full configuration dump and that file will overwrite the the default config on SONiC.

After that any changes done in VM can be exported with containerlab save

If I misunderstood please let me know.

adam-kulagowski avatar Jul 03 '24 16:07 adam-kulagowski

Codecov Report

Attention: Patch coverage is 4.65116% with 41 lines in your changes missing coverage. Please review.

Project coverage is 53.55%. Comparing base (757883b) to head (1af3612). Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2120      +/-   ##
==========================================
- Coverage   53.73%   53.55%   -0.19%     
==========================================
  Files         163      164       +1     
  Lines       11632    11675      +43     
==========================================
+ Hits         6250     6252       +2     
- Misses       4507     4547      +40     
- Partials      875      876       +1     
Files Coverage Δ
clab/register.go 100.00% <100.00%> (ø)
nodes/sonic_vm/sonic_vm.go 2.38% <2.38%> (ø)

codecov[bot] avatar Jul 03 '24 18:07 codecov[bot]

If I misunderstood please let me know.

this was exactly what was missing. Added this to the documentation. Ty

hellt avatar Jul 03 '24 19:07 hellt