Skip to content

[FEATURE REQUEST] update salt.utils.stringutils.human_to_bytes for broader use #61831

@nicholasmhughes

Description

@nicholasmhughes

Is your feature request related to a problem? Please describe.
The stringutils.human_to_bytes utility is pretty narrow in its implementation. It doesn't handle sizes above a petabyte, and also doesn't handle units specified in more than a character (KB or KiB vs K).

Describe the solution you'd like
The virt module has a _handle_unit function that handles this functionality pretty well. This function could be moved over to replace human_to_bytes, centralizing and improving the logic. It'd also be great to have this as a Jinja filter.

Describe alternatives you've considered
Just deal with it? 😉 It works as-is... it's just picky about input.

Additional context
Stumbled upon this while looking at file.tidied, which only accepts sizes in bytes.

Please Note
If this feature request would be considered a substantial change or addition, this should go through a SEP process here https://github.com/saltstack/salt-enhancement-proposals, instead of a feature request.

Metadata

Metadata

Assignees

Labels

Featurenew functionality including changes to functionality and code refactors, etc.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions