75 lines
1.3 KiB
Plaintext
75 lines
1.3 KiB
Plaintext
|
|
ns = params_kw.copy()
|
|
for k,v in ns.items():
|
|
if v == 'NaN' or v == 'null':
|
|
ns[k] = None
|
|
|
|
|
|
userorgid = await get_userorgid()
|
|
if not userorgid:
|
|
return {
|
|
"widgettype":"Error",
|
|
"options":{
|
|
"title":"Authorization Error",
|
|
"timeout":3,
|
|
"cwidth":16,
|
|
"cheight":9,
|
|
"message":"Please login"
|
|
}
|
|
}
|
|
ns['resellerid'] = userorgid
|
|
|
|
|
|
|
|
for k in list(ns.keys()):
|
|
if k.endswith('_at') or k.endswith('_time') or k == 'last_heartbeat':
|
|
v = ns.get(k, '')
|
|
if v == '' or v is None or v == 'None':
|
|
ns[k] = None
|
|
db = DBPools()
|
|
dbname = get_module_dbname('pcpool')
|
|
async with db.sqlorContext(dbname) as sor:
|
|
|
|
ns1 = {
|
|
|
|
"resellerid": userorgid,
|
|
|
|
|
|
"id": params_kw.id
|
|
}
|
|
recs = await sor.R('compute_node', ns1)
|
|
if len(recs) < 1:
|
|
return {
|
|
"widgettype":"Error",
|
|
"options":{
|
|
"title":"Update Error",
|
|
"cwidth":16,
|
|
"cheight":9,
|
|
"timeout":3,
|
|
"message":"Record no exist or with wrong ownership"
|
|
}
|
|
}
|
|
|
|
r = await sor.U('compute_node', ns)
|
|
debug('update success');
|
|
return {
|
|
"widgettype":"Message",
|
|
"options":{
|
|
"title":"Update Success",
|
|
"cwidth":16,
|
|
"cheight":9,
|
|
"timeout":3,
|
|
"message":"ok"
|
|
}
|
|
}
|
|
|
|
return {
|
|
"widgettype":"Error",
|
|
"options":{
|
|
"title":"Update Error",
|
|
"cwidth":16,
|
|
"cheight":9,
|
|
"timeout":3,
|
|
"message":"failed"
|
|
}
|
|
} |