def validate_nodes_devices(node_device_dict, adding_nodes_to_sbd_enabled_cluster=False): """ Validates device list for all nodes. If node is present, it checks if there is at least one device and at max settings.sbd_max_device_num. Also devices have to be specified with absolute path. Returns list of ReportItem dict node_device_dict -- name: node name, key: list of SBD devices bool adding_nodes_to_sbd_enabled_cluster -- provides context to reports """ report_item_list = [] for node_label, device_list in node_device_dict.items(): if not device_list: report_item_list.append( reports.sbd_no_device_for_node( node_label, sbd_enabled_in_cluster=adding_nodes_to_sbd_enabled_cluster) ) elif len(device_list) > settings.sbd_max_device_num: report_item_list.append( reports.sbd_too_many_devices_for_node( node_label, device_list, settings.sbd_max_device_num)) for device in device_list: if not device or not path.isabs(device): report_item_list.append( reports.sbd_device_path_not_absolute(device, node_label)) return report_item_list
def _validate_device_dict(node_device_dict): """ Validates device list for all nodes. If node is present, it checks if there is at least one device and at max settings.sbd_max_device_num. Also devices have to be specified with absolute path. Returns list of ReportItem node_device_dict -- dictionary with NodeAddresses as keys and list of devices as values """ report_item_list = [] for node_label, device_list in node_device_dict.items(): if not device_list: report_item_list.append( reports.sbd_no_device_for_node(node_label) ) continue elif len(device_list) > settings.sbd_max_device_num: report_item_list.append(reports.sbd_too_many_devices_for_node( node_label, device_list, settings.sbd_max_device_num )) continue for device in device_list: if not device or not os.path.isabs(device): report_item_list.append( reports.sbd_device_path_not_absolute(device, node_label) ) return report_item_list
def validate_nodes_devices( node_device_dict, adding_nodes_to_sbd_enabled_cluster=False ): """ Validates device list for all nodes. If node is present, it checks if there is at least one device and at max settings.sbd_max_device_num. Also devices have to be specified with absolute path. Returns list of ReportItem dict node_device_dict -- name: node name, key: list of SBD devices bool adding_nodes_to_sbd_enabled_cluster -- provides context to reports """ report_item_list = [] for node_label, device_list in node_device_dict.items(): if not device_list: report_item_list.append( reports.sbd_no_device_for_node( node_label, sbd_enabled_in_cluster=adding_nodes_to_sbd_enabled_cluster ) ) elif len(device_list) > settings.sbd_max_device_num: report_item_list.append(reports.sbd_too_many_devices_for_node( node_label, device_list, settings.sbd_max_device_num )) for device in device_list: if not device or not path.isabs(device): report_item_list.append( reports.sbd_device_path_not_absolute(device, node_label) ) return report_item_list