Do not check NFV features for old envs

NFV features (DPDK, SR-IOV, NUMA/CPU pinning, HugePages)
can't be checked for old clusters, due to old nailgun-agent.
Old nailgun-agent doesn't send NFV specific information.
So all NFV related checks and functional should be disabled for old
environments.

Change-Id: Ib589d67658f45414b8049398316af5c7298d459e
Closes-Bug: #1594443
This commit is contained in:
Artur Svechnikov 2016-06-23 23:31:08 +03:00
parent ccbf21b15c
commit 79e28facc8
7 changed files with 74 additions and 23 deletions

View File

@ -422,6 +422,9 @@ FUEL_MULTIPLE_FLOATING_IP_RANGES = '8.0'
# version of Fuel when LCM was introduced
FUEL_LCM_AVAILABLE = '9.0'
# version of Fuel when NFV was introduced
FUEL_NFV_AVAILABLE_SINCE = '9.0'
# this file is provided by the fuel-release package
FUEL_RELEASE_FILE = '/etc/fuel_release'

View File

@ -1028,7 +1028,9 @@ class Node(NailgunObject):
def get_kernel_params(cls, instance):
"""Get kernel params.
Assemble kernel_params if they weren't replaced by custom params.
Returns kernel_params if they were replaced by custom ones.
Otherwise assemble kernel_params from cluster default
and node specific params: hugepages, sriov, isolcpus.
"""
if instance.kernel_params:
@ -1036,23 +1038,24 @@ class Node(NailgunObject):
kernel_params = Cluster.get_default_kernel_params(instance.cluster)
# Add intel_iommu=on amd_iommu=on if SR-IOV is enabled on node
for nic in instance.nic_interfaces:
if NIC.is_sriov_enabled(nic):
if 'intel_iommu=' not in kernel_params:
kernel_params += ' intel_iommu=on'
if 'amd_iommu=' not in kernel_params:
kernel_params += ' amd_iommu=on'
break
if Release.is_nfv_supported(instance.cluster.release):
# Add intel_iommu=on amd_iommu=on if SR-IOV is enabled on node
for nic in instance.nic_interfaces:
if NIC.is_sriov_enabled(nic):
if 'intel_iommu=' not in kernel_params:
kernel_params += ' intel_iommu=on'
if 'amd_iommu=' not in kernel_params:
kernel_params += ' amd_iommu=on'
break
if 'hugepages' not in kernel_params:
kernel_params += NodeAttributes.hugepages_kernel_opts(instance)
if 'hugepages' not in kernel_params:
kernel_params += NodeAttributes.hugepages_kernel_opts(instance)
isolated_cpus = NodeAttributes.distribute_node_cpus(
instance)['isolated_cpus']
if isolated_cpus and 'isolcpus' not in kernel_params:
kernel_params += " isolcpus={0}".format(
",".join(six.moves.map(str, isolated_cpus)))
isolated_cpus = NodeAttributes.distribute_node_cpus(
instance)['isolated_cpus']
if isolated_cpus and 'isolcpus' not in kernel_params:
kernel_params += " isolcpus={0}".format(
",".join(six.moves.map(str, isolated_cpus)))
return kernel_params

View File

@ -164,6 +164,16 @@ class Release(NailgunObject):
return (StrictVersion(instance.environment_version) >=
StrictVersion(consts.FUEL_MULTIPLE_FLOATING_IP_RANGES))
@classmethod
def is_nfv_supported(cls, instance):
"""Check if nfv features are available for release
:param instance: a Release instance
:return: boolean
"""
return (StrictVersion(instance.environment_version)
>= StrictVersion(consts.FUEL_NFV_AVAILABLE_SINCE))
@classmethod
def get_deployment_tasks(cls, instance, graph_type=None):
"""Get deployment graph based on release version.

View File

@ -1474,8 +1474,11 @@ class CheckBeforeDeploymentTask(object):
cls._check_public_network(task)
cls._check_vmware_consistency(task)
cls._validate_network_template(task)
cls._check_sriov_properties(task)
cls._check_dpdk_properties(task)
# TODO(asvechnikov): Make an appropriate versioning of tasks
if objects.Release.is_nfv_supported(task.cluster.release):
cls._check_sriov_properties(task)
cls._check_dpdk_properties(task)
if objects.Release.is_external_mongo_enabled(task.cluster.release):
cls._check_mongo_nodes(task)

View File

@ -408,7 +408,7 @@ class TestProvisioningSerializer90(BaseIntegrationTest):
def test_user_account_info(self):
self.cluster_db = self.env.create(
release_kwargs={'version': 'liberty-9.0'},
release_kwargs={'version': 'mitaka-9.0'},
)
self.env.create_nodes_w_interfaces_count(
1, 1,
@ -469,7 +469,7 @@ class TestProvisioningSerializer90(BaseIntegrationTest):
def test_serialize_iommu_parameters_for_sriov(self):
cluster = self.env.create(
release_kwargs={
'version': 'liberty-9.0',
'version': 'mitaka-9.0',
'operating_system': consts.RELEASE_OS.ubuntu},
nodes_kwargs=[
{'roles': ['compute']}]
@ -489,7 +489,10 @@ class TestProvisioningSerializer90(BaseIntegrationTest):
def test_serialize_node_hugepages(self):
self.env.create(
api=False,
release_kwargs={'operating_system': consts.RELEASE_OS.ubuntu},
release_kwargs={
'operating_system': consts.RELEASE_OS.ubuntu,
'version': 'mitaka-9.0',
},
nodes_kwargs=[
{'roles': ['compute']}])
@ -506,7 +509,10 @@ class TestProvisioningSerializer90(BaseIntegrationTest):
def test_serialize_node_cpu_pinning(self):
self.env.create(
api=False,
release_kwargs={'operating_system': consts.RELEASE_OS.ubuntu},
release_kwargs={
'operating_system': consts.RELEASE_OS.ubuntu,
'version': 'mitaka-9.0',
},
nodes_kwargs=[
{'roles': ['compute']}])

View File

@ -274,7 +274,7 @@ class TestNodeObject(BaseIntegrationTest):
)
)
def test_get_kernel_params_overwriten(self):
def test_get_kernel_params_overwritten(self):
"""Test verifies that overwriten kernel params will be returned."""
cluster = self.env.create(
nodes_kwargs=[
@ -293,6 +293,20 @@ class TestNodeObject(BaseIntegrationTest):
objects.Node.get_kernel_params(self.env.nodes[0]),
kernel_params)
def test_get_kernel_params_w_old_release(self):
cluster = self.env.create(
release_kwargs={
'operating_system': consts.RELEASE_OS.ubuntu,
'version': '2015.1.0-8.0',
},
nodes_kwargs=[
{"role": "compute"}
]
)
node = cluster.nodes[0]
del node.meta['numa_topology']
self.assertNotRaises(KeyError, objects.Node.get_kernel_params, node)
def test_should_have_public_with_ip(self):
nodes = [
{'roles': ['controller', 'cinder'], 'pending_addition': True},

View File

@ -679,6 +679,18 @@ class TestCheckBeforeDeploymentTask(BaseTestCase):
with self.assertRaisesRegexp(errors.CheckBeforeDeploymentError, msg):
task.CheckBeforeDeploymentTask._check_vmware_consistency(self.task)
@mock.patch.object(
task, 'fire_callback_on_before_deployment_check')
@mock.patch.object(
task.CheckBeforeDeploymentTask, '_check_sriov_properties')
@mock.patch.object(
task.CheckBeforeDeploymentTask, '_check_dpdk_properties')
def test_execute_w_old_release(self, dpdk_m, sriov_m, callback_m):
task.CheckBeforeDeploymentTask.execute(self.task)
callback_m.assert_called_once_with(self.cluster)
self.assertEqual(0, dpdk_m.call_count)
self.assertEqual(0, sriov_m.call_count)
class TestDeployTask(BaseTestCase):