コード例 #1
0
 def test_get_probed_details(self):
     expected = {}
     nodes = [factory.make_Node() for _ in range(3)]
     for node in nodes:
         # Create some old results. These will _not_ be returned by
         # get probed_details.
         self.make_script_set_and_results(node, "old")
         # Create the current results. These will be returned by
         # get_probed_details.
         script_set, script_results = self.make_script_set_and_results(node)
         node.current_commissioning_script_set = script_set
         node.save()
         expected[node.system_id] = {
             script_output_nsmap[result.script_name]: result.stdout
             for result in script_results
         }
         # Create some new but not current results. These will _not_ be
         # returned by get_probed_details.
         self.make_script_set_and_results(node, "new")
     self.assertDictEqual(expected, get_probed_details(nodes))
コード例 #2
0
def populate_tag_for_multiple_nodes(tag, nodes, batch_size=DEFAULT_BATCH_SIZE):
    """Reevaluate a single tag for a multiple nodes.

    Presumably this tag's expression has recently changed. Use `populate_tags`
    when many nodes need reevaluating AND there are rack controllers available
    to which to farm-out work. Use this only when many nodes need reevaluating
    locally, i.e. when there are no rack controllers connected.
    """
    # Same expression, multuple documents: compile expression with XPath.
    xpath = etree.XPath(tag.definition, namespaces=tag_nsmap)
    # The XML details documents can be large so work in batches.
    for batch in gen_batches(nodes, batch_size):
        probed_details = get_probed_details(batch)
        probed_details_docs_by_node = {
            node: merge_details(probed_details[node.system_id])
            for node in batch
        }
        nodes_matching, nodes_nonmatching = classify(
            partial(try_match_xpath, xpath, logger=maaslog),
            probed_details_docs_by_node.items())
        tag.node_set.remove(*nodes_nonmatching)
        tag.node_set.add(*nodes_matching)
コード例 #3
0
 def get_details(self, nodes):
     return nodeprobeddetails.get_probed_details(
         node.system_id for node in nodes)
コード例 #4
0
 def get_details(self, nodes):
     return nodeprobeddetails.get_probed_details(node.system_id
                                                 for node in nodes)