diff --git a/confluent_server/confluent/plugins/hardwaremanagement/deltapdu.py b/confluent_server/confluent/plugins/hardwaremanagement/deltapdu.py index 0943404f..a413f1e9 100644 --- a/confluent_server/confluent/plugins/hardwaremanagement/deltapdu.py +++ b/confluent_server/confluent/plugins/hardwaremanagement/deltapdu.py @@ -98,6 +98,7 @@ class PDUClient(object): def __init__(self, pdu, configmanager): self.node = pdu self.configmanager = configmanager + self._outletmap = {} self._token = None self._wc = None self.username = None @@ -119,6 +120,24 @@ class PDUClient(object): self.login(self.configmanager) return self._wc + @property + def map_outlets(self): + if not self._outletmap: + rsp, status = self.wc.grab_response('/setting_admin.htm') + if not isinstance(rsp, str): + rsp = rsp.decode('utf8') + for line in rsp.split('\n'): + if 'ibmsys_info_relay' in line and 'onClick="set(' in line: + line = line.partition('onClick="set(\'')[-1] + ident, label = line.split(',')[:2] + ident = ident.replace('\'', '') + label = label.replace('\'', '') + label = label.replace('ibmsys_info_relay', '') + idx = int(label) + self._outletmap[idx] = ident + return self._outletmap + + def login(self, configmanager): credcfg = configmanager.get_node_attributes(self.node, ['secret.hardwaremanagementuser', @@ -155,7 +174,8 @@ class PDUClient(object): def set_outlet(self, outlet, state): state = 0 if state == 'off' else 1 outlet = int(outlet) - sitem = '/SetParm?item=s4r{:02d}?content={}'.format(outlet, state) + ident = self.map_outlets[outlet] + sitem = '/SetParm?item={}?content={}'.format(ident, state) self.wc.grab_response(sitem) def retrieve(nodes, element, configmanager, inputdata):