👏

CMLでSONiCを使う

2022/08/14に公開1

【概要】

CML(Cisco Modeling Labs)では、利用可能なプラットフォームは、標準で用意されているものに加えて自分で定義して利用することも可能です。

この手順はユーザガイドに示されています。
https://developer.cisco.com/docs/modeling-labs/#!custom-vm-images

またSONiCは、仮想マシン及びコンテナでも利用することができます。

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

今回は以前構築したESXiホストにインストールされたCML 2.2.3の環境で、仮想マシン用のSONiCイメージを用いてセットアップを試みたところ、利用を開始できる状態となりました。
以降はその記録となります。

【詳細】

SONiCイメージの入手

  • 今回は以下から入手
    • https://sonic.software/
    • virtual switchのイメージファイルをダウンロード
      • 今回はBranch 202205のものを選択
      • "sonic-vs.img.gz"

Nodeの定義

  • TOOLSからNode and Image Definitionを選択

  • Node Definitionタブを選択されていることを確認し、ADDボタンを押下

  • General欄で以下の情報を選択/入力

    • ID:今回はsonicvsvm
    • Nature:今回はswitch
  • User Interface欄で以下の情報を選択/入力

    • Prefix:今回はsonicvsvm-
    • Icon:今回はswitch
    • Label:今回はSONiC Virtual Switch (VM)

  • Linux Native Simulation欄で以下の情報を選択/入力
    • Domain Driver:KVM
    • Simulation Driver:server
    • Disk Driver:VirtIO
    • Memory:今回は2048
    • CPUs:今回は2
    • CPU Limit:今回は100
    • Network Driver:E1000

  • Interfaces欄で以下の情報を選択/入力

    • Loopback name:Loopback0
    • Number of serial ports:1
    • Default number of physical interfaces:今回は9
    • interface 0:eth0
  • Interfaces欄でADD INTERFACEボタンをDefault number of physical interfacesで指定した数が表示されるまで押下し、以下の情報を入力

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

  • Boot欄で以下の情報を入力

    • Timeout:今回は480
  • Boot欄でADD BOOT LINEボタンを押下し、以下の情報を入力

    • sonic login
  • CREATEボタンを押下

Imageの定義

  • TOOLSからNode and Image Definitionを選択
  • Image Definitionタブを選択
  • MANAGEボタンを押下
  • Upload New Image File欄のChoose a fileを選択し、SONiCイメージを指定
  • UPLOAD IMAGEボタンを押下

  • Uploaded Images欄に指定したファイルの表示を確認した後に、CREATE NEW IMAGE DEFINITIONボタンを押下

  • General欄で以下の情報を選択/入力

    • ID:今回はsonicvsvm-202205
    • Label:今回はSONiC Virtual Switch (VM) 202205
    • Disk Image:アップロードしたSONiCイメージ
    • Node Definition:定義したNode
  • CREATE IMAGE DEFINITIONボタンを押下


動作確認

登録されたノードを使ってラボを作成したところ、起動に成功しました。
また、隣接ノードと通信できていることが確認できました。

【補足など】

デフォルトのユーザ名/パスワードはadmin/YourPaSsWoRdです。

起動ログ

  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:~$ 

Discussion