Example #1
0
    def test_null_data_source(self):
        """
        By default, the NFVI metrics plugin mock installs a 'null'
        implementation that simply returns empty NFVI structures.

        """
        status, metrics = self.plugin.nfvi_metrics(self.account, self.vim_id)
        self.assertEqual(status, RwTypes.RwStatus.SUCCESS)
        self.assertEqual(metrics, RwmonYang.NfviMetrics())

        status, metrics = self.plugin.nfvi_vcpu_metrics(self.account, self.vim_id)
        self.assertEqual(status, RwTypes.RwStatus.SUCCESS)
        self.assertEqual(metrics, RwmonYang.NfviMetrics_Vcpu())

        status, metrics = self.plugin.nfvi_memory_metrics(self.account, self.vim_id)
        self.assertEqual(status, RwTypes.RwStatus.SUCCESS)
        self.assertEqual(metrics, RwmonYang.NfviMetrics_Memory())

        status, metrics = self.plugin.nfvi_storage_metrics(self.account, self.vim_id)
        self.assertEqual(status, RwTypes.RwStatus.SUCCESS)
        self.assertEqual(metrics, RwmonYang.NfviMetrics_Storage())

        status, result = self.plugin.nfvi_metrics_available(self.account)
        self.assertEqual(status, RwTypes.RwStatus.SUCCESS)
        self.assertTrue(result)
Example #2
0
    def do_nfvi_vcpu_metrics(self, account, vm_id):
        try:
            samples = self._get_driver(account).ceilo_nfvi_metrics(vm_id)

            metrics = RwmonYang.NfviMetrics_Vcpu()
            metrics.utilization = samples.get("cpu_util", 0)

            return metrics

        except Exception as e:
            logger.exception(e)
Example #3
0
    def test_mock_data_source(self):
        """
        This test installs a mock data source implementation in the plugin,
        which returns known values. This test simply checks the expected values
        are indeed returned.

        """
        expected_vcpu_metrics = RwmonYang.NfviMetrics_Vcpu()
        expected_vcpu_metrics.utilization = 50.0
        expected_vcpu_metrics.total = 100

        status, metrics = self.plugin.nfvi_vcpu_metrics(self.account, self.vim_id)
        self.assertEqual(status, RwTypes.RwStatus.SUCCESS)
        self.assertEqual(metrics.total, expected_vcpu_metrics.total)
        self.assertEqual(metrics.utilization, expected_vcpu_metrics.utilization)

        expected_memory_metrics = RwmonYang.NfviMetrics_Memory()
        expected_memory_metrics.used = 90
        expected_memory_metrics.total = 100
        expected_memory_metrics.utilization = 90/100

        status, metrics = self.plugin.nfvi_memory_metrics(self.account, self.vim_id)
        self.assertEqual(status, RwTypes.RwStatus.SUCCESS)
        self.assertEqual(metrics.used, expected_memory_metrics.used)
        self.assertEqual(metrics.total, expected_memory_metrics.total)
        self.assertEqual(metrics.utilization, expected_memory_metrics.utilization)

        expected_storage_metrics = RwmonYang.NfviMetrics_Storage()
        expected_storage_metrics.used = 300
        expected_storage_metrics.total = 500
        expected_storage_metrics.utilization = 300/500

        status, metrics = self.plugin.nfvi_storage_metrics(self.account, self.vim_id)
        self.assertEqual(status, RwTypes.RwStatus.SUCCESS)
        self.assertEqual(metrics.used, expected_storage_metrics.used)
        self.assertEqual(metrics.total, expected_storage_metrics.total)
        self.assertEqual(metrics.utilization, expected_storage_metrics.utilization)

        status, metrics = self.plugin.nfvi_metrics(self.account, self.vim_id)
        self.assertEqual(status, RwTypes.RwStatus.SUCCESS)
        self.assertEqual(metrics.vcpu.total, expected_vcpu_metrics.total)
        self.assertEqual(metrics.vcpu.utilization, expected_vcpu_metrics.utilization)
        self.assertEqual(metrics.storage.used, expected_storage_metrics.used)
        self.assertEqual(metrics.storage.total, expected_storage_metrics.total)
        self.assertEqual(metrics.storage.utilization, expected_storage_metrics.utilization)
        self.assertEqual(metrics.memory.used, expected_memory_metrics.used)
        self.assertEqual(metrics.memory.total, expected_memory_metrics.total)
        self.assertEqual(metrics.memory.utilization, expected_memory_metrics.utilization)

        status, result = self.plugin.nfvi_metrics_available(self.account)
        self.assertEqual(status, RwTypes.RwStatus.SUCCESS)
        self.assertTrue(result)
Example #4
0
 def nfvi_vcpu_metrics(self, account, vm_id):
     metrics = RwmonYang.NfviMetrics_Vcpu()
     metrics.total = 100
     metrics.utilization = 50.0
     return metrics
Example #5
0
 def nfvi_vcpu_metrics(self, account, vm_id):
     return rwmon.NfviMetrics_Vcpu()