BIND 10 trac1843, updated. 4429acb90d47320d20e9126457594a1f38191b28 [1843] clean up comments

BIND 10 source code commits bind10-changes at lists.isc.org
Tue May 1 14:00:09 UTC 2012


The branch, trac1843 has been updated
       via  4429acb90d47320d20e9126457594a1f38191b28 (commit)
       via  9a76caecbc29f35dad73a2f9874e8e3a64e4154f (commit)
       via  3de6e881f69c6462cf3da43c662cbc1a35595504 (commit)
      from  4cfab0d82574c3501502a9ed9b84c39112d411a8 (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 4429acb90d47320d20e9126457594a1f38191b28
Author: Jelte Jansen <jelte at isc.org>
Date:   Tue May 1 15:59:56 2012 +0200

    [1843] clean up comments

commit 9a76caecbc29f35dad73a2f9874e8e3a64e4154f
Author: Jelte Jansen <jelte at isc.org>
Date:   Tue May 1 12:29:14 2012 +0200

    [1843] use re for directive matching
    
    to work with both whitespace and case-insensitivity

commit 3de6e881f69c6462cf3da43c662cbc1a35595504
Author: Jelte Jansen <jelte at isc.org>
Date:   Tue May 1 12:06:35 2012 +0200

    [1843] don't revert local config on execute failure
    
    instead, just print some advice

-----------------------------------------------------------------------

Summary of changes:
 src/bin/bindctl/bindcmd.py                      |   28 +++++++-----------
 src/bin/bindctl/command_sets.py                 |   15 ++++++----
 tests/lettuce/data/commands/directives          |   19 +++++++++++--
 tests/lettuce/features/bindctl_commands.feature |   34 ++++++-----------------
 4 files changed, 45 insertions(+), 51 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/bin/bindctl/bindcmd.py b/src/bin/bindctl/bindcmd.py
index 3560692..f1a622e 100644
--- a/src/bin/bindctl/bindcmd.py
+++ b/src/bin/bindctl/bindcmd.py
@@ -739,13 +739,8 @@ class BindCmdInterpreter(Cmd):
            of the sets as defined in command_sets.py'''
         if command.command == 'file':
             try:
-                command_file = open(command.params['filename'])
-                # copy them into a list for consistency with the built-in
-                # sets of commands
-                commands = []
-                for line in command_file:
-                    commands.append(line)
-                command_file.close()
+                with open(command.params['filename']) as command_file:
+                    commands = command_file.readlines()
             except IOError as ioe:
                 print("Error: " + str(ioe))
                 return
@@ -782,23 +777,19 @@ class BindCmdInterpreter(Cmd):
            The execution is stopped if there are any errors.
         '''
         verbose = False
-        # Keep a copy of the original local changes, in case the
-        # given command set changes things but fails later
-        local_changes_backup =\
-            copy.deepcopy(self.config_data.get_local_changes())
         try:
             for line in commands:
                 line = line.strip()
                 if verbose:
                     print(line)
-                if line.startswith('#'):
+                if line.startswith('#') or len(line) == 0:
                     continue
                 elif line.startswith('!'):
-                    if line.startswith('!echo ') and len(line) > 6:
+                    if re.match('^!echo ', line, re.I) and len(line) > 6:
                         print(line[6:])
-                    elif line.startswith('!verbose on'):
+                    elif re.match('^!verbose\s+on\s*$', line, re.I):
                         verbose = True
-                    elif line.startswith('!verbose off'):
+                    elif re.match('^!verbose\s+off$', line, re.I):
                         verbose = False
                     else:
                         print("Warning: ignoring unknown directive: " + line)
@@ -813,8 +804,11 @@ class BindCmdInterpreter(Cmd):
                 isc.cc.data.DataAlreadyPresentError,
                 KeyError) as err:
             print('Error: ', err)
-            # revert changes
-            self.config_data.set_local_changes(local_changes_backup)
+            print()
+            print('Depending on the contents of the script, and which')
+            print('commands it has called, there can be committed and')
+            print('local changes. It is advised to check your settings,')
+            print('and revert local changes with "config revert".')
 
     def apply_cmd(self, cmd):
         '''Handles a general module command'''
diff --git a/src/bin/bindctl/command_sets.py b/src/bin/bindctl/command_sets.py
index 7e9e437..9e2c2ef 100644
--- a/src/bin/bindctl/command_sets.py
+++ b/src/bin/bindctl/command_sets.py
@@ -14,16 +14,19 @@
 # WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
 # This file provides a built-in set of 'execute' commands, for common
-# functions, such as adding an initial auth server
-# These sets must have an associated CommandInfo defined in
-# bindctl_main.py.in, in prepare_execute_commands, and
-# a handler in 
+# functions, such as adding an initial auth server.
+# By calling the function prepare_execute_commands, the
+# commands in the command_sets map are added to the virtual
+# component called 'execute'. This is done in bindctl_main.
 
 from bindctl.moduleinfo import *
 # The name of the 'virtual' command set execution module in bindctl
 EXECUTE_MODULE_NAME = 'execute'
 
 # This is a map of command names to lists
+# Each element in the set should itself be a dict containing:
+# 'description': A string with a description of the command set
+# 'commands': A list of bindctl commands
 command_sets = {
     'init_authoritative_server': {
         'description':
@@ -47,8 +50,8 @@ command_sets = {
             'config add /Boss/components b10-zonemgr',
             'config set /Boss/components/b10-zonemgr/address Zonemgr',
             'config set /Boss/components/b10-zonemgr/kind dispensable',
-            '!echo Components added. Please enter "config commit" to finalize'+
-            'initial setup and run the components.'
+            '!echo Components added. Please enter "config commit" to',
+            '!echo finalize initial setup and run the components.'
             ]
     }
 }
diff --git a/tests/lettuce/data/commands/directives b/tests/lettuce/data/commands/directives
index d8147fb..4fe10f5 100644
--- a/tests/lettuce/data/commands/directives
+++ b/tests/lettuce/data/commands/directives
@@ -1,6 +1,19 @@
 # this is a comment: commentexample1
-!echo this is an echo: echoexample
+!echo this is an echo: echoexample2
 !verbose on
-# this is a comment with verbose on: verbosecommentexample
+# this is a comment with verbose on: verbosecommentexample3
 !verbose off
-# this is a comment with verbose off again: commentexample2
+# this is a comment with verbose off again: commentexample4
+# empty lines and lines with only whitespace should be ignored
+
+
+
+	
+	    	
+# directives are case insensitive, and should handle whitespace
+!ECHO echoexample5
+!eChO echoexample6
+!Verbose     ON
+# verbosecommentexample7
+!verBOSE		off	
+# commentexample8
diff --git a/tests/lettuce/features/bindctl_commands.feature b/tests/lettuce/features/bindctl_commands.feature
index 0c4db5b..1ab506d 100644
--- a/tests/lettuce/features/bindctl_commands.feature
+++ b/tests/lettuce/features/bindctl_commands.feature
@@ -88,39 +88,24 @@ Feature: control with bindctl
         When I send bind10 the command execute file data/commands/directives
         last bindctl output should not contain Error
         last bindctl output should not contain commentexample1
-        last bindctl output should contain echoexample
-        last bindctl output should contain verbosecommentexample
-        last bindctl output should not contain commentexample2
+        last bindctl output should contain echoexample2
+        last bindctl output should contain verbosecommentexample3
+        last bindctl output should not contain commentexample4
+        last bindctl output should contain echoexample5
+        last bindctl output should contain echoexample6
+        last bindctl output should contain verbosecommentexample7
+        last bindctl output should not contain commentexample8
 
         # bad_command contains a bad command, at which point execution should stop
         When I send bind10 the command execute file data/commands/bad_command
         last bindctl output should contain shouldshow
         last bindctl output should contain Error
         last bindctl output should not contain shouldnotshow
-        # This would fail if the entire list was passed, or the configuratio
+        # This would fail if the entire list was passed, or the configuration
+        # was committed
         send bind10 the command config show Boss/components
         last bindctl output should not contain b10-auth
 
-        # the bad command should also keep existing changes intact,
-        # i.e. if we add something, then run a failing script, our
-        # addition should still be there, but those from the script
-        # should not
-        When I send bind10 the following commands:
-        """
-        config add Boss/components b10-resolver
-        config set Boss/components/b10-resolver/kind dispensable
-        config set Boss/components/b10-resolver/special resolver
-        execute file data/commands/bad_command
-        config commit
-        """
-        last bindctl output should contain shouldshow
-        last bindctl output should contain Error
-        last bindctl output should not contain shouldnotshow
-        # This would fail if the entire list was passed, or the configuratio
-        send bind10 the command config show Boss/components
-        last bindctl output should not contain b10-auth
-        last bindctl output should contain b10-resolver
-
         # nested_command contains another execute script
         When I send bind10 the command execute file data/commands/nested
         last bindctl output should contain shouldshow
@@ -169,4 +154,3 @@ Feature: control with bindctl
         bind10 module Xfrout should be running
         bind10 module Xfrin should be running
         bind10 module Zonemgr should be running
-        



More information about the bind10-changes mailing list