Project

General

Profile

Actions

Task #1120

closed

Configuration file parser

Added by Alex Afanasyev almost 11 years ago. Updated almost 11 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
Management
Target version:
Start date:
01/21/2014
Due date:
% Done:

90%

Estimated time:
3.00 h

Description

Develop a configuration file parser.

Section handlers are registered onto the parser.

An existing INFO parser is used to parse the configuration file, and each section is dispatched to the appropriate section handler.

If an unknown section name is found, configuration processing should fail. (similarly, section handlers should fail if an unknown option is found)

Parser API should support std::istream argument type, to facilitate unit testing and usage in ns-3 simulation.


Files

yaml_support.png (12.5 KB) yaml_support.png Anonymous, 02/07/2014 02:21 PM
config_example.xml (2.36 KB) config_example.xml Anonymous, 02/08/2014 05:17 PM
config_example.info (1.86 KB) config_example.info Anonymous, 02/09/2014 08:21 AM

Related issues 1 (0 open1 closed)

Blocks NFD - Task #1227: Command authentication and authorizationClosed

Actions
Actions #1

Updated by Alex Afanasyev almost 11 years ago

  • Target version set to v0.1
Actions #2

Updated by Junxiao Shi almost 11 years ago

  • Subject changed from Implement ConfigFile parser to Configuration file parser
  • Description updated (diff)
  • Category set to Management
  • Estimated time set to 3.00 h
Actions #3

Updated by Anonymous almost 11 years ago

  • Assignee set to Anonymous
Actions #4

Updated by Alex Afanasyev almost 11 years ago

Steve, don't take the config file literally, it is just an example of yml and what kind of information should be in it.

We should have several section, one for each manager module and probably a global section.

Actions #5

Updated by Anonymous almost 11 years ago

  • Status changed from New to In Progress
Actions #6

Updated by Anonymous almost 11 years ago

We basically have two parser options according to the "official yaml site":

Here's the packaging situation:

OS Version libYAML yaml-cpp
OS X 10.9 Yes Yes
Ubuntu 12.04 Yes PPA only
Ubuntu >= 13.04 Yes Yes
CentOS 6.5 Yes Yes
FreeBSD 10 Yes Yes
Actions #7

Updated by Junxiao Shi almost 11 years ago

@Steve can choose an appropriate YAML parser.

NDN Platform Development Guidelines specifies what platforms you must support.

Actions #8

Updated by Anonymous almost 11 years ago

For the sake of clarifying the (failed) table, I've attached an image of our results Alex and I have collected so far.

I do not have access to OS X 10.7/8, so I'm only guessing that both libraries are available through homebrew or ports.

For Ubuntu, what is the official policy for packages available in the official repositories vs. 3rd party PPAs? What is our project's support duration?

Actions #9

Updated by Junxiao Shi almost 11 years ago

  • Description updated (diff)
Actions #10

Updated by Anonymous almost 11 years ago

  • File config_example.xml added

"Duplicate section names and duplicate property names are allowed."

The boost property_tree INI parser disagrees and throws an exception upon hitting the 2nd channel section. I don't think I can get around this (i.e. catch the exception and move on) because the parsing is handled entirely within the property tree's read_ini method. This does not seem to be a boost specific issue because I've found other references that say INI should not contain duplicate sections.

I see our options as:

  1. Write a custom INI parser that allows duplicates. 2 & 3: Use XML or JSON.

1 is undesirable because it sounds like we are unsure INI is sufficient for what we want in the first place. 2 & 3 are easily parseable in boost via the same mechanism, but it's clear that our file is on human readability and ease of editing by hand.

I received external advice that XML is the better choice because it allows comments and this seems to have (rightfully) become an implicit requirement for the configuration. JSON does not allow comments: http://stackoverflow.com/questions/244777/can-i-comment-a-json-file.

I quickly made an XML file (closely) based off the provided INI file. Please feel free to bash/change it. I just wanted to have something to unblock writing and testing the parser.

Actions #11

Updated by Anonymous almost 11 years ago

  • Status changed from In Progress to Code review
Actions #12

Updated by Anonymous almost 11 years ago

  • File deleted (config_example.xml)
Actions #13

Updated by Anonymous almost 11 years ago

  • File config_example.xml added

Updated example XML file. Comments appreciated.

Actions #14

Updated by Anonymous almost 11 years ago

  • File deleted (config_example.xml)
Actions #15

Updated by Anonymous almost 11 years ago

Updated XML example with CDATA for PEM encoded public key.

Actions #16

Updated by Anonymous almost 11 years ago

Another alternative is to use the INFO format: http://www.boost.org/doc/libs/1_55_0/doc/html/boost_propertytree/parsers.html .

INFO is designed for usage with the specific boost parser we are currently using. It's a bit more readable than XML, but it probably doesn't work with any other existing parser (if that matters). It is trivial to switch the current parser from XML to INFO.

Please see the attached example for an overview of what the config file could look like. The example is based off of the XML structure with some minor changes.

Thoughts?

Actions #17

Updated by Junxiao Shi almost 11 years ago

INFO format looks nice. It's easy to read, and supports #include for larger configuration files.

Actions #18

Updated by Junxiao Shi almost 11 years ago

  • Description updated (diff)
  • Status changed from Code review to In Progress

20140209 conference call approves to use INFO format for configuration file.

Actions #19

Updated by Anonymous almost 11 years ago

  • Status changed from In Progress to Code review
Actions #20

Updated by Junxiao Shi almost 11 years ago

  • Description updated (diff)

20140210 conference call decides that configuration parser should fail for unknown section name / option name, because it allows the operator to be notified of a potential configuration error faster.

Actions #21

Updated by Anonymous almost 11 years ago

  • Status changed from Code review to Closed
Actions #22

Updated by Anonymous almost 11 years ago

I've made two tweaks the the configuration file's authorizations section format:

  • Removed "," after fib privilege. The INFO parser treats each item as a value so it was reading the privileges section as having: "fib," and "stats".
  • Changed "face" privilege to "faces" to be consistent with face management namespace.
Actions

Also available in: Atom PDF