ironic_python_agent.utils.
AccumulatedFailures
(exc_class=<class 'RuntimeError'>)[source]¶Bases: object
Object to accumulate failures without raising exception.
ironic_python_agent.utils.
collect_system_logs
(journald_max_lines=None)[source]¶Collect system logs.
Collect system logs, for distributions using systemd the logs will come from journald. On other distributions the logs will come from the /var/log directory and dmesg output.
journald_max_lines – Maximum number of lines to retrieve from the journald. if None, return everything.
A tar, gzip base64 encoded string with the logs.
ironic_python_agent.utils.
create_partition_table
(dev_name, partition_table_type)[source]¶Create a partition table on a disk using parted.
dev_name – the disk where we want to create the partition table.
partition_table_type – the type of partition table we want to create, for example gpt or msdos.
CommandExecutionError if an error is encountered while attempting to create the partition table.
ironic_python_agent.utils.
determine_time_method
()[source]¶Helper method to determine what time utility is present.
“ntpdate” if ntpdate has been found, “chrony” if chrony was located, and None if neither are located. If both tools are present, “chrony” will supercede “ntpdate”.
ironic_python_agent.utils.
execute
(*cmd, **kwargs)[source]¶Convenience wrapper around ironic_lib’s execute() method.
Executes and logs results from a system command.
ironic_python_agent.utils.
extract_device
(part)[source]¶Extract the device from a partition name or path.
part – the partition
a device if success, None otherwise
ironic_python_agent.utils.
get_agent_params
()[source]¶Gets parameters passed to the agent via kernel cmdline or vmedia.
Parameters can be passed using either the kernel commandline or through virtual media. If boot_method is vmedia, merge params provided via vmedia with those read from the kernel command line.
Although it should never happen, if a variable is both set by vmedia and kernel command line, the setting in vmedia will take precedence.
a dict of potential configuration parameters for the agent
ironic_python_agent.utils.
get_command_output
(command)[source]¶Return the output of a given command.
command – The command to be executed.
CommandExecutionError if the execution of the command fails.
A BytesIO string with the output.
ironic_python_agent.utils.
get_efi_part_on_device
(device)[source]¶Looks for the efi partition on a given device.
A boot partition on a GPT disk is assumed to be an EFI partition as well.
device – lock device upon which to check for the efi partition
the efi partition or None
ironic_python_agent.utils.
get_journalctl_output
(lines=None, units=None)[source]¶Query the contents of the systemd journal.
lines – Maximum number of lines to retrieve from the logs. If None, return everything.
units – A list with the names of the units we should retrieve the logs from. If None retrieve the logs for everything.
A log string.
ironic_python_agent.utils.
get_node_boot_mode
(node)[source]¶Returns the node boot mode.
It returns ‘uefi’ if ‘secure_boot’ is set to ‘true’ in ‘instance_info/capabilities’ of node. Otherwise it directly look for boot mode hints into
node – dictionnary.
‘bios’ or ‘uefi’
ironic_python_agent.utils.
get_partition_table_type_from_specs
(node)[source]¶Returns the node partition label, gpt or msdos.
If boot mode is uefi, return gpt. Else, choice is open, look for disk_label capabilities (instance_info has priority over properties).
node –
gpt or msdos
ironic_python_agent.utils.
get_ssl_client_options
(conf)[source]¶Format SSL-related requests options.
conf – oslo_config CONF object
tuple of ‘verify’ and ‘cert’ values to pass to requests
ironic_python_agent.utils.
guess_root_disk
(block_devices, min_size_required=4294967296)[source]¶Find suitable disk provided that root device hints are not given.
If no hints are passed, order the devices by size (primary key) and name (secondary key), and return the first device larger than min_size_required as the root disk.
ironic_python_agent.utils.
gzip_and_b64encode
(io_dict=None, file_list=None)[source]¶Gzip and base64 encode files and BytesIO buffers.
io_dict – A dictionary containing whose the keys are the file names and the value a BytesIO object.
file_list – A list of file path.
A gzipped and base64 encoded string.
ironic_python_agent.utils.
is_journalctl_present
()[source]¶Check if the journalctl command is present.
True if journalctl is present, False if not.
ironic_python_agent.utils.
parse_capabilities
(root)[source]¶Extract capabilities from provided root dictionary-behaving object.
root.get(‘capabilities’, {}) value can either be a dict, or a json str, or a key1:value1,key2:value2 formatted string.
root – Anything behaving like a dict and containing capabilities formatted as expected. Can be node.get(‘properties’, {}), node.get(‘instance_info’, {}).
A dictionary with the capabilities if found and well formatted, otherwise an empty dictionary.
ironic_python_agent.utils.
remove_large_keys
(var)[source]¶Remove specific keys from the var, recursing into dicts and lists.
ironic_python_agent.utils.
scan_partition_table_type
(device)[source]¶Get partition table type, msdos or gpt.
device_name – the name of the device
msdos, gpt or unknown
ironic_python_agent.utils.
sync_clock
(ignore_errors=False)[source]¶Syncs the software clock of the system.
This method syncs the system software clock if a NTP server was defined in the “[DEFAULT]ntp_server” configuration parameter. This method does NOT attempt to sync the hardware clock.
It will try to use either ntpdate or chrony to sync the software clock of the system. If neither is found, an exception is raised.
ignore_errors – Boolean value default False that allows for the method to be called and ultimately not raise an exception. This may be useful for opportunistically attempting to sync the system software clock.
CommandExecutionError if an error is encountered while attempting to sync the software clock.
ironic_python_agent.utils.
try_execute
(*cmd, **kwargs)[source]¶The same as execute but returns None on error.
Executes and logs results from a system command. See docs for oslo_concurrency.processutils.execute for usage.
Instead of raising an exception on failure, this method simply returns None in case of failure.
cmd – positional arguments to pass to processutils.execute()
kwargs – keyword arguments to pass to processutils.execute()
UnknownArgumentError on receiving unknown arguments
tuple of (stdout, stderr) or None in some error cases
Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.