Repository: cobbler/cobbler

Issue:
Kernel not found error message is not precise
### Describe the bug

During debugging an Uyuni Issue, @meaksh and I discovered that the error message actually is not fitting enough.

### Steps to reproduce

1. `cobbler distro add ...`
2. See error about a not found kernel

### Expected behavior

The error message reflects that it could also be the kernel regular expression that prevents the kernel from being accepted.

### Cobbler version

````paste below
````

### Operating system

openSUSE Leap 15.4

### Cobbler log

````paste below
[Thread-1058] 2022-07-12T12:39:42 - INFO | authenticate; ['taskomatic_user', True]
[Thread-1059] 2022-07-12T12:39:42 - INFO | REMOTE new_item(distro); user(taskomatic_user)
[Thread-1061] 2022-07-12T12:39:42 - INFO | Exception occurred: <class 'ValueError'>
[Thread-1061] 2022-07-12T12:39:42 - INFO | Exception value: kernel not found: /srv/www/os-images/1/POS_Image_JeOS7_head-7.0.0-2/POS_Image_JeOS7_head.x86_64-7.0.0-5.3.18-150300.59.76-default.kernel
````

### Screenshots

None

### Additional information

The file is definitely present on the server:

```
suma-test-srv:~ # stat /srv/www/os-images/1/POS_Image_JeOS7_head-7.0.0-2/POS_Image_JeOS7_head.x86_64-7.0.0
  File: /srv/www/os-images/1/POS_Image_JeOS7_head-7.0.0-2/POS_Image_JeOS7_head.x86_64-7.0.0
...
 Change: 2022-07-12 12:39:22.125354739 +0200
 Birth: 2022-07-12 12:38:15.791356599 +0200

suma-test-srv:~ # stat /srv/www/os-images/1/POS_Image_JeOS7_head-7.0.0-2/POS_Image_JeOS7_head.x86_64-7.0.0.initrd.xz
  File: /srv/www/os-images/1/POS_Image_JeOS7_head-7.0.0-2/POS_Image_JeOS7_head.x86_64-7.0.0.initrd.xz
...
Change: 2022-07-12 12:39:31.517637348 +0200
 Birth: 2022-07-12 12:39:28.157536243 +0200
suma-test-srv:~ # stat /srv/www/os-images/1/POS_Image_JeOS7_head-7.0.0-2/POS_Image_JeOS7_head.x86_64-7.0.0-5.3.18-150300.59.76-default.kernel 
  File: /srv/www/os-images/1/POS_Image_JeOS7_head-7.0.0-2/POS_Image_JeOS7_head.x86_64-7.0.0-5.3.18-150300.59.76-default.kernel
...
Change: 2022-07-12 12:39:25.437454399 +0200
 Birth: 2022-07-12 12:39:25.081443686 +0200
```



Discussion:

Resolving patch:
diff --git a/cobbler/items/distro.py b/cobbler/items/distro.py
--- a/cobbler/items/distro.py
+++ b/cobbler/items/distro.py
@@ -158,7 +158,10 @@ def kernel(self, kernel: str):
         if not isinstance(kernel, str):
             raise TypeError("kernel was not of type str")
         if not utils.find_kernel(kernel):
-            raise ValueError("kernel not found: %s" % kernel)
+            raise ValueError(
+                "kernel not found or it does not match with allowed kernel filename pattern [%s]: %s."
+                % (utils.re_kernel.pattern, kernel)
+            )
         self._kernel = kernel
 
     @property
diff --git a/cobbler/utils/__init__.py b/cobbler/utils/__init__.py
--- a/cobbler/utils/__init__.py
+++ b/cobbler/utils/__init__.py
@@ -48,7 +48,7 @@
 """
 
 re_kernel = re.compile(
-    r"(vmlinu[xz]|(kernel|linux(\.img)?)|pxeboot\.n12|wimboot|mboot\.c32)"
+    r"(vmlinu[xz]|(kernel|linux(\.img)?)|pxeboot\.n12|wimboot|mboot\.c32|.+\.kernel)"
 )
 re_initrd = re.compile(r"(initrd(.*)\.img|ramdisk\.image\.gz|boot\.sdi|imgpayld\.tgz)")
 


Test patch: