35 lines
814 B
Plaintext
35 lines
814 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()
|
|
userid = await get_user()
|
|
async with db.sqlorContext('msp') 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
|