From cca6477509bcafe861065f6acf73523ec33dae7e Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Mon, 5 May 2014 18:14:13 -0400 Subject: [PATCH] Implement function to check SOL payload as keepalive The IPMI layer keepalive is sufficient for most scenarios, but SOL additionally cares about the SOL payload specifically. During SOL session, use an SOL specific scheme for keepalive. Change-Id: I23c5b8da4598696aa936274b3e6b527c8204b4db --- pyghmi/ipmi/console.py | 38 ++++++++++++++++++++++++++++++ pyghmi/ipmi/private/session.py | 42 +++++++++++++++++++++++++++++++--- 2 files changed, 77 insertions(+), 3 deletions(-) diff --git a/pyghmi/ipmi/console.py b/pyghmi/ipmi/console.py index a7d034bd..c36a82df 100644 --- a/pyghmi/ipmi/console.py +++ b/pyghmi/ipmi/console.py @@ -51,6 +51,7 @@ class Console(object): self.retriedpayload = 0 self.pendingoutput = [] self.awaitingack = False + self.activated = False self.force_session = force self.ipmi_session = session.Session(bmc=bmc, userid=userid, @@ -114,6 +115,7 @@ class Console(object): return if 'error' in response: self._print_error(response['error']) + self.activated = True #data[0:3] is reserved except for the test mode, which we don't use data = response['data'] self.maxoutcount = (data[5] << 8) + data[4] @@ -125,11 +127,37 @@ class Console(object): raise NotImplementedError("Non-standard SOL Port Number") #ignore data[10:11] for now, the vlan detail, shouldn't matter to this #code anyway... + #NOTE(jbjohnso): + #We will use a special purpose keepalive + self.keepaliveid = self.ipmi_session.register_keepalive( + cmd={'netfn': 6, 'command': 0x4b, 'data': (1, 1)}, + callback=self._got_payload_instance_info) self.ipmi_session.sol_handler = self._got_sol_payload self.connected = True if len(self.pendingoutput) > 0: self._sendpendingoutput() + def _got_payload_instance_info(self, response): + if 'error' in response: + self.activated = False + self.ipmi_session.unregister_keepalive(self.keepaliveid) + self._print_error(response['error']) + return + currowner = struct.unpack( + "