msp/wwwroot/ws/connecthost.xterm
2025-08-18 13:21:56 +08:00

36 lines
849 B
Plaintext

debug(f'{params_kw=},')
def gethostinfo(hostdev):
r = hostdev
return DictObject(**{
"host":r.host,
"port":r.port,
"username":r.user,
"password":password_decode(r.passwd),
})
db = DBPools()
dbname = get_module_dbname('msp')
userid = await get_user()
async with db.sqlorContext(dbname) as sor:
ns = {
# "ownerid":userid,
"id":params_kw.hostid
}
sql="""select a.*, b.enterhostid
from hostdev a, devgroup b
where a.id= ${id}$ and a.devgroupid = b.id
"""
recs = await sor.sqlExe(sql,ns.copy())
if len(recs) > 0:
r = recs[0]
hostinfo = gethostinfo(r)
if hostinfo.enterhostid:
recs = await sor.sqlExe(sql, {'id':r.enterhostid})
if len(recs) > 0:
hostinfo.jumpers = [gethostinfo(recs[0])]
# hostinfo['commandlien'] = 'tail -f /var/log/syslog'
return hostinfo
else:
debug(f'{ns=} get hostdev error')
return None