api: Use the factory result image dir instead of filename for netboot

BUG=b:239795601
TEST=./run_tests

Change-Id: I1a057d4e651f30974173a2fe9b78fb880ab4a470
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/3905573
Tested-by: Madeleine Hardt <hardtmad@google.com>
Reviewed-by: Jack Neus <jackneus@google.com>
Tested-by: Jack Neus <jackneus@google.com>
diff --git a/api/controller/image.py b/api/controller/image.py
index 59c7a0b..61e8741 100644
--- a/api/controller/image.py
+++ b/api/controller/image.py
@@ -332,7 +332,7 @@
                 else:
                     cros_build_lib.Die("Failed to create recovery image.")
             elif mod_type == _NETBOOT_ID:
-                factory_shim_dir = os.path.basename(
+                factory_shim_dir = os.path.dirname(
                     factory_result.images[constants.IMAGE_TYPE_FACTORY_SHIM]
                 )
                 image.create_netboot_kernel(board, factory_shim_dir)
diff --git a/api/controller/image_unittest.py b/api/controller/image_unittest.py
index fb0b45d..dd230b7 100644
--- a/api/controller/image_unittest.py
+++ b/api/controller/image_unittest.py
@@ -221,7 +221,7 @@
         build_patch.assert_any_call(
             "board", [constants.IMAGE_TYPE_FACTORY_SHIM], config=mock.ANY
         )
-        netboot_patch.assert_any_call("board", factory_path.name)
+        netboot_patch.assert_any_call("board", os.path.dirname(factory_path))
 
 
 class RecoveryImageTest(