Allow applications postfix to be configured

The postfix _hosts appended to applications to create host groups is now
configurable.

Signed-off-by: martin f. krafft <madduck@madduck.net>
diff --git a/storage/__init__.py b/storage/__init__.py
index 0613bfe..27cbf7d 100644
--- a/storage/__init__.py
+++ b/storage/__init__.py
@@ -8,9 +8,10 @@
 #
 class NodeStorageBase(object):
 
-    def __init__(self, nodes_uri, classes_uri):
+    def __init__(self, nodes_uri, classes_uri, applications_postfix):
         self._nodes_uri = nodes_uri
         self._classes_uri = classes_uri
+        self._applications_postfix = applications_postfix
 
     nodes_uri = property(lambda self: self._nodes_uri)
     classes_uri = property(lambda self: self._classes_uri)
@@ -32,7 +33,7 @@
     def inventory(self):
         entity, applications, classes = self._list_inventory()
         ret = classes
-        ret.update([(k + '_hosts',v) for k,v in applications.iteritems()])
+        ret.update([(k + self._applications_postfix,v) for k,v in applications.iteritems()])
         return ret
 
 class StorageBackendLoader(object):
diff --git a/storage/yaml_fs/__init__.py b/storage/yaml_fs/__init__.py
index f53048f..9843333 100644
--- a/storage/yaml_fs/__init__.py
+++ b/storage/yaml_fs/__init__.py
@@ -16,8 +16,9 @@
 
 class ExternalNodeStorage(NodeStorageBase):
 
-    def __init__(self, nodes_uri, classes_uri):
-        super(ExternalNodeStorage, self).__init__(nodes_uri, classes_uri)
+    def __init__(self, nodes_uri, classes_uri, applications_postfix):
+        super(ExternalNodeStorage, self).__init__(nodes_uri, classes_uri,
+                                                  applications_postfix)
 
     def _read_nodeinfo(self, name, base_uri, seen, nodename=None):
         path = os.path.join(base_uri, name + FILE_EXTENSION)
diff --git a/storage/yaml_fs/tests/test_yaml_fs.py b/storage/yaml_fs/tests/test_yaml_fs.py
index 89ae294..b3dee9b 100644
--- a/storage/yaml_fs/tests/test_yaml_fs.py
+++ b/storage/yaml_fs/tests/test_yaml_fs.py
@@ -10,14 +10,15 @@
 
 import os
 
+POSTFIX = '_hosts'
 PWD = os.path.dirname(__file__)
 HOSTS = ['red', 'blue', 'green']
-MEMBERSHIPS = {'apt_hosts': HOSTS,
-               'motd_hosts': HOSTS,
-               'firewall_hosts': HOSTS[:2],
-               'lighttpd_hosts': HOSTS[:2],
-               'postfix_hosts': HOSTS[1:],
-               'blues_hosts': HOSTS[1:2],
+MEMBERSHIPS = {'apt%s' % POSTFIX: HOSTS,
+               'motd%s' % POSTFIX: HOSTS,
+               'firewall%s' % POSTFIX: HOSTS[:2],
+               'lighttpd%s' % POSTFIX: HOSTS[:2],
+               'postfix%s' % POSTFIX: HOSTS[1:],
+               'blues%s' % POSTFIX: HOSTS[1:2],
                'basenode': HOSTS,
                'debiannode': HOSTS,
                'debiannode@sid': HOSTS[0:1],
@@ -33,7 +34,8 @@
 
     def setUp(self):
         self._storage = ExternalNodeStorage(os.path.join(PWD, 'nodes'),
-                                            os.path.join(PWD, 'classes'))
+                                            os.path.join(PWD, 'classes'),
+                                            POSTFIX)
         self._inventory = self._storage.inventory()
 
     def test_inventory_setup(self):