Exemple #1
0
 def test_obj_cell_relationships(self):
     obj = objects.NUMATopology(cells=[objects.NUMACell()])
     rel = objects.NUMATopology.obj_relationships['cells']
     for topo_ver, cell_ver in rel:
         prim = obj.obj_to_primitive(target_version=topo_ver)
         cell = objects.NUMATopology.obj_from_primitive(prim).cells[0]
         self.assertEqual(cell_ver, cell.VERSION)
Exemple #2
0
    def test_to_legacy_limits(self):
        limits = objects.NUMATopologyLimits(cpu_allocation_ratio=16,
                                            ram_allocation_ratio=2)
        host_topo = objects.NUMATopology(
            cells=[objects.NUMACell(id=0, cpuset=set([1, 2]), memory=1024)])

        old_style = {
            'cells': [{
                'mem': {
                    'total': 1024,
                    'limit': 2048.0
                },
                'id': 0,
                'cpus': '1,2',
                'cpu_limit': 32.0
            }]
        }
        self.assertEqual(old_style, limits.to_dict_legacy(host_topo))
Exemple #3
0
 def _fake_resources(self, values=None):
     resources = {
         'memory_mb':
         2048,
         'memory_mb_used':
         0,
         'free_ram_mb':
         2048,
         'local_gb':
         20,
         'local_gb_used':
         0,
         'free_disk_gb':
         20,
         'vcpus':
         2,
         'vcpus_used':
         0,
         'numa_topology':
         objects.NUMATopology(cells=[
             objects.NUMACell(id=1,
                              cpuset=set([1, 2]),
                              memory=512,
                              memory_usage=0,
                              cpu_usage=0,
                              mempages=[],
                              siblings=[],
                              pinned_cpus=set([])),
             objects.NUMACell(id=2,
                              cpuset=set([3, 4]),
                              memory=512,
                              memory_usage=0,
                              cpu_usage=0,
                              mempages=[],
                              siblings=[],
                              pinned_cpus=set([]))
         ])._to_json()
     }
     if values:
         resources.update(values)
     return resources
Exemple #4
0
 def test_free_cpus(self):
     obj = objects.NUMATopology(cells=[
         objects.NUMACell(id=0,
                          cpuset=set([1, 2]),
                          memory=512,
                          cpu_usage=2,
                          memory_usage=256,
                          pinned_cpus=set([1]),
                          siblings=[],
                          mempages=[]),
         objects.NUMACell(id=1,
                          cpuset=set([3, 4]),
                          memory=512,
                          cpu_usage=1,
                          memory_usage=128,
                          pinned_cpus=set([]),
                          siblings=[],
                          mempages=[])
     ])
     self.assertEqual(set([2]), obj.cells[0].free_cpus)
     self.assertEqual(set([3, 4]), obj.cells[1].free_cpus)
Exemple #5
0
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.
"""
Fakes For Scheduler tests.
"""

from patron import objects
from patron.scheduler import host_manager

NUMA_TOPOLOGY = objects.NUMATopology(
                           cells=[objects.NUMACell(
                                      id=0, cpuset=set([1, 2]), memory=512,
                               cpu_usage=0, memory_usage=0, mempages=[],
                               siblings=[], pinned_cpus=set([])),
                                  objects.NUMACell(
                                      id=1, cpuset=set([3, 4]), memory=512,
                                cpu_usage=0, memory_usage=0, mempages=[],
                               siblings=[], pinned_cpus=set([]))])

COMPUTE_NODES = [
        objects.ComputeNode(
            id=1, local_gb=1024, memory_mb=1024, vcpus=1,
            disk_available_least=None, free_ram_mb=512, vcpus_used=1,
            free_disk_gb=512, local_gb_used=0, updated_at=None,
            host='host1', hypervisor_hostname='node1', host_ip='127.0.0.1',
            hypervisor_version=0, numa_topology=None,
            hypervisor_type='foo', supported_hv_specs=[],
            pci_device_pools=None, cpu_info=None, stats=None, metrics=None),
        objects.ComputeNode(
Exemple #6
0
NOW = timeutils.utcnow().replace(microsecond=0)
fake_stats = {'num_foo': '10'}
fake_stats_db_format = jsonutils.dumps(fake_stats)
# host_ip is coerced from a string to an IPAddress
# but needs to be converted to a string for the database format
fake_host_ip = '127.0.0.1'
fake_numa_topology = objects.NUMATopology(cells=[
    objects.NUMACell(id=0,
                     cpuset=set([1, 2]),
                     memory=512,
                     cpu_usage=0,
                     memory_usage=0,
                     mempages=[],
                     pinned_cpus=set([]),
                     siblings=[]),
    objects.NUMACell(id=1,
                     cpuset=set([3, 4]),
                     memory=512,
                     cpu_usage=0,
                     memory_usage=0,
                     mempages=[],
                     pinned_cpus=set([]),
                     siblings=[])
])
fake_numa_topology_db_format = fake_numa_topology._to_json()
fake_hv_spec = hv_spec.HVSpec(arch='foo', hv_type='bar', vm_mode='foobar')
fake_supported_hv_specs = [fake_hv_spec]
# for backward compatibility, each supported instance object
# is stored as a list in the database
fake_supported_hv_specs_db_format = jsonutils.dumps([fake_hv_spec.to_list()])
fake_pci = jsonutils.dumps(fake_pci_device_pools.fake_pool_list_primitive)