Skip to content

Commit

Permalink
[docker-mgmt-framework]: update mgmt framework docker to support soni…
Browse files Browse the repository at this point in the history
…c-cli cmd (sonic-net#6148)

- Why I did it

migrate to python3 support
add dependent packages for Klish
allow login as non-root user
- How I did it
update sonic-cli script to start Klish with user name, system name and timeout
update the Dockerfile.j2 to resolve dependent packages
add python3-dev for Klish use

- How to verify it
Incremental buster build with sonic-net/sonic-mgmt-framework#76 and verify the sonic-cli

- Description for the changelog
Migrate to python3.7 support, update sonic-cli script and resolve package dependencies
  • Loading branch information
kwangsuk authored Jun 3, 2021
1 parent 906fb67 commit 1347f29
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 20 deletions.
23 changes: 5 additions & 18 deletions dockers/docker-sonic-mgmt-framework/Dockerfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,7 @@ RUN [ -f /etc/rsyslog.conf ] && sed -ri "s/%syslogtag%/$docker_container_name#%s
ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update && \
apt-get install -y g++ python3-dev libxml2

# TODO: Remove these lines once we no longer need Python 2
RUN apt-get install -f -y python-dev python-pip
RUN pip2 install --upgrade 'pip<21'
RUN apt-get purge -y python-pip
RUN pip2 install setuptools==40.8.0
RUN pip2 install wheel==0.35.1
RUN pip2 install connexion==1.1.15 \
setuptools==21.0.0 \
grpcio-tools==1.20.0 \
certifi==2017.4.17 \
python-dateutil==2.6.0 \
six==1.11.0 \
urllib3==1.21.1
apt-get install -y g++ python3-dev libxml2 libcurl3-gnutls libcjson-dev

RUN pip3 install connexion==2.7.0 \
setuptools==21.0.0 \
Expand All @@ -46,11 +32,12 @@ COPY ["start.sh", "rest-server.sh", "/usr/bin/"]
COPY ["mgmt_vars.j2", "/usr/share/sonic/templates/"]
COPY ["supervisord.conf", "/etc/supervisor/conf.d/"]

# TODO: Remove this line once we no longer need Python 2
RUN apt-get purge -y python-dev
RUN apt-get remove -y g++ python3-dev
RUN apt-get clean -y; apt-get autoclean -y; apt-get autoremove -y
RUN rm -rf /debs

## TODO: symbolic links will be removed when AAA improvements get merged
RUN ln -sf /host_etc/passwd /etc/passwd
RUN ln -sf /host_etc/group /etc/group

ENTRYPOINT ["/usr/local/bin/supervisord"]
21 changes: 19 additions & 2 deletions dockers/docker-sonic-mgmt-framework/base_image_files/sonic-cli
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
#!/bin/bash

docker exec -it mgmt-framework /usr/sbin/cli/clish_start "$@"

# Disallow CLI for the root user, since we don't have auth certs for root
if [[ "$(id -u)" == 0 ]]
then
echo "FATAL: root cannot launch CLI" >&2
exit 1
fi
TIMEOUT=605
if [[ "$1" =~ "prompt=" ]]
then
SYSTEM_NAME=`echo $1 | cut -d"=" -f2`
shift
docker exec -e SYSTEM_NAME=$SYSTEM_NAME -e CLI_USER="$USER" -u $(id -u):$(id -g) -it mgmt-framework /usr/sbin/cli/clish_start -t "$TIMEOUT" "$@"
else
docker exec -e CLI_USER="$USER" -e SYSTEM_NAME=$HOSTNAME -u $(id -u):$(id -g) -it mgmt-framework /usr/sbin/cli/clish_start -t "$TIMEOUT" "$@"
fi
ret=$?
if [ $ret -ne 0 ]; then
[[ -e /tmp/fast-reboot-progress || -e /tmp/reboot-progress ]] && sleep infinity
fi
2 changes: 2 additions & 0 deletions sonic-slave-buster/Dockerfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,8 @@ RUN apt-get update && apt-get install -y \
xsltproc \
python-lxml \
libexpat1-dev \
libcurl3-gnutls \
libcjson-dev \
# For WPA supplication
qtbase5-dev \
aspell-en \
Expand Down

0 comments on commit 1347f29

Please sign in to comment.