bugfix
This commit is contained in:
parent
93fbe33519
commit
75ca27b663
@ -1,35 +1,30 @@
|
|||||||
debug(f'{params_kw=},')
|
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()
|
userid = await get_user()
|
||||||
async with db.sqlorContext(dbname) as sor:
|
async def gethostinfo(sor, ns):
|
||||||
ns = {
|
sql="""select a.*
|
||||||
# "ownerid":userid,
|
from hostdev a
|
||||||
"id":params_kw.hostid
|
where a.id= ${id}$
|
||||||
}
|
and ownerid=${userid}
|
||||||
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())
|
recs = await sor.sqlExe(sql,ns.copy())
|
||||||
if len(recs) > 0:
|
if len(recs) > 0:
|
||||||
r = recs[0]
|
r = recs[0]
|
||||||
hostinfo = gethostinfo(r)
|
r.username = r.user
|
||||||
if hostinfo.enterhostid:
|
if r.password:
|
||||||
recs = await sor.sqlExe(sql, {'id':r.enterhostid})
|
r.password = password_decode(r.password)
|
||||||
if len(recs) > 0:
|
if r.passphrase:
|
||||||
hostinfo.jumpers = [gethostinfo(recs[0])]
|
r.passphrase = password_decode(r.passphrase)
|
||||||
# hostinfo['commandlien'] = 'tail -f /var/log/syslog'
|
if r.jumperid:
|
||||||
return hostinfo
|
r.jumperservers = await gethostinfo(sor, {'id':r.jumperid})
|
||||||
else:
|
return DictObject(**r)
|
||||||
debug(f'{ns=} get hostdev error')
|
|
||||||
|
db = DBPools()
|
||||||
|
userid = await get_user()
|
||||||
|
dbname = get_module_dbname('msp')
|
||||||
|
async with db.sqlorContext(dbname) as sor:
|
||||||
|
ns = {
|
||||||
|
"ownerid":userid,
|
||||||
|
"id":params_kw.hostid
|
||||||
|
}
|
||||||
|
return await gethostinfo(sor, ns)
|
||||||
return None
|
return None
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user