diff --git a/configure b/configure index b7573267..64d81bba 100755 --- a/configure +++ b/configure @@ -2133,7 +2133,7 @@ CLICON_VERSION_MINOR="2" CLICON_VERSION_PATCH="0" CLICON_VERSION="\"${CLICON_VERSION_MAJOR}.${CLICON_VERSION_MINOR}.${CLICON_VERSION_PATCH}\"" # Fix to specific version (eg 3.5) or head (3) -CLIGEN_VERSION="3.5" +CLIGEN_VERSION="3" ac_config_headers="$ac_config_headers include/clicon_config.h lib/clicon/clicon.h" @@ -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" +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" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure @@ -4899,6 +4899,7 @@ do "example/Makefile") CONFIG_FILES="$CONFIG_FILES example/Makefile" ;; "docker/Makefile") CONFIG_FILES="$CONFIG_FILES docker/Makefile" ;; "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 bdce19f3..72d461bf 100644 --- a/configure.ac +++ b/configure.ac @@ -33,7 +33,7 @@ CLICON_VERSION_MINOR="2" CLICON_VERSION_PATCH="0" CLICON_VERSION="\"${CLICON_VERSION_MAJOR}.${CLICON_VERSION_MINOR}.${CLICON_VERSION_PATCH}\"" # Fix to specific version (eg 3.5) or head (3) -CLIGEN_VERSION="3.5" +CLIGEN_VERSION="3" AC_CONFIG_HEADERS([include/clicon_config.h lib/clicon/clicon.h]) @@ -170,5 +170,6 @@ AC_OUTPUT(Makefile example/Makefile docker/Makefile doc/Makefile + docker/Dockerfile ) diff --git a/docker/Dockerfile.in b/docker/Dockerfile.in new file mode 100644 index 00000000..5569ad3c --- /dev/null +++ b/docker/Dockerfile.in @@ -0,0 +1,24 @@ +FROM ubuntu:14.04 +# 12.04 +MAINTAINER Olof Hagsand +ENV DEBIAN_FRONTEND noninteractive +RUN apt-get update && apt-get install -y \ + libqdbm-dev \ + curl +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"] + +EXPOSE 7878 7878/udp + + + + + + diff --git a/docker/Makefile.in b/docker/Makefile.in new file mode 100644 index 00000000..e634787b --- /dev/null +++ b/docker/Makefile.in @@ -0,0 +1,60 @@ +# +# 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@ + +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 +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 + +install: + +uninstall: + +install-include: + +depend: +# $(CC) $(DEPENDFLAGS) $(INCLUDES) $(CFLAGS) -MM $(SRC) > .depend + +#include .depend + diff --git a/docker/README b/docker/README new file mode 100644 index 00000000..6ef0724b --- /dev/null +++ b/docker/README @@ -0,0 +1,80 @@ +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; + } +} + + diff --git a/docker/start.sh b/docker/start.sh new file mode 100755 index 00000000..962e2f77 --- /dev/null +++ b/docker/start.sh @@ -0,0 +1,9 @@ +#!/bin/bash +# Script reads yang spec from stdin then start clicon_cli +read -d $'\cd' -p "input yang spec(end with ^d). Or just ^d for default spec> " spec +if [ "$spec" != "" ]; then + echo "module datamodel{" > /usr/local/share/clicon_yang/yang/clicon_yang.yang + echo $spec >> /usr/local/share/clicon_yang/yang/clicon_yang.yang + echo "}" >> /usr/local/share/clicon_yang/yang/clicon_yang.yang +fi +clicon_cli -cf /usr/local/etc/clicon_yang.conf