mirror of
https://github.com/xcat2/confluent.git
synced 2026-04-28 19:37:45 +00:00
Rework consolesessieon to async create function
This commit is contained in:
@@ -765,8 +765,10 @@ class ConsoleSession(object):
|
||||
:param skipreplay: If true, will skip the attempt to redraw the screen
|
||||
"""
|
||||
|
||||
def __init__(self, node, configmanager, username, datacallback=None,
|
||||
@classmethod
|
||||
async def create(cls, node, configmanager, username, datacallback=None,
|
||||
skipreplay=False, direct=True, width=80, height=24):
|
||||
self = cls()
|
||||
self.registered = False
|
||||
self.tenant = configmanager.tenant
|
||||
if not configmanager.is_node(node):
|
||||
@@ -778,12 +780,13 @@ class ConsoleSession(object):
|
||||
# relay
|
||||
self.width = width
|
||||
self.height = height
|
||||
tasks.spawn(self.connect_session())
|
||||
await self.connect_session()
|
||||
self.registered = True
|
||||
self._evt = None
|
||||
self.node = node
|
||||
self.write = self.conshdl.write
|
||||
tasks.spawn(self.delayinit(datacallback, skipreplay))
|
||||
return self
|
||||
|
||||
async def delayinit(self, datacallback, skipreplay):
|
||||
if datacallback is None:
|
||||
|
||||
@@ -544,7 +544,7 @@ async def wsock_handler(req):
|
||||
datacallback=datacallback,
|
||||
width=width, height=height, sessionid=sessidx)
|
||||
else:
|
||||
consession = consoleserver.ConsoleSession(
|
||||
consession = await consoleserver.ConsoleSession.create(
|
||||
node=node, configmanager=cfgmgr,
|
||||
username=username, skipreplay=skipreplay,
|
||||
datacallback=datacallback,
|
||||
@@ -597,7 +597,7 @@ async def wsock_handler(req):
|
||||
datacallback=datacallback, width=width, height=height
|
||||
)
|
||||
else:
|
||||
consession = consoleserver.ConsoleSession(
|
||||
consession = await consoleserver.ConsoleSession.create(
|
||||
node=nodename, configmanager=cfgmgr,
|
||||
username=username, skipreplay=skipreplay,
|
||||
datacallback=datacallback, width=width, height=height
|
||||
@@ -884,7 +884,7 @@ async def resourcehandler_backend(req, make_response):
|
||||
datacallback=datacallback, width=width, height=height
|
||||
)
|
||||
else:
|
||||
consession = consoleserver.ConsoleSession(
|
||||
consession = await consoleserver.ConsoleSession.create(
|
||||
node=nodename, configmanager=cfgmgr,
|
||||
username=authorized['username'], skipreplay=skipreplay,
|
||||
datacallback=datacallback, width=width, height=height
|
||||
|
||||
@@ -262,7 +262,7 @@ async def start_proxy_term(connection, cert, request):
|
||||
return
|
||||
cfm = configmanager.ConfigManager(request['tenant'])
|
||||
ccons = ClientConsole(connection)
|
||||
consession = consoleserver.ConsoleSession(
|
||||
consession = await consoleserver.ConsoleSession.create(
|
||||
node=request['node'], configmanager=cfm, username=request['user'],
|
||||
datacallback=ccons.sendall, skipreplay=request['skipreplay'],
|
||||
direct=False, width=request.get('width', 80), height=request.get(
|
||||
@@ -280,7 +280,7 @@ async def start_term(authname, cfm, connection, params, path, authdata, skipauth
|
||||
if params and 'skipreplay' in params and params['skipreplay']:
|
||||
skipreplay = True
|
||||
if elems[3] == "console":
|
||||
consession = consoleserver.ConsoleSession(
|
||||
consession = await consoleserver.ConsoleSession.create(
|
||||
node=node, configmanager=cfm, username=authname,
|
||||
datacallback=ccons.sendall, skipreplay=skipreplay)
|
||||
elif len(elems) >= 6 and elems[3:5] == ['shell', 'sessions']:
|
||||
|
||||
Reference in New Issue
Block a user