Commit 7e2512b0 authored by Jelte Jansen's avatar Jelte Jansen
Browse files

compile-time location for parkinglot.spec file

somewhat parse the commands structure in bigtool as they are sent by the config manager


git-svn-id: svn://bind10.isc.org/svn/bind10/branches/jelte-datadef@318 e5f2f494-b856-4b98-b285-d166d9295462
parent 9c62eaeb
......@@ -64,6 +64,7 @@ AC_CONFIG_FILES([Makefile
])
AC_OUTPUT([src/bin/bind-cfgd/bind-cfgd
src/bin/bind10/bind10
src/bin/parkinglot/config.h
], [
chmod +x src/bin/bind-cfgd/bind-cfgd
chmod +x src/bin/bind10/bind10
......
......@@ -27,8 +27,28 @@ def _prepare_fake_data(bigtool):
bigtool.add_module_info(zone_module)
bigtool.add_module_info(boss_module)
def prepare_data_module(bigtool, module_name, module_commands):
module = ModuleInfo(name = module_name,
desc = "same here")
for command in module_commands:
cmd = CommandInfo(name = command["command_name"],
desc = "todo2",
need_inst_param = False)
for arg in command["command_args"]:
param = ParamInfo(name = arg["item_name"],
type = arg["item_type"],
optional = bool(arg["item_optional"]))
if ("item_default" in arg):
param.default = arg["item_default"]
cmd.add_param(param)
module.add_command(cmd)
bigtool.add_module_info(module)
def prepare_data(bigtool, command_spec):
for module_name in command_spec.keys():
prepare_data_module(bigtool, module_name, command_spec[module_name])
if __name__ == '__main__':
try:
cc = ISC.CC.Session()
......@@ -37,6 +57,9 @@ if __name__ == '__main__':
cc.group_subscribe("Boss", "*", "meonly")
tool = BigTool(cc)
cc.group_sendmsg({ "command": ["get_commands"] }, "ConfigManager")
command_spec, env = cc.group_recvmsg(False)
prepare_data(tool, command_spec["result"])
_prepare_fake_data(tool)
tool.cmdloop()
except ISC.CC.SessionError:
......
......@@ -38,6 +38,7 @@
#include "common.h"
#include "ccsession.h"
#include "config.h"
using namespace std;
......@@ -52,9 +53,9 @@ CommandSession::read_data_definition(const std::string& filename) {
std::ifstream file;
// this file should be declared in a @something@ directive
file.open("parkinglot.spec");
file.open(PARKINGLOT_SPECFILE_LOCATION);
if (!file) {
cout << "error opening parkinglot.spec" << endl;
cout << "error opening " << PARKINGLOT_SPECFILE_LOCATION << endl;
exit(1);
}
......
#define PARKINGLOT_SPECFILE_LOCATION "@abs_top_srcdir@/src/bin/parkinglot/parkinglot.spec"
{
"data_specification": {
"module_name": "ParkingLot",
"config_data": [
{
"item_name": "port",
"item_type": "integer",
"item_optional": false,
"item_default": 5300
},
{
"item_name": "zones",
"item_type": "list",
"item_optional": false,
"item_default": [ ],
"list_item_spec": {
"item_name": "zone_name",
"item_type": "string",
"item_optional": false,
"item_default": ""
}
}
],
"commands": [
{
"command_name": "zone_add",
"command_args": [ {
"item_name": "zone_name",
"item_type": "string",
"item_optional": False,
"item_default": ""
} ]
},
{
"command_name": "zone_delete",
"command_args": [ {
"item_name": "zone_name",
"item_type": "string",
"item_optional": False,
"item_default": ""
} ]
}
]
}
}
......@@ -85,7 +85,7 @@ class ConfigManager:
try:
if cmd[0] == "get_commands":
answer["result"] = self.commands
if cmd[0] == "zone" and cmd[1] == "add":
elif cmd[0] == "zone" and cmd[1] == "add":
self.add_zone(cmd[2])
answer["result"] = [ 0 ]
elif cmd[0] == "zone" and cmd[1] == "remove":
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment