/usr/lib/python3/dist-packages/provisioningserver/rpc/tags.py is in python3-maas-provisioningserver 2.4.0~beta2-6865-gec43e47e6-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | # Copyright 2014-2016 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""RPC helpers for dealing with tags."""
__all__ = [
"evaluate_tag",
]
from apiclient.maas_client import (
MAASClient,
MAASDispatcher,
MAASOAuth,
)
from provisioningserver.config import ClusterConfiguration
from provisioningserver.tags import process_node_tags
from provisioningserver.utils.twisted import synchronous
@synchronous
def evaluate_tag(
system_id, nodes, tag_name, tag_definition, tag_nsmap, credentials):
"""Evaluate `tag_definition` against this cluster's nodes' details.
:param system_id: System ID for the rack controller.
:param nodes: List of nodes to evaluate.
:param tag_name: The name of the tag, used for logging.
:param tag_definition: The XPath expression of the tag.
:param tag_nsmap: The namespace map as used by LXML's ETree library.
:param credentials: A 3-tuple of OAuth credentials.
"""
with ClusterConfiguration.open() as config:
maas_url = config.maas_url
client = MAASClient(
auth=MAASOAuth(*credentials), dispatcher=MAASDispatcher(),
base_url=maas_url)
process_node_tags(
rack_id=system_id, nodes=nodes,
tag_name=tag_name, tag_definition=tag_definition,
tag_nsmap=tag_nsmap, client=client)
|