Detect new images added to the default image directory.

* Images can be present before the server starts or while it is running
* Images are recorded in the database
This commit is contained in:
grossmj committed 2022-04-17 16:58:20 +07:00
1 parent 6af1f2afaa
commit e6c8144210
5 files changed
+166 -15

No files matched your search

+4 -3
View File
@@ -15,7 +15,6 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import sys
import asyncio
from typing import Callable
@@ -25,7 +24,7 @@ from gns3server.controller import Controller
from gns3server.compute import MODULES
from gns3server.compute.port_manager import PortManager
from gns3server.utils.http_client import HTTPClient
from gns3server.db.tasks import connect_to_db, get_computes
from gns3server.db.tasks import connect_to_db, get_computes, discover_images_on_filesystem
import logging
@@ -60,7 +59,9 @@ def create_startup_handler(app: FastAPI) -> Callable:
# computing with server start
from gns3server.compute.qemu import Qemu
asyncio.ensure_future(Qemu.instance().list_images())
# Start the discovering new images on file system 5 seconds after the server has started
# to give it a chance to process API requests
loop.call_later(5, asyncio.create_task, discover_images_on_filesystem(app))
for module in MODULES:
log.debug(f"Loading module {module.__name__}")