def _device_has_ibft_connection(self, device): ac = device.get_active_connection() if ac: con = ac.get_connection() if is_ibft_connection(con): return True return False
def get_dracut_arguments(self, iface, target_ip, hostname, ibft): """Get dracut arguments for the iface and iSCSI target. The dracut arguments would activate the iface in initramfs so that the iSCSI target can be attached (for example to mount root filesystem). :param iface: network interface used to connect to the target :param target_ip: IP of the iSCSI target :param hostname: static hostname to be configured :param ibft: the device should be configured from iBFT """ log.debug("Getting dracut arguments for iface %s target %s (ibft==%s)", iface, target_ip, ibft) dracut_args = [] if not self.nm_available: log.debug( "Get dracut arguments: can't be obtained, no NetworkManager available." ) return dracut_args if iface and iface not in (device.get_iface() for device in self.nm_client.get_devices()): log.error("Get dracut arguments for %s: device not found", iface) return dracut_args connections = self.nm_client.get_connections() target_connections = [] if ibft: target_connections = [ con for con in connections if is_ibft_connection(con) ] else: for cfg in self._device_configurations.get_for_device(iface): uuid = cfg.connection_uuid if uuid: connection = self.nm_client.get_connection_by_uuid(uuid) if connection: target_connections.append(connection) if target_connections: if len(target_connections) > 1: log.debug( "Get dracut arguments: " "multiple connections found for traget %s: %s, taking the first one", [con.get_uuid() for con in target_connections], target_ip) connection = target_connections[0] else: log.error( "Get dracut arguments: can't find connection for target %s", target_ip) return dracut_args dracut_args = list( get_dracut_arguments_from_connection(self.nm_client, connection, iface, target_ip, hostname, ibft)) return dracut_args