Fix bugs in log follow command
This commit is contained in:
parent
fe15bdb854
commit
1b8b101b64
|
@ -1002,8 +1002,9 @@ def follow_console_log(config, vm, lines=10):
|
||||||
API arguments: lines={lines}
|
API arguments: lines={lines}
|
||||||
API schema: {"name":"{vmname}","data":"{console_log}"}
|
API schema: {"name":"{vmname}","data":"{console_log}"}
|
||||||
"""
|
"""
|
||||||
|
# We always grab 500 to match the follow call, but only _show_ `lines` number
|
||||||
params = {
|
params = {
|
||||||
'lines': lines
|
'lines': 500
|
||||||
}
|
}
|
||||||
response = call_api(config, 'get', '/vm/{vm}/console'.format(vm=vm), params=params)
|
response = call_api(config, 'get', '/vm/{vm}/console'.format(vm=vm), params=params)
|
||||||
|
|
||||||
|
@ -1012,7 +1013,7 @@ def follow_console_log(config, vm, lines=10):
|
||||||
|
|
||||||
# Shrink the log buffer to length lines
|
# Shrink the log buffer to length lines
|
||||||
console_log = response.json()['data']
|
console_log = response.json()['data']
|
||||||
shrunk_log = console_log.split('\n')[-lines:]
|
shrunk_log = console_log.split('\n')[-int(lines):]
|
||||||
loglines = '\n'.join(shrunk_log)
|
loglines = '\n'.join(shrunk_log)
|
||||||
|
|
||||||
# Print the initial data and begin following
|
# Print the initial data and begin following
|
||||||
|
|
Loading…
Reference in New Issue