Merge "Ensure that 'dpdk' in serialization before update"

This commit is contained in:
Jenkins 2017-01-18 09:11:58 +00:00 committed by Gerrit Code Review
commit 8131924e6d
2 changed files with 30 additions and 1 deletions

View File

@ -601,7 +601,8 @@ class DeploymentHASerializer90(DeploymentHASerializer80):
cpu_pinning.pop('ovs_pmd_core_mask', [])
)
# Allow user to override CPU distribution using attributes
serialized_node.get('dpdk').update(objects.Node.get_attributes(node)
if 'dpdk' in serialized_node:
serialized_node['dpdk'].update(objects.Node.get_attributes(node)
.get('dpdk', {}))
serialized_node['cpu_pinning'] = cpu_pinning

View File

@ -422,6 +422,34 @@ class TestDeploymentAttributesSerialization90(
node_common_attrs = network_data['nodes'][node_name]
self.assertFalse(node_common_attrs['nova_cpu_pinning_enabled'])
def test_pinning_cpu_for_nova(self):
numa_nodes = [
{'id': 0, 'memory': 2 ** 31, 'cpus': [1, 2, 3, 4]},
{'id': 1, 'memory': 2 ** 31, 'cpus': [5, 6, 7, 8]}
]
node = self.env.create_node(
cluster_id=self.cluster_db.id,
roles=['compute'])
node.meta['numa_topology']['numa_nodes'] = numa_nodes
node.attributes.update({
'cpu_pinning': {
'nova': {'value': 2},
}
})
objects.Cluster.prepare_for_deployment(self.cluster_db)
serialized_for_astute = self.serializer.serialize(
self.cluster_db, self.cluster_db.nodes)
serialized_node = serialized_for_astute['nodes'][0]
self.assertNotIn('dpdk', serialized_node)
self.assertEqual(serialized_node['nova']['cpu_pinning'], [1, 2])
node_name = objects.Node.get_slave_name(node)
network_data = serialized_for_astute['common']['network_metadata']
node_common_attrs = network_data['nodes'][node_name]
self.assertTrue(node_common_attrs['nova_cpu_pinning_enabled'])
def test_attributes_override_core_mask(self):
numa_nodes = [
{'id': 0, 'memory': 2 ** 31, 'cpus': [1, 2, 3, 4]},