The bareon.utils.utils Module¶
-
bareon.utils.utils.B2MiB(b, ceil=True)¶
-
bareon.utils.utils.blacklist_udev_rules(udev_rules_dir, udev_rules_lib_dir, udev_rename_substr, udev_empty_rule)¶ Blacklist udev rules
Here is udev’s rules blacklisting to be done: by adding symlinks to /dev/null in /etc/udev/rules.d for already existent rules in /lib/. ‘parted’ generates too many udev events in short period of time so we should increase processing speed for those events, otherwise partitioning is doomed.
-
bareon.utils.utils.calculate_md5(filename, size)¶
-
bareon.utils.utils.dict_diff(dict1, dict2, sfrom='from', sto='to')¶
-
bareon.utils.utils.execute(*cmd, **kwargs)¶
-
bareon.utils.utils.get_data_driver(name)¶
-
bareon.utils.utils.get_deploy_driver(name)¶
-
bareon.utils.utils.get_driver(namespace, name)¶
-
bareon.utils.utils.get_interface_ip(mac_addr)¶ Get IP address of interface with mac_addr
-
bareon.utils.utils.grouper(iterable, n, fillvalue=None)¶ Collect data into fixed-length chunks or blocks
-
bareon.utils.utils.guess_filename(path, regexp, sort=True, reverse=True)¶ Tries to find a file by regexp in a given path.
This method is supposed to be mostly used for looking up for available kernel files which are usually ‘vmlinuz-X.Y.Z-foo’. In order to find the newest one we can sort files in backward direction (by default).
Parameters: - path – Directory where to look for a file
- regexp – (String) Regular expression (must have python syntax)
- sort – (Bool) If True (by default), sort files before looking up.
It can be necessary when regexp does not unambiguously correspond to file. :param reverse: (Bool) If True (by default), sort files in backward direction.
-
bareon.utils.utils.init_http_request(url, byte_range=0)¶
-
bareon.utils.utils.list_opts()¶ Returns a list of oslo.config options available in the library.
The returned list includes all oslo.config options which may be registered at runtime by the library.
Each element of the list is a tuple. The first element is the name of the group under which the list of elements in the second element will be registered. A group name of None corresponds to the [DEFAULT] group in config files.
The purpose of this is to allow tools like the Oslo sample config file generator (oslo-config-generator) to discover the options exposed to users by this library.
Returns: a list of (group_name, opts) tuples
-
bareon.utils.utils.makedirs_if_not_exists(path, mode=493)¶ Create directory if it does not exist
Parameters: - path – Directory path
- mode – Directory mode (Default: 0o755)
-
bareon.utils.utils.parse_kernel_cmdline()¶ Parse linux kernel command line
-
bareon.utils.utils.parse_unit(s, unit, ceil=True)¶ Converts ‘123.1unit’ string into ints
If ceil is True it will be rounded up (124) and and down (123) if ceil is False.
-
bareon.utils.utils.render_and_save(tmpl_dir, tmpl_names, tmpl_data, file_name)¶
-
bareon.utils.utils.text_diff(text1, text2, sfrom='from', sto='to')¶
-
bareon.utils.utils.udevadm_settle()¶
-
bareon.utils.utils.unblacklist_udev_rules(udev_rules_dir, udev_rename_substr)¶ disable udev’s rules blacklisting