summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/lib/Bcfg2/Server/Plugins/Metadata.py15
-rw-r--r--testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestMetadata.py19
2 files changed, 18 insertions, 16 deletions
diff --git a/src/lib/Bcfg2/Server/Plugins/Metadata.py b/src/lib/Bcfg2/Server/Plugins/Metadata.py
index bd02739d5..383e8e1dc 100644
--- a/src/lib/Bcfg2/Server/Plugins/Metadata.py
+++ b/src/lib/Bcfg2/Server/Plugins/Metadata.py
@@ -384,7 +384,7 @@ class MetadataGroup(tuple):
class Metadata(Bcfg2.Server.Plugin.Metadata,
- Bcfg2.Server.Plugin.Statistics,
+ Bcfg2.Server.Plugin.ClientRunHooks,
Bcfg2.Server.Plugin.DatabaseBacked):
"""This class contains data for bcfg2 server metadata."""
__author__ = 'bcfg-dev@mcs.anl.gov'
@@ -392,7 +392,7 @@ class Metadata(Bcfg2.Server.Plugin.Metadata,
def __init__(self, core, datastore, watch_clients=True):
Bcfg2.Server.Plugin.Metadata.__init__(self)
- Bcfg2.Server.Plugin.Statistics.__init__(self, core, datastore)
+ Bcfg2.Server.Plugin.ClientRunHooks.__init__(self)
Bcfg2.Server.Plugin.DatabaseBacked.__init__(self, core, datastore)
self.watch_clients = watch_clients
self.states = dict()
@@ -1252,12 +1252,11 @@ class Metadata(Bcfg2.Server.Plugin.Metadata,
return True
# pylint: enable=R0911,R0912
- def process_statistics(self, meta, _):
- """ Hook into statistics interface to toggle clients in
- bootstrap mode """
- client = meta.hostname
- if client in self.auth and self.auth[client] == 'bootstrap':
- self.update_client(client, dict(auth='cert'))
+ def end_statistics(self, metadata):
+ """ Hook to toggle clients in bootstrap mode """
+ if self.auth.get(metadata.hostname,
+ self.core.setup('authentication')) == 'bootstrap':
+ self.update_client(metadata.hostname, dict(auth='cert'))
def viz(self, hosts, bundles, key, only_client, colors):
"""Admin mode viz support."""
diff --git a/testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestMetadata.py b/testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestMetadata.py
index 35847b2c2..69ea45de6 100644
--- a/testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestMetadata.py
+++ b/testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestMetadata.py
@@ -20,7 +20,7 @@ while path != "/":
path = os.path.dirname(path)
from common import *
from TestPlugin import TestXMLFileBacked, TestMetadata as _TestMetadata, \
- TestStatistics, TestDatabaseBacked
+ TestClientRunHooks, TestDatabaseBacked
def get_clients_test_tree():
@@ -463,7 +463,7 @@ class TestClientMetadata(Bcfg2TestCase):
self.assertFalse(cm.inGroup("group3"))
-class TestMetadata(_TestMetadata, TestStatistics, TestDatabaseBacked):
+class TestMetadata(_TestMetadata, TestClientRunHooks, TestDatabaseBacked):
test_obj = Metadata
use_db = False
@@ -495,7 +495,7 @@ class TestMetadata(_TestMetadata, TestStatistics, TestDatabaseBacked):
metadata = self.get_obj(core=core)
self.assertIsInstance(metadata, Bcfg2.Server.Plugin.Plugin)
self.assertIsInstance(metadata, Bcfg2.Server.Plugin.Metadata)
- self.assertIsInstance(metadata, Bcfg2.Server.Plugin.Statistics)
+ self.assertIsInstance(metadata, Bcfg2.Server.Plugin.ClientRunHooks)
self.assertIsInstance(metadata.clients_xml, XMLMetadataConfig)
self.assertIsInstance(metadata.groups_xml, XMLMetadataConfig)
self.assertIsInstance(metadata.query, MetadataQuery)
@@ -1217,17 +1217,16 @@ class TestMetadata(_TestMetadata, TestStatistics, TestDatabaseBacked):
@patch("Bcfg2.Server.Plugins.Metadata.XMLMetadataConfig.load_xml", Mock())
@patch("Bcfg2.Server.Plugins.Metadata.Metadata.update_client")
- def test_process_statistics(self, mock_update_client):
+ def test_end_statistics(self, mock_update_client):
metadata = self.load_clients_data(metadata=self.load_groups_data())
md = Mock()
md.hostname = "client6"
- metadata.process_statistics(md, None)
- mock_update_client.assert_called_with(md.hostname,
- dict(auth='cert'))
+ metadata.end_statistics(md)
+ mock_update_client.assert_called_with(md.hostname, dict(auth='cert'))
mock_update_client.reset_mock()
md.hostname = "client5"
- metadata.process_statistics(md, None)
+ metadata.end_statistics(md)
self.assertFalse(mock_update_client.called)
def test_viz(self):
@@ -1504,6 +1503,10 @@ class TestMetadata_NoClientsXML(TestMetadataBase):
def test_handle_clients_xml_event(self):
pass
+ def test_end_statistics(self):
+ # bootstrap mode, which is what is being tested here, doesn't
+ # work without clients.xml
+ pass
class TestMetadata_ClientsXML(TestMetadataBase):
""" test Metadata with a clients.xml. """