Example #1
0
    def test_ensure_ltm_monitors_non_default(self):
        """Verifies that the LTM monitors with different default inputs"""
        resp = tju.load_file('pcm_pref.txt')
        self.adpt.read_by_href.return_value = resp

        # Create a side effect that can validate the input to the update
        def validate_of_update(*kargs, **kwargs):
            element = kargs[0]
            etag = kargs[1]
            self.assertIsNotNone(element)

            # Wrap the element so we can validate it.
            pref = pvm_mon.PcmPref.wrap(pvm_e.Entry({'etag': etag},
                                                    element, self.adpt))

            self.assertTrue(pref.compute_ltm_enabled)
            self.assertTrue(pref.ltm_enabled)
            self.assertFalse(pref.stm_enabled)
            self.assertTrue(pref.aggregation_enabled)
            return element
        self.adpt.update.side_effect = validate_of_update

        # This will invoke the validate_of_update
        pvm_t_mon.ensure_ltm_monitors(self.adpt, 'host_uuid', compute_ltm=True,
                                      override_to_default=True)

        # Make sure the update was in fact invoked though
        self.assertEqual(1, self.adpt.update.call_count)
Example #2
0
    def __init__(self):
        super(PowerVMInspector, self).__init__()

        # Build the adapter to the PowerVM API.
        self.adpt = pvm_adpt.Adapter(
            pvm_adpt.Session(), helpers=[log_hlp.log_helper,
                                         vio_hlp.vios_busy_retry_helper])

        # Get the host system UUID
        host_uuid = self._get_host_uuid(self.adpt)

        # Ensure that metrics gathering is running for the host.
        pvm_mon_util.ensure_ltm_monitors(self.adpt, host_uuid)

        # Get the VM Metric Utility
        self.vm_metrics = pvm_mon_util.LparMetricCache(self.adpt, host_uuid)