Browse Source

[5108] Control agent's configuration can be shared with other components.

Marcin Siodelski 7 years ago
parent
commit
65ce0078ee

+ 9 - 0
src/bin/d2/d2_lexer.ll

@@ -467,6 +467,15 @@ ControlCharacterFill            [^"\\]|\\{JSONEscapeSequence}
     }
     }
 }
 }
 
 
+\"Control-agent\" {
+    switch(driver.ctx_) {
+    case isc::d2::D2ParserContext::CONFIG:
+        return isc::d2::D2Parser::make_CONTROL_AGENT(driver.loc_);
+    default:
+        return isc::d2::D2Parser::make_STRING("Control-agent", driver.loc_);
+    }
+}
+
 
 
 {JSONString} {
 {JSONString} {
     /* A string has been matched. It contains the actual string and single quotes.
     /* A string has been matched. It contains the actual string and single quotes.

+ 11 - 2
src/bin/d2/d2_parser.yy

@@ -51,6 +51,7 @@ using namespace std;
 
 
   DHCP6 "Dhcp6"
   DHCP6 "Dhcp6"
   DHCP4 "Dhcp4"
   DHCP4 "Dhcp4"
+  CONTROL_AGENT "Control-agent"
 
 
   DHCPDDNS "DhcpDdns"
   DHCPDDNS "DhcpDdns"
   IP_ADDRESS "ip-address"
   IP_ADDRESS "ip-address"
@@ -204,8 +205,8 @@ unknown_map_entry: STRING COLON {
 };
 };
 
 
 
 
-// This defines the top-level { } that holds Dhcp6, Dhcp4, DhcpDdns or Logging
-// objects.
+// This defines the top-level { } that holds Control-agent, Dhcp6, Dhcp4,
+// DhcpDdns or Logging objects.
 syntax_map: LCURLY_BRACKET {
 syntax_map: LCURLY_BRACKET {
     // This code is executed when we're about to start parsing
     // This code is executed when we're about to start parsing
     // the content of the map
     // the content of the map
@@ -227,6 +228,7 @@ global_object: dhcp6_json_object
              | logging_object
              | logging_object
              | dhcp4_json_object
              | dhcp4_json_object
              | dhcpddns_object
              | dhcpddns_object
+             | control_agent_json_object
              | unknown_map_entry
              | unknown_map_entry
              ;
              ;
 
 
@@ -613,6 +615,13 @@ dhcp4_json_object: DHCP4 {
     ctx.leave();
     ctx.leave();
 };
 };
 
 
+control_agent_json_object: CONTROL_AGENT {
+    ctx.enter(ctx.NO_KEYWORD);
+} COLON value {
+    ctx.stack_.back()->set("Control-agent", $4);
+    ctx.leave();
+};
+
 // --- logging entry -----------------------------------------
 // --- logging entry -----------------------------------------
 
 
 // This defines the top level "Logging" object. It parses
 // This defines the top level "Logging" object. It parses

+ 9 - 0
src/bin/dhcp4/dhcp4_lexer.ll

@@ -1246,6 +1246,15 @@ ControlCharacterFill            [^"\\]|\\{JSONEscapeSequence}
     }
     }
 }
 }
 
 
+\"Control-agent\" {
+    switch(driver.ctx_) {
+    case isc::dhcp::Parser4Context::CONFIG:
+        return isc::dhcp::Dhcp4Parser::make_CONTROL_AGENT(driver.loc_);
+    default:
+        return isc::dhcp::Dhcp4Parser::make_STRING("Control-agent", driver.loc_);
+    }
+}
+
 \"4o6-interface\" {
 \"4o6-interface\" {
     switch(driver.ctx_) {
     switch(driver.ctx_) {
     case isc::dhcp::Parser4Context::SUBNET4:
     case isc::dhcp::Parser4Context::SUBNET4:

+ 13 - 3
src/bin/dhcp4/dhcp4_parser.yy

@@ -183,6 +183,7 @@ using namespace std;
 
 
   DHCP6 "Dhcp6"
   DHCP6 "Dhcp6"
   DHCPDDNS "DhcpDdns"
   DHCPDDNS "DhcpDdns"
+  CONTROL_AGENT "Control-agent"
 
 
  // Not real tokens, just a way to signal what the parser is expected to
  // Not real tokens, just a way to signal what the parser is expected to
  // parse.
  // parse.
@@ -338,8 +339,8 @@ unknown_map_entry: STRING COLON {
 };
 };
 
 
 
 
-// This defines the top-level { } that holds Dhcp6, Dhcp4, DhcpDdns or Logging
-// objects.
+// This defines the top-level { } that holds Control-agent, Dhcp6, Dhcp4,
+// DhcpDdns or Logging objects.
 syntax_map: LCURLY_BRACKET {
 syntax_map: LCURLY_BRACKET {
     // This code is executed when we're about to start parsing
     // This code is executed when we're about to start parsing
     // the content of the map
     // the content of the map
@@ -351,7 +352,8 @@ syntax_map: LCURLY_BRACKET {
     // for it.
     // for it.
 };
 };
 
 
-// This represents top-level entries: Dhcp6, Dhcp4, DhcpDdns, Logging
+// This represents top-level entries: Control-agent, Dhcp6, Dhcp4,
+// DhcpDdns, Logging
 global_objects: global_object
 global_objects: global_object
               | global_objects COMMA global_object
               | global_objects COMMA global_object
               ;
               ;
@@ -361,6 +363,7 @@ global_object: dhcp4_object
              | logging_object
              | logging_object
              | dhcp6_json_object
              | dhcp6_json_object
              | dhcpddns_json_object
              | dhcpddns_json_object
+             | control_agent_json_object
              | unknown_map_entry
              | unknown_map_entry
              ;
              ;
 
 
@@ -1656,6 +1659,13 @@ dhcpddns_json_object: DHCPDDNS {
     ctx.leave();
     ctx.leave();
 };
 };
 
 
+control_agent_json_object: CONTROL_AGENT {
+    ctx.enter(ctx.NO_KEYWORD);
+} COLON value {
+    ctx.stack_.back()->set("Control-agent", $4);
+    ctx.leave();
+};
+
 // --- logging entry -----------------------------------------
 // --- logging entry -----------------------------------------
 
 
 // This defines the top level "Logging" object. It parses
 // This defines the top level "Logging" object. It parses

+ 10 - 0
src/bin/dhcp6/dhcp6_lexer.ll

@@ -1377,6 +1377,16 @@ ControlCharacterFill            [^"\\]|\\{JSONEscapeSequence}
     }
     }
 }
 }
 
 
+\"Control-agent\" {
+    switch(driver.ctx_) {
+    case isc::dhcp::Parser6Context::CONFIG:
+        return isc::dhcp::Dhcp6Parser::make_CONTROL_AGENT(driver.loc_);
+    default:
+        return isc::dhcp::Dhcp6Parser::make_STRING("Control-agent", driver.loc_);
+    }
+}
+
+
 {JSONString} {
 {JSONString} {
     /* A string has been matched. It contains the actual string and single quotes.
     /* A string has been matched. It contains the actual string and single quotes.
        We need to get those quotes out of the way and just use its content, e.g.
        We need to get those quotes out of the way and just use its content, e.g.

+ 12 - 2
src/bin/dhcp6/dhcp6_parser.yy

@@ -190,6 +190,7 @@ using namespace std;
 
 
   DHCP4 "Dhcp4"
   DHCP4 "Dhcp4"
   DHCPDDNS "DhcpDdns"
   DHCPDDNS "DhcpDdns"
+  CONTROL_AGENT "Control-agent"
 
 
  // Not real tokens, just a way to signal what the parser is expected to
  // Not real tokens, just a way to signal what the parser is expected to
  // parse.
  // parse.
@@ -347,8 +348,8 @@ unknown_map_entry: STRING COLON {
 };
 };
 
 
 
 
-// This defines the top-level { } that holds Dhcp6, Dhcp4, DhcpDdns or Logging
-// objects.
+// This defines the top-level { } that holds Control-agent, Dhcp6, Dhcp4,
+// DhcpDdns or Logging objects.
 syntax_map: LCURLY_BRACKET {
 syntax_map: LCURLY_BRACKET {
     // This code is executed when we're about to start parsing
     // This code is executed when we're about to start parsing
     // the content of the map
     // the content of the map
@@ -370,6 +371,7 @@ global_object: dhcp6_object
              | logging_object
              | logging_object
              | dhcp4_json_object
              | dhcp4_json_object
              | dhcpddns_json_object
              | dhcpddns_json_object
+             | control_agent_json_object
              | unknown_map_entry
              | unknown_map_entry
              ;
              ;
 
 
@@ -1752,6 +1754,14 @@ dhcpddns_json_object: DHCPDDNS {
     ctx.leave();
     ctx.leave();
 };
 };
 
 
+control_agent_json_object: CONTROL_AGENT {
+    ctx.enter(ctx.NO_KEYWORD);
+} COLON value {
+    ctx.stack_.back()->set("Control-agent", $4);
+    ctx.leave();
+};
+
+
 // --- logging entry -----------------------------------------
 // --- logging entry -----------------------------------------
 
 
 // This defines the top level "Logging" object. It parses
 // This defines the top level "Logging" object. It parses

+ 75 - 33
src/bin/keactrl/kea.conf.pre

@@ -1,10 +1,10 @@
-// This is a basic configuration for the Kea DHCPv4 and DHCPv6 servers. Subnet
-// declarations are mostly commented out and no interfaces are listed.
-// Therefore, the servers will not listen or respond to any queries.  The basic
-// configuration must be extended to specify interfaces on which the servers
-// should listen. There are a number of example options defined. These probably
-// don't make any sense in your network. Make sure you at least update the
-// following, before running this example in your network:
+// This is a basic configuration for the Kea DHCP servers and Kea Control
+// Agent. Subnet declarations are mostly commented out and no interfaces are
+// listed. Therefore, the servers will not listen or respond to any queries.
+// The basic configuration must be extended to specify interfaces on which
+// the servers should listen. There are a number of example options defined.
+// These probably don't make any sense in your network. Make sure you at least
+// update the following, before running this example in your network:
 // - change the network interface names
 // - change the network interface names
 // - change the subnets to match your actual network
 // - change the subnets to match your actual network
 // - change the option values to match your network
 // - change the option values to match your network
@@ -734,6 +734,41 @@
   "reverse-ddns" : {}
   "reverse-ddns" : {}
 },
 },
 
 
+// This is a basic configuraton for the Kea Control Agent.
+// RESTful interface to be available at http://127.0.0.1:8080/
+"Control-agent": {
+    "http-host": "127.0.0.1",
+    "http-port": 8080,
+
+    // Specify location of the files to which the Control Agent
+    // should connect to forward commands to the DHCPv4 and DHCPv6
+    // server via unix domain socket.
+    "control-sockets": {
+        "dhcp4": {
+            "socket-type": "unix",
+            "socket-name": "/tmp/kea-dhcp4-ctrl.sock"
+        },
+        "dhcp6": {
+            "socket-type": "unix",
+            "socket-name": "/tmp/kea-dhcp6-ctrl.sock"
+        }
+    },
+
+    // Specify hooks libraries that are attached to the Control Agent.
+    // Such hooks libraries should support 'control_command_receive'
+    // hook point. This is currently commented out because it has to
+    // point to the existing hooks library. Otherwise the Control
+    // Agent will fail to start.
+    "hooks-libraries": [
+//  {
+//      "library": "/opt/local/control-agent-commands.so",
+//      "parameters": {
+//          "param1": "foo"
+//      }
+//  }
+    ]
+},
+
 // Logging configuration starts here. Kea uses different loggers to log various
 // Logging configuration starts here. Kea uses different loggers to log various
 // activities. For details (e.g. names of loggers), see Chapter 18.
 // activities. For details (e.g. names of loggers), see Chapter 18.
 "Logging":
 "Logging":
@@ -776,32 +811,39 @@
         // of logs if told to do so.
         // of logs if told to do so.
         "debuglevel": 0
         "debuglevel": 0
     },
     },
-      {
-          // This specifies the logging for kea-dhcp6 logger, i.e. all logs
-          // generated by Kea DHCPv6 server.
-          "name": "kea-dhcp6",
-          "output_options": [
-              {
-                  "output": "@localstatedir@/log/kea-dhcp6.log"
-              }
-          ],
-          "severity": "INFO",
-          "debuglevel": 0
-      },
-      {
-          // This specifies the logging for D2 (DHCP-DDNS) daemon.
-          "name": "kea-dhcp-ddns",
-          "output_options": [
-              {
-                  "output": "@localstatedir@/log/kea-ddns.log"
-              }
-          ],
-          "severity": "INFO",
-          "debuglevel": 0
-      }
+    {
+        // This specifies the logging for kea-dhcp6 logger, i.e. all logs
+        // generated by Kea DHCPv6 server.
+        "name": "kea-dhcp6",
+        "output_options": [
+            {
+                "output": "@localstatedir@/log/kea-dhcp6.log"
+            }
+        ],
+        "severity": "INFO",
+        "debuglevel": 0
+    },
+    {
+        // This specifies the logging for D2 (DHCP-DDNS) daemon.
+        "name": "kea-dhcp-ddns",
+        "output_options": [
+            {
+                "output": "@localstatedir@/log/kea-ddns.log"
+            }
+        ],
+        "severity": "INFO",
+        "debuglevel": 0
+    },
+    {
+        "name": "kea-ctrl-agent",
+        "output_options": [
+            {
+                "output": "@localstatedir@/log/kea-ctrl-agent.log"
+            }
+        ],
+        "severity": "INFO",
+        "debuglevel": 0
+    }
   ]
   ]
 }
 }
-
-    // In the future releases, also Control Agent configuration will be kept here.
-    // However, for the time being, it is kept in a separate file.
 }
 }