Merge "Revert "Semantic check for proper sriov plugin configuration""
This commit is contained in:
commit
773461c830
|
@ -6663,28 +6663,6 @@ class HostController(rest.RestController):
|
|||
% hostupdate.displayid)
|
||||
raise wsme.exc.ClientSideError(msg)
|
||||
|
||||
# Check if the label sriovdp is enabled and there are no
|
||||
# pci-sriov interfaces
|
||||
label = None
|
||||
try:
|
||||
label = pecan.request.dbapi.label_query(
|
||||
ihost['id'],
|
||||
constants.SRIOVDP_LABEL.split('=')[0])
|
||||
except exception.HostLabelNotFoundByKey:
|
||||
pass
|
||||
|
||||
if (label and label.label_value ==
|
||||
constants.SRIOVDP_LABEL.split('=')[1]):
|
||||
for iface in ihost_iinterfaces:
|
||||
if iface.ifclass == constants.NETWORK_TYPE_PCI_SRIOV:
|
||||
break
|
||||
else:
|
||||
msg = _("Cannot unlock host %s if the label '%s' is "
|
||||
"present and no '%s' interfaces are configured."
|
||||
% (hostupdate.displayid, constants.SRIOVDP_LABEL,
|
||||
constants.NETWORK_TYPE_PCI_SRIOV))
|
||||
raise wsme.exc.ClientSideError(msg)
|
||||
|
||||
hostupdate.configure_required = True
|
||||
|
||||
host_uuid = ihost['uuid']
|
||||
|
|
|
@ -2808,76 +2808,6 @@ class TestPatch(TestHost):
|
|||
# is required to populate the storage (OSDs) for the host.
|
||||
self.skipTest("Not yet implemented")
|
||||
|
||||
def _create_sriovdp_test_structure(self, add_label, add_iface):
|
||||
host = self._create_controller_0(
|
||||
invprovision=constants.PROVISIONED,
|
||||
administrative=constants.ADMIN_LOCKED,
|
||||
operational=constants.OPERATIONAL_ENABLED,
|
||||
availability=constants.AVAILABILITY_ONLINE)
|
||||
|
||||
self._create_test_host_platform_interface(host)
|
||||
|
||||
if add_label:
|
||||
sriovdp_key = constants.SRIOVDP_LABEL.split('=')[0]
|
||||
sriovdp_val = constants.SRIOVDP_LABEL.split('=')[1]
|
||||
dbutils.create_test_label(
|
||||
host_id=host.id,
|
||||
label_key=sriovdp_key,
|
||||
label_value=sriovdp_val)
|
||||
|
||||
if add_iface:
|
||||
interface = {
|
||||
'forihostid': host['id'],
|
||||
'ifname': 'sriov0',
|
||||
'iftype': constants.INTERFACE_TYPE_VF,
|
||||
'ifclass': constants.INTERFACE_CLASS_PCI_SRIOV
|
||||
}
|
||||
dbutils.create_test_interface(**interface)
|
||||
|
||||
return host
|
||||
|
||||
def test_unlock_with_sriovdp_label_without_sriov_ifaces(self):
|
||||
host = self._create_sriovdp_test_structure(add_label=True,
|
||||
add_iface=False)
|
||||
|
||||
response = self._patch_host_action(
|
||||
host['hostname'], constants.UNLOCK_ACTION, 'sysinv-test',
|
||||
expect_errors=True)
|
||||
self.assertEqual(response.status_code, http_client.BAD_REQUEST)
|
||||
self.assertTrue(response.json['error_message'])
|
||||
self.assertIn("Cannot unlock host %s if the label '%s' is present "
|
||||
"and no '%s' interfaces are configured." %
|
||||
(host['hostname'], constants.SRIOVDP_LABEL,
|
||||
constants.INTERFACE_CLASS_PCI_SRIOV),
|
||||
response.json['error_message'])
|
||||
|
||||
def test_unlock_with_sriovdp_label_with_sriov_iface(self):
|
||||
host = self._create_sriovdp_test_structure(add_label=True,
|
||||
add_iface=True)
|
||||
|
||||
response = self._patch_host_action(
|
||||
host['hostname'], constants.UNLOCK_ACTION, 'sysinv-test')
|
||||
self.assertEqual(response.content_type, 'application/json')
|
||||
self.assertEqual(response.status_code, http_client.OK)
|
||||
|
||||
def test_unlock_without_sriovdp_label_without_sriov_ifaces(self):
|
||||
host = self._create_sriovdp_test_structure(add_label=False,
|
||||
add_iface=False)
|
||||
|
||||
response = self._patch_host_action(
|
||||
host['hostname'], constants.UNLOCK_ACTION, 'sysinv-test')
|
||||
self.assertEqual(response.content_type, 'application/json')
|
||||
self.assertEqual(response.status_code, http_client.OK)
|
||||
|
||||
def test_unlock_without_sriovdp_label_with_sriov_iface(self):
|
||||
host = self._create_sriovdp_test_structure(add_label=False,
|
||||
add_iface=True)
|
||||
|
||||
response = self._patch_host_action(
|
||||
host['hostname'], constants.UNLOCK_ACTION, 'sysinv-test')
|
||||
self.assertEqual(response.content_type, 'application/json')
|
||||
self.assertEqual(response.status_code, http_client.OK)
|
||||
|
||||
def test_worker_unlock_during_kernel_configuration(self):
|
||||
# Create controller-0
|
||||
self._create_controller_0(
|
||||
|
|
Loading…
Reference in New Issue