Browse Source

[213] Creating plans for adding components

Michal 'vorner' Vaner 13 years ago
parent
commit
8f6ca91d01

+ 25 - 1
src/lib/python/isc/bind10/component.py

@@ -219,7 +219,31 @@ class Configurator:
         Any configuration problems are expected to be handled here, so the
         plan is not yet run.
         """
-        pass
+        plan_add = []
+        plan = []
+        # Handle introduction of new components
+        for cname in new.keys():
+            if cname not in old:
+                params = new[cname]
+                creator = Component
+                if 'special' in params:
+                    # TODO: Better error handling
+                    creator = specials[params['special']]
+                component = creator(params['process'], self.__boss,
+                                    params['kind'])
+                priority = 0
+                if 'priority' in params:
+                    priority = params['priority']
+                # We store tuples, priority first, so we can easily sort
+                plan_add.append((priority, {
+                    'component': component,
+                    'command': 'start',
+                    'name': cname
+                }))
+        # Push the starts there sorted by priority
+        plan.extend([command for (_, command) in sorted(plan_add,
+                                                        reverse=True)])
+        return plan
 
     def _run_plan(self, plan):
         """

+ 1 - 1
src/lib/python/isc/bind10/tests/component_test.py

@@ -445,7 +445,7 @@ class ConfiguratorTest(BossUtils, unittest.TestCase):
                 'kind': 'core'
             }
         }
-        # How they should be started. The are created in the order they are
+        # How they should be started. They are created in the order they are
         # found in the dict, but then they should be started by priority.
         # This expects that the same dict returns its keys in the same order
         # every time