Skip to content

Commit ad76171

Browse files
committed
Add support for illumos/OmniOS
1 parent 2c452eb commit ad76171

37 files changed

Lines changed: 1637 additions & 83 deletions

cloudinit/cmd/main.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@
4545
)
4646
from cloudinit.reporting import events
4747
from cloudinit.safeyaml import load
48-
from cloudinit.settings import PER_INSTANCE, PER_ALWAYS, PER_ONCE, CLOUD_CONFIG
48+
from cloudinit.settings import (PER_INSTANCE, PER_ALWAYS, PER_ONCE,
49+
CLOUD_CONFIG, RUN_CLOUD_CONFIG)
4950

5051
# Welcome message template
5152
WELCOME_MSG_TPL = (
@@ -426,6 +427,15 @@ def main_init(name, args):
426427
_maybe_persist_instance_data(init)
427428
# Stage 6
428429
iid = init.instancify()
430+
if init.is_new_instance():
431+
util.multi_log("""
432+
433+
*********************************************************
434+
* cloud-init is configuring this system, please wait... *
435+
*********************************************************
436+
437+
""", console=True, stderr=True, log=LOG)
438+
429439
LOG.debug(
430440
"[%s] %s will now be targeting instance id: %s. new=%s",
431441
mode,
@@ -702,7 +712,7 @@ def status_wrapper(name, args, data_d=None, link_d=None):
702712
paths = read_cfg_paths()
703713
data_d = paths.get_cpath("data")
704714
if link_d is None:
705-
link_d = os.path.normpath("/run/cloud-init")
715+
link_d = os.path.dirname(os.path.normpath(RUN_CLOUD_CONFIG))
706716

707717
status_path = os.path.join(data_d, "status.json")
708718
status_link = os.path.join(link_d, "status.json")

cloudinit/config/cc_package_update_upgrade_install.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,13 @@ def _multi_cfg_bool_get(cfg, *keys):
7676
return False
7777

7878

79-
def _fire_reboot(wait_attempts=6, initial_sleep=1, backoff=2):
80-
subp.subp(REBOOT_CMD)
79+
def _fire_reboot(cloud, wait_attempts=6, initial_sleep=1, backoff=2):
80+
try:
81+
cmd = cloud.distro.shutdown_command(mode='reboot', delay='now',
82+
message='Rebooting after package installation')
83+
except:
84+
cmd = REBOOT_CMD
85+
subp.subp(cmd)
8186
start = time.time()
8287
wait_time = initial_sleep
8388
for _i in range(wait_attempts):
@@ -135,7 +140,7 @@ def handle(name: str, cfg: Config, cloud: Cloud, args: list) -> None:
135140
)
136141
# Flush the above warning + anything else out...
137142
flush_loggers(LOG)
138-
_fire_reboot()
143+
_fire_reboot(cloud)
139144
except Exception as e:
140145
util.logexc(LOG, "Requested reboot did not happen!")
141146
errors.append(e)

cloudinit/config/cc_resizefs.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import errno
1212
import logging
1313
import os
14+
import re
1415
import stat
1516
from textwrap import dedent
1617

@@ -20,6 +21,7 @@
2021
from cloudinit.config.schema import MetaSchema, get_meta_doc
2122
from cloudinit.distros import ALL_DISTROS
2223
from cloudinit.settings import PER_ALWAYS
24+
from cloudinit import temp_utils
2325

2426
NOBLOCK = "noblock"
2527

@@ -130,6 +132,15 @@ def _can_skip_resize_ufs(mount_point, devpth):
130132
return False
131133

132134

135+
def _can_skip_resize_zfs(zpool, devpth):
136+
try:
137+
(out, _err) = subp.subp(['zpool', 'get', '-Hp', '-o', 'value',
138+
'expandsz', zpool])
139+
return out.strip() == '-'
140+
except subp.ProcessExecutionError as e:
141+
return False
142+
143+
133144
# Do not use a dictionary as these commands should be able to be used
134145
# for multiple filesystem types if possible, e.g. one command for
135146
# ext2, ext3 and ext4.
@@ -143,7 +154,10 @@ def _can_skip_resize_ufs(mount_point, devpth):
143154
("bcachefs", _resize_bcachefs),
144155
]
145156

146-
RESIZE_FS_PRECHECK_CMDS = {"ufs": _can_skip_resize_ufs}
157+
RESIZE_FS_PRECHECK_CMDS = {
158+
"ufs": _can_skip_resize_ufs,
159+
"zfs": _can_skip_resize_zfs,
160+
}
147161

148162

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

270-
devpth = maybe_get_writable_device_path(devpth, info)
284+
if util.is_illumos() and fs_type == 'zfs':
285+
# On illumos ZFS, the devices are just bare words like 'c0t0d0'
286+
# which can be used directly as arguments for the resize.
287+
pass
288+
else:
289+
devpth = maybe_get_writable_device_path(devpth, info)
271290
if not devpth:
272291
return # devpath was not a writable block device
273292

cloudinit/distros/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191
],
9292
"openeuler": ["openeuler"],
9393
"OpenCloudOS": ["OpenCloudOS", "TencentOS"],
94+
"illumos": ["omnios"],
9495
}
9596

9697
LOG = logging.getLogger(__name__)

0 commit comments

Comments
 (0)