Skip to content

Commit

Permalink
ONEImage - Read all platform dependent information from sonic-config-…
Browse files Browse the repository at this point in the history
…engine (#238)

Read all platform dependent information from sonic-config-engine
  • Loading branch information
taoyl-ms authored Feb 3, 2017
1 parent 523a738 commit 60e1fc3
Show file tree
Hide file tree
Showing 15 changed files with 61 additions and 36 deletions.
3 changes: 3 additions & 0 deletions dockers/docker-orchagent/Dockerfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ RUN apt-get install -f -y ifupdown bridge-utils libdbus-1-3 libdaemon0 libjansso
## TODO: implicitly install dependencies
RUN apt-get -y install libjemalloc1

# Dependencies for sonic-cfggen
RUN apt-get install -y python-lxml python-jinja2 python-netaddr python-ipaddr python-yaml

COPY \
{% for deb in docker_orchagent_debs.split(' ') -%}
debs/{{ deb }}{{' '}}
Expand Down
18 changes: 7 additions & 11 deletions dockers/docker-orchagent/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,32 +25,28 @@ trap clean_up SIGTERM SIGKILL

. /host/machine.conf

HWSKU=`sonic-cfggen -m /etc/sonic/minigraph.xml -v minigraph_hwsku`

MAC_ADDRESS=`ip link show eth0 | grep ether | awk '{print $2}'`

ORCHAGENT_ARGS=""

PORTSYNCD_ARGS=""
PORTSYNCD_ARGS="-p /usr/share/sonic/$HWSKU/port_config.ini"

SWSSCONFIG_ARGS="00-copp.config.json "

if [ "$onie_platform" == "x86_64-dell_s6000_s1220-r0" ]; then
if [ "$HWSKU" == "Force10-S6000" ]; then
ORCHAGENT_ARGS+="-m $MAC_ADDRESS"
PORTSYNCD_ARGS+="-p /etc/ssw/Force10-S6000/port_config.ini"
SWSSCONFIG_ARGS+="td2.32ports.qos.1.json td2.32ports.qos.2.json td2.32ports.qos.3.json td2.32ports.qos.4.json td2.32ports.qos.5.json td2.32ports.qos.6.json "
SWSSCONFIG_ARGS+="td2.32ports.buffers.1.json td2.32ports.buffers.2.json td2.32ports.buffers.3.json "
elif [ "$onie_platform" == "x86_64-dell_s6100_c2538-r0" ]; then
elif [ "$HWSKU" == "Force10-S6100" ]; then
ORCHAGENT_ARGS+="-m $MAC_ADDRESS"
PORTSYNCD_ARGS+="-p /etc/ssw/Force10-S6100/port_config.ini"
elif [ "$aboot_platform" == "x86_64-arista_7050_qx32" ]; then
elif [ "$HWSKU" == "Arista-7050-QX32" ]; then
ORCHAGENT_ARGS+="-m $MAC_ADDRESS"
PORTSYNCD_ARGS+="-p /etc/ssw/Arista-7050-QX32/port_config.ini"
SWSSCONFIG_ARGS+="td2.32ports.qos.1.json td2.32ports.qos.2.json td2.32ports.qos.3.json td2.32ports.qos.4.json td2.32ports.qos.5.json td2.32ports.qos.6.json "
SWSSCONFIG_ARGS+="td2.32ports.buffers.1.json td2.32ports.buffers.2.json td2.32ports.buffers.3.json "
elif [ "$onie_platform" == "x86_64-mlnx_x86-r5.0.1400" ] || [ "$onie_platform" == "x86_64-mlnx_msn2700-r0" ]; then
PORTSYNCD_ARGS+="-p /etc/ssw/ACS-MSN2700/port_config.ini"
elif [ "$onie_platform" == "x86_64-accton_as7512_32x-r0" ]; then
elif [ "$HWSKU" == "AS7512" ]; then
ORCHAGENT_ARGS+="-m $MAC_ADDRESS"
PORTSYNCD_ARGS+="-p /etc/ssw/AS7512/port_config.ini"
fi

service rsyslog start
Expand Down
7 changes: 4 additions & 3 deletions dockers/docker-snmp-sv2/config.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
#!/bin/bash

#sysDescription is currently mounted, uncomment this line and provide version.yml instead if use copying instead of mounting
#sonic-cfggen -m /etc/sonic/minigraph.xml -y /etc/sonic/version.yml -t /etc/swss/snmp/sysDescription.j2 >/etc/ssw/sysDescription
mkdir -p /etc/ssw

sonic-cfggen -m /etc/sonic/minigraph.xml -y /etc/sonic/sonic_version.yml -t /etc/swss/snmp/sysDescription.j2 >/etc/ssw/sysDescription

mkdir -p /etc/snmp

sonic-cfggen -m /etc/sonic/minigraph.xml -y /etc/sonic/snmp.yml -t /etc/swss/snmp/snmpd.conf.j2 >/etc/snmp/snmpd.conf

hwsku=`sonic-cfggen -m /etc/sonic/minigraph.xml -v minigraph_hwsku`
/bin/cp -rf /etc/ssw/$hwsku/alias_map.json /etc/snmp/
/bin/cp -rf /usr/share/sonic/$hwsku/alias_map.json /etc/snmp/

mkdir -p /var/sonic
echo "# Config files managed by sonic-config-engine" >/var/sonic/config_status
Expand Down
2 changes: 1 addition & 1 deletion dockers/docker-snmp-sv2/sysDescription.j2
Original file line number Diff line number Diff line change
@@ -1 +1 @@
SONiC Software Version: {{ sonic_baseimage_version}}.SONiC.{{ sonic_version }} - HwSku: {{ minigraph_hwsku }}
SONiC Software Version: {{ build_version }}.SONiC.v2 - HwSku: {{ minigraph_hwsku }} - Distribution: Debian {{ debian_version }} - Kernel: {{ kernel_version }}
11 changes: 3 additions & 8 deletions files/build_templates/sonic_debian_extension.j2
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ set -x -e
. functions.sh
BUILD_TEMPLATES=files/build_templates
IMAGE_CONFIGS=files/image_config
VENDOR_CONFIGS=src/sonic-config-engine/platform

{% if installer_debs.strip() -%}
clean_sys() {
Expand All @@ -46,7 +45,6 @@ sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y in
sudo dpkg --root=$FILESYSTEM_ROOT -i {{config_engine}}

# Create all needed directories
sudo mkdir -p $FILESYSTEM_ROOT/etc/ssw/
sudo mkdir -p $FILESYSTEM_ROOT/etc/sonic/
sudo mkdir -p $FILESYSTEM_ROOT/etc/sonic/templates/

Expand Down Expand Up @@ -86,20 +84,17 @@ sudo cp $IMAGE_CONFIGS/interfaces/*.j2 $FILESYSTEM_ROOT/etc/sonic/templates/
# Copy SNMP configuration files
sudo cp $IMAGE_CONFIGS/snmp/snmp.yml $FILESYSTEM_ROOT/etc/sonic/

# Generate system desription file
# Generate build version file
export git_revision=$(git rev-parse --short HEAD)
export sonic_hwsku={{sonic_hwsku}}
export debian_version=`cat $FILESYSTEM_ROOT/etc/debian_version`
export kernel_version={{kversion}}
j2 $BUILD_TEMPLATES/sysDescription.j2 > sysDescription
sudo mv sysDescription $FILESYSTEM_ROOT/etc/ssw/
j2 $BUILD_TEMPLATES/sonic_version.yml.j2 > sonic_version.yml
sudo mv sonic_version.yml $FILESYSTEM_ROOT/etc/sonic/

# Copy sudoers configuration file
sudo cp $IMAGE_CONFIGS/sudoers/sudoers $FILESYSTEM_ROOT/etc/

# Copy vendor specific configuration files
sudo cp -R $VENDOR_CONFIGS/{{sonic_hwsku}}/ $FILESYSTEM_ROOT/etc/ssw/

{% for deb in installer_debs.strip().split(' ') -%}
sudo dpkg --extract {{deb}} $FILESYSTEM_ROOT
{% endfor %}
Expand Down
4 changes: 4 additions & 0 deletions files/build_templates/sonic_version.yml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
build_version: {{git_revision}}
build_hwsku: {{sonic_hwsku}}
debian_version: {{debian_version}}
kernel_version: {{kernel_version}}
1 change: 0 additions & 1 deletion files/build_templates/sysDescription.j2

This file was deleted.

3 changes: 1 addition & 2 deletions platform/broadcom/docker-orchagent-brcm.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@

DOCKER_ORCHAGENT_BRCM = docker-orchagent-brcm.gz
$(DOCKER_ORCHAGENT_BRCM)_PATH = $(DOCKERS_PATH)/docker-orchagent
$(DOCKER_ORCHAGENT_BRCM)_DEPENDS += $(SWSS) $(REDIS_TOOLS)
$(DOCKER_ORCHAGENT_BRCM)_DEPENDS += $(SWSS) $(REDIS_TOOLS) $(SONIC_CONFIG_ENGINE)
$(DOCKER_ORCHAGENT_BRCM)_LOAD_DOCKERS += $(DOCKER_BASE)
SONIC_DOCKER_IMAGES += $(DOCKER_ORCHAGENT_BRCM)
SONIC_INSTALL_DOCKER_IMAGES += $(DOCKER_ORCHAGENT_BRCM)

$(DOCKER_ORCHAGENT_BRCM)_CONTAINER_NAME = swss
$(DOCKER_ORCHAGENT_BRCM)_RUN_OPT += --net=host --privileged -t
$(DOCKER_ORCHAGENT_BRCM)_RUN_OPT += --volumes-from database
$(DOCKER_ORCHAGENT_BRCM)_RUN_OPT += -v /etc/ssw/:/etc/ssw/:ro
$(DOCKER_ORCHAGENT_BRCM)_RUN_OPT += -v /etc/network/interfaces:/etc/network/interfaces:ro
$(DOCKER_ORCHAGENT_BRCM)_RUN_OPT += -v /etc/network/interfaces.d/:/etc/network/interfaces.d/:ro
$(DOCKER_ORCHAGENT_BRCM)_RUN_OPT += -v /host/machine.conf:/host/machine.conf
Expand Down
3 changes: 1 addition & 2 deletions platform/cavium/docker-orchagent-cavm.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@

DOCKER_ORCHAGENT_CAVM = docker-orchagent-cavm.gz
$(DOCKER_ORCHAGENT_CAVM)_PATH = $(DOCKERS_PATH)/docker-orchagent
$(DOCKER_ORCHAGENT_CAVM)_DEPENDS += $(SWSS) $(REDIS_TOOLS)
$(DOCKER_ORCHAGENT_CAVM)_DEPENDS += $(SWSS) $(REDIS_TOOLS) $(SONIC_CONFIG_ENGINE)
$(DOCKER_ORCHAGENT_CAVM)_LOAD_DOCKERS += $(DOCKER_BASE)
SONIC_DOCKER_IMAGES += $(DOCKER_ORCHAGENT_CAVM)
SONIC_INSTALL_DOCKER_IMAGES += $(DOCKER_ORCHAGENT_CAVM)

$(DOCKER_ORCHAGENT_CAVM)_CONTAINER_NAME = swss
$(DOCKER_ORCHAGENT_CAVM)_RUN_OPT += --net=host --privileged -t
$(DOCKER_ORCHAGENT_CAVM)_RUN_OPT += --volumes-from database
$(DOCKER_ORCHAGENT_CAVM)_RUN_OPT += -v /etc/ssw/:/etc/ssw/:ro
$(DOCKER_ORCHAGENT_CAVM)_RUN_OPT += -v /etc/network/interfaces:/etc/network/interfaces:ro
$(DOCKER_ORCHAGENT_CAVM)_RUN_OPT += -v /etc/network/interfaces.d/:/etc/network/interfaces.d/:ro
$(DOCKER_ORCHAGENT_CAVM)_RUN_OPT += -v /host/machine.conf:/host/machine.conf
Expand Down
3 changes: 1 addition & 2 deletions platform/mellanox/docker-orchagent-mlnx.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@

DOCKER_ORCHAGENT_MLNX = docker-orchagent-mlnx.gz
$(DOCKER_ORCHAGENT_MLNX)_PATH = $(DOCKERS_PATH)/docker-orchagent
$(DOCKER_ORCHAGENT_MLNX)_DEPENDS += $(SWSS) $(REDIS_TOOLS)
$(DOCKER_ORCHAGENT_MLNX)_DEPENDS += $(SWSS) $(REDIS_TOOLS) $(SONIC_CONFIG_ENGINE)
$(DOCKER_ORCHAGENT_MLNX)_LOAD_DOCKERS += $(DOCKER_BASE)
SONIC_DOCKER_IMAGES += $(DOCKER_ORCHAGENT_MLNX)
SONIC_INSTALL_DOCKER_IMAGES += $(DOCKER_ORCHAGENT_MLNX)

$(DOCKER_ORCHAGENT_MLNX)_CONTAINER_NAME = swss
$(DOCKER_ORCHAGENT_MLNX)_RUN_OPT += --net=host --privileged -t
$(DOCKER_ORCHAGENT_MLNX)_RUN_OPT += --volumes-from database
$(DOCKER_ORCHAGENT_MLNX)_RUN_OPT += -v /etc/ssw/:/etc/ssw/:ro
$(DOCKER_ORCHAGENT_MLNX)_RUN_OPT += -v /etc/network/interfaces:/etc/network/interfaces:ro
$(DOCKER_ORCHAGENT_MLNX)_RUN_OPT += -v /etc/network/interfaces.d/:/etc/network/interfaces.d/:ro
$(DOCKER_ORCHAGENT_MLNX)_RUN_OPT += -v /host/machine.conf:/host/machine.conf
Expand Down
1 change: 0 additions & 1 deletion rules/docker-snmp-sv2.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@ SONIC_INSTALL_DOCKER_IMAGES += $(DOCKER_SNMP_SV2)

$(DOCKER_SNMP_SV2)_CONTAINER_NAME = snmp
$(DOCKER_SNMP_SV2)_RUN_OPT += --net=host --privileged -t
$(DOCKER_SNMP_SV2)_RUN_OPT += -v /etc/ssw/:/etc/ssw/:ro
$(DOCKER_SNMP_SV2)_RUN_OPT += -v /etc/sonic:/etc/sonic:ro
1 change: 0 additions & 1 deletion src/sonic-config-engine/platform/AS7512/alias_map.json

This file was deleted.

34 changes: 33 additions & 1 deletion src/sonic-config-engine/platform/AS7512/port_config.ini
Original file line number Diff line number Diff line change
@@ -1 +1,33 @@
# TODO: Add correct info here
# alias lanes
Ethernet0 16,17,18,19
Ethernet4 20,21,22,23
Ethernet8 24,25,26,27
Ethernet12 28,29,30,31
Ethernet16 32,33,34,35
Ethernet20 36,37,38,39
Ethernet24 40,41,42,43
Ethernet28 44,45,46,47
Ethernet32 0,1,2,3
Ethernet36 4,5,6,7
Ethernet40 8,9,10,11
Ethernet44 12,13,14,15
Ethernet48 48,49,50,51
Ethernet52 52,53,54,55
Ethernet56 56,57,58,59
Ethernet60 60,61,62,63
Ethernet64 127,126,125,124
Ethernet68 123,122,121,120
Ethernet72 115,114,113,112
Ethernet76 119,118,117,116
Ethernet80 79,78,77,76
Ethernet84 75,74,73,72
Ethernet88 64,65,66,67
Ethernet92 71,70,68,69
Ethernet96 111,110,109,108
Ethernet100 107,106,105,104
Ethernet104 103,102,101,100
Ethernet108 99,98,97,96
Ethernet112 95,94,93,92
Ethernet116 91,90,89,88
Ethernet120 87,86,85,84
Ethernet124 83,82,81,80
1 change: 0 additions & 1 deletion src/sonic-config-engine/platform/AS7512/sensors.conf

This file was deleted.

5 changes: 3 additions & 2 deletions src/sonic-config-engine/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ def get_platform_file_list():
data_path = os.path.join(repo_path, 'platform')
platforms = os.listdir(data_path)
for platform in platforms:
files = ['platform/' + platform + '/alias_map.json',
'platform/' + platform + '/port_config.ini']
files = ['platform/' + platform + '/port_config.ini']
if os.path.isfile( os.path.join(data_path, platform, 'alias_map.json') ):
files.append('platform/' + platform + '/alias_map.json') #If a platform doesnot have alias_map.json minigraph.py will fall back to no alias mapping
if os.path.isfile( os.path.join(data_path, platform, 'sensors.conf') ):
files.append('platform/' + platform + '/sensors.conf') #Not all platforms need to have a sensors.conf file
data_files.append( (os.path.join('/usr/share/sonic', platform), files) )
Expand Down

0 comments on commit 60e1fc3

Please sign in to comment.