diff --git a/Makefile.in b/Makefile.in index 2a4011d7..d51f5ee7 100644 --- a/Makefile.in +++ b/Makefile.in @@ -41,7 +41,7 @@ SHELL = /bin/sh SUBDIRS = lib apps include etc -.PHONY: doc all clean depend $(SUBDIRS) install loc TAGS .config.status +.PHONY: doc all clean depend $(SUBDIRS) install loc TAGS .config.status docker all: $(SUBDIRS) clicon.conf.cpp clicon.mk @@ -98,6 +98,10 @@ distclean: for i in $(SUBDIRS) doc example; \ do (cd $$i && $(MAKE) $(MFLAGS) $@); done +docker: + for i in docker; \ + do (cd $$i && $(MAKE) $(MFLAGS) $@); done + # Lines of code loc: find . -name '*.[chyl]' -type f | xargs wc -l | tail -1 2> /dev/null diff --git a/apps/backend/Makefile.in b/apps/backend/Makefile.in index 40bd3b55..db963c7e 100644 --- a/apps/backend/Makefile.in +++ b/apps/backend/Makefile.in @@ -97,7 +97,7 @@ uninstall: rm -f $(libdir)/$(MYLIB) rm -f $(includedir)/clicon/* -install-include: clicon_backend.h clicon_backend_api.h +install-include: clicon_backend.h clicon_backend_handle.h clicon_backend_transaction.h install -d $(DESTDIR)$(includedir)/clicon install -m 644 $^ $(DESTDIR)$(includedir)/clicon diff --git a/clicon.conf.cpp.cpp b/clicon.conf.cpp.cpp index 9520e5d7..cc6f8d4f 100644 --- a/clicon.conf.cpp.cpp +++ b/clicon.conf.cpp.cpp @@ -32,9 +32,6 @@ # Location of configuration-file for default values (this file) CLICON_CONFIGFILE sysconfdir/APPNAME.conf -# Database (yang) specification file. -CLICON_DBSPEC_FILE prefix/share/APPNAME/datamodel.spec - # Location of YANG module and submodule files. Only if CLICON_DBSPEC_TYPE is YANG CLICON_YANG_DIR prefix/share/APPNAME/yang diff --git a/configure b/configure index 64d81bba..74b27f8c 100755 --- a/configure +++ b/configure @@ -4191,7 +4191,7 @@ fi -ac_config_files="$ac_config_files Makefile lib/Makefile lib/src/Makefile lib/clicon/Makefile apps/Makefile apps/cli/Makefile apps/backend/Makefile apps/netconf/Makefile apps/dbctrl/Makefile include/Makefile etc/Makefile etc/cliconrc example/Makefile docker/Makefile doc/Makefile docker/Dockerfile" +ac_config_files="$ac_config_files Makefile lib/Makefile lib/src/Makefile lib/clicon/Makefile apps/Makefile apps/cli/Makefile apps/backend/Makefile apps/netconf/Makefile apps/dbctrl/Makefile include/Makefile etc/Makefile etc/cliconrc example/Makefile example/docker/Makefile docker/Makefile docker/cli/Makefile docker/cli/Dockerfile docker/backend/Makefile docker/backend/Dockerfile doc/Makefile" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure @@ -4897,9 +4897,13 @@ do "etc/Makefile") CONFIG_FILES="$CONFIG_FILES etc/Makefile" ;; "etc/cliconrc") CONFIG_FILES="$CONFIG_FILES etc/cliconrc" ;; "example/Makefile") CONFIG_FILES="$CONFIG_FILES example/Makefile" ;; + "example/docker/Makefile") CONFIG_FILES="$CONFIG_FILES example/docker/Makefile" ;; "docker/Makefile") CONFIG_FILES="$CONFIG_FILES docker/Makefile" ;; + "docker/cli/Makefile") CONFIG_FILES="$CONFIG_FILES docker/cli/Makefile" ;; + "docker/cli/Dockerfile") CONFIG_FILES="$CONFIG_FILES docker/cli/Dockerfile" ;; + "docker/backend/Makefile") CONFIG_FILES="$CONFIG_FILES docker/backend/Makefile" ;; + "docker/backend/Dockerfile") CONFIG_FILES="$CONFIG_FILES docker/backend/Dockerfile" ;; "doc/Makefile") CONFIG_FILES="$CONFIG_FILES doc/Makefile" ;; - "docker/Dockerfile") CONFIG_FILES="$CONFIG_FILES docker/Dockerfile" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac diff --git a/configure.ac b/configure.ac index 72d461bf..77158689 100644 --- a/configure.ac +++ b/configure.ac @@ -168,8 +168,12 @@ AC_OUTPUT(Makefile etc/Makefile etc/cliconrc example/Makefile + example/docker/Makefile docker/Makefile + docker/cli/Makefile + docker/cli/Dockerfile + docker/backend/Makefile + docker/backend/Dockerfile doc/Makefile - docker/Dockerfile ) diff --git a/docker/Makefile.in b/docker/Makefile.in index e634787b..ec50e938 100644 --- a/docker/Makefile.in +++ b/docker/Makefile.in @@ -18,43 +18,53 @@ # . # VPATH = @srcdir@ -prefix = @prefix@ -exec_prefix = @exec_prefix@ srcdir = @srcdir@ top_srcdir = @top_srcdir@ -prefix = @prefix@ -bindir = @bindir@ -sbindir = @sbindir@ -libdir = @libdir@ -includedir = @includedir@ -datarootdir = @datarootdir@ +CC = @CC@ +CFLAGS = @CFLAGS@ +LDFLAGS = @LDFLAGS@ +LIBS = @LIBS@ -all: - @echo "Run make docker to build docker image" -clean: +SHELL = /bin/sh -distclean: clean - rm -f Makefile *~ .depend libcli* clicon_cli clicon_backend Dockerfile +SUBDIRS = cli backend -# Kind of reverse install, could have copied from src dir,... -.PHONY: docker -docker: - cp $(DESTDIR)$(libdir)/libcligen.so.@CLIGEN_VERSION@ . - cp $(DESTDIR)$(libdir)/libclicon.so.@CLICON_VERSION_MAJOR@ . - cp $(DESTDIR)$(libdir)/libclicon_cli.so.@CLICON_VERSION_MAJOR@ . - cp $(DESTDIR)$(libdir)/libclicon_backend.so.@CLICON_VERSION_MAJOR@ . - cp $(DESTDIR)$(bindir)/clicon_cli . - cp $(DESTDIR)$(sbindir)/clicon_backend . - touch nullfile +.PHONY: all clean depend install $(SUBDIRS) docker push -install: - -uninstall: - -install-include: +all: $(SUBDIRS) depend: -# $(CC) $(DEPENDFLAGS) $(INCLUDES) $(CFLAGS) -MM $(SRC) > .depend + for i in $(SUBDIRS); \ + do (cd $$i; $(MAKE) $(MFLAGS) $@); done -#include .depend +$(SUBDIRS): + (cd $@; $(MAKE) $(MFLAGS) all) +install-include: + for i in $(SUBDIRS); \ + do (cd $$i ; $(MAKE) $(MFLAGS) $@); done; + +install: + for i in $(SUBDIRS); \ + do (cd $$i; $(MAKE) $(MFLAGS) $@); done + +uninstall: + for i in $(SUBDIRS); \ + do (cd $$i; $(MAKE) $(MFLAGS) $@); done + +clean: + for i in $(SUBDIRS); \ + do (cd $$i; $(MAKE) $(MFLAGS) $@); done + +distclean: clean + rm -f Makefile *~ .depend + for i in $(SUBDIRS); \ + do (cd $$i; $(MAKE) $(MFLAGS) $@); done + +docker: + for i in $(SUBDIRS); \ + do (cd $$i && $(MAKE) $(MFLAGS) $@); done + +push: + for i in $(SUBDIRS); \ + do (cd $$i && $(MAKE) $(MFLAGS) $@); done diff --git a/docker/README b/docker/README index 6ef0724b..a9f48b0f 100644 --- a/docker/README +++ b/docker/README @@ -1,80 +1,6 @@ -You can skip directly to (3) - -1. Building it yourself -+++++++++++++++++++++++ -Ensure that cligen and clicon has been built and installed. -make docker - -2. Building a docker and publishing it -++++++++++++++++++++++++++++++++++++++ -This example pushes it to my (Olof Hagsand)s docker hub repository - -sudo docker build --no-cache=true -t olofhagsand/clicon_cli:v1.0 . -sudo docker push olofhagsand/clicon_yang - -3. From docker -++++++++++++++ -The easiest is just to run it from docker hub: -> sudo docker run -i -t -P olofhagsand/clicon_yang:v1.0 - -Either just try out the default yang specification or try out your own. - -3.1 Enter your own spec ------------------------ -$ sudo docker run -i -t -P olofhagsand/clicon_yang:v1.0 -input yang spec(end with ^d). Or just ^d for default spec> -container hello{ - leaf world{ - type string; } -} -^d -clicon_yang> hello world ! -clicon_yang> show -hello { - world !; -} -clicon_yang> - -3.2 Run the default -------------------- -> sudo docker run -i -t -P olofhagsand/clicon_yang:v1.0 -input yang spec(end with ^d). Or just ^d for default spec> ^d -clicon_yang> a 43 b y 88 -clicon_yang> a 43 c z 12 -clicon_yang> show -a { - x 43; - b { - y 88; - } - c { - z 12; - } -} - -3.3 Show options ----------------- - -There are several show commands where you can display your -specification as CLI, JSON or XML. You can also display the YANG specification. - -clicon_yang> show cli -hello world ! -clicon_yang> show json -{ - "hello": { - "world": "!" - } -} -clicon_yang> show xml - - ! - -clicon_yang> show yang -container hello { - leaf world { - type string; - } -} - +This dir contains docker code - how to build clixon as docker containers + cli Build olofhagsand/clicon_cli container + backend Build olofhagsand/clicon_backend container +You may run the container directly by going directly to example and +the docker runtime scripts there \ No newline at end of file diff --git a/docker/backend/Dockerfile.in b/docker/backend/Dockerfile.in new file mode 100644 index 00000000..85204ec0 --- /dev/null +++ b/docker/backend/Dockerfile.in @@ -0,0 +1,20 @@ +FROM ubuntu:14.04 +# 12.04 +MAINTAINER Olof Hagsand +ENV DEBIAN_FRONTEND noninteractive +RUN apt-get update && apt-get install -y libqdbm-dev +COPY libcligen.so.@CLIGEN_VERSION@ /usr/lib/ +COPY libclicon.so.@CLICON_VERSION_MAJOR@ /usr/lib/ +COPY libclicon_backend.so.@CLICON_VERSION_MAJOR@ /usr/lib/ +COPY clicon_backend /usr/sbin/ +RUN ldconfig +RUN sudo groupadd clicon +CMD ["/usr/sbin/clicon_backend", "-D", "1", "-F", "-f", "/data/clicon.conf"] + +EXPOSE 7878 7878/udp + + + + + + diff --git a/docker/backend/Makefile.in b/docker/backend/Makefile.in new file mode 100644 index 00000000..f2a3053e --- /dev/null +++ b/docker/backend/Makefile.in @@ -0,0 +1,63 @@ +# +# Copyright (C) 2009-2016 Olof Hagsand and Benny Holmgren +# +# This file is part of CLIXON. +# +# CLIXON is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# CLIXON is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with CLIXON; see the file LICENSE. If not, see +# . +# +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +prefix = @prefix@ +bindir = @bindir@ +sbindir = @sbindir@ +libdir = @libdir@ +includedir = @includedir@ +datarootdir = @datarootdir@ +image = olofhagsand/clicon_backend:v1.0 + +all: + @echo "Run make docker to build docker image" +clean: + +distclean: clean + rm -f Makefile *~ .depend libcli* clicon_cli clicon_backend Dockerfile + +# Kind of reverse install, could have copied from src dir,... +.PHONY: docker push +docker: + cp $(DESTDIR)$(libdir)/libcligen.so.@CLIGEN_VERSION@ . + cp $(DESTDIR)$(libdir)/libclicon.so.@CLICON_VERSION_MAJOR@ . + cp $(DESTDIR)$(libdir)/libclicon_backend.so.@CLICON_VERSION_MAJOR@ . + cp $(DESTDIR)$(sbindir)/clicon_backend . + sudo docker build -t $(image) . + +push: + docker push $(image) + + +install: + +uninstall: + +install-include: + +depend: +# $(CC) $(DEPENDFLAGS) $(INCLUDES) $(CFLAGS) -MM $(SRC) > .depend + +#include .depend + diff --git a/docker/backend/README b/docker/backend/README new file mode 100644 index 00000000..f2763a0c --- /dev/null +++ b/docker/backend/README @@ -0,0 +1,6 @@ +Ensure that cligen and clicon has been built and installed. +sudo make docker +make push + +Then go to example and run the example as a docker container + diff --git a/docker/Dockerfile.in b/docker/cli/Dockerfile.in similarity index 58% rename from docker/Dockerfile.in rename to docker/cli/Dockerfile.in index 5569ad3c..cb74cd58 100644 --- a/docker/Dockerfile.in +++ b/docker/cli/Dockerfile.in @@ -2,18 +2,14 @@ FROM ubuntu:14.04 # 12.04 MAINTAINER Olof Hagsand ENV DEBIAN_FRONTEND noninteractive -RUN apt-get update && apt-get install -y \ - libqdbm-dev \ - curl +RUN apt-get update && apt-get install -y libqdbm-dev COPY libcligen.so.@CLIGEN_VERSION@ /usr/lib/ COPY libclicon.so.@CLICON_VERSION_MAJOR@ /usr/lib/ COPY libclicon_cli.so.@CLIGEN_VERSION@ /usr/lib/ COPY clicon_cli /usr/bin/ -COPY nullfile /usr/local/var/clicon_yang/ -COPY start.sh /usr/bin/ RUN ldconfig -#CMD ["clicon_cli", "-c", "-f", "/usr/local/etc/clicon_yang.conf"] -CMD ["start.sh"] +CMD ["/usr/bin/clicon_cli", "-f", "/data/clicon.conf"] + EXPOSE 7878 7878/udp diff --git a/docker/cli/Makefile.in b/docker/cli/Makefile.in new file mode 100644 index 00000000..b8d026fe --- /dev/null +++ b/docker/cli/Makefile.in @@ -0,0 +1,63 @@ +# +# Copyright (C) 2009-2016 Olof Hagsand and Benny Holmgren +# +# This file is part of CLIXON. +# +# CLIXON is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# CLIXON is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with CLIXON; see the file LICENSE. If not, see +# . +# +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +prefix = @prefix@ +bindir = @bindir@ +sbindir = @sbindir@ +libdir = @libdir@ +includedir = @includedir@ +datarootdir = @datarootdir@ +# This is my dockerhub account +image = olofhagsand/clicon_cli:v1.0 + +all: + @echo "Run make docker to build docker image" +clean: + +distclean: clean + rm -f Makefile *~ .depend libcli* clicon_cli clicon_backend Dockerfile + +# Kind of reverse install, could have copied from src dir,... +.PHONY: docker push +docker: + cp $(DESTDIR)$(libdir)/libcligen.so.@CLIGEN_VERSION@ . + cp $(DESTDIR)$(libdir)/libclicon.so.@CLICON_VERSION_MAJOR@ . + cp $(DESTDIR)$(libdir)/libclicon_cli.so.@CLICON_VERSION_MAJOR@ . + cp $(DESTDIR)$(bindir)/clicon_cli . + sudo docker build -t $(image) . + +push: + sudo docker push $(image) + +install: + +uninstall: + +install-include: + +depend: +# $(CC) $(DEPENDFLAGS) $(INCLUDES) $(CFLAGS) -MM $(SRC) > .depend + +#include .depend + diff --git a/docker/cli/README b/docker/cli/README new file mode 100644 index 00000000..f2763a0c --- /dev/null +++ b/docker/cli/README @@ -0,0 +1,6 @@ +Ensure that cligen and clicon has been built and installed. +sudo make docker +make push + +Then go to example and run the example as a docker container + diff --git a/docker/start.sh b/docker/cli/start.sh similarity index 100% rename from docker/start.sh rename to docker/cli/start.sh diff --git a/example/README b/example/README index d4bdeefd..79e23298 100644 --- a/example/README +++ b/example/README @@ -30,4 +30,9 @@ Clixon yang routing example ]]>]]> -]]>]]> \ No newline at end of file +]]>]]> + +3. Run as docker container +-------------------------- +cd docker +# look in README diff --git a/example/docker/Makefile.in b/example/docker/Makefile.in new file mode 100644 index 00000000..dfddc255 --- /dev/null +++ b/example/docker/Makefile.in @@ -0,0 +1,66 @@ +# +# Copyright (C) 2009-2016 Olof Hagsand and Benny Holmgren +# +# This file is part of CLIXON. +# +# CLIXON is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# CLIXON is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with CLIXON; see the file LICENSE. If not, see +# . +# +VPATH = @srcdir@ +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +prefix = @prefix@ +bindir = @bindir@ +includedir = @includedir@ +datarootdir = @datarootdir@ + +APPNAME = routing + +all: $(APPNAME).conf + +-include $(DESTDIR)$(datarootdir)/clicon/clicon.mk + +# Kind of reverse install, could have copied from src dir,... +.PHONY: docker push +docker: $(APPNAME).conf + install -d data + install -d data/yang + install -d data/backend + install -d data/cli + install -d data/netconf + install -d data/clispec + install $(APPNAME).conf data/clicon.conf # docker image assumes /data/clicon.conf + install ../*.yang data/yang/ + install ../routing_cli.so data/cli/ + install ../routing_backend.so data/backend/ + install ../routing_netconf.so data/netconf/ + install ../*.cli data/clispec + +clean: + +distclean: clean + rm -f Makefile *~ .depend + rm -rf data + +install: + +uninstall: + +install-include: + +depend: + $(CC) $(DEPENDFLAGS) $(INCLUDES) $(CFLAGS) -MM $(SRC) > .depend + +#include .depend + diff --git a/example/docker/README b/example/docker/README new file mode 100644 index 00000000..0bcbe585 --- /dev/null +++ b/example/docker/README @@ -0,0 +1,8 @@ +Run the ietf routing example as docker container. +Use the dockerhub container, or alternatively, build clicon as docker images +by doing make docker in the top builddir. + +data_dir="$(pwd)/data" +sudo docker run -ti --rm --net host -v "$data_dir":/data olofhagsand/clicon_backend:v1.0 + +sudo docker run -ti --rm --net host -v "$data_dir":/data olofhagsand/clicon_cli:v1.0 \ No newline at end of file diff --git a/example/docker/routing.conf.local b/example/docker/routing.conf.local new file mode 100644 index 00000000..da86e7f3 --- /dev/null +++ b/example/docker/routing.conf.local @@ -0,0 +1,67 @@ +# Main YANG module first parsed by parser (in CLICON_YANG_DIR). eg clicon.yang. + +# Location of configuration-file for default values (this file) +CLICON_CONFIGFILE /data/clicon.conf +# Location of YANG module and submodule files. Only if CLICON_DBSPEC_TYPE is YANG +CLICON_YANG_DIR /data/yang +# Option used to construct initial yang file: +# [@] +# This option is only relevant if CLICON_DBSPEC_TYPE is YANG +# CLICON_YANG_MODULE_MAIN clicon +# Option used to construct initial yang file: +# [@] +# This option is only relevant if CLICON_DBSPEC_TYPE is YANG +CLICON_YANG_MODULE_REVISION +# Candidate qdbm database +CLICON_CANDIDATE_DB /data/candidate_db +# Running qdbm database +CLICON_RUNNING_DB /data/running_db +# Location of backend .so plugins +CLICON_BACKEND_DIR /data/backend +# Location of netconf (frontend) .so plugins +CLICON_NETCONF_DIR /data/netconf +# Location of cli frontend .so plugins +CLICON_CLI_DIR /data/cli +# Location of frontend .cli cligen spec files +CLICON_CLISPEC_DIR /data/clispec +# Directory where to save configuration commit history (in XML). Snapshots +# are saved chronologically +CLICON_ARCHIVE_DIR /data +# XXX Name of startup configuration file (in XML) +CLICON_STARTUP_CONFIG /data/startup-config +# Address family for communicating with clicon_backend (UNIX|IPv4|IPv6) +CLICON_SOCK_FAMILY UNIX +# If family above is AF_UNIX: Unix socket for communicating with clicon_backend +# If family above is AF_INET: IPv4 address +CLICON_SOCK /data/routing.sock +# Inet socket port for communicating with clicon_backend (only IPv4|IPv6) +CLICON_SOCK_PORT 4535 +# Process-id file +CLICON_BACKEND_PIDFILE /data/routing.pidfile + + +# Save values as XML in database instead of lvec:s. +# This is optimized for yang specified applications +# But not compatible with key-based application (eg Rost) +CLICON_DB_XML 1 + +# Startup CLI mode. This should match the CLICON_MODE in your startup clispec file +CLICON_CLI_MODE routing + +# Option used to construct initial yang file: +# [@] +# This option is only relevant if CLICON_DBSPEC_TYPE is YANG +CLICON_YANG_MODULE_MAIN ietf-ip + +# Option used to construct initial yang file: +# [@] +# This option is only relevant if CLICON_DBSPEC_TYPE is YANG +CLICON_YANG_MODULE_REVISION 2014-06-16 + +# Generate code for CLI completion of existing db symbols +# CLICON_CLI_GENMODEL_COMPLETION 0 +CLICON_CLI_GENMODEL_COMPLETION 1 + +# How to generate and show CLI syntax: VARS|ALL +# CLICON_CLI_GENMODEL_TYPE VARS +CLICON_CLI_GENMODEL_TYPE VARS