wait_for_state is a utilities function to wait the state return by refresh function achieve the specific state, the generally usage is wait the cloud resource, such as uhost, udb … is ready after created.
>>> wait_for_state(
... pending=["pending"],
... target=["running"],
... refresh=lambda: "running",
... timeout=0.5,
... )
pending – pending is the list of pending state, the state is returned by refresh function
target – target is the list of target state, it is usually the terminate state, eg. running and fail
refresh – the customized refresh function, expect no arguments and return a state
timeout – timeout is the total time to wait state is achieved
startup_delay – the time to wait before first refresh function is called
min_backoff_interval – the backoff time for first refresh interval
max_backoff_interval – the max backoff time for refresh interval
base64 decode
s (str) – base64 string
output string
base64 encode
s (str) – input string
base64 string
generate password for any resource
>>> len(gen_password(20))
20
n (int) – password total length
lower_letters (str) – all lowercase letters
upper_letters (str) – all uppercase letters
number_letters (str) – all number letters
special_letters (str) – all special letters
min_lower (int) – minimal number of lowercase letters
min_upper (int) – minimal number of uppercase letters
min_number (int) – minimal number of number letters
min_specials (int) – minimal number of special letters