pierky / arouteserver

A tool to automatically build (and test) feature-rich configurations for BGP route servers.
https://arouteserver.readthedocs.org/
GNU General Public License v3.0
284 stars 46 forks source link

YAML files inclusion failure #64

Closed dorkmatt closed 3 years ago

dorkmatt commented 3 years ago

Using v1.3.0 under OpenBSD 6.8 I'm unable to utilize the YAML !include functionality. I'm guessing this is my own error but haven't been able to debug why

rs-sfo02$ pip3.8 freeze | grep arouteserver
arouteserver==1.3.0

rs-sfo02$ pip3.8 list|egrep '(Jinja2|nose|PyYAML|packaging|six)'
Jinja2       2.11.2
nose         1.3.7
packaging    19.2
PyYAML       5.3.1
six          1.15.0

rs-sfo02$ cat general-openbgpd.conf                                                                                                              
cfg:
  router_id: 206.197.187.254
  path_hiding: false
  !include general-shared.yml

rs-sfo02$ head -10 general-shared.yml                                                                                                            
  rs_as: 63055
  filtering:
    next_hop:
      policy: strict
    ipv4_pref_len:
      max: 24
      min: 8
...
rs-sfo02$ arouteserver html -o test.html --cfg general-openbgpd.conf  
ERROR:root:An error occurred while reading program configuration at general-openbgpd.conf: while scanning a simple key
  in "<unicode string>", line 4, column 1:
    !include general-shared.yml
    ^
could not find expected ':'
  in "<unicode string>", line 5, column 1:

    ^
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/pierky/arouteserver/config/program.py", line 109, in load
    cfg_from_file = yaml.safe_load(f.read())
  File "/usr/local/lib/python3.8/site-packages/yaml/__init__.py", line 162, in safe_load
    return load(stream, SafeLoader)
  File "/usr/local/lib/python3.8/site-packages/yaml/__init__.py", line 114, in load
    return loader.get_single_data()
  File "/usr/local/lib/python3.8/site-packages/yaml/constructor.py", line 49, in get_single_data
    node = self.get_single_node()
  File "/usr/local/lib/python3.8/site-packages/yaml/composer.py", line 36, in get_single_node
    document = self.compose_document()
  File "/usr/local/lib/python3.8/site-packages/yaml/composer.py", line 55, in compose_document
    node = self.compose_node(None, None)
  File "/usr/local/lib/python3.8/site-packages/yaml/composer.py", line 84, in compose_node
    node = self.compose_mapping_node(anchor)
  File "/usr/local/lib/python3.8/site-packages/yaml/composer.py", line 127, in compose_mapping_node
    while not self.check_event(MappingEndEvent):
  File "/usr/local/lib/python3.8/site-packages/yaml/parser.py", line 98, in check_event
    self.current_event = self.state()
  File "/usr/local/lib/python3.8/site-packages/yaml/parser.py", line 428, in parse_block_mapping_key
    if self.check_token(KeyToken):
  File "/usr/local/lib/python3.8/site-packages/yaml/scanner.py", line 115, in check_token
    while self.need_more_tokens():
  File "/usr/local/lib/python3.8/site-packages/yaml/scanner.py", line 152, in need_more_tokens
    self.stale_possible_simple_keys()
  File "/usr/local/lib/python3.8/site-packages/yaml/scanner.py", line 291, in stale_possible_simple_keys
    raise ScannerError("while scanning a simple key", key.mark,
yaml.scanner.ScannerError: while scanning a simple key
  in "<unicode string>", line 4, column 1:
    !include general-shared.yml
    ^
could not find expected ':'
  in "<unicode string>", line 5, column 1:

    ^
ERROR:root:An error occurred: please refer to the log for details.
pierky commented 3 years ago

rs-sfo02$ arouteserver html -o test.html --cfg general-openbgpd.conf

Hi @dorkmatt, you're using the --cfg but instead it should be --general. The !include hack only works for the general route server policy file, not for the program configuration.

So, arouteserver html -o test.html --general general-openbgpd.conf should work. Could you confirm it when you have a chance? Thanks

dorkmatt commented 3 years ago

Yep, that works - thank you!