+ def _checkLabelExistOnHost(self, client, label_to_check, host_id,
+ check_value=False) -> bool:
+ labels = client.label.list(host_id)
+ if check_value:
+ return any(label_to_check['key'] == label.label_key and
+ label_to_check['value'] == label.label_value
+ for label in labels)
+ else:
+ return any(label_to_check['key'] == label.label_key
+ for label in labels)
+
+ def _checkLabelExistOnCluster(self, client, label_to_check,
+ check_value=False) -> bool:
+ hosts = client.ihost.list()
+ for host in hosts:
+ if self._checkLabelExistOnHost(client, label_to_check,
+ host.uuid, check_value):
+ if check_value:
+ logger.info(
+ f"host {host.hostname} has the label "
+ f"{label_to_check['key']} with value "
+ f"{label_to_check['value']}")
+ else:
+ logger.info(
+ f"host {host.hostname} has the label "
+ f"{label_to_check['key']}")
+ return True
+ return False
+
+ def _getK8sNodes(self, k8sclient):
+ return k8sclient.list_node()
+
+ def _getK8sNodeDetail(self, k8sclient, node_name):
+ return k8sclient.read_node(name=node_name)
+
+ def _getK8sCapabilities(self, k8s_client):
+ k8s_capabilities = {}
+ nodes = self._getK8sNodes(k8s_client)
+ for node in nodes.items:
+ logger.debug(f'k8s node {node.metadata.name} allocatable: '
+ f'{node.status.allocatable}')
+ for allocatable in node.status.allocatable:
+ if allocatable.startswith('intel.com/pci_sriov_net_'):
+ k8s_capabilities[f'{node.metadata.name}_sriov'] = True
+ if allocatable == 'windriver.com/isolcpus':
+ k8s_capabilities[f'{node.metadata.name}_isolcpus'] = True
+ return k8s_capabilities
+
+ def _setK8sCapabilities(self, k8scluster, client, k8s_client):
+ capabilities = {}
+ label_OS_2chk = {'key': 'OS', 'value': 'low_latency'}
+ if self._checkLabelExistOnCluster(client, label_OS_2chk, True):
+ logger.debug("low latency host inside of the k8s cluster")
+ capabilities[label_OS_2chk['key']] = label_OS_2chk['value']