def test_updates_nodes_with_tag(self): nodes = [factory.make_Node() for _ in range(5)] for node in nodes[0:2]: make_lldp_result(node, b"<bar/>") tag = factory.make_Tag("bar", "//lldp:bar", populate=False) populate_tag_for_multiple_nodes(tag, nodes) self.assertItemsEqual( [node.hostname for node in nodes[0:2]], [node.hostname for node in Node.objects.filter(tags__name='bar')])
def _populate_nodes_now(self): """Find all nodes that match this tag, and update them, now. All computation will be done within the current transaction, within the current thread. This could be costly. """ # Avoid circular imports. from maasserver.populate_tags import populate_tag_for_multiple_nodes from maasserver.models.node import Node if self.is_defined: # Do the work here and now in this thread. This is probably a # terrible mistake... unless you're testing. populate_tag_for_multiple_nodes(self, Node.objects.all())