|
1 | 1 | __author__ = "desultory" |
2 | | -__version__ = "7.1.2" |
| 2 | +__version__ = "7.1.3" |
3 | 3 |
|
4 | 4 | from pathlib import Path |
5 | 5 | from re import search |
@@ -130,13 +130,16 @@ def _get_mount_dev_fs_type(self, device: str, raise_exception=True) -> str: |
130 | 130 | self.logger.debug("No mount found for device: %s" % device) |
131 | 131 |
|
132 | 132 |
|
133 | | -def _get_mount_source_type(self, mount: dict, with_val=False) -> str: |
134 | | - """Gets the source from the mount config.""" |
| 133 | +def _get_mount_source(self, mount: dict) -> str: |
| 134 | + """Gets the source from the mount config. |
| 135 | + Uses the order of SOURCE_TYPES to determine the source type. |
| 136 | + uuid, partuuid, label, path. |
| 137 | +
|
| 138 | + Returns the source type and value if found, otherwise raises a ValueError. |
| 139 | + """ |
135 | 140 | for source_type in SOURCE_TYPES: |
136 | 141 | if source_type in mount: |
137 | | - if with_val: |
138 | | - return source_type, mount[source_type] |
139 | | - return source_type |
| 142 | + return source_type, mount[source_type] |
140 | 143 | raise ValueError("No source type found in mount: %s" % mount) |
141 | 144 |
|
142 | 145 |
|
@@ -249,8 +252,8 @@ def _get_mount_str(self, mount: dict, pad=False, pad_size=44) -> str: |
249 | 252 | """returns the mount source string based on the config, |
250 | 253 | the output string should work with fstab and mount commands. |
251 | 254 | pad: pads the output string with spaces, defined by pad_size (44).""" |
252 | | - mount_type, mount_name = _get_mount_source_type(self, mount, with_val=True) |
253 | | - out_str = mount_name if mount_type == "path" else f"{mount_type.upper()}={mount_name}" |
| 255 | + mount_type, mount_val = _get_mount_source(self, mount) |
| 256 | + out_str = mount_val if mount_type == "path" else f"{mount_type.upper()}={mount_val}" |
254 | 257 |
|
255 | 258 | if pad: |
256 | 259 | if len(out_str) > pad_size: |
@@ -899,7 +902,7 @@ def _validate_host_mount(self, mount, destination_path=None) -> bool: |
899 | 902 | if mount.get("base_mount"): |
900 | 903 | return self.logger.debug("Skipping host mount validation for base mount: %s" % mount) |
901 | 904 |
|
902 | | - mount_type, mount_val = _get_mount_source_type(self, mount, with_val=True) |
| 905 | + mount_type, mount_val = _get_mount_source(self, mount) |
903 | 906 | # If a destination path is passed, like for /, use that instead of the mount's destination |
904 | 907 | destination_path = str(mount["destination"]) if destination_path is None else destination_path |
905 | 908 |
|
|
0 commit comments