From 4ef60d3106eb71d4bd8c4773a8799379c5cf67c2 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Tue, 6 May 2014 10:06:33 -0400 Subject: [PATCH] Have persistent ipmi command objects break selves on reconfig When any reconfiguration happens, break a command object (and the session that lies beneath). This does cause needless churn in response to some changes that wouldn't matter, but it's a small price to pay for the simplicity of not bothering to be fancier. --- TODO | 5 +---- plugins/hardwaremanagement/ipmi.py | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/TODO b/TODO index 9b8ca6ce..bdd38ab3 100644 --- a/TODO +++ b/TODO @@ -29,7 +29,4 @@ KeyError: '' -confetty to do right thing with respect to status updates when run right on a console. It currently clutters up the screen with data that would land in a titlebar --audit log did not show confetty activity for starting console --ipmi plugin needs to watch for connection attribute changes. test case is to - connect to a bmc and then misconfigure. Currently, it keeps working, it should - break. watchattribs is the key \ No newline at end of file +-audit log did not show confetty activity for starting console \ No newline at end of file diff --git a/plugins/hardwaremanagement/ipmi.py b/plugins/hardwaremanagement/ipmi.py index 3492e297..e42eb9f1 100644 --- a/plugins/hardwaremanagement/ipmi.py +++ b/plugins/hardwaremanagement/ipmi.py @@ -32,6 +32,17 @@ _ipmithread = None _ipmiwaiters = [] +class IpmiCommandWrapper(ipmicommand.Command): + def __init__(self, node, cfm, **kwargs): + self._attribwatcher = cfm.watch_attributes( + (node,),('secret.hardwaremanagementuser', + 'secret.hardwaremanagementpassphrase', 'secret.ipmikg', + 'hardwaremanagement.manager'), self._attribschanged) + super(self.__class__, self).__init__(**kwargs) + + def _attribschanged(self, nodeattribs, configmanager, **kwargs): + self.ipmi_session._mark_broken() + def _ipmi_evtloop(): while True: try: @@ -219,8 +230,9 @@ class IpmiHandler(object): if ((node, tenant) not in persistent_ipmicmds or not persistent_ipmicmds[(node, tenant)].ipmi_session.logged): self._logevt = threading.Event() - persistent_ipmicmds[(node, tenant)] = ipmicommand.Command( - bmc=connparams['bmc'], userid=connparams['username'], + persistent_ipmicmds[(node, tenant)] = IpmiCommandWrapper( + node, cfg, bmc=connparams['bmc'], + userid=connparams['username'], password=connparams['passphrase'], kg=connparams['kg'], port=connparams['port'], onlogon=self.logged) self.ipmicmd = persistent_ipmicmds[(node, tenant)]