Skip to content

Commit

Permalink
Add support for illumos/OmniOS
Browse files Browse the repository at this point in the history
  • Loading branch information
citrus-it committed Dec 29, 2023
1 parent 2c452eb commit ad76171
Show file tree
Hide file tree
Showing 37 changed files with 1,637 additions and 83 deletions.
14 changes: 12 additions & 2 deletions cloudinit/cmd/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@
)
from cloudinit.reporting import events
from cloudinit.safeyaml import load
from cloudinit.settings import PER_INSTANCE, PER_ALWAYS, PER_ONCE, CLOUD_CONFIG
from cloudinit.settings import (PER_INSTANCE, PER_ALWAYS, PER_ONCE,
CLOUD_CONFIG, RUN_CLOUD_CONFIG)

# Welcome message template
WELCOME_MSG_TPL = (
Expand Down Expand Up @@ -426,6 +427,15 @@ def main_init(name, args):
_maybe_persist_instance_data(init)
# Stage 6
iid = init.instancify()
if init.is_new_instance():
util.multi_log("""
*********************************************************
* cloud-init is configuring this system, please wait... *
*********************************************************
""", console=True, stderr=True, log=LOG)

LOG.debug(
"[%s] %s will now be targeting instance id: %s. new=%s",
mode,
Expand Down Expand Up @@ -702,7 +712,7 @@ def status_wrapper(name, args, data_d=None, link_d=None):
paths = read_cfg_paths()
data_d = paths.get_cpath("data")
if link_d is None:
link_d = os.path.normpath("/run/cloud-init")
link_d = os.path.dirname(os.path.normpath(RUN_CLOUD_CONFIG))

status_path = os.path.join(data_d, "status.json")
status_link = os.path.join(link_d, "status.json")
Expand Down
11 changes: 8 additions & 3 deletions cloudinit/config/cc_package_update_upgrade_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,13 @@ def _multi_cfg_bool_get(cfg, *keys):
return False


def _fire_reboot(wait_attempts=6, initial_sleep=1, backoff=2):
subp.subp(REBOOT_CMD)
def _fire_reboot(cloud, wait_attempts=6, initial_sleep=1, backoff=2):
try:
cmd = cloud.distro.shutdown_command(mode='reboot', delay='now',
message='Rebooting after package installation')
except:
cmd = REBOOT_CMD
subp.subp(cmd)
start = time.time()
wait_time = initial_sleep
for _i in range(wait_attempts):
Expand Down Expand Up @@ -135,7 +140,7 @@ def handle(name: str, cfg: Config, cloud: Cloud, args: list) -> None:
)
# Flush the above warning + anything else out...
flush_loggers(LOG)
_fire_reboot()
_fire_reboot(cloud)
except Exception as e:
util.logexc(LOG, "Requested reboot did not happen!")
errors.append(e)
Expand Down
23 changes: 21 additions & 2 deletions cloudinit/config/cc_resizefs.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import errno
import logging
import os
import re
import stat
from textwrap import dedent

Expand All @@ -20,6 +21,7 @@
from cloudinit.config.schema import MetaSchema, get_meta_doc
from cloudinit.distros import ALL_DISTROS
from cloudinit.settings import PER_ALWAYS
from cloudinit import temp_utils

NOBLOCK = "noblock"

Expand Down Expand Up @@ -130,6 +132,15 @@ def _can_skip_resize_ufs(mount_point, devpth):
return False


def _can_skip_resize_zfs(zpool, devpth):
try:
(out, _err) = subp.subp(['zpool', 'get', '-Hp', '-o', 'value',
'expandsz', zpool])
return out.strip() == '-'
except subp.ProcessExecutionError as e:
return False


# Do not use a dictionary as these commands should be able to be used
# for multiple filesystem types if possible, e.g. one command for
# ext2, ext3 and ext4.
Expand All @@ -143,7 +154,10 @@ def _can_skip_resize_ufs(mount_point, devpth):
("bcachefs", _resize_bcachefs),
]

RESIZE_FS_PRECHECK_CMDS = {"ufs": _can_skip_resize_ufs}
RESIZE_FS_PRECHECK_CMDS = {
"ufs": _can_skip_resize_ufs,
"zfs": _can_skip_resize_zfs,
}


def can_skip_resize(fs_type, resize_what, devpth):
Expand Down Expand Up @@ -267,7 +281,12 @@ def handle(name: str, cfg: Config, cloud: Cloud, args: list) -> None:
info = "dev=%s mnt_point=%s path=%s" % (devpth, mount_point, resize_what)
LOG.debug("resize_info: %s", info)

devpth = maybe_get_writable_device_path(devpth, info)
if util.is_illumos() and fs_type == 'zfs':
# On illumos ZFS, the devices are just bare words like 'c0t0d0'
# which can be used directly as arguments for the resize.
pass
else:
devpth = maybe_get_writable_device_path(devpth, info)
if not devpth:
return # devpath was not a writable block device

Expand Down
1 change: 1 addition & 0 deletions cloudinit/distros/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
],
"openeuler": ["openeuler"],
"OpenCloudOS": ["OpenCloudOS", "TencentOS"],
"illumos": ["omnios"],
}

LOG = logging.getLogger(__name__)
Expand Down
Loading

0 comments on commit ad76171

Please sign in to comment.