Exemplo n.º 1
0
def perform_request(operator, node, element,
                    configdata, inputdata, cfg, results):
        try:
            return IpmiHandler(operator, node, element, configdata, inputdata,
                               cfg, results).handle_request()
        except pygexc.IpmiException as ipmiexc:
            excmsg = str(ipmiexc)
            if excmsg in ('Session no longer connected', 'timeout'):
                results.put(msg.ConfluentTargetTimeout(node))
            else:
                results.put(msg.ConfluentNodeError(node, excmsg))
                raise
        except exc.TargetEndpointUnreachable as tu:
            results.put(msg.ConfluentTargetTimeout(node, str(tu)))
        except ssl.SSLEOFError:
            results.put(msg.ConfluentNodeError(
                self.node, 'Unable to communicate with the https server on '
                           'the target BMC'))
        except exc.PubkeyInvalid:
            results.put(msg.ConfluentNodeError(
                node,
                'Mismatch detected between target certificate fingerprint '
                'and pubkeys.tls_hardwaremanager attribute'))
        except pygexc.InvalidParameterValue as e:
            results.put(msg.ConfluentNodeError(node, str(e)))
        except Exception as e:
            results.put(e)
            raise
        finally:
            results.put('Done')
Exemplo n.º 2
0
 def read_sensors(self, sensorname):
     try:
         if sensorname == 'all':
             sensors = self.ipmicmd.get_sensor_descriptions()
             readings = []
             for sensor in filter(self.match_sensor, sensors):
                 try:
                     reading = self.ipmicmd.get_sensor_reading(
                         sensor['name'])
                 except pygexc.IpmiException as ie:
                     if ie.ipmicode == 203:
                         continue
                     raise
                 if hasattr(reading, 'health'):
                     reading.health = _str_health(reading.health)
                 readings.append(reading)
             self.output.put(msg.SensorReadings(readings, name=self.node))
         else:
             self.make_sensor_map()
             if sensorname not in self.sensormap:
                 self.output.put(
                     msg.ConfluentTargetNotFound(self.node,
                                                 'Sensor not found'))
                 return
             reading = self.ipmicmd.get_sensor_reading(
                 self.sensormap[sensorname])
             if hasattr(reading, 'health'):
                 reading.health = _str_health(reading.health)
             self.output.put(
                 msg.SensorReadings([reading],
                                    name=self.node))
     except pygexc.IpmiException:
         self.output.put(msg.ConfluentTargetTimeout(self.node))
Exemplo n.º 3
0
 def list_sensors(self):
     try:
         sensors = self.ipmicmd.get_sensor_descriptions()
     except pygexc.IpmiException:
         self.output.put(msg.ConfluentTargetTimeout(self.node))
         return
     self.output.put(msg.ChildCollection('all'))
     for sensor in filter(self.match_sensor, sensors):
         self.output.put(msg.ChildCollection(simplify_name(sensor['name'])))
Exemplo n.º 4
0
 def list_inventory(self):
     try:
         components = self.ipmicmd.get_inventory_descriptions()
     except pygexc.IpmiException:
         self.output.put(msg.ConfluentTargetTimeout(self.node))
         return
     self.output.put(msg.ChildCollection('all'))
     for component in components:
         self.output.put(msg.ChildCollection(simplify_name(component)))
Exemplo n.º 5
0
def perform_request(operator, node, element,
                    configdata, inputdata, cfg, results):
        try:
            return IpmiHandler(operator, node, element, configdata, inputdata,
                               cfg, results).handle_request()
        except pygexc.IpmiException as ipmiexc:
            excmsg = str(ipmiexc)
            if excmsg == 'Session no longer connected':
                results.put(msg.ConfluentTargetTimeout(node))
            else:
                results.put(msg.ConfluentNodeError(node, excmsg))
                raise
        except exc.TargetEndpointUnreachable as tu:
            results.put(msg.ConfluentTargetTimeout(node, str(tu)))
        except Exception as e:
            results.put(msg.ConfluentNodeError(
                node, 'IPMI PluginException (see stderr log): ' + str(e)))
            raise
        finally:
            results.put('Done')
Exemplo n.º 6
0
 def handle_request(self):
     if self.broken:
         if (self.error == 'timeout' or
                 'Insufficient resources' in self.error):
             self.error = self.error.replace(' reported in RAKP4', '')
             self.output.put(msg.ConfluentTargetTimeout(
                 self.node, self.error))
             return
         elif ('Unauthorized' in self.error or
                 'Incorrect password' in self.error):
             self.output.put(
                 msg.ConfluentTargetInvalidCredentials(self.node))
             return
         else:
             raise Exception(self.error)
     if self.element == ['power', 'state']:
         self.power()
     elif self.element == ['_enclosure', 'reseat_bay']:
         self.reseat_bay()
     elif self.element == ['boot', 'nextdevice']:
         self.bootdevice()
     elif self.element == ['health', 'hardware']:
         self.health()
     elif self.element == ['identify']:
         self.identify()
     elif self.element[0] == 'sensors':
         self.handle_sensors()
     elif self.element[0] == 'configuration':
         self.handle_configuration()
     elif self.element[:3] == ['inventory', 'firmware', 'updates']:
         self.handle_update()
     elif self.element[0] == 'inventory':
         self.handle_inventory()
     elif self.element == ['media', 'attach']:
         self.handle_attach_media()
     elif self.element == ['media', 'detach']:
         self.handle_detach_media()
     elif self.element == ['media', 'uploads']:
         self.handle_media_upload()
     elif self.element == ['media', 'current']:
         self.handle_list_media()
     elif self.element == ['events', 'hardware', 'log']:
         self.do_eventlog()
     elif self.element == ['events', 'hardware', 'decode']:
         self.decode_alert()
     elif self.element == ['console', 'license']:
         self.handle_license()
     else:
         raise Exception('Not Implemented')
Exemplo n.º 7
0
 def health(self):
     if 'read' == self.op:
         try:
             response = self.ipmicmd.get_health()
         except pygexc.IpmiException:
             self.output.put(msg.ConfluentTargetTimeout(self.node))
             return
         health = response['health']
         health = _str_health(health)
         self.output.put(msg.HealthSummary(health, self.node))
         if 'badreadings' in response:
             badsensors = []
             for reading in response['badreadings']:
                 if hasattr(reading, 'health'):
                     reading.health = _str_health(reading.health)
                 badsensors.append(reading)
             self.output.put(msg.SensorReadings(badsensors, name=self.node))
     else:
         raise exc.InvalidArgumentException('health is read-only')
Exemplo n.º 8
0
 def handle_request(self):
     if self._logevt is not None:
         self._logevt.wait()
     self._logevt = None
     if self.broken:
         if (self.error == 'timeout' or
                 'Insufficient resources' in self.error):
             self.error = self.error.replace(' reported in RAKP4', '')
             self.output.put(msg.ConfluentTargetTimeout(
                 self.node, self.error))
             return
         elif ('Unauthorized' in self.error or
                 'Incorrect password' in self.error):
             self.output.put(
                 msg.ConfluentTargetInvalidCredentials(self.node))
             return
         else:
             raise Exception(self.error)
     if self.element == ['power', 'state']:
         self.power()
     elif self.element == ['boot', 'nextdevice']:
         self.bootdevice()
     elif self.element == ['health', 'hardware']:
         self.health()
     elif self.element == ['identify']:
         self.identify()
     elif self.element[0] == 'sensors':
         self.handle_sensors()
     elif self.element[0] == 'configuration':
         self.handle_configuration()
     elif self.element[0] == 'inventory':
         self.handle_inventory()
     elif self.element == ['events', 'hardware', 'log']:
         self.do_eventlog()
     elif self.element == ['events', 'hardware', 'decode']:
         self.decode_alert()
     elif self.element == ['console', 'license']:
         self.handle_license()
     else:
         raise Exception('Not Implemented')