DEV Community

rhira777
rhira777

Posted on

How to use SONiC on CML

Summary

In CML (Cisco Modeling Labs), the available platforms can be defined and used by yourself in addition to the standard ones.

This procedure is shown in the user guide.
https://developer.cisco.com/docs/modeling-labs/#!custom-vm-images

SONiC is also available for virtual machines and containers.

SONiC on virtual machine for Windows
https://github.com/sonic-net/SONiC/wiki/SONiC-on-virtual-machine-for-Windows

HOWTO Use Virtual Switch (VM)
https://github.com/sonic-net/sonic-buildimage/blob/master/platform/vs/README.vsvm.md

HOWTO Use Virtual Switch (Docker)
https://github.com/sonic-net/sonic-buildimage/blob/master/platform/vs/README.vsdocker.md

This time, I tried to set up using SONiC image for virtual machines in CML 2.2.3 environment (installed on the previously built ESXi host), and was able to start using it.
The following is a record of that.

Detail of what I did

Get SONiC image

  • In this case, obtain from the following
    • https://sonic.software/
    • Download the virtual switch image file
      • Select the one from Branch 202205 this time
      • "sonic-vs.img.gz".

Define node

  • Select "Node and Image Definition" from "TOOLS"
  • Confirm that the "Node Definition" tab is selected and click the "ADD" button.
  • Select/enter the following information in the "General" field
    • ID: "sonicvsvm"
    • Nature: "switch"
  • Select/enter the following information in the "User Interface" field
    • Prefix: "sonicvsvm-"
    • Icon: "switch"
    • Label: "SONiC Virtual Switch (VM)" Image description

  • Select/enter the following information in the "Linux Native Simulation" field

    • Domain Driver: "KVM"
    • Simulation Driver: "server"
    • Disk Driver: "VirtIO"
    • Memory: "2048" in this case
    • CPUs: "2" in this case
    • CPU Limit: "100"
    • Network Driver: "E1000" Image description ---
  • Select/enter the following information in the "Interfaces" field

    • Loopback name: "Loopback0"
    • Number of serial ports: "1"
    • Default number of physical interfaces: "9" in this case
    • interface 0:"eth0"
  • In the same field, press the "ADD INTERFACE" button until the number specified in the "Default number of physical interfaces" is displayed, and enter the following information

    • interface 1: "Ethernet0"
    • interface 2: "Ethernet4"
    • interface 3: "Ethernet8"
    • interface 4: "Ethernet12"
    • interface 5: "Ethernet16"
    • interface 6: "Ethernet20"
    • interface 7: "Ethernet24"
    • interface 8: "Ethernet28" Image description

  • Enter the following information in the "Boot" field

    • Timeout: "480" in this case
  • In the same field, click the "ADD BOOT LINE button" and enter the following information

    • "sonic login"
  • Click the CREATE button

    Image description

Define image

  • Select "Node and Image Definition" from "TOOLS"
  • Select the "Image Definition" tab
  • Click the "MANAGE" button
  • Select "Choose a file" in the "Upload New Image File" field and specify the downloaded SONiC image
  • Click the "UPLOAD IMAGE" button Image description

  • After confirming the display of the file specified in the "Uploaded Images" field, press the "CREATE NEW IMAGE DEFINITION" button. Image description

  • Select/enter the following information in the "General" field

    • ID: "sonicvsvm-202205"
    • Label: "SONiC Virtual Switch (VM) 202205"
    • Disk Image: The uploaded SONiC image
    • Node Definition: The defined node
  • Press "CREATE IMAGE DEFINITION" button

    Image description


Confirmation of operation

I created a lab using the registered node and it was successfully started.
It was also confirmed that communication with neighboring nodes was possible.
Image description

Supplemental information and others

The default username/password is admin/YourPaSsWoRd.

startup log

  Booting `SONiC-OS-202205.133812-e8fe21b3a'


Loading SONiC-OS OS kernel ...

Loading SONiC-OS OS initial ramdisk ...

tune2fs 1.46.2 (28-Feb-2021)
Setting reserved blocks percentage to 0% (0 blocks)
Setting reserved blocks count to 0
[    5.274055] rc.local[357]: + cat /etc/sonic/sonic_version.yml
[    5.286346] rc.local[358]: + grep build_version
[    5.308838] rc.local[372]: + sed -e s/build_version: //g;s/'//g
[    5.346575] rc.local[354]: + SONIC_VERSION=202205.133812-e8fe21b3a
[    5.374217] rc.local[354]: + FIRST_BOOT_FILE=/host/image-202205.133812-e8fe21b3a/platform/firsttime
[    5.406043] rc.local[354]: + SONIC_CONFIG_DIR=/host/image-202205.133812-e8fe21b3a/sonic-config
[    5.414535] rc.local[354]: + SONIC_ENV_FILE=/host/image-202205.133812-e8fe21b3a/sonic-config/sonic-environment
[    5.442671] rc.local[354]: + [ -d /host/image-202205.133812-e8fe21b3a/sonic-config -a -f /host/image-202205.133812-e8fe21b3a/sonic-config/sonic-environment ]
[    5.479881] rc.local[354]: + logger SONiC version 202205.133812-e8fe21b3a starting up...
[    5.551047] rc.local[354]: + grub_installation_needed=
[    5.579501] rc.local[354]: + [ ! -e /host/machine.conf ]
[    5.606349] rc.local[354]: + . /host/machine.conf
[    5.634855] rc.local[354]: + onie_arch=x86_64
[    5.641530] rc.local[354]: + onie_bin=
[    5.655218] rc.local[354]: + onie_boot_reason=install
[    5.664985] rc.local[354]: + onie_build_date=2018-11-17T04:18+00:00
[    5.672286] rc.local[354]: + onie_build_machine=kvm_x86_64
[    5.682261] rc.local[354]: + onie_build_platform=x86_64-kvm_x86_64-r0
[    5.699784] rc.local[354]: + onie_config_version=1
[    5.709808] rc.local[354]: + onie_dev=/dev/vda2
[    5.718218] rc.local[354]: + onie_disco_boot_reason=install
[    5.724046] rc.local[354]: + onie_disco_dns=10.0.2.3
[    5.739660] rc.local[354]: + onie_disco_interface=eth0
[    5.746767] rc.local[354]: + onie_disco_ip=10.0.2.15
[    5.752000] rc.local[354]: + onie_disco_lease=86400
[    5.762114] rc.local[354]: + onie_disco_mask=24
[    5.763791] rc.local[354]: + onie_disco_opt53=05
[    5.775585] rc.local[354]: + onie_disco_router=10.0.2.2
[    5.787520] rc.local[354]: + onie_disco_serverid=10.0.2.2
[    5.795402] rc.local[354]: + onie_disco_siaddr=10.0.2.2
[    5.797178] rc.local[354]: + onie_disco_subnet=255.255.255.0
[    5.803935] rc.local[354]: + onie_exec_url=file://dev/vdb/onie-installer.bin
[    5.817521] rc.local[354]: + onie_firmware=auto
[    5.823414] rc.local[354]: + onie_grub_image_name=shimx64.efi
[    5.827010] rc.local[354]: + onie_initrd_tmp=/
[    5.828773] rc.local[354]: + onie_installer=/var/tmp/installer
[    5.839240] rc.local[354]: + onie_kernel_version=4.9.95
[    5.842667] rc.local[354]: + onie_local_parts=
[    5.846107] rc.local[354]: + onie_machine=kvm_x86_64
[    5.851656] rc.local[354]: + onie_machine_rev=0
[    5.866354] rc.local[354]: + onie_neighs=[fe80::2-eth0],
[    5.870137] rc.local[354]: + onie_partition_type=gpt
[    5.873605] rc.local[354]: + onie_platform=x86_64-kvm_x86_64-r0
[    5.883782] rc.local[354]: + onie_root_dir=/mnt/onie-boot/onie
[    5.891640] rc.local[354]: + onie_secure_boot=yes
[    5.895686] rc.local[354]: + onie_skip_ethmgmt_macs=yes
[    5.900815] rc.local[354]: + onie_switch_asic=qemu
[    5.910116] rc.local[354]: + onie_uefi_arch=x64
[    5.914736] rc.local[354]: + onie_uefi_boot_loader=shimx64.efi
[    5.918640] rc.local[354]: + onie_vendor_id=42623
[    5.929991] rc.local[354]: + onie_version=master-201811170418
[    5.935779] rc.local[354]: + program_console_speed
[    5.961289] rc.local[381]: + cat /proc/cmdline
[    5.967825] rc.local[382]: + grep -Eo console=ttyS[0-9]+,[0-9]+
[    5.969963] kdump-tools[348]: Starting kdump-tools:
[    5.983970] rc.local[391]: + cut -d , -f2
[    5.989988] kdump-tools[385]: no crashkernel= parameter in the kernel cmdline ...
[    5.994164] kdump-tools[431]:  failed!
[    6.015307] rc.local[354]: + speed=115200
[    6.016722] rc.local[354]: + [ -z 115200 ]
[    6.022641] rc.local[354]: + CONSOLE_SPEED=115200
[    6.034225] rc.local[395]: + grep keep-baud
[    6.038480] rc.local[394]: + grep agetty /lib/systemd/system/serial-getty@.service
[    6.043188] rc.local[395]: ExecStart=-/sbin/agetty -o '-p -- \\u' --keep-baud 115200,57600,38400,9600 %I $TERM
[    6.052015] rc.local[354]: + [ 0 = 0 ]
[    6.053117] rc.local[354]: + sed -i s|\-\-keep\-baud .* %I| 115200 %I|g /lib/systemd/system/serial-getty@.service
[    6.059409] rc.local[354]: + systemctl daemon-reload
[    6.065592] rc.local[354]: + [ -f /host/image-202205.133812-e8fe21b3a/platform/firsttime ]
[    6.074332] rc.local[354]: + echo First boot detected. Performing first boot tasks...
[    6.078155] rc.local[354]: First boot detected. Performing first boot tasks...
[    6.081148] rc.local[354]: + [ -n  ]
[    6.086179] rc.local[354]: + [ -n x86_64-kvm_x86_64-r0 ]
[    6.088825] rc.local[354]: + platform=x86_64-kvm_x86_64-r0
[    6.090372] rc.local[354]: + [ -d /host/old_config ]
[    6.094434] rc.local[354]: + [ -f /host/minigraph.xml ]
[    6.096638] rc.local[354]: + [ -n  ]
[    6.101041] rc.local[354]: + touch /tmp/pending_config_initialization
[    6.102851] rc.local[354]: + touch /tmp/notify_firstboot_to_platform
[    6.108945] rc.local[354]: + [ ! -d /host/reboot-cause/platform ]
[    6.114369] rc.local[354]: + mkdir -p /host/reboot-cause/platform
[    6.116093] rc.local[354]: + [ -d /host/image-202205.133812-e8fe21b3a/platform/x86_64-kvm_x86_64-r0 ]
[    6.121007] rc.local[354]: + sync
[    6.126091] rc.local[354]: + [ -n x86_64-kvm_x86_64-r0 ]
[    6.135691] rc.local[354]: + [ -n  ]
[    6.138201] rc.local[354]: + mkdir -p /var/platform
[    6.143169] rc.local[354]: + [ -f /etc/default/kdump-tools ]
[    6.147718] rc.local[354]: + sed -i -e s/__PLATFORM__/x86_64-kvm_x86_64-r0/g /etc/default/kdump-tools
[    6.152807] rc.local[354]: + firsttime_exit
[    6.155310] rc.local[354]: + rm -rf /host/image-202205.133812-e8fe21b3a/platform/firsttime
[    6.165820] rc.local[354]: + exit 0


Debian GNU/Linux 11 sonic ttyS0

sonic login: admin

Password: 
Linux sonic 5.10.0-12-2-amd64 #1 SMP Debian 5.10.103-1 (2022-03-07) x86_64
You are on
  ____   ___  _   _ _  ____
 / ___| / _ \| \ | (_)/ ___|
 \___ \| | | |  \| | | |
  ___) | |_| | |\  | | |___
 |____/ \___/|_| \_|_|\____|

-- Software for Open Networking in the Cloud --

Unauthorized access and/or use are prohibited.
All access and/or use are subject to monitoring.

Help:    http://azure.github.io/SONiC/

admin@sonic:~$ 

admin@sonic:~$ show lldp table

Capability codes: (R) Router, (B) Bridge, (O) Other
LocalPort    RemoteDevice    RemotePortID    Capability    RemotePortDescr
-----------  --------------  --------------  ------------  -----------------
Ethernet0    sonic           fortyGigE0/0    BR            Ethernet0
--------------------------------------------------
Total entries displayed:  1
admin@sonic:~$ 
Enter fullscreen mode Exit fullscreen mode

Top comments (0)