Skip to content

Commit 1347f29

Browse files
authored
[docker-mgmt-framework]: update mgmt framework docker to support sonic-cli cmd (#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
1 parent 906fb67 commit 1347f29

File tree

3 files changed

+26
-20
lines changed

3 files changed

+26
-20
lines changed

dockers/docker-sonic-mgmt-framework/Dockerfile.j2

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,7 @@ RUN [ -f /etc/rsyslog.conf ] && sed -ri "s/%syslogtag%/$docker_container_name#%s
77
ENV DEBIAN_FRONTEND=noninteractive
88

99
RUN apt-get update && \
10-
apt-get install -y g++ python3-dev libxml2
11-
12-
# TODO: Remove these lines once we no longer need Python 2
13-
RUN apt-get install -f -y python-dev python-pip
14-
RUN pip2 install --upgrade 'pip<21'
15-
RUN apt-get purge -y python-pip
16-
RUN pip2 install setuptools==40.8.0
17-
RUN pip2 install wheel==0.35.1
18-
RUN pip2 install connexion==1.1.15 \
19-
setuptools==21.0.0 \
20-
grpcio-tools==1.20.0 \
21-
certifi==2017.4.17 \
22-
python-dateutil==2.6.0 \
23-
six==1.11.0 \
24-
urllib3==1.21.1
10+
apt-get install -y g++ python3-dev libxml2 libcurl3-gnutls libcjson-dev
2511

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

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

39+
## TODO: symbolic links will be removed when AAA improvements get merged
40+
RUN ln -sf /host_etc/passwd /etc/passwd
41+
RUN ln -sf /host_etc/group /etc/group
42+
5643
ENTRYPOINT ["/usr/local/bin/supervisord"]
Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,21 @@
11
#!/bin/bash
22

3-
docker exec -it mgmt-framework /usr/sbin/cli/clish_start "$@"
4-
3+
# Disallow CLI for the root user, since we don't have auth certs for root
4+
if [[ "$(id -u)" == 0 ]]
5+
then
6+
echo "FATAL: root cannot launch CLI" >&2
7+
exit 1
8+
fi
9+
TIMEOUT=605
10+
if [[ "$1" =~ "prompt=" ]]
11+
then
12+
SYSTEM_NAME=`echo $1 | cut -d"=" -f2`
13+
shift
14+
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" "$@"
15+
else
16+
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" "$@"
17+
fi
18+
ret=$?
19+
if [ $ret -ne 0 ]; then
20+
[[ -e /tmp/fast-reboot-progress || -e /tmp/reboot-progress ]] && sleep infinity
21+
fi

sonic-slave-buster/Dockerfile.j2

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,8 @@ RUN apt-get update && apt-get install -y \
302302
xsltproc \
303303
python-lxml \
304304
libexpat1-dev \
305+
libcurl3-gnutls \
306+
libcjson-dev \
305307
# For WPA supplication
306308
qtbase5-dev \
307309
aspell-en \

0 commit comments

Comments
 (0)