Пример #1
0
    def deploy_service(self, service_name, class_path, pool_size=1,
                       description=CConstants.UNDEFINED,
                       initial_state=CConstants.UNDEFINED):
        """Sends request to DPE to deploy given service

        Args:
            service_name (String): service name in canonical form
            class_path (String): class path to given service
            pool_size (int): available pool size for service execution
            description (String): short description of what the service does
            initial_state (String): initial state for service
        """
        if not ClaraUtils.is_service_name(service_name):
            raise ValueError("Bad Service name")

        dpe = ClaraUtils.get_dpe_name(service_name)
        container_name = ClaraUtils.get_container_canonical_name(service_name)
        engine_name = ClaraUtils.get_engine_name(service_name)

        topic = ClaraUtils.build_topic(CConstants.DPE, dpe)
        data = ClaraUtils.build_data(CConstants.START_SERVICE,
                                     container_name,
                                     engine_name,
                                     class_path,
                                     pool_size,
                                     description,
                                     initial_state)

        self.base.send(self._create_request(topic, data))
Пример #2
0
    def remove_service(self, service_name):
        """Sends request to DPE to remove given service

        Args:
            service_name (String): service name in canonical form
        """
        if not ClaraUtils.is_service_name(service_name):
            raise ValueError("Bad Service name")
        dpe_name = ClaraUtils.get_dpe_name(service_name)
        container_name = ClaraUtils.get_container_name(service_name)
        engine_name = ClaraUtils.get_engine_name(service_name)

        topic = ClaraUtils.build_topic(CConstants.DPE, dpe_name)
        data = ClaraUtils.build_data(CConstants.STOP_SERVICE,
                                     container_name,
                                     engine_name)

        self.base.send(self._create_request(topic, data))