2
0
mirror of https://github.com/xcat2/confluent.git synced 2026-02-19 06:04:25 +00:00

Have browserfs based import work with async

This commit is contained in:
Jarrod Johnson
2024-08-20 15:57:56 -04:00
parent 30b8979e2c
commit 53d0d09ae1
2 changed files with 7 additions and 6 deletions

View File

@@ -183,12 +183,12 @@ class PluginRoute(object):
def handle_storage(configmanager, inputdata, pathcomponents, operation):
async def handle_storage(configmanager, inputdata, pathcomponents, operation):
if len(pathcomponents) == 1:
yield msg.ChildCollection('remote/')
return
if pathcomponents[1] == 'remote':
for rsp in mountmanager.handle_request(configmanager, inputdata, pathcomponents[2:], operation):
async for rsp in mountmanager.handle_request(configmanager, inputdata, pathcomponents[2:], operation):
yield rsp
async def handle_deployment(configmanager, inputdata, pathcomponents,
@@ -243,7 +243,8 @@ async def handle_deployment(configmanager, inputdata, pathcomponents,
return
if pathcomponents[1] == 'fingerprint':
if operation == 'create':
importer = osimage.MediaImporter(inputdata['filename'], configmanager, checkonly=True)
importer = osimage.MediaImporter()
await importer.init(inputdata['filename'], configmanager, checkonly=True)
medinfo = {
'targetpath': importer.targpath,
'name': importer.osname,

View File

@@ -4,7 +4,7 @@ import eventlet
import confluent.messages as msg
import confluent.exceptions as exc
import struct
import eventlet.green.socket as socket
import socket
import os
mountsbyuser = {}
_browserfsd = None
@@ -23,7 +23,7 @@ async def assure_browserfs():
await asyncio.sleep(0.5)
def handle_request(configmanager, inputdata, pathcomponents, operation):
async def handle_request(configmanager, inputdata, pathcomponents, operation):
curruser = configmanager.current_user
if len(pathcomponents) == 0:
mounts = mountsbyuser.get(curruser, [])
@@ -39,7 +39,7 @@ def handle_request(configmanager, inputdata, pathcomponents, operation):
curridx = 1
while curridx in usedidx:
curridx += 1
currmount = requestmount(curruser, inputdata['name'])
currmount = await requestmount(curruser, inputdata['name'])
currmount['index'] = curridx
if curruser not in mountsbyuser:
mountsbyuser[curruser] = []