bugfix
This commit is contained in:
parent
93fbe33519
commit
75ca27b663
@ -1,35 +1,30 @@
|
||||
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
|
||||
async def gethostinfo(sor, ns):
|
||||
sql="""select a.*
|
||||
from hostdev a
|
||||
where a.id= ${id}$
|
||||
and ownerid=${userid}
|
||||
"""
|
||||
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')
|
||||
r.username = r.user
|
||||
if r.password:
|
||||
r.password = password_decode(r.password)
|
||||
if r.passphrase:
|
||||
r.passphrase = password_decode(r.passphrase)
|
||||
if r.jumperid:
|
||||
r.jumperservers = await gethostinfo(sor, {'id':r.jumperid})
|
||||
return DictObject(**r)
|
||||
|
||||
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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user