Example #1
0
def plan(desired_group_state, servers, lb_nodes, now, build_timeout):
    """
    Get an optimized convergence plan.

    Takes the same arguments as :func:`converge`.
    """
    steps = converge(desired_group_state, servers, lb_nodes, now,
                     timeout=build_timeout)
    steps = limit_steps_by_count(steps)
    return optimize_steps(steps)
Example #2
0
def plan_launch_stack(desired_group_state, now, build_timeout, stacks):
    """
    Get an optimized convergence plan.

    The arguments `now` and `build_timeout` are ignored and only necessary to
    match those of `plan_launch_server`. The arguments `desired_group_state`
    and `stacks` are the same as in `converge_launch_stack`.
    """
    steps = converge_launch_stack(desired_group_state, stacks)
    steps = limit_steps_by_count(steps)
    return optimize_steps(steps)
Example #3
0
def plan_launch_server(desired_group_state, now, build_timeout, step_limits,
                       servers, lb_nodes, lbs):
    """
    Get an optimized convergence plan.

    Takes the same arguments as :func:`converge_launch_server`
    except `step_limits` which is dict of step class -> limit
    """
    steps = converge_launch_server(desired_group_state, servers, lb_nodes, lbs,
                                   now, timeout=build_timeout)
    steps = limit_steps_by_count(steps, step_limits)
    return optimize_steps(steps)
Example #4
0
def plan_launch_stack(desired_group_state, now, build_timeout, step_limits,
                      stacks):
    """
    Get an optimized convergence plan.

    The arguments `now` and `build_timeout` are ignored and only necessary to
    match those of `plan_launch_server`. The arguments `desired_group_state`
    and `stacks` are the same as in `converge_launch_stack`. `step_limits` is
    dict of step class -> limit
    """
    steps = converge_launch_stack(desired_group_state, stacks)
    steps = limit_steps_by_count(steps, step_limits)
    return optimize_steps(steps)
Example #5
0
 def _test_limit_step_count(self, in_step_counts, step_limits):
     """
     Create some steps, limit them, assert they were limited.
     """
     in_steps = self._create_some_steps(in_step_counts)
     out_steps = limit_steps_by_count(in_steps, step_limits)
     expected_step_counts = {
         cls: step_limits.get(cls, in_step_count)
         for (cls, in_step_count) in in_step_counts.iteritems()
     }
     actual_step_counts = {
         cls: len(steps_of_this_type)
         for (cls,
              steps_of_this_type) in groupby(type, out_steps).iteritems()
     }
     self.assertEqual(expected_step_counts, actual_step_counts)
Example #6
0
 def _test_limit_step_count(self, in_step_counts, step_limits):
     """
     Create some steps, limit them, assert they were limited.
     """
     in_steps = self._create_some_steps(in_step_counts)
     out_steps = limit_steps_by_count(in_steps, step_limits)
     expected_step_counts = {
         cls: step_limits.get(cls, in_step_count)
         for (cls, in_step_count)
         in in_step_counts.iteritems()
     }
     actual_step_counts = {
         cls: len(steps_of_this_type)
         for (cls, steps_of_this_type)
         in groupby(type, out_steps).iteritems()
     }
     self.assertEqual(expected_step_counts, actual_step_counts)