Exemple #1
0
 def __init__(self, *args, **kwargs):
     super(API, self).__init__(*args, **kwargs)
     operation_api.API().register_get_progress_method(
             "image-add",
             self._get_add_item_progress)
     operation_api.API().register_get_progress_method(
             "image-delete",
             self._get_delete_item_progress)
Exemple #2
0
def save_operation(context, action_result):
    if context.operation is None or context.operation_start_time is None:
        return None
    return operation_api.API().save_operation(
        context, context.operation, context.operation_start_time,
        context.operation_get_progress_method, context.operation_item_id,
        action_result)
Exemple #3
0
def init_operation(context, op_type, target_type, target_name, scope):
    if context.operation is not None:
        return
    operation = operation_api.API().construct_operation(
        context, op_type, target_type, target_name, scope)
    context.operation = operation
    return operation
Exemple #4
0
def _continue_operation(context, func):
    operation = context.operation
    try:
        operation_result = func()
        if not is_final_progress(operation_result):
            continue_operation(context, func, timeout=2)
    except Exception as ex:
        operation_result = ex

    operation_api.API().update_operation(context, operation["id"],
                                         operation_result)
Exemple #5
0
    def __init__(self, api):
        """Base initialization.

        Inherited classes should init _api and call super().
        """

        self._api = api
        self._type_name = self._api._get_type()
        self._collection_name = utils.get_collection_name(self._type_name)
        self._type_kind = utils.get_type_kind(self._type_name)
        self._list_kind = utils.get_list_kind(self._type_name)
        self._aggregated_kind = utils.get_aggregated_kind(self._type_name)
        self._operation_api = operation_api.API()
Exemple #6
0
 def __init__(self, *args, **kwargs):
     super(API, self).__init__(*args, **kwargs)
     operation_api.API().register_get_progress_method(
         "attached_disk-delete", self._get_delete_item_progress)
Exemple #7
0
 def __init__(self, *args, **kwargs):
     super(Controller, self).__init__(operation_api.API(), *args, **kwargs)