Ejemplo n.º 1
0
 def fetch(self, url, results):
     rsp, status = self.wc.grab_json_response_with_status(url)
     if status == 401:
         results.put(
             msg.ConfluentTargetInvalidCredentials(
                 self.node, 'Unable to authenticate'))
         return {}
     elif status != 200:
         results.put(
             msg.ConfluentNodeError(
                 self.node,
                 'Unknown error: ' + rsp + ' while retrieving ' + url))
         return {}
     return rsp
Ejemplo n.º 2
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')
Ejemplo n.º 3
0
 def fetch(self, url, results):
     try:
         rsp, status = self.wc.grab_json_response_with_status(url)
     except exc.PubkeyInvalid:
         results.put(msg.ConfluentNodeError(self.node,
             'Mismatch detected between '
             'target certificate fingerprint and '
             'pubkeys.tls_hardwaremanager attribute'))
         return {}
     if status == 401:
         results.put(msg.ConfluentTargetInvalidCredentials(self.node, 'Unable to authenticate'))
         return {}
     elif status != 200:
         results.put(msg.ConfluentNodeError(self.node, 'Unknown error: ' + rsp + ' while retrieving ' + url))
         return {}
     return rsp
Ejemplo n.º 4
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')