bindctl.py 3.52 KB
Newer Older
Likun Zhang's avatar
Likun Zhang committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
# Copyright (C) 2009  Internet Systems Consortium.
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SYSTEMS CONSORTIUM
# DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
# INTERNET SYSTEMS CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
# FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.


Likun Zhang's avatar
Likun Zhang committed
17
from moduleinfo  import *
18
from bindcmd import *
19
import isc
20
import pprint
Likun Zhang's avatar
Likun Zhang committed
21 22


23
def prepare_config_commands(tool):
24 25 26 27 28 29 30 31 32
    module = ModuleInfo(name = "config", desc = "Configuration commands")
    cmd = CommandInfo(name = "show", desc = "Show configuration", need_inst_param = False)
    param = ParamInfo(name = "identifier", type = "string", optional=True)
    cmd.add_param(param)
    module.add_command(cmd)

    cmd = CommandInfo(name = "add", desc = "Add entry to configuration list", need_inst_param = False)
    param = ParamInfo(name = "identifier", type = "string", optional=True)
    cmd.add_param(param)
33
    param = ParamInfo(name = "value", type = "string", optional=False)
34 35 36 37 38 39
    cmd.add_param(param)
    module.add_command(cmd)

    cmd = CommandInfo(name = "remove", desc = "Remove entry from configuration list", need_inst_param = False)
    param = ParamInfo(name = "identifier", type = "string", optional=True)
    cmd.add_param(param)
40
    param = ParamInfo(name = "value", type = "string", optional=False)
41 42 43 44 45 46
    cmd.add_param(param)
    module.add_command(cmd)

    cmd = CommandInfo(name = "set", desc = "Set a configuration value", need_inst_param = False)
    param = ParamInfo(name = "identifier", type = "string", optional=True)
    cmd.add_param(param)
47
    param = ParamInfo(name = "value", type = "string", optional=False)
48 49 50 51
    cmd.add_param(param)
    module.add_command(cmd)

    cmd = CommandInfo(name = "unset", desc = "Unset a configuration value", need_inst_param = False)
52
    param = ParamInfo(name = "identifier", type = "string", optional=False)
53 54
    cmd.add_param(param)
    module.add_command(cmd)
55 56 57

    cmd = CommandInfo(name = "diff", desc = "Show all local changes", need_inst_param = False)
    module.add_command(cmd)
58 59 60 61 62 63 64

    cmd = CommandInfo(name = "revert", desc = "Revert all local changes", need_inst_param = False)
    module.add_command(cmd)

    cmd = CommandInfo(name = "commit", desc = "Commit all local changes", need_inst_param = False)
    module.add_command(cmd)

65 66 67 68 69
    cmd = CommandInfo(name = "go", desc = "Go to a specific configuration part", need_inst_param = False)
    param = ParamInfo(name = "identifier", type="string", optional=False)
    cmd.add_param(param)
    module.add_command(cmd)

70
    tool.add_module_info(module)
Likun Zhang's avatar
Likun Zhang committed
71 72

if __name__ == '__main__':
73 74 75 76 77 78 79 80 81 82 83 84
    tool = BindCmdInterpreter("localhost:8080")
    prepare_config_commands(tool)
    tool.run()
# TODO: put below back, was removed to see errors
#if __name__ == '__main__':
    #try:
        #tool = BindCmdInterpreter("localhost:8080")
        #prepare_config_commands(tool)
        #tool.run()
    #except Exception as e:
        #print(e)
        #print("Failed to connect with b10-cmdctl module, is it running?")
85

Likun Zhang's avatar
Likun Zhang committed
86