Пример #1
0
    def check_size(self, request, share_id, new_size):
        share = manila.share_get(request, share_id)
        timeout = 30
        interval = 0.35
        time_elapsed = 0
        while share.status != 'available':
            time.sleep(interval)
            time_elapsed += interval
            share = manila.share_get(request, share_id)
            if time_elapsed > timeout:
                raise exceptions.WorkflowError(
                    _("The operation timed out while resizing. "
                      "Please try again."))

        if share.size == new_size:
            message = _('Resized share "%s"') % share.name
            messages.success(request, message)
            return True
        raise exceptions.WorkflowError(_("Unable to resize share. "))
Пример #2
0
 def _verify_contributions(self, context):
     for key in self.contributes:
         # Make sure we don't skip steps based on weird behavior of
         # POST query dicts.
         field = self.action.fields.get(key, None)
         if field and field.required and not context.get(key):
             context.pop(key, None)
     failed_to_contribute = set(self.contributes)
     failed_to_contribute -= set(context.keys())
     if failed_to_contribute:
         raise exceptions.WorkflowError(
             "The following expected data was "
             "not added to the workflow context "
             "by the step %s: %s." % (self.__class__, failed_to_contribute))
     return True
Пример #3
0
 def _order_steps(self):
     steps = list(copy.copy(self.default_steps))
     additional = self._registry.keys()
     for step in additional:
         try:
             min_pos = steps.index(step.after)
         except ValueError:
             min_pos = 0
         try:
             max_pos = steps.index(step.before)
         except ValueError:
             max_pos = len(steps)
         if min_pos > max_pos:
             raise exceptions.WorkflowError("The step %(new)s can't be "
                                            "placed between the steps "
                                            "%(after)s and %(before)s; the "
                                            "step %(before)s comes before "
                                            "%(after)s."
                                            % {"new": additional,
                                               "after": step.after,
                                               "before": step.before})
         steps.insert(max_pos, step)
     return steps