Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Alpine Linux support. #535

Merged
merged 19 commits into from
Aug 19, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
More review-based changes.
  • Loading branch information
dermotbradley committed Aug 19, 2020
commit 985b620146853517f5c8ef233b51bb48633d8929
4 changes: 2 additions & 2 deletions cloudinit/config/cc_apk_configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
{% if testing_enabled -%}
{% if alpine_version != 'edge' %}
#
# Testing - using this with a non-Edge installation will likely cause problems!
# Testing - using with non-Edge installation may cause problems!
#
{% endif %}
{{ alpine_baseurl }}/edge/testing
Expand Down Expand Up @@ -187,7 +187,7 @@ def handle(name, cfg, cloud, log, _args):

@param name: The module name "apk-configure" from cloud.cfg
@param cfg: A nested dict containing the entire cloud config contents.
@param cloud: The L{CloudInit} object in use.
@param cloud: The CloudInit object in use.
@param log: Pre-initialized Python logger object to use for logging.
@param _args: Any module arguments from cloud.cfg
"""
Expand Down
27 changes: 15 additions & 12 deletions cloudinit/config/cc_power_state_change.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,7 @@ def convert_delay(delay, fmt=None, scale=None):
if not scale:
scale = 1

try:
delay = fmt % int(int(delay) * int(scale))
except ValueError:
pass
delay = fmt % int(int(delay) * int(scale))

return delay

Expand All @@ -178,24 +175,30 @@ def load_power_state(cfg, distro_name):
(','.join(opt_map.keys()), mode))

delay = pstate.get("delay", "now")
if delay != "now" and not re.match(r"^\+[0-9]+$", delay):
raise TypeError(
"power_state[delay] must be 'now' or '+m' (minutes)."
" found '%s'." % delay)

if distro_name == 'alpine':
if delay == "now":
# Alpine's halt/poweroff/reboot commands do not understand "now"
delay = "0"
else:
# Convert integer 30 or string '30' to '1800' (seconds) as Alpine's
# halt/poweroff/reboot commands take seconds as param with no "+"
delay = convert_delay(delay, fmt="%s", scale=60)
try:
delay = convert_delay(delay, fmt="%s", scale=60)
except ValueError:
raise TypeError(
"power_state[delay] must be 'now' or '+m' (minutes)."
" found '%s'." % delay)

args = [mode, "-d", delay]
else:
# convert integer 30 or string '30' to '+30'
delay = convert_delay(delay, fmt="+%s", scale=1)
if delay != "now":
# convert integer 30 or string '30' to '+30'
try:
delay = convert_delay(delay, fmt="+%s", scale=1)
except ValueError:
raise TypeError(
"power_state[delay] must be 'now' or '+m' (minutes)."
" found '%s'." % delay)

args = ["shutdown", opt_map[mode], delay]

Expand Down
Loading