Exemple #1
0
 def test_bulk_remove_from_rcv3(self):
     """Logs :obj:`BulkRemoveFromRCv3`."""
     adds = pbag([
         BulkRemoveFromRCv3(lb_node_pairs=pset([(
             'lb1',
             'node1'), ('lb1',
                        'node2'), ('lb2',
                                   'node2'), ('lb2',
                                              'node3'), ('lb3', 'node4')])),
         BulkRemoveFromRCv3(
             lb_node_pairs=pset([('lba',
                                  'nodea'), ('lba',
                                             'nodeb'), ('lb1', 'nodea')]))
     ])
     self.assert_logs(adds, [
         Log('convergence-remove-rcv3-nodes',
             fields={
                 'lb_id': 'lb1',
                 'servers': ['node1', 'node2', 'nodea'],
                 'cloud_feed': True
             }),
         Log('convergence-remove-rcv3-nodes',
             fields={
                 'lb_id': 'lb2',
                 'servers': ['node2', 'node3'],
                 'cloud_feed': True
             }),
         Log('convergence-remove-rcv3-nodes',
             fields={
                 'lb_id': 'lb3',
                 'servers': ['node4'],
                 'cloud_feed': True
             }),
         Log('convergence-remove-rcv3-nodes',
             fields={
                 'lb_id': 'lba',
                 'servers': ['nodea', 'nodeb'],
                 'cloud_feed': True
             })
     ])
Exemple #2
0
def remove_node_from_lb(node):
    """
    Remove a node from the load balancing entity.

    :ivar node: The node to be removed.
    :type node: :class:`ILBNode` provider
    """
    if isinstance(node, CLBNode):
        return RemoveNodesFromCLB(lb_id=node.description.lb_id,
                                  node_ids=pset([node.node_id]))
    elif isinstance(node, RCv3Node):
        return BulkRemoveFromRCv3(lb_node_pairs=pset(
            [(node.description.lb_id, node.cloud_server_id)]))
Exemple #3
0
 def test_rcv3_mixed(self):
     """
     Multiple BulkAddToRCv3 and BulkRemoveFromRCv3 steps are combined
     into one BulkAddToRCv3 step and one BulkRemoveFromRCv3 step
     """
     steps = [
         BulkAddToRCv3(lb_node_pairs=pset([("l1", "s1"), ("l1", "s2")])),
         # Same pair for different class does not conflict
         BulkRemoveFromRCv3(lb_node_pairs=pset([("l1", "s1")])),
         BulkAddToRCv3(lb_node_pairs=pset([("l1", "s3")])),
         BulkRemoveFromRCv3(lb_node_pairs=pset([("l3", "s3"), ("l2",
                                                               "s3")]))
     ]
     self.assertEqual(
         optimize_steps(steps),
         pbag([
             BulkAddToRCv3(lb_node_pairs=pset([("l1",
                                                "s1"), ("l1",
                                                        "s2"), ("l1",
                                                                "s3")])),
             BulkRemoveFromRCv3(
                 lb_node_pairs=pset([("l1", "s1"), ("l3", "s3"), ("l2",
                                                                  "s3")]))
         ]))
Exemple #4
0
 def test_optimize_leaves_other_steps(self):
     """
     Unoptimizable steps pass the optimizer unchanged.
     """
     steps = pbag([
         AddNodesToCLB(lb_id='5',
                       address_configs=s(
                           ('1.1.1.1', CLBDescription(lb_id='5',
                                                      port=80)))),
         RemoveNodesFromCLB(lb_id='6', node_ids=s('1')),
         CreateServer(server_config=pmap({})),
         BulkRemoveFromRCv3(lb_node_pairs=pset([("lb-1", "node-a")])),
         BulkAddToRCv3(lb_node_pairs=pset([("lb-2", "node-b")]))
         # Note that the add & remove pair should not be the same;
         # the optimizer might reasonably optimize opposite
         # operations away in the future.
     ])
     self.assertEqual(optimize_steps(steps), steps)
Exemple #5
0
 def setUp(self):
     from otter.convergence.steps import rcv3 as step_rcv3
     self.patch(step_rcv3, "bulk_delete", intent_func("bd"))
     self.pairs = pset([("l1", "n1"), ("l2", "n2")])
     self.step = BulkRemoveFromRCv3(lb_node_pairs=self.pairs)