def ordered(actions, flat_topology): order = dependencyGraph.get_ordered_list(flat_topology) first = [] last = [] for action in actions: if action.action_type == action_type['create_vm']: first.append(action) elif action.action_type == action_type['delete_vm']: last.append(action) result = [] if len(first): result.append(first) for sub_list in order: current = [] for action in actions: if isinstance(action, ContainerAction): tier_name = action.container for order_tier in sub_list: if tier_name == order_tier: current.append(action) if len(current): result.append(current) if len(last): result.append(last) return result
def test(self): ordered_nodes = dependencyGraph.get_ordered_list(nodes) expected = [['node4'], ['node2'], ['node1'], ['node0', 'node3']] self.assertEquals(ordered_nodes, expected)