Browse Source

Dockers separados para la v1.4.0

Espinoza Guillermo 7 years ago
parent
commit
b6a00260f6

+ 63 - 31
.drone.yml

@@ -6,22 +6,6 @@ pipeline:
       - env
       - php -v
 
- docker_kea_oss_1.3.0:
-   repo : docker.infra.flowdat.com/fd3/kea-oss-1.3.0
-   image: plugins/docker
-   pull: true
-   email: luciano@interlink.com.ar
-   registry: docker.infra.flowdat.com
-   dockerfile: 1.3.0/kea-oss/Dockerfile
-   context: 1.3.0/kea-oss/
-   tag:
-      - latest
-      - "1.3.0-kea-oss"
-      - "1.3-kea-oss"
-   when:
-      event: [pull_request, push, tag]
-      branch: master
-
  docker_kea_ik_1.3.0:
    repo : docker.infra.flowdat.com/fd3/kea-ik-1.3.0
    image: plugins/docker
@@ -54,18 +38,66 @@ pipeline:
       event: [pull_request, push, tag]
       branch: master
 
- docker_kea_1.4.0:
-   repo : docker.infra.flowdat.com/fd3/kea-1.4.0
-   image: plugins/docker
-   pull: true
-   email: luciano@interlink.com.ar
-   registry: docker.infra.flowdat.com
-   dockerfile: 1.4.0/Dockerfile
-   context: 1.4.0/
-   tag:
-      - latest
-      - "1.4.0"
-      - "1.4"
-   when:
-      event: [pull_request, push, tag]
-      branch: master
+docker_kea_ik_1.4.0:
+  repo : docker.infra.flowdat.com/fd3/kea-ik-1.4.0
+  image: plugins/docker
+  pull: true
+  email: luciano@interlink.com.ar
+  registry: docker.infra.flowdat.com
+  dockerfile: 1.4.0/kea-ik/Dockerfile
+  context: 1.4.0/kea-ik/
+  tag:
+     - latest
+     - "1.4.0-kea-ik"
+     - "1.4-kea-ik"
+  when:
+     event: [pull_request, push, tag]
+     branch: master
+
+docker_kea_premium_1.4.0:
+  repo : docker.infra.flowdat.com/fd3/kea-premium-1.4.0
+  image: plugins/docker
+  pull: true
+  email: luciano@interlink.com.ar
+  registry: docker.infra.flowdat.com
+  dockerfile: 1.4.0/kea-premium/Dockerfile
+  context: 1.4.0/kea-premium/
+  tag:
+     - latest
+     - "1.4.0-kea-premium"
+     - "1.4-kea-premium"
+  when:
+     event: [pull_request, push, tag]
+     branch: master
+     
+     # docker_kea_oss_1.3.0:
+     #   repo : docker.infra.flowdat.com/fd3/kea-oss-1.3.0
+     #   image: plugins/docker
+     #   pull: true
+     #   email: luciano@interlink.com.ar
+     #   registry: docker.infra.flowdat.com
+     #   dockerfile: 1.3.0/kea-oss/Dockerfile
+     #   context: 1.3.0/kea-oss/
+     #   tag:
+     #      - latest
+     #      - "1.3.0-kea-oss"
+     #      - "1.3-kea-oss"
+     #   when:
+     #      event: [pull_request, push, tag]
+     #      branch: master
+     
+     # docker_kea_1.4.0:
+     #   repo : docker.infra.flowdat.com/fd3/kea-1.4.0
+     #   image: plugins/docker
+     #   pull: true
+     #   email: luciano@interlink.com.ar
+     #   registry: docker.infra.flowdat.com
+     #   dockerfile: 1.4.0/Dockerfile
+     #   context: 1.4.0/
+     #   tag:
+     #      - latest
+     #      - "1.4.0"
+     #      - "1.4"
+     #   when:
+     #      event: [pull_request, push, tag]
+     #      branch: master

+ 1 - 0
.gitignore

@@ -0,0 +1 @@
+conf/kea-dhcp4.conf

+ 0 - 29
1.4.0/hook/amqp/Makefile

@@ -1,29 +0,0 @@
-
-KEA_MSG_COMPILER ?= /opt/kea/bin/kea-msg-compiler
-KEA_INCLUDE ?= ~/kea-1.4.0/src/lib
-KEA_LIB ?= /opt/kea/lib/
-
-OBJECTS = src/messages.o src/logger.o src/load.o src/callouts.o src/version.o src/amqppublisher.o
-DEPS = $(OBJECTS:.o=.d)
-CXXFLAGS = -I $(KEA_INCLUDE) -g -fPIC -Wno-deprecated -std=c++11
-LDFLAGS = -L $(KEA_LIB) -shared
-LIBRARIES = -lkea-dhcpsrv -lkea-dhcp++ -lkea-hooks -lkea-log -lkea-util -lkea-exceptions -lamqpcpp -lrabbitmq
-
-kea-hook-flowdat3.so: $(OBJECTS)
-	$(CXX) -o $@ $(CXXFLAGS) $(LDFLAGS) $(OBJECTS) $(LIBRARIES)
-
-%.o: %.cc
-	$(CXX) -MMD -MP -c $(CXXFLAGS) -o $@ $<
-
-# Compile messages (for logging)
-src/messages.h src/messages.cc: s-messages
-s-messages: src/messages.mes
-	$(KEA_MSG_COMPILER) -d src/ $<
-	touch $@
-
-clean:
-	rm -f src/*.o *.so
-	rm -f src/messages.h src/messages.cc s-messages
-
--include $(DEPS)
-

+ 0 - 31
1.4.0/hook/amqp/src/amqppublisher.cc

@@ -1,31 +0,0 @@
-#include <AMQPcpp.h>
-#include "amqppublisher.h"
-
-#include <string>
-
-int AMQPPublisher::publish(std::string message)
-{
-    try {
-        AMQP amqp("amqp:5672");
-        
-        AMQPExchange * ex = amqp.createExchange("kea");
-    
-        ex->Declare("kea", "fanout");
-    
-        AMQPQueue * qu2 = amqp.createQueue("kea");
-        
-        qu2->Declare();
-        qu2->Bind("kea", "");
-        
-        ex->setHeader("Expiration", "10000");
-        ex->setHeader("Delivery-mode", "2");
-        ex->setHeader("Content-type", "text/text");
-        ex->setHeader("Content-encoding", "UTF-8");
-    
-        ex->Publish(message, "");				
-    } catch (AMQPException e) {
-        std::cout << e.getMessage() << std::endl;
-    }
-    
-    return 0;
-}

+ 0 - 14
1.4.0/hook/amqp/src/amqppublisher.h

@@ -1,14 +0,0 @@
-#ifndef amqppublisher_H
-#define amqppublisher_H
-
-#include <string>
-
-class AMQPPublisher 
-{
-    
-    public:
-        int publish(std::string);
-        
-};
-
-#endif

+ 0 - 307
1.4.0/hook/amqp/src/callouts.cc

@@ -1,307 +0,0 @@
-#include <hooks/hooks.h>
-#include <dhcp/pkt4.h>
-#include <dhcp/hwaddr.h>
-#include <dhcpsrv/subnet.h>
-#include <dhcpsrv/lease.h>
-#include <util/strutil.h>
-#include <dhcp/option_string.h>
-#include <dhcp/option4_addrlst.h>
-#include <dhcp/docsis3_option_defs.h>
-#include <string>
-#include <dhcp/dhcp6.h>
-#include <dhcp/pkt6.h>
-#include <dhcp/option6_ia.h>
-
-#include <boost/foreach.hpp>
-
-#include "logger.h"
-#include "common.h"
-
-using namespace isc::dhcp;
-using namespace isc::hooks;
-
-extern "C" {
-
-#include <numeric>    //inner_product
-#include <functional> //plus, equal_to, not2
-#include <string>   
-#include <stdexcept>
-
-
-#include "amqppublisher.h"
-
-AMQPPublisher amqp;
-
-/* IPv4 callouts */
-int pkt4_receive(CalloutHandle& handle) 
-{
-    Pkt4Ptr query;
-    handle.getArgument("query4", query);
-
-    amqp.publish(query->toText());
-
-    return 0;
-}
-
-int pkt4_send(CalloutHandle& handle) 
-{
-    Pkt4Ptr response;
-    Pkt4Ptr query;
-    handle.getArgument("response4", response);
-    handle.getArgument("query4", query);
-
-    amqp.publish(query->toText());
-    amqp.publish(response->toText());
-
-    return 0;
-}
-
-int subnet4_select(CalloutHandle& handle) {
-    std::vector<std::string> env;
-    Pkt4Ptr query;
-    Subnet4Ptr subnet;
-    handle.getArgument("query4", query);
-    handle.getArgument("subnet4", subnet);
-    
-    amqp.publish(query->toText());
-    amqp.publish(subnet->toText());
-    
-    return 0;
-}
-
-int lease4_select(CalloutHandle& handle) {
-    std::vector<std::string> env;
-    Pkt4Ptr query;
-    Subnet4Ptr subnet;
-    bool fake_allocation;
-    Lease4Ptr lease;
-    handle.getArgument("query4", query);
-    handle.getArgument("subnet4", subnet);
-    handle.getArgument("fake_allocation", fake_allocation);
-    handle.getArgument("lease4", lease);
-    
-    amqp.publish(query->toText());
-    amqp.publish(subnet->toText());
-    amqp.publish(lease->toText());
-    
-    return 0;
-}
-
-int lease4_renew(CalloutHandle& handle) {
-    std::vector<std::string> env;
-    Pkt4Ptr query;
-    Subnet4Ptr subnet;
-    Lease4Ptr lease;
-    handle.getArgument("query4", query);
-    handle.getArgument("subnet4", subnet);
-    handle.getArgument("lease4", lease);
-    
-    amqp.publish(query->toText());
-    amqp.publish(subnet->toText());
-    amqp.publish(lease->toText());
-    
-    return 0;
-}
-
-int lease4_release(CalloutHandle& handle) {
-    std::vector<std::string> env;
-    Pkt4Ptr query;
-    Lease4Ptr lease;
-    handle.getArgument("query4", query);
-    handle.getArgument("lease4", lease);
-    
-    amqp.publish(query->toText());
-    amqp.publish(lease->toText());
-    
-    return 0;
-}
-
-int lease4_decline(CalloutHandle& handle) {
-    std::vector<std::string> env;
-    Pkt4Ptr query;
-    Lease4Ptr lease;
-    handle.getArgument("query4", query);
-    handle.getArgument("lease4", lease);
-    
-    amqp.publish(query->toText());
-    amqp.publish(lease->toText());
-    
-    return 0;
-}
-
-int lease4_expire(CalloutHandle& handle) {
-    std::vector<std::string> env;
-    Lease4Ptr lease;
-    bool remove_lease;
-    handle.getArgument("lease4", lease);
-    handle.getArgument("remove_lease", remove_lease);
-    
-    amqp.publish(lease->toText());
-    
-    return 0;
-}
-
-int lease4_recover(CalloutHandle& handle) {
-    std::vector<std::string> env;
-    Lease4Ptr lease;
-    handle.getArgument("lease4", lease);
-    
-    amqp.publish(lease->toText());
-    
-    return 0;
-}
-
-/* IPv6 callouts */
-int pkt6_receive(CalloutHandle& handle) {
-    std::vector<std::string> env;
-    Pkt6Ptr query;
-    handle.getArgument("query6", query);
-    
-    amqp.publish(query->toText());
-    
-    return 0;
-}
-
-int pkt6_send(CalloutHandle& handle) {
-    std::vector<std::string> env;
-    Pkt6Ptr query, response;
-    handle.getArgument("query6", query);
-    handle.getArgument("response6", response);
-    
-    amqp.publish(query->toText());
-    amqp.publish(response->toText());
-    
-    return 0;
-}
-
-int subnet6_select(CalloutHandle& handle) {
-    std::vector<std::string> env;
-    Pkt6Ptr query;
-    Subnet6Ptr subnet;
-    handle.getArgument("query6", query);
-    handle.getArgument("subnet6", subnet);
-    
-    amqp.publish(query->toText());
-    amqp.publish(subnet->toText());
-    
-    return 0;
-}
-
-int lease6_select(CalloutHandle& handle) {
-    std::vector<std::string> env;
-    Pkt6Ptr query;
-    Subnet6Ptr subnet;
-    bool fake_allocation;
-    Lease6Ptr lease;
-    handle.getArgument("query6", query);
-    handle.getArgument("subnet6", subnet);
-    handle.getArgument("fake_allocation", fake_allocation);
-    handle.getArgument("lease6", lease);
-    
-    amqp.publish(query->toText());
-    amqp.publish(subnet->toText());
-    amqp.publish(lease->toText());
-    
-    return 0;
-}
-
-int lease6_renew(CalloutHandle& handle) {
-    std::vector<std::string> env;
-    Pkt6Ptr query;
-    Lease6Ptr lease;
-    boost::shared_ptr<Option6IA> ia_na;
-    boost::shared_ptr<Option6IA> ia_pd;
-    handle.getArgument("query6", query);
-    handle.getArgument("lease6", lease);
-    
-    amqp.publish(query->toText());
-    amqp.publish(lease->toText());
-    
-    try {
-        handle.getArgument("ia_na", ia_na);
-        amqp.publish(ia_na->toText());
-    } catch (const NoSuchArgument&) { }
-    
-    try {
-        handle.getArgument("ia_pd", ia_pd);
-        amqp.publish(ia_pd->toText());
-    } catch (const NoSuchArgument&) { }
-    
-    return 0;
-}
-
-int lease6_rebind(CalloutHandle& handle) {
-    std::vector<std::string> env;
-    Pkt6Ptr query;
-    Lease6Ptr lease;
-    boost::shared_ptr<Option6IA> ia_na;
-    boost::shared_ptr<Option6IA> ia_pd;
-    handle.getArgument("query6", query);
-    handle.getArgument("lease6", lease);
-    
-    amqp.publish(query->toText());
-    amqp.publish(lease->toText());
-    
-    try {
-        handle.getArgument("ia_na", ia_na);
-        amqp.publish(ia_na->toText());
-    } catch (const NoSuchArgument&) { }
-    
-    try {
-        handle.getArgument("ia_pd", ia_pd);
-        amqp.publish(ia_pd->toText());
-    } catch (const NoSuchArgument&) { }
-    
-    return 0;
-}
-
-int lease6_decline(CalloutHandle& handle) {
-    std::vector<std::string> env;
-    Pkt6Ptr query;
-    Lease6Ptr lease;
-    handle.getArgument("query6", query);
-    handle.getArgument("lease6", lease);
-    
-    amqp.publish(query->toText());
-    amqp.publish(lease->toText());
-    
-    return 0;
-}
-
-int lease6_release(CalloutHandle& handle) {
-    std::vector<std::string> env;
-    Pkt6Ptr query;
-    Lease6Ptr lease;
-    handle.getArgument("query6", query);
-    handle.getArgument("lease6", lease);
-    
-    amqp.publish(query->toText());
-    amqp.publish(lease->toText());
-    
-    return 0;
-}
-
-int lease6_expire(CalloutHandle& handle) {
-    std::vector<std::string> env;
-    Lease6Ptr lease;
-    bool remove_lease;
-    handle.getArgument("lease6", lease);
-    handle.getArgument("remove_lease", remove_lease);
-    
-    amqp.publish(lease->toText());
-    
-    return 0;
-}
-
-int lease6_recover(CalloutHandle& handle) {
-    std::vector<std::string> env;
-    Lease6Ptr lease;
-    handle.getArgument("lease6", lease);
-    
-    amqp.publish(lease->toText());
-    
-    return 0;
-}
-
-
-} // end extern "C"

+ 0 - 12
1.4.0/hook/amqp/src/common.h

@@ -1,12 +0,0 @@
-#include <string>
-#include <map>
-
-extern "C" {
-
-/* From load.cc */
-
-/* Maps of the cablemodem states */
-extern std::map<std::string, std::string> cm_map;
-extern std::map<std::string, std::string> option122_map;
-
-}

+ 0 - 62
1.4.0/hook/amqp/src/load.cc

@@ -1,62 +0,0 @@
-#include <hooks/hooks.h>
-#include <map>
-#include <boost/foreach.hpp>
-
-#include "logger.h"
-#include "common.h"
-
-
-using namespace isc::hooks;
-using namespace isc::data;
-
-std::map<std::string, std::string> cm_map;
-std::map<std::string, std::string> option122_map;
-
-extern "C" {
-
-int loadMappging(std::string base_map_config, LibraryHandle& handle, std::map<std::string, std::string>& map){
-
-    ConstElementPtr curr_map = handle.getParameter(base_map_config);
-    if (Element::map != curr_map->getType()){
-        LOG_ERROR(runscript_logger, RUNSCRIPT_MISTYPED_PARAM).arg(base_map_config);
-        return 1;
-    }
-
-    std::map<std::string, ConstElementPtr> map_config = curr_map->mapValue();;
-    std::pair<std::string, ConstElementPtr> me; 
-
-    BOOST_FOREACH(me, map_config) {
-	std::string class_to_map = me.first;
-	std::cout << me.first << "\n";
-	ConstElementPtr table = me.second;
-	if(table->getType() != Element::list){
-		LOG_ERROR(runscript_logger, RUNSCRIPT_MISTYPED_PARAM).arg(base_map_config + "." + me.first);
-		return 1;
-	} 
-	const std::vector<ElementPtr> mac_list = table->listValue();
-	for(int i = 0; i < mac_list.size(); i++) {
-		ElementPtr it = mac_list[i];
-		if(it->getType() != Element::string){
-			LOG_ERROR(runscript_logger, RUNSCRIPT_MISTYPED_PARAM).arg(base_map_config + "." + me.first + "[" + std::to_string(i) + "]");
-			return 1;
-		}
-		std::cout << mac_list[i]->stringValue() << "\n";
-		std::string mac = mac_list[i]->stringValue();
-		std::transform(mac.begin(), mac.end(),mac.begin(), ::toupper);
-
-		map[mac] = class_to_map;
-	}
-    }
-
-    return 0;
-}
-
-int load(LibraryHandle& handle) 
-{
-    
-    return 0;
-}
-
-
-
-} // end extern "C"

+ 0 - 3
1.4.0/hook/amqp/src/logger.cc

@@ -1,3 +0,0 @@
-#include "logger.h"
-
-isc::log::Logger runscript_logger("hook-ik-cablemodem");

+ 0 - 11
1.4.0/hook/amqp/src/logger.h

@@ -1,11 +0,0 @@
-#ifndef RUNSCRIPT_LOGGER_H
-#define RUNSCRIPT_LOGGER_H
-#include <log/logger.h>
-#include <log/message_initializer.h>
-#include <log/macros.h>
-
-#include "messages.h"
-
-extern isc::log::Logger runscript_logger;
-
-#endif

+ 0 - 30
1.4.0/hook/amqp/src/messages.mes

@@ -1,30 +0,0 @@
-% RUNSCRIPT_MISSING_PARAM required parameter "%1" missing in configuration
-A required parameter of this library hook is missing in the configuration,
-which prevents the library from working correctly.
-
-% RUNSCRIPT_MISTYPED_PARAM parameter "%1" in configuration has wrong type
-A parameter of this library hook is defined in the configuration but has the
-wrong type.  For instance, a string may have been passed as parameter while
-an integer was expected.
-
-% RUNSCRIPT_FORK_FAILED fork() failed with error: %1
-Running the user-defined script is done with fork + exec, and there was an error
-during the fork, possibly due to a lack of resources.
-
-% RUNSCRIPT_EXEC_FAILED exec() failed, please check that the script exists and is executable. Error: %1
-Attempting to execute the user-defined script failed.
-
-% RUNSCRIPT_WAITPID_FAILED waitpid() failed with error: %1
-The main hook process failed to wait for the child process to exit.
-The hook runs the user-defined script in a child process, and normally waits for it to exit.
-
-% RUNSCRIPT_WAITING_SCRIPT the user-defined script is running, and the main process is currently waiting
-The user-defined script has just been launched, and Kea is waiting for it to exit.
-This is useful to know, because if the user-defined script blocks, Kea will stay stuck
-at this point.
-
-% RUNSCRIPT_DEBUG_STRING %1
-Something somthing shomething
-
-% FLOWDAT_DEBUG_STRING %1
-Something somthing shomething

+ 0 - 7
1.4.0/hook/amqp/src/version.cc

@@ -1,7 +0,0 @@
-// version.cc
-#include <hooks/hooks.h>
-extern "C" {
-int version() {
-    return (KEA_HOOKS_VERSION);
-}
-}

+ 14 - 39
1.4.0/Dockerfile

@@ -1,37 +1,6 @@
-FROM ubuntu:16.04
+FROM docker.infra.flowdat.com/fd3/kea-oss-1.4.0:latest
 
-RUN apt-get update && apt-get install -yq git vim build-essential dhcping
-
-RUN apt-get update && apt-get install -yq dh-autoreconf automake
-RUN apt-get update && apt-get install -yq libssl-dev liblog4cplus-dev libboost-dev libmysqlclient-dev libboost-all-dev mysql-client wget
-
-RUN wget -O kea-1.4.0-P1.tar.gz https://www.isc.org/downloads/file/kea-1-4-0-p1/?version=tar-gz
-RUN tar -zxvf kea-1.4.0-P1.tar.gz
-RUN mv kea-1.4.0-P1 /opt/kea
-
-# KEA HOOKS
-RUN cd /opt/kea && wget -O kea-subscription-1.4.0.tar.gz https://ftp.isc.org/isc/kea/private/f62aefe6b659324b/kea-subscription-1.4.0.tar.gz && tar xvzf kea-subscription-1.4.0.tar.gz
-
-RUN cd /opt/kea && autoreconf --install
-RUN cd /opt/kea && ./configure --with-dhcp-mysql --enable-shell
-RUN cd /opt/kea && make && make install
-
-RUN cd /opt/kea && ldconfig
-
-EXPOSE 67/udp
-EXPOSE 68/udp
-
-ENV KEA_MSG_COMPILER=/usr/local/bin/kea-msg-compiler
-ENV KEA_LIB=/opt/kea/src/lib
-ENV KEA_INCLUDE=/opt/kea/src/lib
-
-RUN mkdir ~/.ssh
-RUN ssh-keyscan -H -p 22  bitbucket.org >> ~/.ssh/known_hosts
-COPY keys/ /opt/keys
-RUN chmod 0600 /opt/keys/bitbucket.id_rsa
-RUN eval $(ssh-agent) && ssh-add /opt/keys/bitbucket.id_rsa && git clone git@bitbucket.org:ikflowdat/kea-cm-hook.git
-
-RUN cd kea-cm-hook && git checkout kea-test && make
+# C++ LIBRARIES
 
 RUN git clone git://github.com/alanxz/rabbitmq-c.git
 RUN apt-get update && apt-get install -yq cmake
@@ -44,19 +13,25 @@ RUN cd amqpcpp && make && make install
 RUN cp -P /usr/local/lib/x86_64-linux-gnu/librabbitmq.* /usr/local/lib/
 RUN cp amqpcpp/libamqpcpp.a /usr/local/lib/libamqpcpp.a
 RUN cp amqpcpp/libamqpcpp.so /usr/local/lib/libamqpcpp.so
-RUN ldconfig
-
-COPY hook/ hook/
-RUN cd hook/amqp && make
 
 RUN wget -O libzdb-3.1.tar.gz http://www.tildeslash.com/libzdb/dist/libzdb-3.1.tar.gz
 RUN tar xvzf libzdb-3.1.tar.gz
 RUN cd libzdb-3.1 && ./configure --without-postgresql --without-sqlite && make && make install
 
-RUN apt install -yq python-pip supervisor
-RUN pip install superfsmon
+RUN ldconfig
+
+# FLOWDAT KEA HOOK
+
+RUN mkdir ~/.ssh
+RUN ssh-keyscan -H -p 22  bitbucket.org >> ~/.ssh/known_hosts
+COPY keys/ /opt/keys
+RUN chmod 0600 /opt/keys/bitbucket.id_rsa
+RUN eval $(ssh-agent) && ssh-add /opt/keys/bitbucket.id_rsa && git clone git@bitbucket.org:ikflowdat/kea-cm-hook.git
+
+RUN cd kea-cm-hook && git checkout kea-test && make
 
 COPY script.sh /opt/script.sh
 RUN chmod +x /opt/script.sh
+
 CMD /opt/script.sh
 HEALTHCHECK --interval=5s --timeout=3s CMD pgrep kea-dhcp4

1.4.0/keys/bitbucket.id_rsa → 1.4.0/kea-ik/keys/bitbucket.id_rsa


1.4.0/keys/bitbucket.id_rsa.pub → 1.4.0/kea-ik/keys/bitbucket.id_rsa.pub


+ 15 - 0
1.4.0/kea-ik/script.sh

@@ -0,0 +1,15 @@
+echo "[mysql]\nprotocol=tcp\n[client]\nhost=mysql" >> /etc/my.cnf
+echo "[mysql]\nprotocol=tcp\n[client]\nhost=mysql" >> /etc/mysql/my.cnf
+
+DATABASE=kea
+
+if ! mysql -u$MYSQL_USER -p$MYSQL_ROOT_PASSWORD -e "use ${DATABASE}"; then
+  mysql -u$MYSQL_USER -p$MYSQL_ROOT_PASSWORD -e "CREATE DATABASE ${DATABASE} /*\!40100 DEFAULT CHARACTER SET utf8 */;"
+fi
+
+kea-admin lease-init mysql -h mysql -u $MYSQL_USER -p $MYSQL_ROOT_PASSWORD -n $DATABASE
+
+cd /opt/hooks/amqp && make
+cd /opt/hooks/mysql && make
+
+supervisord --configuration /etc/supervisord/supervisor.conf  --nodaemon

+ 27 - 0
1.4.0/kea-oss/Dockerfile

@@ -0,0 +1,27 @@
+FROM ubuntu:16.04
+
+RUN apt-get update && apt-get install -yq git vim build-essential dhcping
+
+RUN apt-get update && apt-get install -yq dh-autoreconf automake
+RUN apt-get update && apt-get install -yq libssl-dev liblog4cplus-dev libboost-dev libmysqlclient-dev libboost-all-dev mysql-client wget python-pip supervisor cmake
+
+RUN pip install superfsmon
+
+RUN wget -O kea-1.4.0-P1.tar.gz https://www.isc.org/downloads/file/kea-1-4-0-p1/?version=tar-gz
+RUN tar -zxvf kea-1.4.0-P1.tar.gz
+RUN mv kea-1.4.0-P1 /opt/kea
+
+RUN cd /opt/kea && autoreconf --install && ./configure --with-dhcp-mysql --enable-shell && make && make install && ldconfig
+
+EXPOSE 67/udp
+EXPOSE 68/udp
+
+ENV KEA_MSG_COMPILER=/usr/local/bin/kea-msg-compiler
+ENV KEA_LIB=/opt/kea/src/lib
+ENV KEA_INCLUDE=/opt/kea/src/lib
+
+COPY script.sh /opt/script.sh
+RUN chmod +x /opt/script.sh
+
+CMD /opt/script.sh
+HEALTHCHECK --interval=5s --timeout=3s CMD pgrep kea-dhcp4

+ 1 - 7
1.4.0/script.sh

@@ -9,10 +9,4 @@ fi
 
 kea-admin lease-init mysql -h mysql -u $MYSQL_USER -p $MYSQL_ROOT_PASSWORD -n $DATABASE
 
-keactrl start -s dhcp4
-
-/usr/local/sbin/kea-dhcp4 -c /usr/local/etc/kea/kea-dhcp4.conf
-
-keactrl status
-
-tail -f /dev/null
+supervisord --configuration /etc/supervisord/supervisor.conf  --nodaemon

+ 7 - 0
1.4.0/kea-premium/Dockerfile

@@ -0,0 +1,7 @@
+FROM docker.infra.flowdat.com/fd3/kea-oss-1.4.0:latest
+
+WORKDIR /opt/kea
+
+RUN wget -O kea-subscription-1.4.0.tar.gz https://ftp.isc.org/isc/kea/private/f62aefe6b659324b/kea-subscription-1.4.0.tar.gz && tar xvzf kea-subscription-1.4.0.tar.gz
+
+RUN autoreconf --install && ./configure --with-dhcp-mysql --enable-shell && make && make install && ldconfig

+ 46 - 0
README.md

@@ -0,0 +1,46 @@
+# KEA DOCKER
+
+Para generar los container de kea oss editar el archivo docker-compose.yml y luego ejecutar docker-compose up -d kea-oss
+
+docker-compose.yml:
+
+v1.3.0
+
+```
+kea-oss:
+    image: docker.infra.flowdat.com/fd3/kea-oss-1.3.0:latest    
+    build:
+        context: kea/1.3.0/kea-oss
+    environment:
+        MYSQL_ROOT_PASSWORD: 235r2342gtfsw
+        MYSQL_USER: root
+    ports:
+        - "8080:8080"
+        - "67:67/udp"
+        - "68:68/udp"
+    volumes:
+        - ./kea/conf/kea-ctrl-agent.conf:/usr/local/etc/kea/kea-ctrl-agent.conf
+        - ./kea/conf/kea-dhcp4.conf:/usr/local/etc/kea/kea-dhcp4.conf
+        - ./kea/supervisord:/etc/supervisord
+```
+
+v1.4.0
+
+```
+kea-oss:
+    image: docker.infra.flowdat.com/fd3/kea-oss-1.4.0:latest    
+    build:
+        context: kea/1.4.0/kea-oss
+    environment:
+        MYSQL_ROOT_PASSWORD: 235r2342gtfsw
+        MYSQL_USER: root
+    ports:
+        - "8080:8080"
+        - "67:67/udp"
+        - "68:68/udp"
+    volumes:
+        - ./kea/conf/kea-ctrl-agent.conf:/usr/local/etc/kea/kea-ctrl-agent.conf
+        - ./kea/conf/kea-dhcp4.conf:/usr/local/etc/kea/kea-dhcp4.conf
+        - ./kea/supervisord:/etc/supervisord
+```
+

+ 0 - 127
conf/kea-dhcp4.conf

@@ -1,127 +0,0 @@
-{
-    "Dhcp4": {
-        "control-socket": {
-            "socket-name": "\/tmp\/kea-dhcp4-ctrl.sock",
-            "socket-type": "unix"
-        },
-        "lease-database": {
-            "host": "mysql",
-            "name": "kea",
-            "user": "root",
-            "password": "235r2342gtfsw",
-            "type": "mysql"
-        },
-        "hosts-database": {
-            "host": "mysql",
-            "name": "kea",
-            "user": "root",
-            "password": "235r2342gtfsw",
-            "type": "mysql"
-        },
-        "subnet4": [
-            {
-                "subnet": "10.42.0.0\/16",
-                "pools": [
-                    {
-                        "pool": "10.42.40.150 - 10.42.40.250"
-                    }
-                ],
-                "next-server": "200.50.168.111",
-                "client-class": "cm-active"
-            },
-            {
-                "subnet": "10.72.0.0\/16",
-                "pools": [
-                    {
-                        "pool": "10.72.40.150 - 10.72.40.250"
-                    }
-                ],
-                "next-server": "200.50.168.111",
-                "client-class": "cm-active"
-            },
-            {
-                "subnet": "10.62.0.0\/16",
-                "pools": [
-                    {
-                        "pool": "10.62.40.150 - 10.62.40.250"
-                    }
-                ],
-                "next-server": "200.50.168.111",
-                "client-class": "cm-active"
-            },
-            {
-                "subnet": "10.65.0.0\/16",
-                "pools": [
-                    {
-                        "pool": "10.65.0.10 - 10.65.10.254"
-                    }
-                ],
-                "next-server": "200.50.168.111",
-                "client-class": "cm-active"
-            }
-        ],
-        "hooks-libraries": [
-            {
-                "library": "\/hook\/amqp\/kea-hook-flowdat3.so",
-                "parameters": ""
-            },
-            {
-                "library": "\/kea-cm-hook\/kea-hook-flowdat.so",
-                "parameters": {
-                    "option122": {
-                        "200.50.168.111": [
-                            "0005ca9d1160",
-                            "001311836bea",
-                            "001cea29f3c4",
-                            "001e46b6c800",
-                            "00237406d524",
-                            "0023746d0120",
-                            "0023ed6734f5",
-                            "008ef234ec20",
-                            "5c571abff352",
-                            "bc14014ff2b8",
-                            "e83efce89f72"
-                        ]
-                    },
-                    "remote-id-map": {
-                        "active": [
-                            "0005ca9d1160",
-                            "001311836bea",
-                            "001cea29f3c4",
-                            "001e46b6c800",
-                            "00237406d524",
-                            "0023746d0120",
-                            "0023ed6734f5",
-                            "008ef234ec20",
-                            "5c571abff352",
-                            "bc14014ff2b8",
-                            "e83efce89f72"
-                        ]
-                    }
-                }
-            }
-        ],
-        "interfaces-config": {
-            "interfaces": [
-                "*"
-            ]
-        }
-    },
-    "Logging": {
-        "loggers": [
-            {
-                "debuglevel": 0,
-                "name": "kea-dhcp4",
-                "output_options": [
-                    {
-                        "flush": true,
-                        "maxsize": 10240000,
-                        "maxver": 1,
-                        "output": "\/usr\/local\/var\/log\/kea-dhcp4.log"
-                    }
-                ],
-                "severity": "INFO"
-            }
-        ]
-    }
-}