Esempio n. 1
0
    def test_get_vitrage_resource(self):
        """Test the resource returned after processing a list of mappings

        :return:
        """
        # Action
        nagios_conf = NagiosConfig(self.conf)

        # Test assertions
        mapped_resource = nagios_conf.get_vitrage_resource(None)
        self.assertIsNone(mapped_resource, 'expected None')

        mapped_resource = nagios_conf.get_vitrage_resource('')
        self.assertIsNone(mapped_resource, 'expected None')

        mapped_resource = nagios_conf.get_vitrage_resource('compute-1')
        self.assertIsNotNone(mapped_resource, 'expected Not None')
        self.assertEqual(NOVA_HOST_DATASOURCE, mapped_resource[0])
        self.assertEqual('compute-1', mapped_resource[1])

        mapped_resource = nagios_conf.get_vitrage_resource('compute-2')
        self.assertIsNotNone(mapped_resource, 'expected Not None')
        self.assertEqual(NOVA_HOST_DATASOURCE, mapped_resource[0])
        self.assertEqual('host2', mapped_resource[1])

        mapped_resource = nagios_conf.get_vitrage_resource('compute-88')
        self.assertIsNotNone(mapped_resource, 'expected Not None')
        self.assertEqual(NOVA_HOST_DATASOURCE, mapped_resource[0])
        self.assertEqual('compute-88', mapped_resource[1])

        mapped_resource = nagios_conf.get_vitrage_resource('instance-7')
        self.assertIsNotNone(mapped_resource, 'expected Not None')
        self.assertEqual(NOVA_INSTANCE_DATASOURCE, mapped_resource[0])
        self.assertEqual('instance-7', mapped_resource[1])
Esempio n. 2
0
    def test_nagios_configuration_loading(self):
        # Action
        nagios_conf = NagiosConfig(self.conf)

        # Test assertions
        mappings = nagios_conf.mappings
        self.assertIsNotNone(nagios_conf, "no nagios configuration loaded")
        self.assertEqual(len(self.MAPPINGS), len(mappings))

        for expected_mapping in self.MAPPINGS:
            self.assertTrue(
                TestNagiosConfig._check_contains(expected_mapping, mappings))
        for expected_mapping in self.NON_EXISTING_MAPPINGS:
            self.assertFalse(
                TestNagiosConfig._check_contains(expected_mapping, mappings))
Esempio n. 3
0
 def __init__(self, conf):
     super(NagiosDriver, self).__init__()
     self.conf = conf
     self.config = NagiosConfig(conf)