From ad71260b802526d6751d4726a2efda62515fbf24 Mon Sep 17 00:00:00 2001 From: Scott Moser Date: Wed, 9 Oct 2013 10:03:03 -0400 Subject: power_state_change: convert an int input for delay to string, improve doc this adds 'timeout' to the documentation for power_state_change, and supports delay being an integer or a string. This is so that yaml can contain: delay: 30 rather than delay: "+30" or dealy: "30" --- cloudinit/config/cc_power_state_change.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'cloudinit/config/cc_power_state_change.py') diff --git a/cloudinit/config/cc_power_state_change.py b/cloudinit/config/cc_power_state_change.py index 188047e5..e3150808 100644 --- a/cloudinit/config/cc_power_state_change.py +++ b/cloudinit/config/cc_power_state_change.py @@ -75,6 +75,12 @@ def load_power_state(cfg): ','.join(opt_map.keys())) delay = pstate.get("delay", "now") + # convert integer 30 or string '30' to '+30' + try: + delay = "+%s" % int(delay) + except ValueError: + pass + if delay != "now" and not re.match(r"\+[0-9]+", delay): raise TypeError("power_state[delay] must be 'now' or '+m' (minutes).") -- cgit v1.2.3