コード例 #1
0
ファイル: server.py プロジェクト: yanhc519/core
 def GetServiceDefaults(self, request, context):
     logging.debug("get service defaults: %s", request)
     session = self.get_session(request.session_id, context)
     all_service_defaults = []
     for node_type in session.services.default_services:
         services = session.services.default_services[node_type]
         service_defaults = core_pb2.ServiceDefaults(node_type=node_type,
                                                     services=services)
         all_service_defaults.append(service_defaults)
     return core_pb2.GetServiceDefaultsResponse(
         defaults=all_service_defaults)
コード例 #2
0
    def set_service_defaults(self, session_id, service_defaults):
        """
        Set default services for node models.

        :param int session_id: session id
        :param dict service_defaults: node models to lists of services
        :return: response with result of success or failure
        :rtype: core_pb2.SetServiceDefaultsResponse
        :raises grpc.RpcError: when session doesn't exist
        """
        defaults = []
        for node_type in service_defaults:
            services = service_defaults[node_type]
            default = core_pb2.ServiceDefaults(node_type=node_type,
                                               services=services)
            defaults.append(default)
        request = core_pb2.SetServiceDefaultsRequest(session_id=session_id,
                                                     defaults=defaults)
        return self.stub.SetServiceDefaults(request)