From 76460b63f9c310c7de4e5f0c11d1525bedd277e1 Mon Sep 17 00:00:00 2001 From: Scott Moser Date: Wed, 14 Mar 2018 10:41:46 -0600 Subject: tests: Centralize and re-use skipTest based on json schema presense. This just centralizes a hunk of duplicated code and uses it from the new location. --- tests/unittests/test_handler/test_handler_resizefs.py | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'tests/unittests/test_handler/test_handler_resizefs.py') diff --git a/tests/unittests/test_handler/test_handler_resizefs.py b/tests/unittests/test_handler/test_handler_resizefs.py index 5aa3c498..c2a7f9fb 100644 --- a/tests/unittests/test_handler/test_handler_resizefs.py +++ b/tests/unittests/test_handler/test_handler_resizefs.py @@ -7,21 +7,13 @@ from collections import namedtuple import logging import textwrap -from cloudinit.tests.helpers import (CiTestCase, mock, skipIf, util, - wrap_and_call) +from cloudinit.tests.helpers import ( + CiTestCase, mock, skipUnlessJsonSchema, util, wrap_and_call) LOG = logging.getLogger(__name__) -try: - import jsonschema - assert jsonschema # avoid pyflakes error F401: import unused - _missing_jsonschema_dep = False -except ImportError: - _missing_jsonschema_dep = True - - class TestResizefs(CiTestCase): with_logs = True @@ -76,7 +68,7 @@ class TestResizefs(CiTestCase): 'DEBUG: Skipping module named cc_resizefs, resizing disabled\n', self.logs.getvalue()) - @skipIf(_missing_jsonschema_dep, "No python-jsonschema dependency") + @skipUnlessJsonSchema() def test_handle_schema_validation_logs_invalid_resize_rootfs_value(self): """The handle reports json schema violations as a warning. -- cgit v1.2.3 From 20e3ddab7f55c2bf5e700c69fd24a0ac2206dbcf Mon Sep 17 00:00:00 2001 From: Dominic Schlegel Date: Tue, 27 Mar 2018 10:10:42 -0400 Subject: FreeBSD: resizefs module now able to handle zfs/zpool. Previously there was no support at all for zfs file system. With this change it is now possible to use the resizefs module to grow a zpool to its maximum partition size on FreeBSD. LP: #1721243 --- cloudinit/config/cc_resizefs.py | 22 ++++++++ cloudinit/util.py | 44 ++++++++++++---- tests/data/mount_parse_ext.txt | 19 +++++++ tests/data/mount_parse_zfs.txt | 21 ++++++++ tests/data/zpool_status_simple.txt | 10 ++++ .../test_handler/test_handler_resizefs.py | 58 +++++++++++++++++++++- tests/unittests/test_util.py | 50 +++++++++++++++++++ 7 files changed, 214 insertions(+), 10 deletions(-) create mode 100644 tests/data/mount_parse_ext.txt create mode 100644 tests/data/mount_parse_zfs.txt create mode 100644 tests/data/zpool_status_simple.txt (limited to 'tests/unittests/test_handler/test_handler_resizefs.py') diff --git a/cloudinit/config/cc_resizefs.py b/cloudinit/config/cc_resizefs.py index cec22bb7..c8e1752f 100644 --- a/cloudinit/config/cc_resizefs.py +++ b/cloudinit/config/cc_resizefs.py @@ -84,6 +84,10 @@ def _resize_ufs(mount_point, devpth): return ('growfs', devpth) +def _resize_zfs(mount_point, devpth): + return ('zpool', 'online', '-e', mount_point, devpth) + + def _get_dumpfs_output(mount_point): dumpfs_res, err = util.subp(['dumpfs', '-m', mount_point]) return dumpfs_res @@ -148,6 +152,7 @@ RESIZE_FS_PREFIXES_CMDS = [ ('ext', _resize_ext), ('xfs', _resize_xfs), ('ufs', _resize_ufs), + ('zfs', _resize_zfs), ] RESIZE_FS_PRECHECK_CMDS = { @@ -188,6 +193,13 @@ def maybe_get_writable_device_path(devpath, info, log): log.debug("Not attempting to resize devpath '%s': %s", devpath, info) return None + # FreeBSD zpool can also just use gpt/