Nodes and node¶
nodes¶
Module for jenkinsapi nodes
- class jenkinsapi.nodes.Nodes(baseurl: str, jenkins_obj: Jenkins)[source]¶
Bases:
JenkinsBase
Class to hold information on a collection of nodes
- create_node(name: str, node_dict: dict) Node [source]¶
Create a new slave node
- Parameters:
name (str) – name of slave
node_dict (dict) – node dict (See Node class)
- Returns:
node obj
- create_node_with_config(name: str, config: dict) Node | None [source]¶
Create a new slave node with specific configuration. Config should be resemble the output of node.get_node_attributes() :param str name: name of slave :param dict config: Node attributes for Jenkins API request
to create node (See function output Node.get_node_attributes())
- Returns:
node obj
- items() list[tuple[str, Node]] [source]¶
Return a copy of the container’s list of (name, node) pairs.
- iteritems() Iterator[tuple[str, Node]] [source]¶
Return an iterator over the container’s (name, node) pairs.
Using iteritems() while creating nodes may raise a RuntimeError or fail to iterate over all entries.
- iterkeys() Iterator[str] [source]¶
Return an iterator over the container’s node names.
Using iterkeys() while creating nodes may raise a RuntimeError or fail to iterate over all entries.
node¶
Module for jenkinsapi Node class
- class jenkinsapi.node.Node(jenkins_obj: Jenkins, baseurl: str, nodename: str, node_dict, poll: bool = True)[source]¶
Bases:
JenkinsBase
Class to hold information on nodes that are attached as slaves to the master jenkins instance
- block_until_idle(timeout: int, poll_time: int = 5) None [source]¶
Blocks until the node become idle. :param timeout: Time in second when the wait is aborted. :param poll_time: Interval in seconds between each check. :@raise TimeOut
- get_available_physical_memory() int [source]¶
Returns the node’s available physical memory in bytes.
- get_clock_difference() int [source]¶
Returns the difference between the node’s clock and the master Jenkins clock. Used to detect out of sync clocks.
- get_config_element(el_name: str) str [source]¶
Returns simple config element.
Better not to be used to return “nodeProperties” or “launcher”
- get_labels() str | None [source]¶
Returns the labels for a slave as a string with each label separated by the ‘ ‘ character.
- get_monitor(monitor_name: str, poll_monitor=True) str [source]¶
Polls the node returning one of the monitors in the monitorData branch of the returned node api tree.
- get_node_attributes() dict [source]¶
Gets node attributes as dict
Used by Nodes object when node is created
- Returns:
Node attributes dict formatted for Jenkins API request to create node
- get_workspace_path() str [source]¶
Returns the local path to the node’s Jenkins workspace directory.
- get_workspace_size() int [source]¶
Returns the size in bytes of the node’s Jenkins workspace directory.
- launch() None [source]¶
Tries to launch a connection with the slave if it is currently disconnected. Because launching a connection with the slave does not mean it is online (a slave can be launched, but set offline), this function does not check if the launch was successful.
- load_config() None [source]¶
Loads the config.xml for the node allowing it to be re-queried without generating new requests.
- set_num_executors(value: int | str) None [source]¶
Sets number of executors for node
Warning! Setting number of executors on master node will erase all other settings
- set_offline(message='requested from jenkinsapi') None [source]¶
Set node offline. If after run node state has not been changed raise AssertionError. : param message: optional string explain why you are taking this
node offline
- set_online() None [source]¶
Set node online. Before change state verify client state: if node set ‘offline’ but ‘temporarilyOffline’ is not set - client has connection problems and AssertionError raised. If after run node state has not been changed raise AssertionError.
- toggle_temporarily_offline(message='requested from jenkinsapi') None [source]¶
Switches state of connected node (online/offline) and set ‘temporarilyOffline’ property (True/False) Calling the same method again will bring node status back. :param message: optional string can be used to explain why you
are taking this node offline