Exemple #1
0
    def create_scheduled_operation(self, context, operation):
        LOG.debug("Create scheduled operation.")
        self.operation_manager.check_operation_definition(
            operation.operation_type,
            operation.operation_definition,
        )

        # register operation
        self.trigger_manager.register_operation(operation.trigger_id,
                                                operation.id)
        trust_id = self.user_trust_manager.add_operation(context, operation.id)

        # create ScheduledOperationState record
        state_info = {
            "operation_id": operation.id,
            "service_id": self._service_id,
            "trust_id": trust_id,
            "state": constants.OPERATION_STATE_REGISTERED
        }
        operation_state = objects.ScheduledOperationState(
            context, **state_info)
        try:
            operation_state.create()
        except Exception:
            self.trigger_manager.unregister_operation(operation.trigger_id,
                                                      operation.id)
            raise
Exemple #2
0
 def _create_operation_state(self, operation_id, service_id):
     state_info = {
         'operation_id': operation_id,
         'service_id': service_id,
         'trust_id': '123',
         'state': 'triggered',
     }
     state = objects.ScheduledOperationState(self.context, **state_info)
     state.create()
     return state
 def _create_operation_state(self, operation_id, service_id):
     state_info = {
         'operation_id': operation_id,
         'service_id': service_id,
         'trust_id': '123',
         'state': constants.OPERATION_STATE_INIT,
     }
     state = objects.ScheduledOperationState(self.context, **state_info)
     state.create()
     return state
Exemple #4
0
 def _create_operation_state(self, operation_id):
     state_info = {
         "operation_id": operation_id,
         "service_id": self.manager._service_id,
         'trust_id': '123',
         "state": constants.OPERATION_STATE_REGISTERED
     }
     operation_state = objects.ScheduledOperationState(
         context, **state_info)
     operation_state.create()
     return operation_state