Browse Source

[213] Make parameters optional

Not all parameters were optional before, now they are.
Michal 'vorner' Vaner 13 years ago
parent
commit
a3e7bf95ad

+ 5 - 4
src/lib/python/isc/bind10/component.py

@@ -73,7 +73,7 @@ class Component:
         self.__running = False
         # Dead like really dead. No resurrection possible.
         self.__dead = False
-        self.__kind = kind
+        self._kind = kind
         self._boss = boss
         self._process = process
         self._start_func = None
@@ -157,8 +157,8 @@ class Component:
         self.failed_internal()
         # If it is a core component or the needed component failed to start
         # (including it stopped really soon)
-        if self.__kind == 'core' or \
-            (self.__kind == 'needed' and time.time() - 10 < self.__start_time):
+        if self._kind == 'core' or \
+            (self._kind == 'needed' and time.time() - 10 < self.__start_time):
             self.__dead = True
             logger.fatal(BIND10_COMPONENT_UNSATISFIED, self.name())
             self._boss.component_shutdown(1)
@@ -391,7 +391,8 @@ class Configurator:
                     # TODO: Better error handling
                     creator = specials[params['special']]
                 component = creator(params.get('process', cname), self.__boss,
-                                    params['kind'], params.get('address'),
+                                    params.get('kind', 'dispensable'),
+                                    params.get('address'),
                                     params.get('params'))
                 priority = params.get('priority', 0)
                 # We store tuples, priority first, so we can easily sort

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

@@ -631,8 +631,20 @@ class ConfiguratorTest(BossUtils, unittest.TestCase):
         self.assertEqual('component', component.name())
         self.assertEqual([1, 2], component._params)
         self.assertEqual('address', component._address)
+        self.assertEqual('needed', component._kind)
         # We don't use isinstance on purpose, it would allow a descendand
         self.assertTrue(type(component) is Component)
+        plan = configurator._build_plan({}, {
+            'component': { }
+        })
+        self.assertEqual(1, len(plan))
+        self.assertEqual('start', plan[0]['command'])
+        self.assertEqual('component', plan[0]['name'])
+        component = plan[0]['component']
+        self.assertEqual('component', component.name())
+        self.assertIsNone(component._params)
+        self.assertIsNone(component._address)
+        self.assertEqual('dispensable', component._kind)
 
     def __do_switch(self, option, value):
         """