"Fossies" - the Fresh Open Source Software Archive

Member "glance-24.1.0/glance/async_/flows/plugins/no_op.py" (8 Jun 2022, 1882 Bytes) of package /linux/misc/openstack/glance-24.1.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. For more information about "no_op.py" see the Fossies "Dox" file reference documentation.

    1 # Copyright 2017 Red Hat, Inc.
    2 # All Rights Reserved.
    3 #
    4 #    Licensed under the Apache License, Version 2.0 (the "License"); you may
    5 #    not use this file except in compliance with the License. You may obtain
    6 #    a copy of the License at
    7 #
    8 #         http://www.apache.org/licenses/LICENSE-2.0
    9 #
   10 #    Unless required by applicable law or agreed to in writing, software
   11 #    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
   12 #    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
   13 #    License for the specific language governing permissions and limitations
   14 #    under the License.
   15 
   16 from oslo_config import cfg
   17 from oslo_log import log as logging
   18 from taskflow.patterns import linear_flow as lf
   19 from taskflow import task
   20 
   21 LOG = logging.getLogger(__name__)
   22 
   23 CONF = cfg.CONF
   24 
   25 
   26 class _Noop(task.Task):
   27 
   28     def __init__(self, task_id, task_type, image_repo):
   29         self.task_id = task_id
   30         self.task_type = task_type
   31         self.image_repo = image_repo
   32         super(_Noop, self).__init__(
   33             name='%s-Noop-%s' % (task_type, task_id))
   34 
   35     def execute(self, **kwargs):
   36 
   37         LOG.debug("No_op import plugin")
   38         return
   39 
   40     def revert(self, result=None, **kwargs):
   41         # NOTE(flaper87): If result is None, it probably
   42         # means this task failed. Otherwise, we would have
   43         # a result from its execution.
   44         if result is not None:
   45             LOG.debug("No_op import plugin failed")
   46             return
   47 
   48 
   49 def get_flow(**kwargs):
   50     """Return task flow for no-op.
   51 
   52     :param task_id: Task ID.
   53     :param task_type: Type of the task.
   54     :param image_repo: Image repository used.
   55     """
   56     task_id = kwargs.get('task_id')
   57     task_type = kwargs.get('task_type')
   58     image_repo = kwargs.get('image_repo')
   59 
   60     return lf.Flow(task_type).add(
   61         _Noop(task_id, task_type, image_repo),
   62     )