Example #1
0
 def read(self, params):
     """Read the information about the service space using the names of the platform
     node instance and the service space"""
     self._logger.info("%s called" % params)
     result = RCMPMessage()
     try:
         res = {}
         if self.pni[RCMPlatformNode.PNI_IS_MASTER]:
             res[self.RES_EXISTING_SS_KEY] = self.get_service_spaces(params)
         if self.I_ADDRESS_KEY in params and params[self.I_ADDRESS_KEY] and \
                 params[self.I_ADDRESS_KEY] != self.pni[RCMPlatformNode.PNI_ADDRESS]:
             # the read must be executed by another platform node
             d_res = self.delegate(params)
             if d_res.is_ok():
                 # the search of installed nodes has gone well
                 res.update(d_res.get_response_reason())
             else:
                 raise Exception(d_res.get_response_reason())
             result.create_ok_response(res)
         else:
             # this is the platform node that has to do the read
             res[self.RES_INSTALLED_SN_KEY] = self.find_packages_info()
             result.create_ok_response(res)
     except Exception as e:
         reason = "The %s read failed: %s" % (self._who, e)
         result.create_error_response(reason)
     self._logger.info(result.get_txt())
     return result