Browse Source

[1651] Small command handling improvements.

Tomek Mrugalski 13 years ago
parent
commit
977c4a2b57
3 changed files with 36 additions and 21 deletions
  1. 14 13
      doc/guide/bind10-guide.xml
  2. 9 3
      src/bin/dhcp4/dhcp4.spec
  3. 13 5
      src/bin/dhcp4/main.cc

+ 14 - 13
doc/guide/bind10-guide.xml

@@ -2037,21 +2037,22 @@ then change those defaults with config set Resolver/forward_addresses[0]/address
       </para>
 
       <para>
-        The DHCPv4 server is implemented as <command>b10-dhcp4</command>
-        daemon. As it is not configurable yet, it is fully autonomous,
-        that is it does not interact with <command>b10-cfgmgr</command>.
-        To start DHCPv4 server, simply input:
-
-        <screen>
-#<userinput>cd src/bin/dhcp4</userinput>
-#<userinput>./b10-dhcp4</userinput>
-</screen>
+        <command>b10-dhcp4</command> is a BIND10 component and is being
+        run under BIND10 framework. To add a DHCPv4 process to the set of running
+        BIND10 services, you can use following commands in <command>bindctl</command>:
+        <screen>&gt; <userinput>config add Boss/components b10-dhcp4</userinput>
+&gt; <userinput>config set Boss/components/b10-resolver/kind dispensable</userinput>
+&gt; <userinput>config commit</userinput></screen></para>
 
-        Depending on your installation, <command>b10-dhcp4</command>
-        binary may reside in src/bin/dhcp4 in your source code
-        directory, in /usr/local/bin/b10-dhcp4 or other directory
-        you specified during compilation.
+       <para>
+         To shutdown running <command>b10-dhcp4</command>, please use the
+         following command:
+         <screen>&gt; <userinput>dhcp4 shutdown</userinput></screen>
+         or
+         <screen>&gt; <userinput>config remove Boss/components b10-dhcp4</userinput>
+&gt; <userinput>config commit</userinput></screen></para>
 
+      <para>
         At start, the server will detect available network interfaces
         and will attempt to open UDP sockets on all interfaces that
         are up, running, are not loopback, and have IPv4 address

+ 9 - 3
src/bin/dhcp4/dhcp4.spec

@@ -1,6 +1,6 @@
 {
   "module_spec": {
-    "module_name": "dhcp4",
+    "module_name": "Dhcp4",
     "module_description": "DHCPv4 server daemon",
     "config_data": [
       { "item_name": "interface",
@@ -12,8 +12,14 @@
     "commands": [
         {
             "command_name": "shutdown",
-            "command_description": "Shut down DHCPv4 server",
-            "command_args": []
+            "command_description": "Shuts down DHCPv4 server.",
+            "command_args": [
+                {
+                    "item_name": "pid",
+                    "item_type": "integer",
+                    "item_optional": true
+                }
+            ]
         }
     ]
   }

+ 13 - 5
src/bin/dhcp4/main.cc

@@ -65,11 +65,13 @@ usage() {
 }
 } // end of anonymous namespace
 
+IOService io_service;
+
 ConstElementPtr
 dhcp4_config_handler(ConstElementPtr new_config) {
     cout << "b10-dhcp4: Received new config:" << new_config->str() << endl;
     ConstElementPtr answer = isc::config::createAnswer(0,
-                             "All good here. Thanks for sending config.");
+                             "Thanks for sending config.");
     return (answer);
 }
 
@@ -77,8 +79,16 @@ ConstElementPtr
 dhcp4_command_handler(const string& command, ConstElementPtr args) {
     cout << "b10-dhcp4: Received new command: [" << command << "], args="
          << args->str() << endl;
-    ConstElementPtr answer = isc::config::createAnswer(0,
-                             "All good here. Thanks for asking.");
+    if (command == "shutdown") {
+        io_service.stop();
+        ConstElementPtr answer = isc::config::createAnswer(0,
+                                 "Shutting down.");
+        return (answer);
+    }
+
+    ConstElementPtr answer = isc::config::createAnswer(1,
+                             "Unrecognized command.");
+
     return (answer);
 }
 
@@ -98,8 +108,6 @@ void establish_session() {
 
     cout << "b10-dhcp4: my specfile is " << specfile << endl;
 
-    IOService io_service;
-
     cc_session = new Session(io_service.get_io_service());
 
     config_session = new ModuleCCSession(specfile, *cc_session,