updates to force CoreCommandError to contain string values for stderr and stdout, couple bugfixes in handling bad commands when using execute commands from tlv based api or coresendmsg, also updates to coresendmsg to display everything in lowercase to mimic previous look and feel, however coresendmg will now work regardless of casing to avoid breaking things again
This commit is contained in:
parent
454dc8091e
commit
95d3a6ca8c
7 changed files with 29 additions and 36 deletions
|
@ -880,12 +880,7 @@ class CoreHandler(socketserver.BaseRequestHandler):
|
|||
except CoreCommandError as e:
|
||||
res = e.stderr
|
||||
status = e.returncode
|
||||
logging.info(
|
||||
"done exec cmd=%s with status=%d res=(%d bytes)",
|
||||
command,
|
||||
status,
|
||||
len(res),
|
||||
)
|
||||
logging.info("done exec cmd=%s with status=%d", command, status)
|
||||
if message.flags & MessageFlags.TEXT.value:
|
||||
tlv_data += coreapi.CoreExecuteTlv.pack(
|
||||
ExecuteTlvs.RESULT.value, res
|
||||
|
|
|
@ -836,7 +836,6 @@ class EmaneManager(ModelManager):
|
|||
result = True
|
||||
except CoreCommandError:
|
||||
result = False
|
||||
|
||||
return result
|
||||
|
||||
|
||||
|
|
|
@ -522,7 +522,6 @@ class CoreNode(CoreNodeBase):
|
|||
self.host_cmd(f"kill -0 {self.pid}")
|
||||
except CoreCommandError:
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
def startup(self) -> None:
|
||||
|
|
|
@ -35,7 +35,7 @@ class DockerClient:
|
|||
output = self.run(args)
|
||||
data = json.loads(output)
|
||||
if not data:
|
||||
raise CoreCommandError(-1, args, f"docker({self.name}) not present")
|
||||
raise CoreCommandError(1, args, f"docker({self.name}) not present")
|
||||
return data[0]
|
||||
|
||||
def is_alive(self) -> bool:
|
||||
|
|
|
@ -34,7 +34,7 @@ class LxdClient:
|
|||
output = self.run(args)
|
||||
data = json.loads(output)
|
||||
if not data:
|
||||
raise CoreCommandError(-1, args, f"LXC({self.name}) not present")
|
||||
raise CoreCommandError(1, args, f"LXC({self.name}) not present")
|
||||
return data[0]
|
||||
|
||||
def is_alive(self) -> bool:
|
||||
|
|
|
@ -231,14 +231,17 @@ def cmd(
|
|||
p = Popen(args, stdout=PIPE, stderr=PIPE, env=env, cwd=cwd, shell=shell)
|
||||
if wait:
|
||||
stdout, stderr = p.communicate()
|
||||
stdout = stdout.decode("utf-8").strip()
|
||||
stderr = stderr.decode("utf-8").strip()
|
||||
status = p.wait()
|
||||
if status != 0:
|
||||
raise CoreCommandError(status, args, stdout, stderr)
|
||||
return stdout.decode("utf-8").strip()
|
||||
return stdout
|
||||
else:
|
||||
return ""
|
||||
except OSError:
|
||||
raise CoreCommandError(-1, args)
|
||||
except OSError as e:
|
||||
logging.error("cmd error: %s", e.strerror)
|
||||
raise CoreCommandError(1, args, "", e.strerror)
|
||||
|
||||
|
||||
def file_munge(pathname: str, header: str, text: str) -> None:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue