Browse Source

[2136] Introduced an address() method for the Component classes

It returns the "_address" attribute of the classes. This is used for the
"show_processes" command of Boss to provide address information.
Naoki Kambe 12 years ago
parent
commit
5fa38c2002

+ 14 - 0
src/lib/python/isc/bind10/component.py

@@ -371,6 +371,14 @@ class BaseComponent:
         """
         """
         pass
         pass
 
 
+    def address(self):
+        """
+        Provides the name of the address used on the message bus
+
+        You need to provide this method in a concrete implementation.
+        """
+        pass
+
 class Component(BaseComponent):
 class Component(BaseComponent):
     """
     """
     The most common implementation of a component. It can be used either
     The most common implementation of a component. It can be used either
@@ -454,6 +462,12 @@ class Component(BaseComponent):
             else:
             else:
                 self._procinfo.process.terminate()
                 self._procinfo.process.terminate()
 
 
+    def address(self):
+        """
+        Returns the name of the address used on the message bus
+        """
+        return self._address
+
 class Configurator:
 class Configurator:
     """
     """
     This thing keeps track of configuration changes and starts and stops
     This thing keeps track of configuration changes and starts and stops

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

@@ -164,6 +164,13 @@ class ComponentTests(BossUtils, unittest.TestCase):
         component = self.__create_component('core')
         component = self.__create_component('core')
         self.assertEqual('No process', component.name())
         self.assertEqual('No process', component.name())
 
 
+    def test_address(self):
+        """
+        Test the address provides whatever we passed to the constructor as process.
+        """
+        component = self.__create_component('core')
+        self.assertEqual("homeless", component.address())
+
     def test_guts(self):
     def test_guts(self):
         """
         """
         Test the correct data are stored inside the component.
         Test the correct data are stored inside the component.