Beispiel #1
0
    def _get_available_resource(self):
        # Get host information
        data = pvm_host.build_host_resource_from_ms(self.host_wrapper)

        # Add the disk information
        data["local_gb"] = self.disk_dvr.capacity
        data["local_gb_used"] = self.disk_dvr.capacity_used

        return data
Beispiel #2
0
    def _get_available_resource(self):
        # Get host information
        data = pvm_host.build_host_resource_from_ms(self.host_wrapper)

        # Add the disk information
        data["local_gb"] = self.disk_dvr.capacity
        data["local_gb_used"] = self.disk_dvr.capacity_used

        return data
Beispiel #3
0
    def test_host_resources(self):
        # Create objects to test with
        ms_wrapper = mock.create_autospec(pvm_ms.System, spec_set=True)
        mtms = mock.create_autospec(pvm_mtms.MTMS, spec_set=True)
        mtms.configure_mock(mtms_str='8484923A123456')
        asio = mock.create_autospec(pvm_ms.ASIOConfig, spec_set=True)
        ms_wrapper.configure_mock(
            proc_units_configurable=500,
            proc_units_avail=500,
            memory_configurable=5242880,
            memory_free=5242752,
            mtms=mtms,
            memory_region_size='big',
            asio_config=asio)

        # Run the actual test
        stats = pvm_host.build_host_resource_from_ms(ms_wrapper)
        self.assertIsNotNone(stats)

        # Check for the presence of fields
        fields = (('vcpus', 500), ('vcpus_used', 0),
                  ('memory_mb', 5242880), ('memory_mb_used', 128),
                  'hypervisor_type', 'hypervisor_version',
                  'hypervisor_hostname', 'cpu_info',
                  'supported_instances', 'stats')
        for fld in fields:
            if isinstance(fld, tuple):
                value = stats.get(fld[0], None)
                self.assertEqual(value, fld[1])
            else:
                value = stats.get(fld, None)
                self.assertIsNotNone(value)
        # Check for individual stats
        hstats = (('proc_units', '500.00'), ('proc_units_used', '0.00'))
        for stat in hstats:
            if isinstance(stat, tuple):
                value = stats['stats'].get(stat[0], None)
                self.assertEqual(value, stat[1])
            else:
                value = stats['stats'].get(stat, None)
                self.assertIsNotNone(value)
Beispiel #4
0
    def test_host_resources(self):
        # Create objects to test with
        ms_wrapper = mock.create_autospec(pvm_ms.System, spec_set=True)
        asio = mock.create_autospec(pvm_ms.ASIOConfig, spec_set=True)
        ms_wrapper.configure_mock(
            proc_units_configurable=500,
            proc_units_avail=500,
            memory_configurable=5242880,
            memory_free=5242752,
            memory_region_size='big',
            asio_config=asio)
        self.flags(host='the_hostname')

        # Run the actual test
        stats = pvm_host.build_host_resource_from_ms(ms_wrapper)
        self.assertIsNotNone(stats)

        # Check for the presence of fields
        fields = (('vcpus', 500), ('vcpus_used', 0),
                  ('memory_mb', 5242880), ('memory_mb_used', 128),
                  'hypervisor_type', 'hypervisor_version',
                  ('hypervisor_hostname', 'the_hostname'), 'cpu_info',
                  'supported_instances', 'stats')
        for fld in fields:
            if isinstance(fld, tuple):
                value = stats.get(fld[0], None)
                self.assertEqual(value, fld[1])
            else:
                value = stats.get(fld, None)
                self.assertIsNotNone(value)
        # Check for individual stats
        hstats = (('proc_units', '500.00'), ('proc_units_used', '0.00'))
        for stat in hstats:
            if isinstance(stat, tuple):
                value = stats['stats'].get(stat[0], None)
                self.assertEqual(value, stat[1])
            else:
                value = stats['stats'].get(stat, None)
                self.assertIsNotNone(value)
Beispiel #5
0
    def get_available_resource(self, nodename):
        """Retrieve resource information.

        This method is called when nova-compute launches, and as part of a
        periodic task.

        :param nodename: Node from which the caller wants to get resources.
                         A driver that manages only one node can safely ignore
                         this.
        :return: Dictionary describing resources.
        """
        # TODO(efried): Switch to get_inventory, per blueprint
        #               custom-resource-classes-pike
        # Do this here so it refreshes each time this method is called.
        self.host_wrapper = pvm_ms.System.get(self.adapter)[0]
        # Get host information
        data = host.build_host_resource_from_ms(self.host_wrapper)
        # Add the disk information
        # TODO(efried): Get real stats when disk support is added.
        data["local_gb"] = 100000
        data["local_gb_used"] = 10
        return data
Beispiel #6
0
    def get_available_resource(self, nodename):
        """Retrieve resource information.

        This method is called when nova-compute launches, and as part of a
        periodic task.

        :param nodename: Node from which the caller wants to get resources.
                         A driver that manages only one node can safely ignore
                         this.
        :return: Dictionary describing resources.
        """
        # TODO(efried): Switch to get_inventory, per blueprint
        #               custom-resource-classes-pike
        # Do this here so it refreshes each time this method is called.
        self.host_wrapper = pvm_ms.System.get(self.adapter)[0]
        # Get host information
        data = pvm_host.build_host_resource_from_ms(self.host_wrapper)

        # Add the disk information
        data["local_gb"] = self.disk_dvr.capacity
        data["local_gb_used"] = self.disk_dvr.capacity_used

        return data