ccsession.py 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580
  1. # Copyright (C) 2009 Internet Systems Consortium.
  2. #
  3. # Permission to use, copy, modify, and distribute this software for any
  4. # purpose with or without fee is hereby granted, provided that the above
  5. # copyright notice and this permission notice appear in all copies.
  6. #
  7. # THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SYSTEMS CONSORTIUM
  8. # DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
  9. # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
  10. # INTERNET SYSTEMS CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
  11. # INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
  12. # FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
  13. # NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
  14. # WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. #
  16. # Client-side functionality for configuration and commands
  17. #
  18. # It keeps a cc-channel session with the configuration manager daemon,
  19. # and handles configuration updates and direct commands
  20. # modeled after ccsession.h/cc 'protocol' changes here need to be
  21. # made there as well
  22. """Classes and functions for handling configuration and commands
  23. This module provides the ModuleCCSession and UIModuleCCSession
  24. classes, as well as a set of utility functions to create and parse
  25. messages related to commands and configuration
  26. Modules should use the ModuleCCSession class to connect to the
  27. configuration manager, and receive updates and commands from
  28. other modules.
  29. Configuration user interfaces should use the UIModuleCCSession
  30. to connect to b10-cmdctl, and receive and send configuration and
  31. commands through that to the configuration manager.
  32. """
  33. from isc.cc import Session
  34. from isc.config.config_data import ConfigData, MultiConfigData, BIND10_CONFIG_DATA_VERSION
  35. import isc
  36. from isc.util.file import path_search
  37. import bind10_config
  38. from isc.log import log_config_update
  39. import json
  40. from config_messages import *
  41. logger = isc.log.Logger("config")
  42. class ModuleCCSessionError(Exception): pass
  43. def parse_answer(msg):
  44. """Returns a tuple (rcode, value), where value depends on the
  45. command that was called. If rcode != 0, value is a string
  46. containing an error message"""
  47. if type(msg) != dict:
  48. raise ModuleCCSessionError("Answer message is not a dict: " + str(msg))
  49. if 'result' not in msg:
  50. raise ModuleCCSessionError("answer message does not contain 'result' element")
  51. elif type(msg['result']) != list:
  52. raise ModuleCCSessionError("wrong result type in answer message")
  53. elif len(msg['result']) < 1:
  54. raise ModuleCCSessionError("empty result list in answer message")
  55. elif type(msg['result'][0]) != int:
  56. raise ModuleCCSessionError("wrong rcode type in answer message")
  57. else:
  58. if len(msg['result']) > 1:
  59. if (msg['result'][0] != 0 and type(msg['result'][1]) != str):
  60. raise ModuleCCSessionError("rcode in answer message is non-zero, value is not a string")
  61. return msg['result'][0], msg['result'][1]
  62. else:
  63. return msg['result'][0], None
  64. def create_answer(rcode, arg = None):
  65. """Creates an answer packet for config&commands. rcode must be an
  66. integer. If rcode == 0, arg is an optional value that depends
  67. on what the command or option was. If rcode != 0, arg must be
  68. a string containing an error message"""
  69. if type(rcode) != int:
  70. raise ModuleCCSessionError("rcode in create_answer() must be an integer")
  71. if rcode != 0 and type(arg) != str:
  72. raise ModuleCCSessionError("arg in create_answer for rcode != 0 must be a string describing the error")
  73. if arg != None:
  74. return { 'result': [ rcode, arg ] }
  75. else:
  76. return { 'result': [ rcode ] }
  77. # 'fixed' commands
  78. """Fixed names for command and configuration messages"""
  79. COMMAND_CONFIG_UPDATE = "config_update"
  80. COMMAND_MODULE_SPECIFICATION_UPDATE = "module_specification_update"
  81. COMMAND_GET_COMMANDS_SPEC = "get_commands_spec"
  82. COMMAND_GET_CONFIG = "get_config"
  83. COMMAND_SET_CONFIG = "set_config"
  84. COMMAND_GET_MODULE_SPEC = "get_module_spec"
  85. COMMAND_MODULE_SPEC = "module_spec"
  86. COMMAND_SHUTDOWN = "shutdown"
  87. def parse_command(msg):
  88. """Parses what may be a command message. If it looks like one,
  89. the function returns (command, value) where command is a
  90. string. If it is not, this function returns None, None"""
  91. if type(msg) == dict and len(msg.items()) == 1:
  92. cmd, value = msg.popitem()
  93. if cmd == "command" and type(value) == list:
  94. if len(value) == 1 and type(value[0]) == str:
  95. return value[0], None
  96. elif len(value) > 1 and type(value[0]) == str:
  97. return value[0], value[1]
  98. return None, None
  99. def create_command(command_name, params = None):
  100. """Creates a module command message with the given command name (as
  101. specified in the module's specification, and an optional params
  102. object"""
  103. # TODO: validate_command with spec
  104. if type(command_name) != str:
  105. raise ModuleCCSessionError("command in create_command() not a string")
  106. cmd = [ command_name ]
  107. if params:
  108. cmd.append(params)
  109. msg = { 'command': cmd }
  110. return msg
  111. def default_logconfig_handler(new_config, config_data):
  112. errors = []
  113. if config_data.get_module_spec().validate_config(False, new_config, errors):
  114. isc.log.log_config_update(json.dumps(new_config),
  115. json.dumps(config_data.get_module_spec().get_full_spec()))
  116. else:
  117. logger.error(CONFIG_LOG_CONFIG_ERRORS, errors)
  118. class ModuleCCSession(ConfigData):
  119. """This class maintains a connection to the command channel, as
  120. well as configuration options for modules. The module provides
  121. a specification file that contains the module name, configuration
  122. options, and commands. It also gives the ModuleCCSession two callback
  123. functions, one to call when there is a direct command to the
  124. module, and one to update the configuration run-time. These
  125. callbacks are called when 'check_command' is called on the
  126. ModuleCCSession"""
  127. def __init__(self, spec_file_name, config_handler, command_handler, cc_session=None, handle_logging_config=True):
  128. """Initialize a ModuleCCSession. This does *NOT* send the
  129. specification and request the configuration yet. Use start()
  130. for that once the ModuleCCSession has been initialized.
  131. specfile_name is the path to the specification file.
  132. config_handler and command_handler are callback functions,
  133. see set_config_handler and set_command_handler for more
  134. information on their signatures.
  135. cc_session can be used to pass in an existing CCSession,
  136. if it is None, one will be set up. This is mainly intended
  137. for testing purposes.
  138. handle_logging_config: if True, the module session will
  139. automatically handle logging configuration for the module;
  140. it will read the system-wide Logging configuration and call
  141. the logger manager to apply it. It will also inform the
  142. logger manager when the logging configuration gets updated.
  143. The module does not need to do anything except intializing
  144. its loggers, and provide log messages. Defaults to true.
  145. """
  146. module_spec = isc.config.module_spec_from_file(spec_file_name)
  147. ConfigData.__init__(self, module_spec)
  148. self._module_name = module_spec.get_module_name()
  149. self.set_config_handler(config_handler)
  150. self.set_command_handler(command_handler)
  151. if not cc_session:
  152. self._session = Session()
  153. else:
  154. self._session = cc_session
  155. self._session.group_subscribe(self._module_name, "*")
  156. self._remote_module_configs = {}
  157. self._remote_module_callbacks = {}
  158. if handle_logging_config:
  159. self.add_remote_config(path_search('logging.spec', bind10_config.PLUGIN_PATHS),
  160. default_logconfig_handler)
  161. def __del__(self):
  162. # If the CC Session obejct has been closed, it returns
  163. # immediately.
  164. if self._session._closed: return
  165. self._session.group_unsubscribe(self._module_name, "*")
  166. for module_name in self._remote_module_configs:
  167. self._session.group_unsubscribe(module_name)
  168. def start(self):
  169. """Send the specification for this module to the configuration
  170. manager, and request the current non-default configuration.
  171. The config_handler will be called with that configuration"""
  172. self.__send_spec()
  173. self.__request_config()
  174. def get_socket(self):
  175. """Returns the socket from the command channel session. This
  176. should *only* be used for select() loops to see if there
  177. is anything on the channel. If that loop is not completely
  178. time-critical, it is strongly recommended to only use
  179. check_command(), and not look at the socket at all."""
  180. return self._session._socket
  181. def close(self):
  182. """Close the session to the command channel"""
  183. self._session.close()
  184. def check_command(self, nonblock=True):
  185. """Check whether there is a command or configuration update on
  186. the channel. This function does a read on the cc session, and
  187. returns nothing.
  188. It calls check_command_without_recvmsg()
  189. to parse the received message.
  190. If nonblock is True, it just checks if there's a command
  191. and does nothing if there isn't. If nonblock is False, it
  192. waits until it arrives. It temporarily sets timeout to infinity,
  193. because commands may not come in arbitrary long time."""
  194. timeout_orig = self._session.get_timeout()
  195. self._session.set_timeout(0)
  196. try:
  197. msg, env = self._session.group_recvmsg(nonblock)
  198. finally:
  199. self._session.set_timeout(timeout_orig)
  200. self.check_command_without_recvmsg(msg, env)
  201. def check_command_without_recvmsg(self, msg, env):
  202. """Parse the given message to see if there is a command or a
  203. configuration update. Calls the corresponding handler
  204. functions if present. Responds on the channel if the
  205. handler returns a message."""
  206. # should we default to an answer? success-by-default? unhandled error?
  207. if msg is not None and not 'result' in msg:
  208. answer = None
  209. try:
  210. module_name = env['group']
  211. cmd, arg = isc.config.ccsession.parse_command(msg)
  212. if cmd == COMMAND_CONFIG_UPDATE:
  213. new_config = arg
  214. # If the target channel was not this module
  215. # it might be in the remote_module_configs
  216. if module_name != self._module_name:
  217. if module_name in self._remote_module_configs:
  218. # no checking for validity, that's up to the
  219. # module itself.
  220. newc = self._remote_module_configs[module_name].get_local_config()
  221. isc.cc.data.merge(newc, new_config)
  222. self._remote_module_configs[module_name].set_local_config(newc)
  223. if self._remote_module_callbacks[module_name] != None:
  224. self._remote_module_callbacks[module_name](new_config,
  225. self._remote_module_configs[module_name])
  226. # For other modules, we're not supposed to answer
  227. return
  228. # ok, so apparently this update is for us.
  229. errors = []
  230. if not self._config_handler:
  231. answer = create_answer(2, self._module_name + " has no config handler")
  232. elif not self.get_module_spec().validate_config(False, new_config, errors):
  233. answer = create_answer(1, ", ".join(errors))
  234. else:
  235. isc.cc.data.remove_identical(new_config, self.get_local_config())
  236. answer = self._config_handler(new_config)
  237. rcode, val = parse_answer(answer)
  238. if rcode == 0:
  239. newc = self.get_local_config()
  240. isc.cc.data.merge(newc, new_config)
  241. self.set_local_config(newc)
  242. else:
  243. # ignore commands for 'remote' modules
  244. if module_name == self._module_name:
  245. if self._command_handler:
  246. answer = self._command_handler(cmd, arg)
  247. else:
  248. answer = create_answer(2, self._module_name + " has no command handler")
  249. except Exception as exc:
  250. answer = create_answer(1, str(exc))
  251. if answer:
  252. self._session.group_reply(env, answer)
  253. def set_config_handler(self, config_handler):
  254. """Set the config handler for this module. The handler is a
  255. function that takes the full configuration and handles it.
  256. It should return an answer created with create_answer()"""
  257. self._config_handler = config_handler
  258. # should we run this right now since we've changed the handler?
  259. def set_command_handler(self, command_handler):
  260. """Set the command handler for this module. The handler is a
  261. function that takes a command as defined in the .spec file
  262. and return an answer created with create_answer()"""
  263. self._command_handler = command_handler
  264. def add_remote_config(self, spec_file_name, config_update_callback = None):
  265. """Gives access to the configuration of a different module.
  266. These remote module options can at this moment only be
  267. accessed through get_remote_config_value(). This function
  268. also subscribes to the channel of the remote module name
  269. to receive the relevant updates. It is not possible to
  270. specify your own handler for this right now.
  271. start() must have been called on this CCSession
  272. prior to the call to this method.
  273. Returns the name of the module."""
  274. module_spec = isc.config.module_spec_from_file(spec_file_name)
  275. module_cfg = ConfigData(module_spec)
  276. module_name = module_spec.get_module_name()
  277. self._session.group_subscribe(module_name)
  278. # Get the current config for that module now
  279. seq = self._session.group_sendmsg(create_command(COMMAND_GET_CONFIG, { "module_name": module_name }), "ConfigManager")
  280. try:
  281. answer, env = self._session.group_recvmsg(False, seq)
  282. except isc.cc.SessionTimeout:
  283. raise ModuleCCSessionError("No answer from ConfigManager when "
  284. "asking about Remote module " +
  285. module_name)
  286. if answer:
  287. rcode, value = parse_answer(answer)
  288. if rcode == 0:
  289. if value != None and module_spec.validate_config(False, value):
  290. module_cfg.set_local_config(value)
  291. if config_update_callback is not None:
  292. config_update_callback(value, module_cfg)
  293. # all done, add it
  294. self._remote_module_configs[module_name] = module_cfg
  295. self._remote_module_callbacks[module_name] = config_update_callback
  296. return module_name
  297. def remove_remote_config(self, module_name):
  298. """Removes the remote configuration access for this module"""
  299. if module_name in self._remote_module_configs:
  300. self._session.group_unsubscribe(module_name)
  301. del self._remote_module_configs[module_name]
  302. del self._remote_module_callbacks[module_name]
  303. def get_remote_config_value(self, module_name, identifier):
  304. """Returns the current setting for the given identifier at the
  305. given module. If the module has not been added with
  306. add_remote_config, a ModuleCCSessionError is raised"""
  307. if module_name in self._remote_module_configs:
  308. return self._remote_module_configs[module_name].get_value(identifier)
  309. else:
  310. raise ModuleCCSessionError("Remote module " + module_name +
  311. " not found")
  312. def __send_spec(self):
  313. """Sends the data specification to the configuration manager"""
  314. msg = create_command(COMMAND_MODULE_SPEC, self.get_module_spec().get_full_spec())
  315. seq = self._session.group_sendmsg(msg, "ConfigManager")
  316. try:
  317. answer, env = self._session.group_recvmsg(False, seq)
  318. except isc.cc.SessionTimeout:
  319. # TODO: log an error?
  320. pass
  321. def __request_config(self):
  322. """Asks the configuration manager for the current configuration, and call the config handler if set.
  323. Raises a ModuleCCSessionError if there is no answer from the configuration manager"""
  324. seq = self._session.group_sendmsg(create_command(COMMAND_GET_CONFIG, { "module_name": self._module_name }), "ConfigManager")
  325. try:
  326. answer, env = self._session.group_recvmsg(False, seq)
  327. if answer:
  328. rcode, value = parse_answer(answer)
  329. if rcode == 0:
  330. errors = []
  331. if value != None:
  332. if self.get_module_spec().validate_config(False,
  333. value,
  334. errors):
  335. self.set_local_config(value)
  336. if self._config_handler:
  337. self._config_handler(value)
  338. else:
  339. raise ModuleCCSessionError(
  340. "Wrong data in configuration: " +
  341. " ".join(errors))
  342. else:
  343. logger.error(CONFIG_GET_FAILED, value)
  344. else:
  345. raise ModuleCCSessionError("No answer from configuration manager")
  346. except isc.cc.SessionTimeout:
  347. raise ModuleCCSessionError("CC Session timeout waiting for configuration manager")
  348. class UIModuleCCSession(MultiConfigData):
  349. """This class is used in a configuration user interface. It contains
  350. specific functions for getting, displaying, and sending
  351. configuration settings through the b10-cmdctl module."""
  352. def __init__(self, conn):
  353. """Initialize a UIModuleCCSession. The conn object that is
  354. passed must have send_GET and send_POST functions"""
  355. MultiConfigData.__init__(self)
  356. self._conn = conn
  357. self.request_specifications()
  358. self.request_current_config()
  359. def request_specifications(self):
  360. """Request the module specifications from b10-cmdctl"""
  361. # this step should be unnecessary but is the current way cmdctl returns stuff
  362. # so changes are needed there to make this clean (we need a command to simply get the
  363. # full specs for everything, including commands etc, not separate gets for that)
  364. specs = self._conn.send_GET('/module_spec')
  365. for module in specs.keys():
  366. self.set_specification(isc.config.ModuleSpec(specs[module]))
  367. def update_specs_and_config(self):
  368. self.request_specifications()
  369. self.request_current_config()
  370. def request_current_config(self):
  371. """Requests the current configuration from the configuration
  372. manager through b10-cmdctl, and stores those as CURRENT"""
  373. config = self._conn.send_GET('/config_data')
  374. if 'version' not in config or config['version'] != BIND10_CONFIG_DATA_VERSION:
  375. raise ModuleCCSessionError("Bad config version")
  376. self._set_current_config(config)
  377. def _add_value_to_list(self, identifier, value, module_spec):
  378. cur_list, status = self.get_value(identifier)
  379. if not cur_list:
  380. cur_list = []
  381. if value is None:
  382. if "item_default" in module_spec["list_item_spec"]:
  383. value = module_spec["list_item_spec"]["item_default"]
  384. if value is None:
  385. raise isc.cc.data.DataNotFoundError(
  386. "No value given and no default for " + str(identifier))
  387. if value not in cur_list:
  388. cur_list.append(value)
  389. self.set_value(identifier, cur_list)
  390. else:
  391. raise isc.cc.data.DataAlreadyPresentError(value +
  392. " already in "
  393. + identifier)
  394. def _add_value_to_named_set(self, identifier, value, item_value):
  395. if type(value) != str:
  396. raise isc.cc.data.DataTypeError("Name for named_set " +
  397. identifier +
  398. " must be a string")
  399. # fail on both None and empty string
  400. if not value:
  401. raise isc.cc.data.DataNotFoundError(
  402. "Need a name to add a new item to named_set " +
  403. str(identifier))
  404. else:
  405. cur_map, status = self.get_value(identifier)
  406. if not cur_map:
  407. cur_map = {}
  408. if value not in cur_map:
  409. cur_map[value] = item_value
  410. self.set_value(identifier, cur_map)
  411. else:
  412. raise isc.cc.data.DataAlreadyPresentError(value +
  413. " already in "
  414. + identifier)
  415. def add_value(self, identifier, value_str = None, set_value_str = None):
  416. """Add a value to a configuration list. Raises a DataTypeError
  417. if the value does not conform to the list_item_spec field
  418. of the module config data specification. If value_str is
  419. not given, we add the default as specified by the .spec
  420. file. Raises a DataNotFoundError if the given identifier
  421. is not specified in the specification as a map or list.
  422. Raises a DataAlreadyPresentError if the specified element
  423. already exists."""
  424. module_spec = self.find_spec_part(identifier)
  425. if module_spec is None:
  426. raise isc.cc.data.DataNotFoundError("Unknown item " + str(identifier))
  427. # the specified element must be a list or a named_set
  428. if 'list_item_spec' in module_spec:
  429. value = None
  430. # in lists, we might get the value with spaces, making it
  431. # the third argument. In that case we interpret both as
  432. # one big string meant as the value
  433. if value_str is not None:
  434. if set_value_str is not None:
  435. value_str += set_value_str
  436. value = isc.cc.data.parse_value_str(value_str)
  437. self._add_value_to_list(identifier, value, module_spec)
  438. elif 'named_set_item_spec' in module_spec:
  439. item_name = None
  440. item_value = None
  441. if value_str is not None:
  442. item_name = isc.cc.data.parse_value_str(value_str)
  443. if set_value_str is not None:
  444. item_value = isc.cc.data.parse_value_str(set_value_str)
  445. else:
  446. if 'item_default' in module_spec['named_set_item_spec']:
  447. item_value = module_spec['named_set_item_spec']['item_default']
  448. self._add_value_to_named_set(identifier, item_name,
  449. item_value)
  450. else:
  451. raise isc.cc.data.DataNotFoundError(str(identifier) + " is not a list or a named set")
  452. def _remove_value_from_list(self, identifier, value):
  453. if value is None:
  454. # we are directly removing an list index
  455. id, list_indices = isc.cc.data.split_identifier_list_indices(identifier)
  456. if list_indices is None:
  457. raise DataTypeError("identifier in remove_value() does not contain a list index, and no value to remove")
  458. else:
  459. self.set_value(identifier, None)
  460. else:
  461. cur_list, status = self.get_value(identifier)
  462. if not cur_list:
  463. cur_list = []
  464. elif value in cur_list:
  465. cur_list.remove(value)
  466. self.set_value(identifier, cur_list)
  467. def _remove_value_from_named_set(self, identifier, value):
  468. if value is None:
  469. raise isc.cc.data.DataNotFoundError("Need a name to remove an item from named_set " + str(identifier))
  470. elif type(value) != str:
  471. raise isc.cc.data.DataTypeError("Name for named_set " + identifier + " must be a string")
  472. else:
  473. cur_map, status = self.get_value(identifier)
  474. if not cur_map:
  475. cur_map = {}
  476. if value in cur_map:
  477. del cur_map[value]
  478. else:
  479. raise isc.cc.data.DataNotFoundError(value + " not found in named_set " + str(identifier))
  480. def remove_value(self, identifier, value_str):
  481. """Remove a value from a configuration list or named set.
  482. The value string must be a string representation of the full
  483. item. Raises a DataTypeError if the value at the identifier
  484. is not a list, or if the given value_str does not match the
  485. list_item_spec """
  486. module_spec = self.find_spec_part(identifier)
  487. if module_spec is None:
  488. raise isc.cc.data.DataNotFoundError("Unknown item " + str(identifier))
  489. value = None
  490. if value_str is not None:
  491. value = isc.cc.data.parse_value_str(value_str)
  492. if 'list_item_spec' in module_spec:
  493. if value is not None:
  494. isc.config.config_data.check_type(module_spec['list_item_spec'], value)
  495. self._remove_value_from_list(identifier, value)
  496. elif 'named_set_item_spec' in module_spec:
  497. self._remove_value_from_named_set(identifier, value)
  498. else:
  499. raise isc.cc.data.DataNotFoundError(str(identifier) + " is not a list or a named_set")
  500. def commit(self):
  501. """Commit all local changes, send them through b10-cmdctl to
  502. the configuration manager"""
  503. if self.get_local_changes():
  504. response = self._conn.send_POST('/ConfigManager/set_config',
  505. [ self.get_local_changes() ])
  506. answer = isc.cc.data.parse_value_str(response.read().decode())
  507. # answer is either an empty dict (on success), or one
  508. # containing errors
  509. if answer == {}:
  510. self.request_current_config()
  511. self.clear_local_changes()
  512. elif "error" in answer:
  513. raise ModuleCCSessionError("Error: " + str(answer["error"]) + "\n" + "Configuration not committed")
  514. else:
  515. raise ModuleCCSessionError("Unknown format of answer in commit(): " + str(answer))