def test_numa_topology_online_migration_when_load(self):
        """Ensure legacy NUMA topology objects are reserialized to o.vo's."""
        cn = fake_compute_obj.obj_clone()
        cn._context = self.context
        cn.create()

        legacy_topology = jsonutils.dumps({
            "cells": [
                {
                    "id": 0,
                    "cpus": "0-3",
                    "mem": {"total": 512, "used": 256},
                    "cpu_usage": 2,
                },
                {
                    "id": 1,
                    "cpus": "4,5,6,7",
                    "mem": {"total": 512, "used": 0},
                    "cpu_usage": 0,
                }
            ]
        })
        db.compute_node_update(
            self.context, cn.id, {'numa_topology': legacy_topology})

        cn_db = db.compute_node_get(self.context, cn.id)
        self.assertEqual(legacy_topology, cn_db['numa_topology'])
        self.assertNotIn('nova_object.name', cn_db['numa_topology'])

        # trigger online migration
        objects.ComputeNodeList.get_all(self.context)

        cn_db = db.compute_node_get(self.context, cn.id)
        self.assertNotEqual(legacy_topology, cn_db['numa_topology'])
        self.assertIn('nova_object.name', cn_db['numa_topology'])
Example #2
0
    def _create_zero_and_none_cn(self):
        cn1 = fake_compute_obj.obj_clone()
        cn1._context = self.context
        cn1.create()

        db.compute_node_update(
            self.context, cn1.id, {
                'cpu_allocation_ratio': 0.0,
                'disk_allocation_ratio': 0.0,
                'ram_allocation_ratio': 0.0
            })
        cn1_db = db.compute_node_get(self.context, cn1.id)
        for x in ['cpu', 'disk', 'ram']:
            self.assertEqual(0.0, cn1_db['%s_allocation_ratio' % x])

        cn2 = fake_compute_obj.obj_clone()
        cn2._context = self.context
        cn2.host += '-alt'
        cn2.create()
        # We can't set a cn_obj.xxx_allocation_ratio to None,
        # so we set ratio to None in db directly
        db.compute_node_update(
            self.context, cn2.id, {
                'cpu_allocation_ratio': None,
                'disk_allocation_ratio': None,
                'ram_allocation_ratio': None
            })
        cn2_db = db.compute_node_get(self.context, cn2.id)
        for x in ['cpu', 'disk', 'ram']:
            self.assertIsNone(None, cn2_db['%s_allocation_ratio' % x])
Example #3
0
    def _create_zero_and_none_cn(self):
        cn1 = fake_compute_obj.obj_clone()
        cn1._context = self.context
        cn1.create()

        db.compute_node_update(self.context, cn1.id,
                               {'cpu_allocation_ratio': 0.0,
                                'disk_allocation_ratio': 0.0,
                                'ram_allocation_ratio': 0.0})
        cn1_db = db.compute_node_get(self.context, cn1.id)
        for x in ['cpu', 'disk', 'ram']:
            self.assertEqual(0.0, cn1_db['%s_allocation_ratio' % x])

        cn2 = fake_compute_obj.obj_clone()
        cn2._context = self.context
        cn2.host += '-alt'
        cn2.create()
        # We can't set a cn_obj.xxx_allocation_ratio to None,
        # so we set ratio to None in db directly
        db.compute_node_update(self.context, cn2.id,
                               {'cpu_allocation_ratio': None,
                                'disk_allocation_ratio': None,
                                'ram_allocation_ratio': None})
        cn2_db = db.compute_node_get(self.context, cn2.id)
        for x in ['cpu', 'disk', 'ram']:
            self.assertIsNone(None, cn2_db['%s_allocation_ratio' % x])
Example #4
0
 def get_by_id(cls, context, compute_id):
     db_compute = db.compute_node_get(context, compute_id)
     return cls._from_db_object(context, cls(), db_compute)