Add SRIOV validation to CheckBeforeDeploymentTask
Hypervisor type should be checked on pre-deployment stage as only KVM hypervisor is compatible with SRIOV feature. Change-Id: Ideec889ade22ab7736a84644f8376f6f2a2e68f0 Partial-bug: #1563254
This commit is contained in:
parent
253f0fe201
commit
8b3cec96be
|
@ -1213,6 +1213,13 @@ class Node(NailgunObject):
|
|||
return True
|
||||
return False
|
||||
|
||||
@classmethod
|
||||
def sriov_enabled(cls, instance):
|
||||
for iface in instance.nic_interfaces:
|
||||
if NIC.is_sriov_enabled(iface):
|
||||
return True
|
||||
return False
|
||||
|
||||
@classmethod
|
||||
def get_attributes(cls, instance):
|
||||
return copy.deepcopy(instance.attributes)
|
||||
|
|
|
@ -1315,6 +1315,7 @@ class CheckBeforeDeploymentTask(object):
|
|||
cls._check_vmware_consistency(task)
|
||||
cls._validate_network_template(task)
|
||||
cls._check_deployment_graph_for_correctness(task)
|
||||
cls._check_sriov_properties(task)
|
||||
|
||||
if objects.Release.is_external_mongo_enabled(task.cluster.release):
|
||||
cls._check_mongo_nodes(task)
|
||||
|
@ -1615,6 +1616,20 @@ class CheckBeforeDeploymentTask(object):
|
|||
deployment_tasks)
|
||||
graph_validator.check()
|
||||
|
||||
@classmethod
|
||||
def _check_sriov_properties(self, task):
|
||||
# check hypervisor type
|
||||
h_type = objects.Cluster.get_editable_attributes(
|
||||
task.cluster)['common']['libvirt_type']['value']
|
||||
|
||||
for node in task.cluster.nodes:
|
||||
if not objects.Node.sriov_enabled(node):
|
||||
continue
|
||||
|
||||
if h_type != consts.HYPERVISORS.kvm:
|
||||
raise errors.InvalidData(
|
||||
'Only KVM hypervisor works with SRIOV.')
|
||||
|
||||
|
||||
class DumpTask(object):
|
||||
@classmethod
|
||||
|
|
|
@ -285,7 +285,14 @@ class TestCheckBeforeDeploymentTask(BaseTestCase):
|
|||
release_kwargs={'version': '1111-8.0'},
|
||||
cluster_kwargs={
|
||||
'net_provider': 'neutron',
|
||||
'net_segment_type': 'gre'
|
||||
'net_segment_type': 'vlan',
|
||||
'editable_attributes': {
|
||||
'common': {
|
||||
'libvirt_type': {
|
||||
'value': consts.HYPERVISORS.qemu
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
nodes_kwargs=[{'roles': ['controller']}])
|
||||
|
||||
|
@ -463,6 +470,23 @@ class TestCheckBeforeDeploymentTask(BaseTestCase):
|
|||
self.task
|
||||
)
|
||||
|
||||
def test_sriov_is_enabled_with_non_kvm_hypervisor(self):
|
||||
objects.NIC.update(self.node.nic_interfaces[0],
|
||||
{'interface_properties':
|
||||
{
|
||||
'sriov': {'enabled': True,
|
||||
'sriov_totalvfs': 4,
|
||||
'sriov_numfs': 2,
|
||||
'available': True},
|
||||
}})
|
||||
|
||||
self.assertRaisesRegexp(
|
||||
errors.InvalidData,
|
||||
'Only KVM hypervisor works with SRIOV',
|
||||
task.CheckBeforeDeploymentTask._check_sriov_properties,
|
||||
self.task,
|
||||
)
|
||||
|
||||
def test_check_public_networks(self):
|
||||
cluster = self.env.clusters[0]
|
||||
self.env.create_nodes(
|
||||
|
|
Loading…
Reference in New Issue