BIND 10 trac547, updated. 0d63af8d4515315c188633d451ffbe886fac48e5 [trac547] add a proposed Changelog entry
BIND 10 source code commits
bind10-changes at lists.isc.org
Wed Mar 9 02:42:31 UTC 2011
The branch, trac547 has been updated
via 0d63af8d4515315c188633d451ffbe886fac48e5 (commit)
via c9c1d1bf1920a521e85c937c07dfff740203bd07 (commit)
via 5777790e4debd80251ef72a67775fe4b7e81a2de (commit)
via 2bbed10c1b3d3bb5f711fb5fec15eb1dc04755ba (commit)
via 96c13d3a987642aacc406ab304e325ea19abc376 (commit)
via 350445aff09ce7ef3b1b68e44e467f9302831e5d (commit)
via a3d72187e1dcba7af6bd15ab5f2bc47b2fccb848 (commit)
via f5d402e8ca21b14c658632a8cf8a4e7c1c843c26 (commit)
via a3a7700ad22137c182c5bf998c8cd103dd204b3d (commit)
from 7fa757c0318ac40d78a88c31ffbf2a3d32292c6c (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 0d63af8d4515315c188633d451ffbe886fac48e5
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Wed Mar 9 11:40:24 2011 +0900
[trac547] add a proposed Changelog entry
commit c9c1d1bf1920a521e85c937c07dfff740203bd07
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Wed Mar 9 11:39:54 2011 +0900
[trac547] fix typo and minor change
commit 5777790e4debd80251ef72a67775fe4b7e81a2de
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Wed Mar 9 11:39:30 2011 +0900
[trac547] minor change
commit 2bbed10c1b3d3bb5f711fb5fec15eb1dc04755ba
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Tue Mar 8 22:38:38 2011 +0900
[trac547] add more document
commit 96c13d3a987642aacc406ab304e325ea19abc376
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Tue Mar 8 22:38:29 2011 +0900
[trac547] add more document
commit 350445aff09ce7ef3b1b68e44e467f9302831e5d
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Tue Mar 8 21:41:12 2011 +0900
[trac547] add more document
commit a3d72187e1dcba7af6bd15ab5f2bc47b2fccb848
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Tue Mar 8 21:39:00 2011 +0900
[trac547]
- remove ::1 from default setting
- change descriptions
commit f5d402e8ca21b14c658632a8cf8a4e7c1c843c26
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Tue Mar 8 21:37:37 2011 +0900
[trac547] add more document
commit a3a7700ad22137c182c5bf998c8cd103dd204b3d
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Tue Mar 8 09:54:47 2011 +0900
[trac547] change verbose message
-----------------------------------------------------------------------
Summary of changes:
ChangeLog | 11 ++
src/bin/stats/b10-stats-httpd.8 | 88 ++++++++++++++++--
src/bin/stats/b10-stats-httpd.xml | 132 ++++++++++++++++++++++++---
src/bin/stats/stats-httpd.spec.in | 8 +-
src/bin/stats/stats_httpd.py.in | 75 ++++++++++++---
src/bin/stats/tests/b10-stats-httpd_test.py | 8 ++
6 files changed, 276 insertions(+), 46 deletions(-)
-----------------------------------------------------------------------
diff --git a/ChangeLog b/ChangeLog
index b7d113a..0c80261 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+ nnn. [func] naokikambe
+ Added the HTTP/XML interface(b10-stats-httpd) to the statistics feature
+ in BIND 10. b10-stats-httpd is a standalone HTTP server and it requests
+ statistics data to the stats daemon(b10-stats) and sends it to HTTP
+ clients in XML format. Items of the data collected via b10-stats-httpd
+ are almost equivalent to ones which are collected via bindctl. Since it
+ also can send XSL(Extensible Stylessheet Language) document and XSD(XML
+ Schema definition) document, XML document is human-friendly to view
+ through web browsers and its data types are strictly defined.
+ (Trac #547, git tbdtbdtbdtbdtbdtbdtbdtbdtbdtbdtbdtbdttbd)
+
189. [bug] jreed
Do not install the log message compiler.
(Trac #634, git eb6441aca464980d00e3ff827cbf4195c5a7afc5)
diff --git a/src/bin/stats/b10-stats-httpd.8 b/src/bin/stats/b10-stats-httpd.8
index e9c0eef..ebd7b3e 100644
--- a/src/bin/stats/b10-stats-httpd.8
+++ b/src/bin/stats/b10-stats-httpd.8
@@ -2,12 +2,12 @@
.\" Title: b10-stats-httpd
.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author]
.\" Generator: DocBook XSL Stylesheets v1.76.1 <http://docbook.sf.net/>
-.\" Date: Mar xx, 2011
+.\" Date: Mar 8, 2011
.\" Manual: BIND10
.\" Source: BIND10
.\" Language: English
.\"
-.TH "B10\-STATS\-HTTPD" "8" "Mar xx, 2011" "BIND10" "BIND10"
+.TH "B10\-STATS\-HTTPD" "8" "Mar 8, 2011" "BIND10" "BIND10"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
@@ -28,37 +28,103 @@
.\" * MAIN CONTENT STARTS HERE *
.\" -----------------------------------------------------------------
.SH "NAME"
-b10-stats-httpd \- BIND 10 HTTP/XML interface for statistics module
+b10-stats-httpd \- BIND 10 HTTP server for HTTP/XML interface of statistics
.SH "SYNOPSIS"
.HP \w'\fBb10\-stats\-httpd\fR\ 'u
-\fBb10\-stats\-httpd\fR [\fB\-v\fR] [\fB\-\-verbose\fR]
+\fBb10\-stats\-httpd\fR [\fB\-v\fR]| [\fB\-\-verbose\fR]
.SH "DESCRIPTION"
.PP
-The
+
\fBb10\-stats\-httpd\fR
-is HTTP/XML interface for statistics module\&. \&.\&.\&.\&.
+is a stand\-alone HTTP server\&. It is intended for HTTP/XML interface for statistics module\&. This server process runs as a process separated from the process of the BIND 10 Stats daemon (\fBb10\-stats\fR)\&. The server is initially executed by the BIND 10 boss process (\fBbind10\fR) and finally exited by it\&. The server is intended to be requested by HTTP clients like web browsers and third\-party modules\&. When the server is requested, it requests BIND 10 statistics data to
+\fBb10\-stats\fR, and
+\fBb10\-stats\fR
+sends the data to the server in Python dictionary format and the server converts it into XML format\&. The server sends it to the HTTP client\&. The server can send three types of document, which are XML (Extensible Markup Language), XSD(XML Schema definition) and XSL(Extensible Stylesheet Language)\&. The XML document is the statistics data of BIND 10, The XSD document is the data schema of it, and The XSL document is the style sheet to be showed for the web browsers\&. Please see the manual and the spec file of
+\fBb10\-stats\fR
+for more details about the items of BIND 10 statistics\&. The server uses CC session in communication with
+\fBb10\-stats\fR\&. CC session is provided by
+\fBb10\-msgq\fR
+which is started by
+\fBbind10\fR
+in advance\&. The server is implemented by HTTP\-server libraries included in Python 3\&. The parameter of the server is a list of pairs of the listening address and the port number specified in the spec file of it\&. The server obtains the configuration from the config manager (\fBb10\-cfgmgr\fR) in runtime\&. Please see below for more details about this spec file and configuration of the server\&.
.SH "OPTIONS"
.PP
The arguments are as follows:
.PP
\fB\-v\fR, \fB\-\-verbose\fR
.RS 4
-This
+
\fBb10\-stats\-httpd\fR
-switches to verbose mode\&. It sends verbose messages to STDOUT\&.
+switches to verbose mode and sends verbose messages to STDOUT\&.
.RE
.SH "FILES"
.PP
-/path/to/file
-\(em This is a file for \&.\&.
+
+/usr/local/share/bind10\-devel/stats\-httpd\&.spec
+\(em the spec file of
+\fBb10\-stats\-httpd\fR\&. This file contains configurable settings of
+\fBb10\-stats\-httpd\fR\&. This setting can be configured in runtime via
+bindctl(1)\&. Please see the manual of
+bindctl(1)
+about how to configure the settings\&.
+.PP
+
+/usr/local/share/bind10\-devel/stats\-httpd\-xml\&.tpl
+\(em the template file of XML document\&.
+.PP
+
+/usr/local/share/bind10\-devel/stats\-httpd\-xsd\&.tpl
+\(em the template file of XSD document\&.
+.PP
+
+/usr/local/share/bind10\-devel/stats\-httpd\-xsl\&.tpl
+\(em the template file of XSL document\&.
+.SH "CONFIGURATION AND COMMANDS"
+.PP
+The configurable setting in
+stats\-httpd\&.spec
+is:
+.PP
+\fIlisten_on\fR
+.RS 4
+a list of pairs of address and port for
+\fBb10\-stats\-httpd\fR
+to listen HTTP requests on\&. The pair is consist of the
+\fIaddress\fR
+string and
+\fIport\fR
+number\&. The default setting is the list of address 127\&.0\&.0\&.1 port 8000\&. If the server is started by the default setting being left, for example, the URL for XML document is http://127\&.0\&.0\&.1:8000/bind10/statistics/xml\&. And also IPv6 addresses can be configured and they works in the runtime environment for dual stack\&.
+.RE
+.PP
+The configuration commands in
+stats\-httpd\&.spec
+are:
+.PP
+\fBstatus\fR
+.RS 4
+shows the status of
+\fBb10\-stats\-httpd\fR
+with its PID on the runtime machine\&.
+.RE
+.PP
+\fBshutdown\fR
+.RS 4
+exits the
+\fBb10\-stats\-httpd\fR
+process\&. (Note that the BIND 10 boss process will restart this service\&.)
+.RE
.SH "SEE ALSO"
.PP
\fBb10-stats\fR(8),
+\fBb10-msgq\fR(8),
+\fBb10-cfgmgr\fR(8),
+\fBbind10\fR(8),
+\fBbindctl\fR(1),
BIND 10 Guide\&.
.SH "HISTORY"
.PP
-The
+
\fBb10\-stats\-httpd\fR
was designed and implemented by Naoki Kambe of JPRS in Mar 2011\&.
.SH "COPYRIGHT"
diff --git a/src/bin/stats/b10-stats-httpd.xml b/src/bin/stats/b10-stats-httpd.xml
index 09f25df..46955aa 100644
--- a/src/bin/stats/b10-stats-httpd.xml
+++ b/src/bin/stats/b10-stats-httpd.xml
@@ -20,7 +20,7 @@
<refentry>
<refentryinfo>
- <date>Mar xx, 2011</date>
+ <date>Mar 8, 2011</date>
</refentryinfo>
<refmeta>
@@ -31,7 +31,7 @@
<refnamediv>
<refname>b10-stats-httpd</refname>
- <refpurpose>BIND 10 HTTP/XML interface for statistics module</refpurpose>
+ <refpurpose>BIND 10 HTTP server for HTTP/XML interface of statistics</refpurpose>
</refnamediv>
<docinfo>
@@ -42,18 +42,41 @@
</docinfo>
<refsynopsisdiv>
- <cmdsynopsis>
- <command>b10-stats-httpd</command>
- <arg><option>-v</option></arg>
- <arg><option>--verbose</option></arg>
+ <cmdsynopsis> <command>b10-stats-httpd</command>
+ <arg><option>-v</option></arg>|<arg><option>--verbose</option></arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>DESCRIPTION</title>
<para>
- The <command>b10-stats-httpd</command> is HTTP/XML interface for
- statistics module. ....
+ <command>b10-stats-httpd</command> is a standalone HTTP server. It is
+ intended for HTTP/XML interface for statistics module. This server
+ process runs as a process separated from the process of the BIND 10 Stats
+ daemon (<command>b10-stats</command>). The server is initially executed
+ by the BIND 10 boss process (<command>bind10</command>) and finally
+ exited by it. The server is intended to be requested by HTTP clients
+ like web browsers and third-party modules. When the server is requested,
+ it requests BIND 10 statistics data to <command>b10-stats</command>,
+ and <command>b10-stats</command> sends the data to the server in Python
+ dictionary format and the server converts it into XML format. The server
+ sends it to the HTTP client. The server can send three types of document,
+ which are XML (Extensible Markup Language), XSD(XML Schema definition)
+ and XSL(Extensible Stylesheet Language). The XML document is the
+ statistics data of BIND 10, The XSD document is the data schema of it,
+ and The XSL document is the style sheet to be showed for the web
+ browsers. Please see the manual and the spec file
+ of <command>b10-stats</command> for more details about the items of BIND
+ 10 statistics. The server uses CC session in communication
+ with <command>b10-stats</command>. CC session is provided
+ by <command>b10-msgq</command> which is started
+ by <command>bind10</command> in advance. The server is implemented by
+ HTTP-server libraries included in Python 3. The parameter of the server
+ is a list of pairs of the listening address and the port number specified
+ in the spec file of it. The server obtains the configuration from the
+ config manager (<command>b10-cfgmgr</command>) in runtime. Please see
+ below for more details about this spec file and configuration of the
+ server.
</para>
</refsect1>
@@ -65,8 +88,8 @@
<term><option>-v</option>, <option>--verbose</option></term>
<listitem>
<para>
- This <command>b10-stats-httpd</command> switches to verbose
- mode. It sends verbose messages to STDOUT.
+ <command>b10-stats-httpd</command> switches to verbose mode and sends
+ verbose messages to STDOUT.
</para>
</listitem>
</varlistentry>
@@ -75,9 +98,78 @@
<refsect1>
<title>FILES</title>
- <para><filename>/path/to/file</filename>
- — This is a file for ..
+ <para>
+ <filename>/usr/local/share/bind10-devel/stats-httpd.spec</filename>
+ — the spec file of <command>b10-stats-httpd</command>. This file
+ contains configurable settings
+ of <command>b10-stats-httpd</command>. This setting can be configured in
+ runtime via
+ <refentrytitle>bindctl</refentrytitle><manvolnum>1</manvolnum>. Please
+ see the manual
+ of <refentrytitle>bindctl</refentrytitle><manvolnum>1</manvolnum> about
+ how to configure the settings.
+ </para>
+ <para>
+ <filename>/usr/local/share/bind10-devel/stats-httpd-xml.tpl</filename>
+ — the template file of XML document.
+ </para>
+ <para>
+ <filename>/usr/local/share/bind10-devel/stats-httpd-xsd.tpl</filename>
+ — the template file of XSD document.
+ </para>
+ <para>
+ <filename>/usr/local/share/bind10-devel/stats-httpd-xsl.tpl</filename>
+ — the template file of XSL document.
+ </para>
+ </refsect1>
+
+ <refsect1>
+ <title>CONFIGURATION AND COMMANDS</title>
+ <para>
+ The configurable setting in
+ <filename>stats-httpd.spec</filename> is:
+ </para>
+ <variablelist>
+ <varlistentry>
+ <term><varname>listen_on</varname></term>
+ <listitem>
+ <para>
+ a list of pairs of address and port for
+ <command>b10-stats-httpd</command> to listen HTTP requests on. The
+ pair is consist of the <varname>address</varname> string
+ and <varname>port</varname> number. The default setting is the list
+ of address 127.0.0.1 port 8000. If the server is started by the
+ default setting being left, for example, the URL for XML document
+ is http://127.0.0.1:8000/bind10/statistics/xml. And also IPv6
+ addresses can be configured and they works in the runtime
+ environment for dual stack.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ <para>
+ The configuration commands in <filename>stats-httpd.spec</filename> are:
</para>
+ <variablelist>
+ <varlistentry>
+ <term><command>status</command></term>
+ <listitem>
+ <para>
+ shows the status of <command>b10-stats-httpd</command> with its
+ PID on the runtime machine.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><command>shutdown</command></term>
+ <listitem>
+ <para>
+ exits the <command>b10-stats-httpd</command> process. (Note that
+ the BIND 10 boss process will restart this service.)
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
</refsect1>
<refsect1>
@@ -86,6 +178,18 @@
<citerefentry>
<refentrytitle>b10-stats</refentrytitle><manvolnum>8</manvolnum>
</citerefentry>,
+ <citerefentry>
+ <refentrytitle>b10-msgq</refentrytitle><manvolnum>8</manvolnum>
+ </citerefentry>,
+ <citerefentry>
+ <refentrytitle>b10-cfgmgr</refentrytitle><manvolnum>8</manvolnum>
+ </citerefentry>,
+ <citerefentry>
+ <refentrytitle>bind10</refentrytitle><manvolnum>8</manvolnum>
+ </citerefentry>,
+ <citerefentry>
+ <refentrytitle>bindctl</refentrytitle><manvolnum>1</manvolnum>
+ </citerefentry>,
<citetitle>BIND 10 Guide</citetitle>.
</para>
</refsect1>
@@ -93,8 +197,8 @@
<refsect1>
<title>HISTORY</title>
<para>
- The <command>b10-stats-httpd</command> was designed
- and implemented by Naoki Kambe of JPRS in Mar 2011.
+ <command>b10-stats-httpd</command> was designed and implemented by Naoki
+ Kambe of JPRS in Mar 2011.
</para>
</refsect1>
</refentry><!--
diff --git a/src/bin/stats/stats-httpd.spec.in b/src/bin/stats/stats-httpd.spec.in
index f4d7a52..6307135 100644
--- a/src/bin/stats/stats-httpd.spec.in
+++ b/src/bin/stats/stats-httpd.spec.in
@@ -9,10 +9,6 @@
"item_optional": false,
"item_default": [
{
- "address": "::1",
- "port": 8000
- },
- {
"address": "127.0.0.1",
"port": 8000
}
@@ -28,14 +24,14 @@
"item_type": "string",
"item_optional": true,
"item_default": "127.0.0.1",
- "item_description": "http listen-on address"
+ "item_description": "listen-on address for HTTP"
},
{
"item_name": "port",
"item_type": "integer",
"item_optional": true,
"item_default": 8000,
- "item_description": "http listen-on port"
+ "item_description": "listen-on port for HTTP"
}
]
},
diff --git a/src/bin/stats/stats_httpd.py.in b/src/bin/stats/stats_httpd.py.in
index ab0a291..830ef73 100644
--- a/src/bin/stats/stats_httpd.py.in
+++ b/src/bin/stats/stats_httpd.py.in
@@ -46,19 +46,26 @@ XML_TEMPLATE_LOCATION = BASE_LOCATION + os.sep + "stats-httpd-xml.tpl"
XSD_TEMPLATE_LOCATION = BASE_LOCATION + os.sep + "stats-httpd-xsd.tpl"
XSL_TEMPLATE_LOCATION = BASE_LOCATION + os.sep + "stats-httpd-xsl.tpl"
+# These variables are paths part of URL.
+# eg. "http://${address}" + XXX_URL_PATH
XML_URL_PATH = '/bind10/statistics/xml'
XSD_URL_PATH = '/bind10/statistics/xsd'
XSL_URL_PATH = '/bind10/statistics/xsl'
-XSD_NAMESPACE = 'http://bind10.isc.org' + XSD_URL_PATH # TODO: should be considered later
+# TODO: This should be considered later.
+XSD_NAMESPACE = 'http://bind10.isc.org' + XSD_URL_PATH
DEFAULT_CONFIG = dict(listen_on=[('127.0.0.1', 8000)])
-MAX_SIZE_OF_TEMPLATE = 102400 # under 100k
+# The size of template file should be under 100k. TODO: should be
+# considered later.
+MAX_SIZE_OF_TEMPLATE = 102400
# Assign this process name
isc.util.process.rename()
class HttpHandler(http.server.BaseHTTPRequestHandler):
- """HTTP handler class"""
+ """HTTP handler class for HttpServer class. The class inhrits the super
+ class http.server.BaseHTTPRequestHandler. It implemets do_GET()
+ and do_HEAD() and orverrides log_message()"""
def do_GET(self):
body = self.send_head()
if body is not None:
@@ -113,11 +120,20 @@ class HttpHandler(http.server.BaseHTTPRequestHandler):
format%args))
class HttpServerError(Exception):
- """To be passed from the HttpServer object to the StatsHttpd object"""
+ """Exception class for HttpServer class. It is intended to be
+ passed from the HttpServer object to the StatsHttpd object."""
pass
class HttpServer(http.server.HTTPServer):
- """HTTP Server class"""
+ """HTTP Server class. The class inherits the super
+ http.server.HTTPServer. Some parameters are specified as
+ arguments, which are xml_handler, xsd_handler, xsl_handler, and
+ log_writer. These all are parameters which the StatsHttpd object
+ has. The handler parameters are references of functions which
+ return body of each document. The last parameter log_writer is
+ reference of writer function to just write to
+ sys.stderr.write. They are intended to be referred by HttpHandler
+ object."""
def __init__(self, server_address, handler,
xml_handler, xsd_handler, xsl_handler, log_writer, verbose=False):
self.server_address = server_address
@@ -129,12 +145,16 @@ class HttpServer(http.server.HTTPServer):
http.server.HTTPServer.__init__(self, server_address, handler)
class StatsHttpdError(Exception):
- """To be passed from the StatsHttpd object to the HttpHandler object"""
+ """Exception class for StatsHttpd class. It is intended to be
+ thrown from the the StatsHttpd object to the HttpHandler object or
+ main routine."""
pass
class StatsHttpd:
- """
- """
+ """The main class of HTTP server of HTTP/XML interface for
+ statistics module. It handles HTTP requests, and command channel
+ and config channel CC session. It uses select.select function
+ while waiting for clients requests."""
def __init__(self, verbose=False):
self.verbose = verbose
self.running = False
@@ -148,6 +168,7 @@ class StatsHttpd:
self.open_httpd()
def open_mccs(self):
+ """Opens a ModuleCCSession object"""
# create ModuleCCSession
if self.verbose:
self.write_log("[b10-stats-httpd] Starting CC Session\n")
@@ -163,6 +184,7 @@ class StatsHttpd:
self.cc_session.group_subscribe(self.stats_module_name, "*")
def close_mccs(self):
+ """Closes a ModuleCCSession object"""
if self.mccs is None:
return
if self.verbose:
@@ -176,6 +198,8 @@ class StatsHttpd:
self.mccs = None
def load_config(self, new_config={}):
+ """Loads configuration from spec file or new configuration
+ from the config manager"""
# load config
if len(new_config) > 0:
assert type(self.config) is dict
@@ -197,6 +221,8 @@ class StatsHttpd:
)
def open_httpd(self):
+ """Opens sockets for HTTP. Iterating each HTTP address to be
+ configured in spec file"""
assert type(self.http_addrs) is list
for addr in self.http_addrs:
self.httpd.append(self._open_httpd(addr))
@@ -232,6 +258,7 @@ class StatsHttpd:
return httpd
def close_httpd(self):
+ """Closes sockets for HTTP"""
if len(self.httpd) == 0:
return
for ht in self.httpd:
@@ -245,6 +272,8 @@ class StatsHttpd:
self.httpd = []
def start(self):
+ """Starts StatsHttpd objects to run. Waiting for client
+ requests by using select.select functions"""
self.mccs.start()
self.running = True
while self.running:
@@ -267,12 +296,15 @@ class StatsHttpd:
self.stop()
def stop(self):
+ """Stops the running StatsHttpd objects. Closes CC session and
+ HTTP handling sockets"""
if self.verbose:
self.write_log("[b10-stats-httpd] Shutting down\n")
self.close_httpd()
self.close_mccs()
def get_sockets(self):
+ """Returns sockets to select.select"""
sockets = []
if self.mccs is not None:
sockets.append(self.mccs.get_socket())
@@ -282,10 +314,11 @@ class StatsHttpd:
return sockets
def config_handler(self, new_config):
- """config handler for ModuleCCSession object"""
+ """Config handler for the ModuleCCSession object. It resets
+ addresses and ports to listen HTTP requests on."""
assert type(new_config) is dict
if self.verbose:
- self.write_log("[b10-stats-httpd] Loading new config : %s\n" % str(new_config))
+ self.write_log("[b10-stats-httpd] Loading config : %s\n" % str(new_config))
for key in new_config.keys():
if key not in DEFAULT_CONFIG:
if self.verbose:
@@ -311,9 +344,8 @@ class StatsHttpd:
return isc.config.ccsession.create_answer(0)
def command_handler(self, command, args):
- """
- command handler
- """
+ """Command handler for the ModuleCCSesson object. It handles
+ "status" and "shutdown" commands."""
if command == "status":
if self.verbose:
self.write_log("[b10-stats-httpd] Received 'status' command\n")
@@ -332,6 +364,8 @@ class StatsHttpd:
1, "Unknown command: " + str(command))
def get_stats_data(self):
+ """Requests statistics data to the Stats daemon and returns
+ the data which obtains from it"""
try:
seq = self.cc_session.group_sendmsg(
isc.config.ccsession.create_command('show'),
@@ -352,11 +386,15 @@ class StatsHttpd:
raise StatsHttpdError("Stats module: %s" % str(value))
def get_stats_spec(self):
- """return spec data"""
+ """Just returns spec data"""
return self.stats_config_spec
def load_templates(self):
- """open templates of XSD and XSL and create their string"""
+ """Setup the bodies of XSD and XSL documents to be responds to
+ HTTP clients. Before that it also creates XML tag structures by
+ using xml.etree.ElementTree.Element class and substitutes
+ concrete strings with parameters embed in the string.Template
+ object."""
# for XSD
xsd_root = xml.etree.ElementTree.Element("all") # started with "all" tag
for item in self.get_stats_spec():
@@ -408,6 +446,8 @@ class StatsHttpd:
assert self.xsl_body is not None
def xml_handler(self):
+ """Handler which requests to Stats daemon to obtain statistics
+ data and returns the body of XML document"""
xml_list=[]
for (k, v) in self.get_stats_data().items():
(k, v) = (str(k), str(v))
@@ -426,12 +466,17 @@ class StatsHttpd:
return self.xml_body
def xsd_handler(self):
+ """Handler which just returns the body of XSD document"""
return self.xsd_body
def xsl_handler(self):
+ """Handler which just returns the body of XSL document"""
return self.xsl_body
def open_template(self, file_name):
+ """Opens a template file with size limitation, loads all lines to a
+ string variable and returns string.Template object include the
+ variable."""
lines = "".join(
open(file_name, 'r').readlines(MAX_SIZE_OF_TEMPLATE))
assert lines is not None
diff --git a/src/bin/stats/tests/b10-stats-httpd_test.py b/src/bin/stats/tests/b10-stats-httpd_test.py
index 20168b0..0b1ec18 100644
--- a/src/bin/stats/tests/b10-stats-httpd_test.py
+++ b/src/bin/stats/tests/b10-stats-httpd_test.py
@@ -52,6 +52,7 @@ def pull_query(stats_httpd):
return (ret, arg, env)
class TestHttpHandler(unittest.TestCase):
+ """Tests for HttpHandler class"""
def setUp(self):
self.verbose = True
@@ -173,6 +174,8 @@ class TestHttpHandler(unittest.TestCase):
log_message))
class TestHttpServerError(unittest.TestCase):
+ """Tests for HttpServerError exception"""
+
def test_raises(self):
try:
raise stats_httpd.HttpServerError('Nothing')
@@ -180,6 +183,8 @@ class TestHttpServerError(unittest.TestCase):
self.assertEqual(str(err), 'Nothing')
class TestHttpServer(unittest.TestCase):
+ """Tests for HttpServer class"""
+
def setUp(self):
self.verbose = True
self.stats_httpd = stats_httpd.StatsHttpd(self.verbose)
@@ -195,6 +200,8 @@ class TestHttpServer(unittest.TestCase):
self.assertTrue(isinstance(self.ht.socket, socket.socket))
class TestStatsHttpdError(unittest.TestCase):
+ """Tests for StatsHttpdError exception"""
+
def test_raises(self):
try:
raise stats_httpd.StatsHttpdError('Nothing')
@@ -202,6 +209,7 @@ class TestStatsHttpdError(unittest.TestCase):
self.assertEqual(str(err), 'Nothing')
class TestStatsHttpd(unittest.TestCase):
+ """Tests for StatsHttpd class"""
def setUp(self):
self.verbose = True
More information about the bind10-changes
mailing list