title: Parsing icinga conf files in python
body: <p>I'm trying to write a wrapper for an icinga2 instance. The objets inside the config files look like this;</p>
  
  <pre><code>object object_type "object_name" {
    some_property = "some_value"
  }
  </code></pre>
  
  <p>example;</p>
  
  <pre><code>object Host "server1" {
    import "generic-host"
    address = "192.168.0.1"
    vars.os = "Linux"
  }
  
  object Host "server2" {
    import "generic-host"
    address = "192.168.0.2"
    vars.os = "Linux"
  }
  </code></pre>
  
  <p>I'm looking to do something like:</p>
  
  <pre><code>icinga = icinga("/etc/icinga2/conf.d/hosts.conf")
  
  print icinga.hosts_list()
  
  icinga.hosts_add("server3","192.168.0.3")
  icinga.hosts_remove("server1")
  </code></pre>
  
  <p>So I tried using pynag, something like;</p>
  
  <pre><code>nc = Config('/etc/icinga2/conf.d/hosts.conf')
  nc.parse()
  print nc.get_host('server1')
  </code></pre>
  
  <p>but I'm getting;</p>
  
  <pre><code>File "./icinga.py", line 51, in &lt;module&gt;
      print nc.get_host('server1')
    File "/Library/Python/2.7/site-packages/pynag/Parsers/__init__.py", line 1259, in get_host
      return self.get_object('host', object_name, user_key=user_key)
    File "/Library/Python/2.7/site-packages/pynag/Parsers/__init__.py", line 1238, in get_object
      for item in self.data['all_%s' % object_type]:
  KeyError: 'all_host'
  </code></pre>
  
  <p>Is there an easy way to work with this kind of formar?</p>