Set default label for XFS disks
As described, we want to set the default label for XFS disks to the shorter value. For example, you hit this when setting the old FS_TYPE environment variable to 'xfs' (which sets the "root-fs-type" parameter, which gets passed through to 'type'; but does not set a default label). Change-Id: I41dce6e25766562db4366021309b8c2b74a8ab80 Closes-Bug: 1742170
This commit is contained in:
parent
894de9d9af
commit
c7da8bc90a
@ -172,13 +172,20 @@ class BlockDevice(object):
|
|||||||
trap - EXIT
|
trap - EXIT
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def _merge_into_config(self):
|
def _merge_rootfs_params(self):
|
||||||
"""Merge old (default) config into new
|
"""Merge rootfs related parameters into configuration
|
||||||
|
|
||||||
|
To maintain compatability with some old block-device
|
||||||
|
environment variables from before we had a specific
|
||||||
|
block-device config, disk-image-create provides a "parameters"
|
||||||
|
file that translates the old bash-environment variables into a
|
||||||
|
YAML based configuration file (``self.params``).
|
||||||
|
|
||||||
|
Here we merge the values in this parameters file that relate
|
||||||
|
to the root file-system into the final configuration. We look
|
||||||
|
for the ``mkfs_root`` node in the new config, and pull the
|
||||||
|
relevant settings from the parameters into it.
|
||||||
|
|
||||||
There is the need to be compatible using some old environment
|
|
||||||
variables. This is done in the way, that if there is no
|
|
||||||
explicit value given, these values are inserted into the current
|
|
||||||
configuration.
|
|
||||||
"""
|
"""
|
||||||
for entry in self.config:
|
for entry in self.config:
|
||||||
for k, v in entry.items():
|
for k, v in entry.items():
|
||||||
@ -198,7 +205,18 @@ class BlockDevice(object):
|
|||||||
if self.params['root-label'] is not None:
|
if self.params['root-label'] is not None:
|
||||||
v['label'] = self.params['root-label']
|
v['label'] = self.params['root-label']
|
||||||
else:
|
else:
|
||||||
v['label'] = "cloudimg-rootfs"
|
# The default label is "cloudimg-rootfs"
|
||||||
|
# for historical reasons (upstream
|
||||||
|
# images/EC2 defaults/cloud-init etc). We
|
||||||
|
# want to remain backwards compatible, but
|
||||||
|
# unfortunately that's too long for XFS so
|
||||||
|
# we've decided on 'img-rootfs' in that
|
||||||
|
# case. Note there's separate checks if
|
||||||
|
# the label is specified explicitly.
|
||||||
|
if v.get('type') == 'xfs':
|
||||||
|
v['label'] = 'img-rootfs'
|
||||||
|
else:
|
||||||
|
v['label'] = 'cloudimg-rootfs'
|
||||||
|
|
||||||
def __init__(self, params):
|
def __init__(self, params):
|
||||||
"""Create BlockDevice object
|
"""Create BlockDevice object
|
||||||
@ -241,7 +259,7 @@ class BlockDevice(object):
|
|||||||
logger.debug("Config before merge [%s]", self.config)
|
logger.debug("Config before merge [%s]", self.config)
|
||||||
self.config = config_tree_to_graph(self.config)
|
self.config = config_tree_to_graph(self.config)
|
||||||
logger.debug("Config before merge [%s]", self.config)
|
logger.debug("Config before merge [%s]", self.config)
|
||||||
self._merge_into_config()
|
self._merge_rootfs_params()
|
||||||
logger.debug("Final config [%s]", self.config)
|
logger.debug("Final config [%s]", self.config)
|
||||||
# Write the final config
|
# Write the final config
|
||||||
with open(self.config_json_file_name, "wt") as fd:
|
with open(self.config_json_file_name, "wt") as fd:
|
||||||
@ -282,18 +300,21 @@ class BlockDevice(object):
|
|||||||
:param symbol: the symbol to get
|
:param symbol: the symbol to get
|
||||||
"""
|
"""
|
||||||
logger.info("Getting value for [%s]", symbol)
|
logger.info("Getting value for [%s]", symbol)
|
||||||
|
|
||||||
if symbol == "root-label":
|
if symbol == "root-label":
|
||||||
root_mount = self._config_get_mount("/")
|
root_mount = self._config_get_mount("/")
|
||||||
root_fs = self._config_get_mkfs(root_mount['base'])
|
root_fs = self._config_get_mkfs(root_mount['base'])
|
||||||
logger.debug("root-label [%s]", root_fs['label'])
|
logger.debug("root-label [%s]", root_fs['label'])
|
||||||
print("%s" % root_fs['label'])
|
print("%s" % root_fs['label'])
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
if symbol == "root-fstype":
|
if symbol == "root-fstype":
|
||||||
root_mount = self._config_get_mount("/")
|
root_mount = self._config_get_mount("/")
|
||||||
root_fs = self._config_get_mkfs(root_mount['base'])
|
root_fs = self._config_get_mkfs(root_mount['base'])
|
||||||
logger.debug("root-fstype [%s]", root_fs['type'])
|
logger.debug("root-fstype [%s]", root_fs['type'])
|
||||||
print("%s" % root_fs['type'])
|
print("%s" % root_fs['type'])
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
if symbol == 'mount-points':
|
if symbol == 'mount-points':
|
||||||
mount_points = self._config_get_all_mount_points()
|
mount_points = self._config_get_all_mount_points()
|
||||||
# we return the mountpoints joined by a pipe, because it is not
|
# we return the mountpoints joined by a pipe, because it is not
|
||||||
|
@ -58,13 +58,6 @@ class FilesystemNode(NodeBase):
|
|||||||
if self.label is None:
|
if self.label is None:
|
||||||
self.label = self.name
|
self.label = self.name
|
||||||
|
|
||||||
# Historic reasons - this will hopefully vanish in one of
|
|
||||||
# the next major releases
|
|
||||||
if self.label == "cloudimg-rootfs" and self.type == "xfs":
|
|
||||||
logger.warning("Default label [cloudimg-rootfs] too long for xfs "
|
|
||||||
"file system - using [img-rootfs] instead")
|
|
||||||
self.label = "img-rootfs"
|
|
||||||
|
|
||||||
# ensure we don't already have a fs with this label ... they
|
# ensure we don't already have a fs with this label ... they
|
||||||
# all must be unique.
|
# all must be unique.
|
||||||
if 'fs_labels' in self.state:
|
if 'fs_labels' in self.state:
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- |
|
||||||
|
This fixes bug 1742170 where the grub root label is different than the
|
||||||
|
file system label when booting from a whole disk image.
|
Loading…
Reference in New Issue
Block a user