config_data.py 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606
  1. # Copyright (C) 2010 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. Classes to store configuration data and module specifications
  17. Used by the config manager, (python) modules, and UI's (those last
  18. two through the classes in ccsession)
  19. """
  20. import isc.cc.data
  21. import isc.config.module_spec
  22. import ast
  23. class ConfigDataError(Exception): pass
  24. BIND10_CONFIG_DATA_VERSION = 2
  25. def check_type(spec_part, value):
  26. """Does nothing if the value is of the correct type given the
  27. specification part relevant for the value. Raises an
  28. isc.cc.data.DataTypeError exception if not. spec_part can be
  29. retrieved with find_spec_part()"""
  30. if type(spec_part) == dict and 'item_type' in spec_part:
  31. data_type = spec_part['item_type']
  32. else:
  33. raise isc.cc.data.DataTypeError(str("Incorrect specification part for type checking"))
  34. if data_type == "integer" and type(value) != int:
  35. raise isc.cc.data.DataTypeError(str(value) + " is not an integer")
  36. elif data_type == "real" and type(value) != float:
  37. raise isc.cc.data.DataTypeError(str(value) + " is not a real")
  38. elif data_type == "boolean" and type(value) != bool:
  39. raise isc.cc.data.DataTypeError(str(value) + " is not a boolean")
  40. elif data_type == "string" and type(value) != str:
  41. raise isc.cc.data.DataTypeError(str(value) + " is not a string")
  42. elif data_type == "list":
  43. if type(value) != list:
  44. raise isc.cc.data.DataTypeError(str(value) + " is not a list")
  45. else:
  46. for element in value:
  47. check_type(spec_part['list_item_spec'], element)
  48. elif data_type == "map" and type(value) != dict:
  49. # todo: check types of map contents too
  50. raise isc.cc.data.DataTypeError(str(value) + " is not a map")
  51. def convert_type(spec_part, value):
  52. """Convert the given value(type is string) according specification
  53. part relevant for the value. Raises an isc.cc.data.DataTypeError
  54. exception if conversion failed.
  55. """
  56. if type(spec_part) == dict and 'item_type' in spec_part:
  57. data_type = spec_part['item_type']
  58. else:
  59. raise isc.cc.data.DataTypeError(str("Incorrect specification part for type conversion"))
  60. try:
  61. if data_type == "integer":
  62. return int(value)
  63. elif data_type == "real":
  64. return float(value)
  65. elif data_type == "boolean":
  66. return str.lower(str(value)) != 'false'
  67. elif data_type == "string":
  68. return str(value)
  69. elif data_type == "list":
  70. ret = []
  71. if type(value) == list:
  72. for item in value:
  73. ret.append(convert_type(spec_part['list_item_spec'], item))
  74. elif type(value) == str:
  75. value = value.split(',')
  76. for item in value:
  77. sub_value = item.split()
  78. for sub_item in sub_value:
  79. ret.append(convert_type(spec_part['list_item_spec'],
  80. sub_item))
  81. if ret == []:
  82. raise isc.cc.data.DataTypeError(str(value) + " is not a list")
  83. return ret
  84. elif data_type == "map":
  85. map = ast.literal_eval(value)
  86. if type(map) == dict:
  87. # todo: check types of map contents too
  88. return map
  89. else:
  90. raise isc.cc.data.DataTypeError(
  91. "Value in convert_type not a string "
  92. "specifying a dict")
  93. else:
  94. return value
  95. except ValueError as err:
  96. raise isc.cc.data.DataTypeError(str(err))
  97. except TypeError as err:
  98. raise isc.cc.data.DataTypeError(str(err))
  99. def _get_map_or_list(spec_part):
  100. """Returns the list or map specification if this is a list or a
  101. map specification part. If not, returns the given spec_part
  102. itself"""
  103. if "map_item_spec" in spec_part:
  104. return spec_part["map_item_spec"]
  105. elif "list_item_spec" in spec_part:
  106. return spec_part["list_item_spec"]
  107. else:
  108. return spec_part
  109. def _find_spec_part_single(cur_spec, id_part):
  110. """Find the spec part for the given (partial) name. This partial
  111. name does not contain separators ('/'), and the specification
  112. part should be a direct child of the given specification part.
  113. id_part may contain list selectors, which will be ignored.
  114. Returns the child part.
  115. Raises DataNotFoundError if it was not found."""
  116. # strip list selector part
  117. # don't need it for the spec part, so just drop it
  118. id, list_indices = isc.cc.data.split_identifier_list_indices(id_part)
  119. # The specification we want a sub-part for should be either a
  120. # list or a map, which is internally represented by a dict with
  121. # an element 'map_item_spec', a dict with an element 'list_item_spec',
  122. # or a list.
  123. if type(cur_spec) == dict and 'map_item_spec' in cur_spec.keys():
  124. for cur_spec_item in cur_spec['map_item_spec']:
  125. if cur_spec_item['item_name'] == id:
  126. return cur_spec_item
  127. # not found
  128. raise isc.cc.data.DataNotFoundError(id + " not found")
  129. elif type(cur_spec) == dict and 'list_item_spec' in cur_spec.keys():
  130. return cur_spec['list_item_spec']
  131. elif type(cur_spec) == list:
  132. for cur_spec_item in cur_spec:
  133. if cur_spec_item['item_name'] == id:
  134. return cur_spec_item
  135. # not found
  136. raise isc.cc.data.DataNotFoundError(id + " not found")
  137. else:
  138. raise isc.cc.data.DataNotFoundError("Not a correct config specification")
  139. def find_spec_part(element, identifier):
  140. """find the data definition for the given identifier
  141. returns either a map with 'item_name' etc, or a list of those"""
  142. if identifier == "":
  143. return element
  144. id_parts = identifier.split("/")
  145. id_parts[:] = (value for value in id_parts if value != "")
  146. cur_el = element
  147. # up to the last element, if the result is a map or a list,
  148. # we want its subspecification (i.e. list_item_spec or
  149. # map_item_spec). For the last element in the identifier we
  150. # always want the 'full' spec of the item
  151. for id_part in id_parts[:-1]:
  152. cur_el = _find_spec_part_single(cur_el, id_part)
  153. cur_el = _get_map_or_list(cur_el)
  154. cur_el = _find_spec_part_single(cur_el, id_parts[-1])
  155. return cur_el
  156. def spec_name_list(spec, prefix="", recurse=False):
  157. """Returns a full list of all possible item identifiers in the
  158. specification (part). Raises a ConfigDataError if spec is not
  159. a correct spec (as returned by ModuleSpec.get_config_spec()"""
  160. result = []
  161. if prefix != "" and not prefix.endswith("/"):
  162. prefix += "/"
  163. if type(spec) == dict:
  164. if 'map_item_spec' in spec:
  165. for map_el in spec['map_item_spec']:
  166. name = map_el['item_name']
  167. if map_el['item_type'] == 'map':
  168. name += "/"
  169. if recurse and 'map_item_spec' in map_el:
  170. result.extend(spec_name_list(map_el['map_item_spec'], prefix + map_el['item_name'], recurse))
  171. else:
  172. result.append(prefix + name)
  173. else:
  174. for name in spec:
  175. result.append(prefix + name + "/")
  176. if recurse:
  177. result.extend(spec_name_list(spec[name],name, recurse))
  178. elif type(spec) == list:
  179. for list_el in spec:
  180. if 'item_name' in list_el:
  181. if list_el['item_type'] == "map" and recurse:
  182. result.extend(spec_name_list(list_el['map_item_spec'], prefix + list_el['item_name'], recurse))
  183. else:
  184. name = list_el['item_name']
  185. result.append(prefix + name)
  186. else:
  187. raise ConfigDataError("Bad specification")
  188. else:
  189. raise ConfigDataError("Bad specication")
  190. return result
  191. class ConfigData:
  192. """This class stores the module specs and the current non-default
  193. config values. It provides functions to get the actual value or
  194. the default value if no non-default value has been set"""
  195. def __init__(self, specification):
  196. """Initialize a ConfigData instance. If specification is not
  197. of type ModuleSpec, a ConfigDataError is raised."""
  198. if type(specification) != isc.config.ModuleSpec:
  199. raise ConfigDataError("specification is of type " + str(type(specification)) + ", not ModuleSpec")
  200. self.specification = specification
  201. self.data = {}
  202. def get_value(self, identifier):
  203. """Returns a tuple where the first item is the value at the
  204. given identifier, and the second item is a bool which is
  205. true if the value is an unset default. Raises an
  206. isc.cc.data.DataNotFoundError if the identifier is bad"""
  207. value = isc.cc.data.find_no_exc(self.data, identifier)
  208. if value != None:
  209. return value, False
  210. spec = find_spec_part(self.specification.get_config_spec(), identifier)
  211. if spec and 'item_default' in spec:
  212. return spec['item_default'], True
  213. return None, False
  214. def get_default_value(self, identifier):
  215. """Returns the default from the specification, or None if there
  216. is no default"""
  217. spec = find_spec_part(self.specification.get_config_spec(), identifier)
  218. if spec and 'item_default' in spec:
  219. return spec['item_default']
  220. else:
  221. return None
  222. def get_module_spec(self):
  223. """Returns the ModuleSpec object associated with this ConfigData"""
  224. return self.specification
  225. def set_local_config(self, data):
  226. """Set the non-default config values, as passed by cfgmgr"""
  227. self.data = data
  228. def get_local_config(self):
  229. """Returns the non-default config values in a dict"""
  230. return self.data;
  231. def get_item_list(self, identifier = None, recurse = False):
  232. """Returns a list of strings containing the full identifiers of
  233. all 'sub'options at the given identifier. If recurse is True,
  234. it will also add all identifiers of all children, if any"""
  235. if identifier:
  236. spec = find_spec_part(self.specification.get_config_spec(), identifier)
  237. return spec_name_list(spec, identifier + "/")
  238. return spec_name_list(self.specification.get_config_spec(), "", recurse)
  239. def get_full_config(self):
  240. """Returns a dict containing identifier: value elements, for
  241. all configuration options for this module. If there is
  242. a local setting, that will be used. Otherwise the value
  243. will be the default as specified by the module specification.
  244. If there is no default and no local setting, the value will
  245. be None"""
  246. items = self.get_item_list(None, True)
  247. result = {}
  248. for item in items:
  249. value, default = self.get_value(item)
  250. result[item] = value
  251. return result
  252. # should we just make a class for these?
  253. def _create_value_map_entry(name, type, value, status = None):
  254. entry = {}
  255. entry['name'] = name
  256. entry['type'] = type
  257. entry['value'] = value
  258. entry['modified'] = False
  259. entry['default'] = False
  260. if status == MultiConfigData.LOCAL:
  261. entry['modified'] = True
  262. if status == MultiConfigData.DEFAULT:
  263. entry['default'] = True
  264. return entry
  265. class MultiConfigData:
  266. """This class stores the module specs, current non-default
  267. configuration values and 'local' (uncommitted) changes for
  268. multiple modules"""
  269. LOCAL = 1
  270. CURRENT = 2
  271. DEFAULT = 3
  272. NONE = 4
  273. def __init__(self):
  274. self._specifications = {}
  275. self._current_config = {}
  276. self._local_changes = {}
  277. def set_specification(self, spec):
  278. """Add or update a ModuleSpec. Raises a ConfigDataError is spec is not a ModuleSpec"""
  279. if type(spec) != isc.config.ModuleSpec:
  280. raise ConfigDataError("not a datadef: " + str(type(spec)))
  281. self._specifications[spec.get_module_name()] = spec
  282. def remove_specification(self, module_name):
  283. """Removes the specification with the given module name. Does nothing if it wasn't there."""
  284. if module_name in self._specifications:
  285. del self._specifications[module_name]
  286. def have_specification(self, module_name):
  287. """Returns True if we have a specification for the module with the given name.
  288. Returns False if we do not."""
  289. return module_name in self._specifications
  290. def get_module_spec(self, module):
  291. """Returns the ModuleSpec for the module with the given name.
  292. If there is no such module, it returns None"""
  293. if module in self._specifications:
  294. return self._specifications[module]
  295. else:
  296. return None
  297. def find_spec_part(self, identifier):
  298. """Returns the specification for the item at the given
  299. identifier, or None if not found. The first part of the
  300. identifier (up to the first /) is interpreted as the module
  301. name. Returns None if not found, or if identifier is not a
  302. string."""
  303. if type(identifier) != str or identifier == "":
  304. return None
  305. if identifier[0] == '/':
  306. identifier = identifier[1:]
  307. module, sep, id = identifier.partition("/")
  308. try:
  309. return find_spec_part(self._specifications[module].get_config_spec(), id)
  310. except isc.cc.data.DataNotFoundError as dnfe:
  311. return None
  312. except KeyError as ke:
  313. return None
  314. # this function should only be called by __request_config
  315. def _set_current_config(self, config):
  316. """Replace the full current config values."""
  317. self._current_config = config
  318. def get_current_config(self):
  319. """Returns the current configuration as it is known by the
  320. configuration manager. It is a dict where the first level is
  321. the module name, and the value is the config values for
  322. that module"""
  323. return self._current_config
  324. def get_local_changes(self):
  325. """Returns the local config changes, i.e. those that have not
  326. been committed yet and are not known by the configuration
  327. manager or the modules."""
  328. return self._local_changes
  329. def clear_local_changes(self):
  330. """Reverts all local changes"""
  331. self._local_changes = {}
  332. def get_local_value(self, identifier):
  333. """Returns a specific local (uncommitted) configuration value,
  334. as specified by the identifier. If the local changes do not
  335. contain a new setting for this identifier, or if the
  336. identifier cannot be found, None is returned. See
  337. get_value() for a general way to find a configuration value
  338. """
  339. return isc.cc.data.find_no_exc(self._local_changes, identifier)
  340. def get_current_value(self, identifier):
  341. """Returns the current non-default value as known by the
  342. configuration manager, or None if it is not set.
  343. See get_value() for a general way to find a configuration
  344. value
  345. """
  346. return isc.cc.data.find_no_exc(self._current_config, identifier)
  347. def get_default_value(self, identifier):
  348. """Returns the default value for the given identifier as
  349. specified by the module specification, or None if there is
  350. no default or the identifier could not be found.
  351. See get_value() for a general way to find a configuration
  352. value
  353. """
  354. try:
  355. if identifier[0] == '/':
  356. identifier = identifier[1:]
  357. module, sep, id = identifier.partition("/")
  358. # if there is a 'higher-level' list index specified, we need
  359. # to check if that list specification has a default that
  360. # overrides the more specific default in the final spec item
  361. # (ie. list_default = [1, 2, 3], list_item_spec=int, default=0)
  362. # def default list[1] should return 2, not 0
  363. id_parts = isc.cc.data.split_identifier(id)
  364. id_prefix = ""
  365. while len(id_parts) > 0:
  366. id_part = id_parts.pop(0)
  367. item_id, list_indices = isc.cc.data.split_identifier_list_indices(id_part)
  368. id_list = module + "/" + id_prefix + "/" + item_id
  369. id_prefix += "/" + id_part
  370. if list_indices is not None:
  371. # there's actually two kinds of default here for
  372. # lists; they can have a default value (like an
  373. # empty list), but their elements can also have
  374. # default values.
  375. # So if the list item *itself* is a default,
  376. # we need to get the value out of that. If not, we
  377. # need to find the default for the specific element.
  378. list_value, type = self.get_value(id_list)
  379. list_spec = find_spec_part(self._specifications[module].get_config_spec(), id_prefix)
  380. if type == self.DEFAULT:
  381. if 'item_default' in list_spec:
  382. list_value = list_spec['item_default']
  383. for i in list_indices:
  384. if i < len(list_value):
  385. list_value = list_value[i]
  386. else:
  387. # out of range, return None
  388. return None
  389. if len(id_parts) > 0:
  390. rest_of_id = "/".join(id_parts)
  391. return isc.cc.data.find(list_value, rest_of_id)
  392. else:
  393. return list_value
  394. else:
  395. # we do have a non-default list, see if our indices
  396. # exist
  397. for i in list_indices:
  398. if i < len(list_value):
  399. list_value = list_value[i]
  400. else:
  401. # out of range, return None
  402. return None
  403. spec = find_spec_part(self._specifications[module].get_config_spec(), id)
  404. if 'item_default' in spec:
  405. return spec['item_default']
  406. else:
  407. return None
  408. except isc.cc.data.DataNotFoundError as dnfe:
  409. return None
  410. def get_value(self, identifier, default = True):
  411. """Returns a tuple containing value,status.
  412. The value contains the configuration value for the given
  413. identifier. The status reports where this value came from;
  414. it is one of: LOCAL, CURRENT, DEFAULT or NONE, corresponding
  415. (local change, current setting, default as specified by the
  416. specification, or not found at all). Does not check and
  417. set DEFAULT if the argument 'default' is False (default
  418. defaults to True)"""
  419. value = self.get_local_value(identifier)
  420. if value != None:
  421. return value, self.LOCAL
  422. value = self.get_current_value(identifier)
  423. if value != None:
  424. return value, self.CURRENT
  425. if default:
  426. value = self.get_default_value(identifier)
  427. if value != None:
  428. return value, self.DEFAULT
  429. return None, self.NONE
  430. def _append_value_item(self, result, spec_part, identifier, all, first = False):
  431. # Look at the spec; it is a list of items, or a map containing 'item_name' etc
  432. if type(spec_part) == list:
  433. for spec_part_element in spec_part:
  434. spec_part_element_name = spec_part_element['item_name']
  435. self._append_value_item(result, spec_part_element, identifier + "/" + spec_part_element_name, all)
  436. elif type(spec_part) == dict:
  437. # depending on item type, and the value of argument 'all'
  438. # we need to either add an item, or recursively go on
  439. # In the case of a list that is empty, we do need to show that
  440. item_name = spec_part['item_name']
  441. item_type = spec_part['item_type']
  442. if item_type == "list" and (all or first):
  443. spec_part_list = spec_part['list_item_spec']
  444. list_value, status = self.get_value(identifier)
  445. if list_value is None:
  446. raise isc.cc.data.DataNotFoundError(identifier)
  447. if type(list_value) != list:
  448. # the identifier specified a single element
  449. self._append_value_item(result, spec_part_list, identifier, all)
  450. else:
  451. list_len = len(list_value)
  452. if len(list_value) == 0 and (all or first):
  453. entry = _create_value_map_entry(identifier,
  454. item_type,
  455. [], status)
  456. result.append(entry)
  457. else:
  458. for i in range(len(list_value)):
  459. self._append_value_item(result, spec_part_list, "%s[%d]" % (identifier, i), all)
  460. elif item_type == "map":
  461. # just show the specific contents of a map, we are
  462. # almost never interested in just its name
  463. spec_part_map = spec_part['map_item_spec']
  464. self._append_value_item(result, spec_part_map, identifier, all)
  465. else:
  466. value, status = self.get_value(identifier)
  467. entry = _create_value_map_entry(identifier,
  468. item_type,
  469. value, status)
  470. result.append(entry)
  471. return
  472. def get_value_maps(self, identifier = None, all = False):
  473. """Returns a list of dicts, containing the following values:
  474. name: name of the entry (string)
  475. type: string containing the type of the value (or 'module')
  476. value: value of the entry if it is a string, int, double or bool
  477. modified: true if the value is a local change that has not
  478. been committed
  479. default: true if the value has not been changed (i.e. the
  480. value is the default from the specification)
  481. TODO: use the consts for those last ones
  482. Throws DataNotFoundError if the identifier is bad
  483. """
  484. result = []
  485. if not identifier:
  486. # No identifier, so we need the list of current modules
  487. for module in self._specifications.keys():
  488. if all:
  489. spec = self.get_module_spec(module)
  490. if spec:
  491. spec_part = spec.get_config_spec()
  492. self._append_value_item(result, spec_part, module, all, True)
  493. else:
  494. entry = _create_value_map_entry(module, 'module', None)
  495. result.append(entry)
  496. else:
  497. if identifier[0] == '/':
  498. identifier = identifier[1:]
  499. module, sep, id = identifier.partition('/')
  500. spec = self.get_module_spec(module)
  501. if spec:
  502. spec_part = find_spec_part(spec.get_config_spec(), id)
  503. self._append_value_item(result, spec_part, identifier, all, True)
  504. return result
  505. def set_value(self, identifier, value):
  506. """Set the local value at the given identifier to value. If
  507. there is a specification for the given identifier, the type
  508. is checked."""
  509. spec_part = self.find_spec_part(identifier)
  510. if spec_part is not None:
  511. if value is not None:
  512. id, list_indices = isc.cc.data.split_identifier_list_indices(identifier)
  513. if list_indices is not None \
  514. and spec_part['item_type'] == 'list':
  515. spec_part = spec_part['list_item_spec']
  516. check_type(spec_part, value)
  517. else:
  518. raise isc.cc.data.DataNotFoundError(identifier)
  519. # Since we do not support list diffs (yet?), we need to
  520. # copy the currently set list of items to _local_changes
  521. # if we want to modify an element in there
  522. # (for any list indices specified in the full identifier)
  523. id_parts = isc.cc.data.split_identifier(identifier)
  524. cur_id_part = '/'
  525. for id_part in id_parts:
  526. id, list_indices = isc.cc.data.split_identifier_list_indices(id_part)
  527. if list_indices is not None:
  528. cur_list, status = self.get_value(cur_id_part + id)
  529. if status != MultiConfigData.LOCAL:
  530. isc.cc.data.set(self._local_changes,
  531. cur_id_part + id,
  532. cur_list)
  533. cur_id_part = cur_id_part + id_part + "/"
  534. isc.cc.data.set(self._local_changes, identifier, value)
  535. def get_config_item_list(self, identifier = None, recurse = False):
  536. """Returns a list of strings containing the item_names of
  537. the child items at the given identifier. If no identifier is
  538. specified, returns a list of module names. The first part of
  539. the identifier (up to the first /) is interpreted as the
  540. module name"""
  541. if identifier and identifier != "/":
  542. if identifier.startswith("/"):
  543. identifier = identifier[1:]
  544. spec = self.find_spec_part(identifier)
  545. return spec_name_list(spec, identifier + "/", recurse)
  546. else:
  547. if recurse:
  548. id_list = []
  549. for module in self._specifications.keys():
  550. id_list.extend(spec_name_list(self.find_spec_part(module), module, recurse))
  551. return id_list
  552. else:
  553. return list(self._specifications.keys())