use local yangmodels/openconfig (if present) instead of github

This commit is contained in:
Olof hagsand 2023-09-29 22:06:18 +02:00
parent 794a17c2bb
commit 06d8e85290
9 changed files with 58 additions and 39 deletions

View file

@ -44,17 +44,13 @@ RUN apk add --update net-snmp net-snmp-dev
# Checkout standard YANG models for tests (note >1G for full repo) # Checkout standard YANG models for tests (note >1G for full repo)
RUN mkdir -p /usr/local/share/yang RUN mkdir -p /usr/local/share/yang
WORKDIR /usr/local/share/yang WORKDIR /usr/local/share/yang
COPY yang .
RUN git config --global init.defaultBranch master # Checkout OPENCONFIG YANG models for tests
RUN git init; RUN mkdir -p /usr/local/share/openconfig
RUN git remote add -f origin https://github.com/YangModels/yang; WORKDIR /usr/local/share/openconfig
RUN git config core.sparseCheckout true COPY openconfig .
RUN echo "standard/" >> .git/info/sparse-checkout
RUN echo "experimental/" >> .git/info/sparse-checkout
RUN git pull origin main
# Create a directory to hold source-code, dependencies etc # Create a directory to hold source-code, dependencies etc
RUN mkdir -p /clixon/build RUN mkdir -p /clixon/build
@ -126,7 +122,9 @@ RUN adduser -D -H clicon
COPY --from=0 /clixon/build/ / COPY --from=0 /clixon/build/ /
COPY --from=0 /usr/local/share/yang/ /usr/local/share/yang/ COPY --from=0 /usr/local/share/yang/ /usr/local/share/yang/
COPY --from=0 /usr/local/share/openconfig/* /usr/local/share/openconfig/
COPY --from=0 /usr/local/share/mib-yangs/* /usr/local/share/mib-yangs/ COPY --from=0 /usr/local/share/mib-yangs/* /usr/local/share/mib-yangs/
COPY --from=0 /clixon/build/mibs/* /usr/share/snmp/mibs/
# Log to stderr. # Log to stderr.
CMD /usr/local/bin/startsystem.sh CMD /usr/local/bin/startsystem.sh

View file

@ -43,23 +43,13 @@ RUN apk add --update net-snmp net-snmp-dev
# Checkout standard YANG models for tests (note >1G for full repo) # Checkout standard YANG models for tests (note >1G for full repo)
RUN mkdir -p /usr/local/share/yang RUN mkdir -p /usr/local/share/yang
WORKDIR /usr/local/share/yang WORKDIR /usr/local/share/yang
COPY yang .
RUN git config --global init.defaultBranch master # Checkout OPENCONFIG YANG models for tests
RUN git init
RUN git remote add -f origin https://github.com/YangModels/yang
RUN git config core.sparseCheckout true
RUN echo "standard/" >> .git/info/sparse-checkout
RUN echo "experimental/" >> .git/info/sparse-checkout
RUN git pull origin main
RUN mkdir -p /usr/local/share/openconfig RUN mkdir -p /usr/local/share/openconfig
WORKDIR /usr/local/share/openconfig WORKDIR /usr/local/share/openconfig
COPY openconfig .
# Checkut Openconfig models for tests
RUN git clone https://github.com/openconfig/public
# Create a directory to hold source-code, dependencies etc # Create a directory to hold source-code, dependencies etc
RUN mkdir -p /clixon/build RUN mkdir -p /clixon/build
@ -156,6 +146,7 @@ RUN adduser www-data clicon
COPY --from=0 /clixon/build/ / COPY --from=0 /clixon/build/ /
COPY --from=0 /usr/local/share/yang/ /usr/local/share/yang/ COPY --from=0 /usr/local/share/yang/ /usr/local/share/yang/
COPY --from=0 /usr/local/share/openconfig/* /usr/local/share/openconfig/
COPY --from=0 /usr/local/share/mib-yangs/* /usr/local/share/mib-yangs/ COPY --from=0 /usr/local/share/mib-yangs/* /usr/local/share/mib-yangs/
COPY --from=0 /clixon/build/mibs/* /usr/share/snmp/mibs/ COPY --from=0 /clixon/build/mibs/* /usr/share/snmp/mibs/

View file

@ -46,23 +46,13 @@ RUN apk add --update net-snmp net-snmp-dev
# Checkout standard YANG models for tests (note >1G for full repo) # Checkout standard YANG models for tests (note >1G for full repo)
RUN mkdir -p /usr/local/share/yang RUN mkdir -p /usr/local/share/yang
WORKDIR /usr/local/share/yang WORKDIR /usr/local/share/yang
COPY yang .
RUN git config --global init.defaultBranch master # Checkout OPENCONFIG YANG models for tests
RUN git init
RUN git remote add -f origin https://github.com/YangModels/yang
RUN git config core.sparseCheckout true
RUN echo "standard/" >> .git/info/sparse-checkout
RUN echo "experimental/" >> .git/info/sparse-checkout
RUN git pull origin main
RUN mkdir -p /usr/local/share/openconfig RUN mkdir -p /usr/local/share/openconfig
WORKDIR /usr/local/share/openconfig WORKDIR /usr/local/share/openconfig
COPY openconfig .
# Checkut Openconfig models for tests
RUN git clone https://github.com/openconfig/public
# Create a directory to hold source-code, dependencies etc # Create a directory to hold source-code, dependencies etc
RUN mkdir -p /clixon/build RUN mkdir -p /clixon/build

View file

@ -66,12 +66,18 @@ clixon:
git clone file://$(realpath ${top_srcdir}) git clone file://$(realpath ${top_srcdir})
clean: clean:
rm -rf clixon # clone of top-srcdir rm -rf clixon yang openconfig
distclean: clean distclean: clean
rm -f Makefile *~ .depend rm -f Makefile *~ .depend
docker: clixon $(DOCKERFILE) yang:
./getyang.sh
openconfig:
./getopenconfig.sh
docker: clixon yang openconfig $(DOCKERFILE)
sudo docker build -f $(DOCKERFILE) -t $(IMG) $(DOCKERFLAGS) . sudo docker build -f $(DOCKERFILE) -t $(IMG) $(DOCKERFLAGS) .
push: push:

14
docker/test/getopenconfig.sh Executable file
View file

@ -0,0 +1,14 @@
#!/usr/bin/env bash
# Script to get openconfig, either from local installation, or from remote
# This is an optimization from always getting it from github inside the dockerfile
if [ -d openconfig ]; then
rm -rf openconfig
fi
mkdir -p openconfig
if [ -d /usr/local/share/openconfig ]; then
cp -R /usr/local/share/openconfig openconfig/
else
(cd openconfig && git clone https://github.com/openconfig/public)
fi

19
docker/test/getyang.sh Executable file
View file

@ -0,0 +1,19 @@
#!/usr/bin/env bash
# Script to get yangmodels, either from local installation, or from remote
# This is an optimization from always getting it from github inside the dockerfile
if [ -d yang ]; then
rm -rf yang
fi
mkdir -p yang/standard
if [ -d /usr/local/share/yang/standard ]; then
cp -R /usr/local/share/yang/standard yang/
else
cd yang
git init
git remote add -f origin https://github.com/YangModels/yang
git config core.sparseCheckout true
echo "standard/" >> .git/info/sparse-checkout
echo "experimental/" >> .git/info/sparse-checkout
git pull origin main
fi

View file

@ -67,6 +67,7 @@ EOF
# Patch to override YANG_INSTALLDIRS # Patch to override YANG_INSTALLDIRS
cat <<EOF >> /usr/local/bin/test/config.sh cat <<EOF >> /usr/local/bin/test/config.sh
YANG_INSTALLDIR=/usr/local/share/clixon YANG_INSTALLDIR=/usr/local/share/clixon
OPENCONFIG=/usr/local/share/openconfig/public
EOF EOF
# Patch yang syntax errors # Patch yang syntax errors

View file

@ -97,7 +97,7 @@ EOF
# Patch to override YANG_INSTALLDIRS # Patch to override YANG_INSTALLDIRS
cat <<EOF >> /usr/local/bin/test/config.sh cat <<EOF >> /usr/local/bin/test/config.sh
YANG_INSTALLDIR=/usr/local/share/clixon YANG_INSTALLDIR=/usr/local/share/clixon
OPENCONFIG=/usr/local/share/openconfig OPENCONFIG=/usr/local/share/openconfig/public
EOF EOF
# Patch yang syntax errors # Patch yang syntax errors

View file

@ -64,7 +64,7 @@ EOF
# Patch to override YANG_INSTALLDIRS # Patch to override YANG_INSTALLDIRS
cat <<EOF >> /usr/local/bin/test/config.sh cat <<EOF >> /usr/local/bin/test/config.sh
YANG_INSTALLDIR=/usr/local/share/clixon YANG_INSTALLDIR=/usr/local/share/clixon
OPENCONFIG=/usr/local/share/openconfig OPENCONFIG=/usr/local/share/openconfig/public
EOF EOF
# Patch yang syntax errors # Patch yang syntax errors