Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
simonJi2018 committed Nov 27, 2018
2 parents 7ac1862 + 7056b49 commit b338aaf
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 3 deletions.
5 changes: 5 additions & 0 deletions build_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ elif [ "$IMAGE_TYPE" = "kvm" ]; then

SONIC_USERNAME=$USERNAME PASSWD=$PASSWORD sudo -E ./build_kvm_image.sh $KVM_IMAGE_DISK $onie_recovery_image $OUTPUT_ONIE_IMAGE $KVM_IMAGE_DISK_SIZE

if [ $? -ne 0 ]; then
echo "Error : build kvm image failed"
exit 1
fi

[ -r $KVM_IMAGE_DISK ] || {
echo "Error : $KVM_IMAGE_DISK not generated!"
exit 1
Expand Down
2 changes: 1 addition & 1 deletion build_kvm_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ prepare_installer_disk
-vga std \
-drive file=$DISK,media=disk,if=virtio,index=0 \
-drive file=$INSTALLER_DISK,if=virtio,index=1 \
-serial telnet:localhost:$KVM_PORT,server > $kvm_log 2>&1 &
-serial telnet:127.0.0.1:$KVM_PORT,server > $kvm_log 2>&1 &

kvm_pid=$!

Expand Down
6 changes: 6 additions & 0 deletions dockers/docker-fpm-frr/Dockerfile.j2
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
FROM docker-config-engine

ARG docker_container_name
ARG frr_user_uid
ARG frr_user_gid

RUN [ -f /etc/rsyslog.conf ] && sed -ri "s/%syslogtag%/$docker_container_name#%syslogtag%/;" /etc/rsyslog.conf

# Make apt-get non-interactive
Expand All @@ -18,6 +21,9 @@ RUN apt-get install -y libdbus-1-3 libdaemon0 libjansson4 libc-ares2 iproute lib
COPY debs/{{ deb }} /debs/
{%- endfor %}

RUN groupadd -g ${frr_user_gid} frr
RUN useradd -u ${frr_user_uid} -g ${frr_user_gid} -M -s /bin/false frr

# Install locally-built Debian packages and implicitly install their dependencies
{%- for deb in docker_fpm_frr_debs.split(' ') %}
RUN dpkg_apt() { [ -f $1 ] && { dpkg -i $1 || apt-get -y install -f; } || return 1; }; dpkg_apt /debs/{{ deb }}
Expand Down
7 changes: 6 additions & 1 deletion dockers/docker-fpm-frr/config.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
#!/bin/bash

mkdir -p /etc/frr
sonic-cfggen -d -t /usr/share/sonic/templates/frr.conf.j2 >/etc/frr/frr.conf

CONFIG_TYPE=`sonic-cfggen -d -v 'DEVICE_METADATA["localhost"]["docker_routing_config_mode"]'`

if [ -z "$CONFIG_TYPE" ] || [ "$CONFIG_TYPE" == "unified" ]; then
sonic-cfggen -d -t /usr/share/sonic/templates/frr.conf.j2 >/etc/frr/frr.conf
fi

sonic-cfggen -d -t /usr/share/sonic/templates/isolate.j2 >/usr/sbin/bgp-isolate
chown root:root /usr/sbin/bgp-isolate
Expand Down
14 changes: 13 additions & 1 deletion files/build_templates/sonic_debian_extension.j2
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,10 @@ sudo dpkg --root=$FILESYSTEM_ROOT -P {{ debname }}

sudo rm -f $FILESYSTEM_ROOT/usr/sbin/policy-rc.d

## Revise /etc/init.d/networking for Arista switches
## Revise /etc/init.d/networking and /lib/systemd/system/networking.service for Arista switches
if [ "$image_type" = "aboot" ]; then
sudo sed -i 's/udevadm settle/udevadm settle -E \/sys\/class\/net\/eth0/' $FILESYSTEM_ROOT/etc/init.d/networking
sudo sed -i 's/udevadm settle/udevadm settle -E \/sys\/class\/net\/eth0/' $FILESYSTEM_ROOT/lib/systemd/system/networking.service
fi

## copy platform rc.local
Expand Down Expand Up @@ -319,3 +320,14 @@ sudo cp target/files/$MLNX_FW_FILE $FILESYSTEM_ROOT/etc/mlnx/fw-SPC.mfa
j2 platform/mellanox/mlnx-fw-upgrade.j2 | sudo tee $FILESYSTEM_ROOT/usr/bin/mlnx-fw-upgrade.sh
sudo chmod 755 $FILESYSTEM_ROOT/usr/bin/mlnx-fw-upgrade.sh
{% endif %}

{%- if SONIC_ROUTING_STACK == "frr" %}
sudo mkdir $FILESYSTEM_ROOT/etc/sonic/frr
sudo touch $FILESYSTEM_ROOT/etc/sonic/frr/frr.conf
sudo touch $FILESYSTEM_ROOT/etc/sonic/frr/vtysh.conf
sudo cp dockers/docker-fpm-frr/daemons.conf $FILESYSTEM_ROOT/etc/sonic/frr/
sudo cp dockers/docker-fpm-frr/daemons $FILESYSTEM_ROOT/etc/sonic/frr/
sudo chown -R $FRR_USER_UID:$FRR_USER_GID $FILESYSTEM_ROOT/etc/sonic/frr
sudo chmod 750 $FILESYSTEM_ROOT/etc/sonic/frr
sudo chmod -R 640 $FILESYSTEM_ROOT/etc/sonic/frr/
{%- endif %}
9 changes: 9 additions & 0 deletions rules/config
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,12 @@ ENABLE_ORGANIZATION_EXTENSIONS = y
# build: build kernel from source
# download: download pre-built kernel from Azure storage.
DEFAULT_KERNEL_PROCURE_METHOD = build

# FRR user and group id values. These only take effect when SONIC_ROUTING_STACK is frr.
# Note: these values match the admin uid/gid of the host's admin account. If these values
# change and user doesn't want the frr uid/gid to potentially match a random user on the
# host, then either the appropriate account and group will need to be created on the host
# manually or changes need to be made when the image is built to create the account and
# group during installation.
FRR_USER_UID = 1000
FRR_USER_GID = 1000
1 change: 1 addition & 0 deletions rules/docker-fpm-frr.mk
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ SONIC_DOCKER_IMAGES += $(DOCKER_FPM_FRR)
$(DOCKER_FPM_FRR)_CONTAINER_NAME = bgp
$(DOCKER_FPM_FRR)_RUN_OPT += --net=host --privileged -t
$(DOCKER_FPM_FRR)_RUN_OPT += -v /etc/sonic:/etc/sonic:ro
$(DOCKER_FPM_FRR)_RUN_OPT += -v /etc/sonic/frr:/etc/frr:rw

$(DOCKER_FPM_FRR)_BASE_IMAGE_FILES += vtysh:/usr/bin/vtysh
14 changes: 14 additions & 0 deletions slave.mk
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,14 @@ endif
MAKEFLAGS += -j $(SONIC_BUILD_JOBS)
export SONIC_CONFIG_MAKE_JOBS

###############################################################################
## Routing stack related exports
###############################################################################

export SONIC_ROUTING_STACK
export FRR_USER_UID
export FRR_USER_GID

###############################################################################
## Dumping key config attributes associated to current building exercise
###############################################################################
Expand All @@ -134,6 +142,10 @@ $(info "SHUTDOWN_BGP_ON_START" : "$(SHUTDOWN_BGP_ON_START)")
$(info "ENABLE_PFCWD_ON_START" : "$(ENABLE_PFCWD_ON_START)")
$(info "INSTALL_DEBUG_TOOLS" : "$(INSTALL_DEBUG_TOOLS)")
$(info "ROUTING_STACK" : "$(SONIC_ROUTING_STACK)")
ifeq ($(SONIC_ROUTING_STACK),frr)
$(info "FRR_USER_UID" : "$(FRR_USER_UID)")
$(info "FRR_USER_GID" : "$(FRR_USER_GID)")
endif
$(info "ENABLE_SYNCD_RPC" : "$(ENABLE_SYNCD_RPC)")
$(info "ENABLE_ORGANIZATION_EXTENSIONS" : "$(ENABLE_ORGANIZATION_EXTENSIONS)")
$(info "HTTP_PROXY" : "$(HTTP_PROXY)")
Expand Down Expand Up @@ -463,6 +475,8 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_DOCKER_IMAGES)) : $(TARGET_PATH)/%.gz : .pl
--build-arg uid=$(UID) \
--build-arg guid=$(GUID) \
--build-arg docker_container_name=$($*.gz_CONTAINER_NAME) \
--build-arg frr_user_uid=$(FRR_USER_UID) \
--build-arg frr_user_gid=$(FRR_USER_GID) \
--label Tag=$(SONIC_GET_VERSION) \
-t $* $($*.gz_PATH) $(LOG)
docker save $* | gzip -c > $@
Expand Down
5 changes: 5 additions & 0 deletions src/sonic-config-engine/minigraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,7 @@ def parse_xml(filename, platform=None, port_config_file=None):
neighbors = None
devices = None
hostname = None
docker_routing_config_mode = "unified"
port_speeds_default = {}
port_speed_png = {}
port_descriptions = {}
Expand All @@ -437,11 +438,14 @@ def parse_xml(filename, platform=None, port_config_file=None):

hwsku_qn = QName(ns, "HwSku")
hostname_qn = QName(ns, "Hostname")
docker_routing_config_mode_qn = QName(ns, "DockerRoutingConfigMode")
for child in root:
if child.tag == str(hwsku_qn):
hwsku = child.text
if child.tag == str(hostname_qn):
hostname = child.text
if child.tag == str(docker_routing_config_mode_qn):
docker_routing_config_mode = child.text

(ports, alias_map) = get_port_config(hwsku, platform, port_config_file)
port_alias_map.update(alias_map)
Expand All @@ -464,6 +468,7 @@ def parse_xml(filename, platform=None, port_config_file=None):
results['DEVICE_METADATA'] = {'localhost': {
'bgp_asn': bgp_asn,
'deployment_id': deployment_id,
'docker_routing_config_mode': docker_routing_config_mode,
'hostname': hostname,
'hwsku': hwsku,
'type': current_device['type']
Expand Down

0 comments on commit b338aaf

Please sign in to comment.