diff --git a/nailgun/nailgun/consts.py b/nailgun/nailgun/consts.py index 4900ec0698..b7a237d0ad 100644 --- a/nailgun/nailgun/consts.py +++ b/nailgun/nailgun/consts.py @@ -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' diff --git a/nailgun/nailgun/objects/node.py b/nailgun/nailgun/objects/node.py index 002f9a9ff8..6b70db914f 100644 --- a/nailgun/nailgun/objects/node.py +++ b/nailgun/nailgun/objects/node.py @@ -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 diff --git a/nailgun/nailgun/objects/release.py b/nailgun/nailgun/objects/release.py index 5ce8b0d52e..6b4fdaa3c1 100644 --- a/nailgun/nailgun/objects/release.py +++ b/nailgun/nailgun/objects/release.py @@ -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. diff --git a/nailgun/nailgun/task/task.py b/nailgun/nailgun/task/task.py index 6cce104866..9417c50ddc 100644 --- a/nailgun/nailgun/task/task.py +++ b/nailgun/nailgun/task/task.py @@ -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) diff --git a/nailgun/nailgun/test/integration/test_provisioning_serializer.py b/nailgun/nailgun/test/integration/test_provisioning_serializer.py index 15f3a3141e..23f89fa9f5 100644 --- a/nailgun/nailgun/test/integration/test_provisioning_serializer.py +++ b/nailgun/nailgun/test/integration/test_provisioning_serializer.py @@ -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']}]) diff --git a/nailgun/nailgun/test/unit/test_objects.py b/nailgun/nailgun/test/unit/test_objects.py index 38687aeebc..640b3e56fc 100644 --- a/nailgun/nailgun/test/unit/test_objects.py +++ b/nailgun/nailgun/test/unit/test_objects.py @@ -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}, diff --git a/nailgun/nailgun/test/unit/test_task.py b/nailgun/nailgun/test/unit/test_task.py index 5f6721cf35..5b96579e0c 100644 --- a/nailgun/nailgun/test/unit/test_task.py +++ b/nailgun/nailgun/test/unit/test_task.py @@ -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):