Skip to content

Commit de45e72

Browse files
committed
Add support for illumos/OmniOS
1 parent 76066fe commit de45e72

26 files changed

Lines changed: 1353 additions & 97 deletions

cloudinit/cmd/main.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@
4242
from cloudinit import reporting
4343
from cloudinit.reporting import events
4444

45-
from cloudinit.settings import PER_INSTANCE, PER_ALWAYS, PER_ONCE, CLOUD_CONFIG
45+
from cloudinit.settings import (PER_INSTANCE, PER_ALWAYS, PER_ONCE,
46+
CLOUD_CONFIG, RUN_CLOUD_CONFIG)
4647

4748
from cloudinit import atomic_helper
4849

@@ -417,6 +418,15 @@ def main_init(name, args):
417418
_maybe_persist_instance_data(init)
418419
# Stage 6
419420
iid = init.instancify()
421+
if init.is_new_instance():
422+
util.multi_log("""
423+
424+
*********************************************************
425+
* cloud-init is configuring this system, please wait... *
426+
*********************************************************
427+
428+
""", console=True, stderr=True, log=LOG)
429+
420430
LOG.debug(
421431
"[%s] %s will now be targeting instance id: %s. new=%s",
422432
mode,
@@ -692,7 +702,7 @@ def status_wrapper(name, args, data_d=None, link_d=None):
692702
paths = read_cfg_paths()
693703
data_d = paths.get_cpath("data")
694704
if link_d is None:
695-
link_d = os.path.normpath("/run/cloud-init")
705+
link_d = os.path.dirname(os.path.normpath(RUN_CLOUD_CONFIG))
696706

697707
status_path = os.path.join(data_d, "status.json")
698708
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
@@ -69,8 +69,13 @@ def _multi_cfg_bool_get(cfg, *keys):
6969
return False
7070

7171

72-
def _fire_reboot(log, wait_attempts=6, initial_sleep=1, backoff=2):
73-
subp.subp(REBOOT_CMD)
72+
def _fire_reboot(log, cloud, wait_attempts=6, initial_sleep=1, backoff=2):
73+
try:
74+
cmd = cloud.distro.shutdown_command(mode='reboot', delay='now',
75+
message='Rebooting after package installation')
76+
except:
77+
cmd = REBOOT_CMD
78+
subp.subp(cmd)
7479
start = time.time()
7580
wait_time = initial_sleep
7681
for _i in range(wait_attempts):
@@ -130,7 +135,7 @@ def handle(
130135
)
131136
# Flush the above warning + anything else out...
132137
logging.flushLoggers(log)
133-
_fire_reboot(log)
138+
_fire_reboot(log, cloud)
134139
except Exception as e:
135140
util.logexc(log, "Requested reboot did not happen!")
136141
errors.append(e)

cloudinit/config/cc_resizefs.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
import errno
1212
import os
13+
import re
1314
import stat
1415
from logging import Logger
1516
from textwrap import dedent
@@ -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

@@ -123,6 +125,15 @@ def _can_skip_resize_ufs(mount_point, devpth):
123125
return False
124126

125127

128+
def _can_skip_resize_zfs(zpool, devpth):
129+
try:
130+
(out, _err) = subp.subp(['zpool', 'get', '-Hp', '-o', 'value',
131+
'expandsz', zpool])
132+
return out.strip() == '-'
133+
except subp.ProcessExecutionError as e:
134+
return False
135+
136+
126137
# Do not use a dictionary as these commands should be able to be used
127138
# for multiple filesystem types if possible, e.g. one command for
128139
# ext2, ext3 and ext4.
@@ -135,7 +146,10 @@ def _can_skip_resize_ufs(mount_point, devpth):
135146
("hammer2", _resize_hammer2),
136147
]
137148

138-
RESIZE_FS_PRECHECK_CMDS = {"ufs": _can_skip_resize_ufs}
149+
RESIZE_FS_PRECHECK_CMDS = {
150+
"ufs": _can_skip_resize_ufs,
151+
"zfs": _can_skip_resize_zfs,
152+
}
139153

140154

141155
def can_skip_resize(fs_type, resize_what, devpth):
@@ -258,7 +272,12 @@ def handle(
258272
info = "dev=%s mnt_point=%s path=%s" % (devpth, mount_point, resize_what)
259273
log.debug("resize_info: %s" % info)
260274

261-
devpth = maybe_get_writable_device_path(devpth, info, log)
275+
if util.is_illumos() and fs_type == 'zfs':
276+
# On illumos ZFS, the devices are just bare words like 'c0t0d0'
277+
# which can be used directly as arguments for the resize.
278+
pass
279+
else:
280+
devpth = maybe_get_writable_device_path(devpth, info, log)
262281
if not devpth:
263282
return # devpath was not a writable block device
264283

cloudinit/distros/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
],
7575
"openEuler": ["openEuler"],
7676
"OpenCloudOS": ["OpenCloudOS", "TencentOS"],
77+
"illumos": ["omnios"],
7778
}
7879

7980
LOG = logging.getLogger(__name__)

0 commit comments

Comments
 (0)