From: Martin Willi Date: Mon, 9 Mar 2015 11:16:10 +0000 (+0100) Subject: vici: Evaluate Python streamed command results, and raise CommandException X-Git-Tag: 5.3.0rc1~28^2~7 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b5d17e55d78c513ba0642c96f32685297d82b24c;p=thirdparty%2Fstrongswan.git vici: Evaluate Python streamed command results, and raise CommandException --- diff --git a/src/libcharon/plugins/vici/python/vici/session.py b/src/libcharon/plugins/vici/python/vici/session.py index da79ecd646..9f4dc5fa7e 100644 --- a/src/libcharon/plugins/vici/python/vici/session.py +++ b/src/libcharon/plugins/vici/python/vici/session.py @@ -295,7 +295,7 @@ class SessionHandler(object): break if response.response_type == Packet.CMD_RESPONSE: - Message.deserialize(response.payload) + command_response = Message.deserialize(response.payload) else: raise SessionException( "Unexpected response type {type}, " @@ -316,3 +316,12 @@ class SessionHandler(object): confirm=Packet.EVENT_CONFIRM, ) ) + + # evaluate command result, if any + if "success" in command_response: + if command_response["success"] != "yes": + raise CommandException( + "Command failed: {errmsg}".format( + errmsg=command_response["errmsg"] + ) + )