sonic-buildimage/platform/vs
Joe LeVeque 890e1f38cc [sonic-py-common] get_platform(): Refactor method of retrieving platform identifier (#5094)
Applications running in the host OS can read the platform identifier from /host/machine.conf. When loading configuration, sonic-config-engine *needs* to read the platform identifier from machine.conf, as it it responsible for populating the value in Config DB.

When an application is running inside a Docker container, the machine.conf file is not accessible, as the /host directory is not mounted. So we need to retrieve the platform identifier from Config DB if get_platform() is called from inside a Docker 
container. However, we can't simply check that we're running in a Docker container because the host OS of the SONiC virtual switch is running inside a Docker container. So I refactored `get_platform()` to:
    1. Read from the `PLATFORM` environment variable if it exists (which is defined in a virtual switch Docker container)
    2. Read from machine.conf if possible (works in the host OS of a standard SONiC image, critical for sonic-config-engine at boot)
    3. Read the value from Config DB (needed for Docker containers running in SONiC, as machine.conf is not accessible to them)

- Also fix typo in daemon_base.py
- Also changes to align `get_hwsku()` with `get_platform()`
2020-08-09 10:40:20 -07:00
..
docker-sonic-vs [sonic-py-common] get_platform(): Refactor method of retrieving platform identifier (#5094) 2020-08-09 10:40:20 -07:00
docker-syncd-vs [201911][dockers] Update critical_processes file syntax (#4854) 2020-06-26 11:37:05 -07:00
sonic-version [vs]: build sonic vs kvm image (#2269) 2018-11-20 22:32:40 -08:00
tests [FRR]: Port some patches from sonic-quagga repo (#3017) 2019-06-23 15:26:02 -07:00
create_vnet.sh [vs]: build sonic vs kvm image (#2269) 2018-11-20 22:32:40 -08:00
docker-sonic-vs.mk [201911] Introduce sonic-py-common package (#5063) 2020-08-03 11:50:06 -07:00
docker-syncd-vs.mk [docker-{sonic,syncd}-vs]: upgrade {sonic,syncd}-vs docker to stretch (#2865) 2019-05-06 07:19:36 -07:00
kvm-image.mk [build]: Move Systemd service start to systemd generator (#3172) 2019-07-29 15:52:15 -07:00
one-image.mk [build]: Move Systemd service start to systemd generator (#3172) 2019-07-29 15:52:15 -07:00
onie.mk [vs]: build sonic vs kvm image (#2269) 2018-11-20 22:32:40 -08:00
platform.conf [vs]: build sonic vs kvm image (#2269) 2018-11-20 22:32:40 -08:00
README.gns3.md [vsimage]: Support for the creation of a GNS3 appliance file (#3553) 2019-10-07 07:16:11 -07:00
README.vsdocker.md [vs]: build sonic vs kvm image (#2269) 2018-11-20 22:32:40 -08:00
README.vsvm.md [baseimage]: support building multi-asic component (#3856) 2020-02-03 15:32:21 -08:00
rules.mk [build]: Makefile: Extend to build debug docker images for all stretch dockers (#2789) 2019-04-19 18:49:21 -07:00
sonic_multiasic.xml Multi-ASIC implementation (#3888) 2020-04-15 13:08:34 -07:00
sonic-gns3a.sh [vsimage]: Support for the creation of a GNS3 appliance file (#3553) 2019-10-07 07:16:11 -07:00
sonic-version.mk [vs]: build sonic vs kvm image (#2269) 2018-11-20 22:32:40 -08:00
sonic.xml [vs]: sync changes to disk and add e1000 driver to sonic vm (#2288) 2018-11-22 12:09:21 -08:00
syncd-vs.mk [virtualswitch]: build docker-sonic-vs docker based on SAI virtual switch (#1065) 2017-10-23 22:01:42 -07:00

HOWTO Use Virtual Switch (VM)

  1. Install libvirt, kvm, qemu
sudo apt-get install libvirt-clients qemu-kvm libvirt-bin
  1. Create SONiC VM for single ASIC HWSKU
$ sudo virsh
Welcome to virsh, the virtualization interactive terminal.

Type:  'help' for help with commands
       'quit' to quit

virsh # 
virsh # create sonic.xml
Domain sonic created from sonic.xml

virsh # 
  1. Create SONiC VM for multi-ASIC HWSKU Update sonic_multiasic.xml with the external interfaces required for HWSKU.
$ sudo virsh
Welcome to virsh, the virtualization interactive terminal.

Type:  'help' for help with commands
       'quit' to quit

virsh #
virsh # create sonic_multiasic.xml 
Domain sonic created from sonic.xml

virsh #

Once booted up, create a file "asic.conf" with the content:
NUM_ASIC=<Number of asics>
under /usr/share/sonic/device/x86_64-kvm_x86_64-r0/
Also, create a "topology.sh" file which will simulate the internal
asic connectivity of the hardware under
/usr/share/sonic/device/x86_64-kvm_x86_64-r0/<HWSKU>
The HWSKU directory will have the required files like port_config.ini
for each ASIC.

Having done this, a new service "topology.service" will be started
during bootup which will invoke topology.sh script.

3. Access virtual switch:

    1. Connect SONiC VM via console
    ```
    $ telnet 127.0.0.1 7000
    ```
    
    OR

    2. Connect SONiC VM via SSH
        
        1. Connect via console (see 3.1 above)

        2. Request a new DHCP address
        ```
        sudo dhclient -v
        ```
        
        3. Connect via SSH
        ```
        $ ssh -p 3040 admin@127.0.0.1
        ```