diff options
author | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2012-08-09 11:51:06 -0400 |
---|---|---|
committer | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2012-08-09 12:02:45 -0400 |
commit | 35bb03c45a057d1f0f313d129125cc0d1f7c1042 (patch) | |
tree | 4956dc23eacdef5bc699a68fe53c02768052220b | |
parent | 53d5423f3e5e09812c751360ba53f0a2639d2f29 (diff) | |
download | bcfg2-35bb03c45a057d1f0f313d129125cc0d1f7c1042.tar.gz bcfg2-35bb03c45a057d1f0f313d129125cc0d1f7c1042.tar.bz2 bcfg2-35bb03c45a057d1f0f313d129125cc0d1f7c1042.zip |
move MetadataConsistency/RuntimeError exceptions into Plugin.py so we don't depend on a particular Metadata plugin
-rw-r--r-- | src/lib/Bcfg2/Server/Core.py | 25 | ||||
-rw-r--r-- | src/lib/Bcfg2/Server/Plugin.py | 16 | ||||
-rw-r--r-- | src/lib/Bcfg2/Server/Plugins/Metadata.py | 59 | ||||
-rw-r--r-- | testsuite/Testlib/TestServer/TestPlugin.py | 1 | ||||
-rw-r--r-- | testsuite/Testlib/TestServer/TestPlugins/TestMetadata.py | 74 | ||||
-rw-r--r-- | testsuite/Testlib/TestServer/TestPlugins/TestProbes.py | 1 |
6 files changed, 80 insertions, 96 deletions
diff --git a/src/lib/Bcfg2/Server/Core.py b/src/lib/Bcfg2/Server/Core.py index 7e0e33024..5b84a334d 100644 --- a/src/lib/Bcfg2/Server/Core.py +++ b/src/lib/Bcfg2/Server/Core.py @@ -10,15 +10,10 @@ import time import inspect import lxml.etree from traceback import format_exc - -# this must be set before we import the Metadata plugin -os.environ['DJANGO_SETTINGS_MODULE'] = 'Bcfg2.settings' - import Bcfg2.settings import Bcfg2.Server import Bcfg2.Logger import Bcfg2.Server.FileMonitor -import Bcfg2.Server.Plugins.Metadata from Bcfg2.Bcfg2Py3k import xmlrpclib from Bcfg2.Server.Plugin import PluginInitError, PluginExecutionError @@ -31,6 +26,8 @@ try: except: pass +os.environ['DJANGO_SETTINGS_MODULE'] = 'Bcfg2.settings' + def exposed(func): func.exposed = True return func @@ -356,7 +353,7 @@ class BaseCore(object): revision=self.revision) try: meta = self.build_metadata(client) - except Bcfg2.Server.Plugins.Metadata.MetadataConsistencyError: + except Bcfg2.Server.Plugin.MetadataConsistencyError: self.logger.error("Metadata consistency error for client %s" % client) return lxml.etree.Element("error", type='metadata error') @@ -447,7 +444,7 @@ class BaseCore(object): """Build the metadata structure.""" if not hasattr(self, 'metadata'): # some threads start before metadata is even loaded - raise Bcfg2.Server.Plugins.Metadata.MetadataRuntimeError + raise Bcfg2.Server.Plugin.MetadataRuntimeError imd = self.metadata.get_initial_metadata(client_name) for conn in self.connectors: grps = conn.get_additional_groups(imd) @@ -483,11 +480,11 @@ class BaseCore(object): meta = self.build_metadata(client) else: meta = None - except Bcfg2.Server.Plugins.Metadata.MetadataConsistencyError: + except Bcfg2.Server.Plugin.MetadataConsistencyError: err = sys.exc_info()[1] self.critical_error("Client metadata resolution error for %s: %s" % (address[0], err)) - except Bcfg2.Server.Plugins.Metadata.MetadataRuntimeError: + except Bcfg2.Server.Plugin.MetadataRuntimeError: err = sys.exc_info()[1] self.critical_error('Metadata system runtime failure for %s: %s' % (address[0], err)) @@ -526,8 +523,8 @@ class BaseCore(object): client, metadata = self.resolve_client(address) try: self.metadata.set_version(client, version) - except (Bcfg2.Server.Plugins.Metadata.MetadataConsistencyError, - Bcfg2.Server.Plugins.Metadata.MetadataRuntimeError): + except (Bcfg2.Server.Plugin.MetadataConsistencyError, + Bcfg2.Server.Plugin.MetadataRuntimeError): err = sys.exc_info()[1] self.critical_error("Unable to set version for %s: %s" % (client, err)) @@ -584,8 +581,8 @@ class BaseCore(object): client = self.resolve_client(address, metadata=False)[0] try: self.metadata.set_profile(client, profile, address) - except (Bcfg2.Server.Plugins.Metadata.MetadataConsistencyError, - Bcfg2.Server.Plugins.Metadata.MetadataRuntimeError): + except (Bcfg2.Server.Plugin.MetadataConsistencyError, + Bcfg2.Server.Plugin.MetadataRuntimeError): err = sys.exc_info()[1] self.critical_error("Unable to assert profile for %s: %s" % (client, err)) @@ -599,7 +596,7 @@ class BaseCore(object): config = self.BuildConfiguration(client) return lxml.etree.tostring(config, encoding='UTF-8', xml_declaration=True) - except Bcfg2.Server.Plugins.Metadata.MetadataConsistencyError: + except Bcfg2.Server.Plugin.MetadataConsistencyError: self.critical_error("Metadata consistency failure for %s" % client) @exposed diff --git a/src/lib/Bcfg2/Server/Plugin.py b/src/lib/Bcfg2/Server/Plugin.py index 31c62018a..e030ff1bd 100644 --- a/src/lib/Bcfg2/Server/Plugin.py +++ b/src/lib/Bcfg2/Server/Plugin.py @@ -72,6 +72,18 @@ class PluginExecutionError(Exception): pass +class MetadataConsistencyError(Exception): + """This error gets raised when metadata is internally inconsistent.""" + pass + + +class MetadataRuntimeError(Exception): + """This error is raised when the metadata engine + is called prior to reading enough data. + """ + pass + + class Debuggable(object): __rmi__ = ['toggle_debug'] @@ -294,7 +306,7 @@ class ThreadedStatistics(Statistics, threading.Thread): try: metadata = self.core.build_metadata(pmetadata) break - except Bcfg2.Server.Plugins.Metadata.MetadataRuntimeError: + except MetadataRuntimeError: pass self.terminate.wait(5) @@ -311,7 +323,7 @@ class ThreadedStatistics(Statistics, threading.Thread): lxml_error = sys.exc_info()[1] self.logger.error("Unable to load saved interaction: %s" % lxml_error) - except Bcfg2.Server.Plugins.Metadata.MetadataConsistencyError: + except MetadataConsistencyError: self.logger.error("Unable to load metadata for save " "interaction: %s" % pmetadata) try: diff --git a/src/lib/Bcfg2/Server/Plugins/Metadata.py b/src/lib/Bcfg2/Server/Plugins/Metadata.py index 79aaddbf6..fcef6ebb7 100644 --- a/src/lib/Bcfg2/Server/Plugins/Metadata.py +++ b/src/lib/Bcfg2/Server/Plugins/Metadata.py @@ -81,18 +81,6 @@ if has_django: return False -class MetadataConsistencyError(Exception): - """This error gets raised when metadata is internally inconsistent.""" - pass - - -class MetadataRuntimeError(Exception): - """This error is raised when the metadata engine - is called prior to reading enough data. - """ - pass - - class XMLMetadataConfig(Bcfg2.Server.Plugin.XMLFileBacked): """Handles xml config files and all XInclude statements""" def __init__(self, metadata, watch_clients, basefile): @@ -117,13 +105,15 @@ class XMLMetadataConfig(Bcfg2.Server.Plugin.XMLFileBacked): @property def xdata(self): if not self.data: - raise MetadataRuntimeError("%s has no data" % self.basefile) + raise Bcfg2.Server.Plugin.MetadataRuntimeError("%s has no data" % + self.basefile) return self.data @property def base_xdata(self): if not self.basedata: - raise MetadataRuntimeError("%s has no data" % self.basefile) + raise Bcfg2.Server.Plugin.MetadataRuntimeError("%s has no data" % + self.basefile) return self.basedata def load_xml(self): @@ -158,7 +148,7 @@ class XMLMetadataConfig(Bcfg2.Server.Plugin.XMLFileBacked): except IOError: msg = "Failed to write %s: %s" % (tmpfile, sys.exc_info()[1]) self.logger.error(msg) - raise MetadataRuntimeError(msg) + raise Bcfg2.Server.Plugin.MetadataRuntimeError(msg) # prep data dataroot = xmltree.getroot() newcontents = lxml.etree.tostring(dataroot, pretty_print=True) @@ -174,7 +164,7 @@ class XMLMetadataConfig(Bcfg2.Server.Plugin.XMLFileBacked): (tmpfile, sys.exc_info()[1]) self.logger.error(msg, exc_info=1) os.unlink(tmpfile) - raise MetadataRuntimeError(msg) + raise Bcfg2.Server.Plugin.MetadataRuntimeError(msg) datafile.close() # check if clients.xml is a symlink if os.path.islink(fname): @@ -187,7 +177,7 @@ class XMLMetadataConfig(Bcfg2.Server.Plugin.XMLFileBacked): msg = "Metadata: Failed to rename %s: %s" % (tmpfile, sys.exc_info()[1]) self.logger.error(msg) - raise MetadataRuntimeError(msg) + raise Bcfg2.Server.Plugin.MetadataRuntimeError(msg) def find_xml_for_xpath(self, xpath): """Find and load xml file containing the xpath query""" @@ -434,7 +424,7 @@ class Metadata(Bcfg2.Server.Plugin.Metadata, node = self._search_xdata(tag, name, config.xdata, alias=alias) if node != None: self.logger.error("%s \"%s\" already exists" % (tag, name)) - raise MetadataConsistencyError + raise Bcfg2.Server.Plugin.MetadataConsistencyError element = lxml.etree.SubElement(config.base_xdata.getroot(), tag, name=name) if attribs: @@ -478,13 +468,13 @@ class Metadata(Bcfg2.Server.Plugin.Metadata, node = self._search_xdata(tag, name, config.xdata, alias=alias) if node == None: self.logger.error("%s \"%s\" does not exist" % (tag, name)) - raise MetadataConsistencyError + raise Bcfg2.Server.Plugin.MetadataConsistencyError xdict = config.find_xml_for_xpath('.//%s[@name="%s"]' % (tag, node.get('name'))) if not xdict: self.logger.error("Unexpected error finding %s \"%s\"" % (tag, name)) - raise MetadataConsistencyError + raise Bcfg2.Server.Plugin.MetadataConsistencyError for key, val in list(attribs.items()): xdict['xquery'][0].set(key, val) config.write_xml(xdict['filename'], xdict['xmltree']) @@ -520,13 +510,13 @@ class Metadata(Bcfg2.Server.Plugin.Metadata, node = self._search_xdata(tag, name, config.xdata) if node == None: self.logger.error("%s \"%s\" does not exist" % (tag, name)) - raise MetadataConsistencyError + raise Bcfg2.Server.Plugin.MetadataConsistencyError xdict = config.find_xml_for_xpath('.//%s[@name="%s"]' % (tag, node.get('name'))) if not xdict: self.logger.error("Unexpected error finding %s \"%s\"" % (tag, name)) - raise MetadataConsistencyError + raise Bcfg2.Server.Plugin.MetadataConsistencyError xdict['xquery'][0].getparent().remove(xdict['xquery'][0]) config.write_xml(xdict['filename'], xdict['xmltree']) @@ -556,7 +546,7 @@ class Metadata(Bcfg2.Server.Plugin.Metadata, except MetadataClientModel.DoesNotExist: msg = "Client %s does not exist" % client_name self.logger.warning(msg) - raise MetadataConsistencyError(msg) + raise Bcfg2.Server.Plugin.MetadataConsistencyError(msg) client.delete() self.clients = self.list_clients() else: @@ -739,16 +729,16 @@ class Metadata(Bcfg2.Server.Plugin.Metadata, self.logger.info("Asserting client %s profile to %s" % (client, profile)) if False in list(self.states.values()): - raise MetadataRuntimeError + raise Bcfg2.Server.Plugin.MetadataRuntimeError("Metadata has not been read yet") if not force and profile not in self.groups: msg = "Profile group %s does not exist" % profile self.logger.error(msg) - raise MetadataConsistencyError(msg) + raise Bcfg2.Server.Plugin.MetadataConsistencyError(msg) group = self.groups[profile] if not force and not group.is_public: msg = "Cannot set client %s to private group %s" % (client, profile) self.logger.error(msg) - raise MetadataConsistencyError(msg) + raise Bcfg2.Server.Plugin.MetadataConsistencyError(msg) if client in self.clients: if self._use_db: @@ -795,7 +785,7 @@ class Metadata(Bcfg2.Server.Plugin.Metadata, else: msg = "Cannot set version on non-existent client %s" % client self.logger.error(msg) - raise MetadataConsistencyError(msg) + raise Bcfg2.Server.Plugin.MetadataConsistencyError(msg) self.versions[client] = version self.clients_xml.write() @@ -829,7 +819,7 @@ class Metadata(Bcfg2.Server.Plugin.Metadata, if len(self.addresses[address]) != 1: err = "Address %s has multiple reverse assignments; a uuid must be used" % address self.logger.error(err) - raise MetadataConsistencyError(err) + raise Bcfg2.Server.Plugin.MetadataConsistencyError(err) return self.addresses[address][0] try: cname = socket.gethostbyaddr(address)[0].lower() @@ -839,7 +829,7 @@ class Metadata(Bcfg2.Server.Plugin.Metadata, except socket.herror: warning = "address resolution error for %s" % address self.logger.warning(warning) - raise MetadataConsistencyError(warning) + raise Bcfg2.Server.Plugin.MetadataConsistencyError(warning) def _merge_groups(self, client, groups, categories=None): """ set group membership based on the contents of groups.xml @@ -869,7 +859,7 @@ class Metadata(Bcfg2.Server.Plugin.Metadata, def get_initial_metadata(self, client): """Return the metadata for a given client.""" if False in list(self.states.values()): - raise MetadataRuntimeError("Metadata has not been read yet") + raise Bcfg2.Server.Plugin.MetadataRuntimeError("Metadata has not been read yet") client = client.lower() if client in self.aliases: client = self.aliases[client] @@ -896,7 +886,7 @@ class Metadata(Bcfg2.Server.Plugin.Metadata, else: msg = "Cannot add new client %s; no default group set" % client self.logger.error(msg) - raise MetadataConsistencyError(msg) + raise Bcfg2.Server.Plugin.MetadataConsistencyError(msg) if client in self.clientgroups: for cgroup in self.clientgroups[client]: @@ -1050,9 +1040,10 @@ class Metadata(Bcfg2.Server.Plugin.Metadata, id_method = 'address' try: client = self.resolve_client(address) - except MetadataConsistencyError: - self.logger.error("Client %s failed to resolve; metadata problem" - % address[0]) + except Bcfg2.Server.Plugin.MetadataConsistencyError: + err = sys.exc_info()[1] + self.logger.error("Client %s failed to resolve: %s" % + (address[0], err)) return False else: id_method = 'uuid' diff --git a/testsuite/Testlib/TestServer/TestPlugin.py b/testsuite/Testlib/TestServer/TestPlugin.py index 0d1c0f810..3f25f922d 100644 --- a/testsuite/Testlib/TestServer/TestPlugin.py +++ b/testsuite/Testlib/TestServer/TestPlugin.py @@ -6,7 +6,6 @@ import lxml.etree from mock import Mock, MagicMock, patch from Bcfg2.Server.Plugin import * import Bcfg2.Server -import Bcfg2.Server.Plugins.Metadata datastore = '/' diff --git a/testsuite/Testlib/TestServer/TestPlugins/TestMetadata.py b/testsuite/Testlib/TestServer/TestPlugins/TestMetadata.py index 381bd978e..24e8f9d75 100644 --- a/testsuite/Testlib/TestServer/TestPlugins/TestMetadata.py +++ b/testsuite/Testlib/TestServer/TestPlugins/TestMetadata.py @@ -20,6 +20,7 @@ try: except ImportError: has_django = False + import Bcfg2.Server import Bcfg2.Server.Plugin from Bcfg2.Server.Plugins.Metadata import * @@ -169,15 +170,9 @@ class TestClientVersions(unittest.TestCase): self.assertEqual(v['client2'], "1.2.2") self.assertIsNone(v['client5']) - # test exception on nonexistent client. can't use assertRaises - # for this because assertRaises requires a callable - try: + # test exception on nonexistent client + with self.assertRaises(KeyError): v['clients__getitem'] - assert False - except KeyError: - assert True - except: - assert False def test__len(self): v = ClientVersions() @@ -211,27 +206,16 @@ class TestXMLMetadataConfig(unittest.TestCase): def test_xdata(self): config = self.get_config_object() - # we can't use assertRaises here because xdata is a property - try: + with self.assertRaises(Bcfg2.Server.Plugin.MetadataRuntimeError): config.xdata - assert False - except MetadataRuntimeError: - assert True - except: - assert False config.data = "<test/>" self.assertEqual(config.xdata, "<test/>") def test_base_xdata(self): config = self.get_config_object() # we can't use assertRaises here because base_xdata is a property - try: + with self.assertRaises(Bcfg2.Server.Plugin.MetadataRuntimeError): config.base_xdata - assert False - except MetadataRuntimeError: - assert True - except: - assert False config.basedata = "<test/>" self.assertEqual(config.base_xdata, "<test/>") @@ -323,16 +307,16 @@ class TestXMLMetadataConfig(unittest.TestCase): mock_rename.assert_called_with(tmpfile, linkdest) mock_rename.side_effect = OSError - self.assertRaises(MetadataRuntimeError, + self.assertRaises(Bcfg2.Server.Plugin.MetadataRuntimeError, config.write_xml, fpath, self.clients_test_tree) mock_open.return_value.write.side_effect = IOError - self.assertRaises(MetadataRuntimeError, + self.assertRaises(Bcfg2.Server.Plugin.MetadataRuntimeError, config.write_xml, fpath, self.clients_test_tree) mock_unlink.assert_called_with(tmpfile) mock_open.side_effect = IOError - self.assertRaises(MetadataRuntimeError, + self.assertRaises(Bcfg2.Server.Plugin.MetadataRuntimeError, config.write_xml, fpath, self.clients_test_tree) @patch("Bcfg2.Server.Plugins.Metadata.XMLMetadataConfig.load_xml", Mock()) @@ -514,7 +498,7 @@ class TestMetadata(unittest.TestCase): metadata.groups_xml.basedata = copy.copy(metadata.groups_xml.data) metadata.groups_xml.write.reset_mock() - self.assertRaises(MetadataConsistencyError, + self.assertRaises(Bcfg2.Server.Plugin.MetadataConsistencyError, metadata.add_group, "test1", dict()) self.assertFalse(metadata.groups_xml.write.called) @@ -532,7 +516,7 @@ class TestMetadata(unittest.TestCase): self.assertEqual(grp.get("foo"), "bar") self.assertTrue(metadata.groups_xml.write_xml.called) - self.assertRaises(MetadataConsistencyError, + self.assertRaises(Bcfg2.Server.Plugin.MetadataConsistencyError, metadata.update_group, "bogus_group", dict()) @@ -547,7 +531,7 @@ class TestMetadata(unittest.TestCase): self.assertIsNone(grp) self.assertTrue(metadata.groups_xml.write_xml.called) - self.assertRaises(MetadataConsistencyError, + self.assertRaises(Bcfg2.Server.Plugin.MetadataConsistencyError, metadata.remove_group, "bogus_group") @@ -569,7 +553,7 @@ class TestMetadata(unittest.TestCase): metadata.groups_xml.basedata = copy.copy(metadata.groups_xml.data) metadata.groups_xml.write.reset_mock() - self.assertRaises(MetadataConsistencyError, + self.assertRaises(Bcfg2.Server.Plugin.MetadataConsistencyError, metadata.add_bundle, "bundle1") self.assertFalse(metadata.groups_xml.write.called) @@ -585,7 +569,7 @@ class TestMetadata(unittest.TestCase): self.assertIsNone(grp) self.assertTrue(metadata.groups_xml.write_xml.called) - self.assertRaises(MetadataConsistencyError, + self.assertRaises(Bcfg2.Server.Plugin.MetadataConsistencyError, metadata.remove_bundle, "bogus_bundle") @@ -619,7 +603,7 @@ class TestMetadata(unittest.TestCase): metadata.clients_xml.basedata = copy.copy(metadata.clients_xml.data) metadata.clients_xml.write.reset_mock() - self.assertRaises(MetadataConsistencyError, + self.assertRaises(Bcfg2.Server.Plugin.MetadataConsistencyError, metadata.add_client, new1, dict()) self.assertFalse(metadata.clients_xml.write.called) @@ -638,7 +622,7 @@ class TestMetadata(unittest.TestCase): self.assertTrue(metadata.clients_xml.write_xml.called) new = self.get_nonexistent_client(metadata) - self.assertRaises(MetadataConsistencyError, + self.assertRaises(Bcfg2.Server.Plugin.MetadataConsistencyError, metadata.update_client, new, dict()) @@ -755,18 +739,18 @@ class TestMetadata(unittest.TestCase): metadata = self.get_metadata_object() if 'clients.xml' in metadata.states: metadata.states['clients.xml'] = False - self.assertRaises(MetadataRuntimeError, + self.assertRaises(Bcfg2.Server.Plugin.MetadataRuntimeError, metadata.set_profile, None, None, None) self.load_groups_data(metadata=metadata) self.load_clients_data(metadata=metadata) - self.assertRaises(MetadataConsistencyError, + self.assertRaises(Bcfg2.Server.Plugin.MetadataConsistencyError, metadata.set_profile, "client1", "group5", None) - self.assertRaises(MetadataConsistencyError, + self.assertRaises(Bcfg2.Server.Plugin.MetadataConsistencyError, metadata.set_profile, "client1", "group3", None) @@ -820,7 +804,7 @@ class TestMetadata(unittest.TestCase): metadata.session_cache[('1.2.3.3', None)] = (time.time(), 'client3') self.assertEqual(metadata.resolve_client(('1.2.3.3', None)), 'client3') - self.assertRaises(MetadataConsistencyError, + self.assertRaises(Bcfg2.Server.Plugin.MetadataConsistencyError, metadata.resolve_client, ('1.2.3.2', None)) self.assertEqual(metadata.resolve_client(('1.2.3.1', None)), 'client1') @@ -844,7 +828,7 @@ class TestMetadata(unittest.TestCase): mock_gethostbyaddr.reset_mock() mock_gethostbyaddr.return_value = None mock_gethostbyaddr.side_effect = socket.herror - self.assertRaises(MetadataConsistencyError, + self.assertRaises(Bcfg2.Server.Plugin.MetadataConsistencyError, metadata.resolve_client, ('1.2.3.8', None)) mock_gethostbyaddr.assert_called_with('1.2.3.8') @@ -856,7 +840,7 @@ class TestMetadata(unittest.TestCase): metadata = self.get_metadata_object() if 'clients.xml' in metadata.states: metadata.states['clients.xml'] = False - self.assertRaises(MetadataRuntimeError, + self.assertRaises(Bcfg2.Server.Plugin.MetadataRuntimeError, metadata.get_initial_metadata, None) self.load_groups_data(metadata=metadata) @@ -910,7 +894,7 @@ class TestMetadata(unittest.TestCase): # test new client with no default profile metadata.default = None new2 = self.get_nonexistent_client(metadata) - self.assertRaises(MetadataConsistencyError, + self.assertRaises(Bcfg2.Server.Plugin.MetadataConsistencyError, metadata.get_initial_metadata, new2) @patch("Bcfg2.Server.Plugins.Metadata.XMLMetadataConfig.load_xml", Mock()) @@ -1076,7 +1060,8 @@ class TestMetadata(unittest.TestCase): self.assertTrue(metadata.AuthenticateConnection(None, "root", "password1", "1.2.3.8")) - mock_resolve_client.side_effect = MetadataConsistencyError + mock_resolve_client.side_effect = \ + Bcfg2.Server.Plugin.MetadataConsistencyError self.assertFalse(metadata.AuthenticateConnection(None, "root", "password1", "1.2.3.8")) @@ -1219,7 +1204,7 @@ class TestMetadataBase(TestMetadata): metadata = self.get_metadata_object() client_name = self.get_nonexistent_client(metadata) - self.assertRaises(MetadataConsistencyError, + self.assertRaises(Bcfg2.Server.Plugin.MetadataConsistencyError, metadata.remove_client, client_name) @@ -1256,7 +1241,7 @@ class TestMetadata_NoClientsXML(TestMetadataBase): metadata = self.get_metadata_object() if 'clients.xml' in metadata.states: metadata.states['clients.xml'] = False - self.assertRaises(MetadataRuntimeError, + self.assertRaises(Bcfg2.Server.Plugin.MetadataRuntimeError, metadata.get_initial_metadata, None) self.load_groups_data(metadata=metadata) @@ -1300,7 +1285,7 @@ class TestMetadata_NoClientsXML(TestMetadataBase): # test exception on new client with no default profile metadata.default = None new2 = self.get_nonexistent_client(metadata) - self.assertRaises(MetadataConsistencyError, + self.assertRaises(Bcfg2.Server.Plugin.MetadataConsistencyError, metadata.get_initial_metadata, new2) @@ -1342,7 +1327,8 @@ class TestMetadata_NoClientsXML(TestMetadataBase): self.assertTrue(metadata.AuthenticateConnection(None, "root", "password1", "1.2.3.8")) - mock_resolve_client.side_effect = MetadataConsistencyError + mock_resolve_client.side_effect = \ + Bcfg2.Server.Plugin.MetadataConsistencyError self.assertFalse(metadata.AuthenticateConnection(None, "root", "password1", "1.2.3.8")) @@ -1368,7 +1354,7 @@ class TestMetadata_NoClientsXML(TestMetadataBase): mock_gethostbyaddr.reset_mock() mock_gethostbyaddr.return_value = None mock_gethostbyaddr.side_effect = socket.herror - self.assertRaises(MetadataConsistencyError, + self.assertRaises(Bcfg2.Server.Plugin.MetadataConsistencyError, metadata.resolve_client, ('1.2.3.8', None)) mock_gethostbyaddr.assert_called_with('1.2.3.8') diff --git a/testsuite/Testlib/TestServer/TestPlugins/TestProbes.py b/testsuite/Testlib/TestServer/TestPlugins/TestProbes.py index 92e0037f3..ffc6add26 100644 --- a/testsuite/Testlib/TestServer/TestPlugins/TestProbes.py +++ b/testsuite/Testlib/TestServer/TestPlugins/TestProbes.py @@ -408,7 +408,6 @@ text probes._write_data_xml(None) xdata = \ lxml.etree.XML(str(mock_open.return_value.write.call_args[0][0])) - print "rv = %s" % lxml.etree.tostring(xdata) mock_parse.return_value = xdata.getroottree() probes.probedata = dict() probes.cgroups = dict() |