Commit 6c3c6db9 authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

storage: Add operation for “vgreduce --removemissing”


Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 4b37cac5
......@@ -199,6 +199,9 @@ SF_FREE = "free"
SF_USED = "used"
SF_ALLOCATABLE = "allocatable"
# Storage operations
SO_FIX_CONSISTENCY = "fix-consistency"
# Available fields per storage type
VALID_STORAGE_FIELDS = {
ST_FILE: frozenset([SF_NAME, SF_USED, SF_FREE]),
......@@ -211,6 +214,7 @@ MODIFIABLE_STORAGE_FIELDS = {
}
VALID_STORAGE_OPERATIONS = {
ST_LVM_VG: frozenset([SO_FIX_CONSISTENCY]),
}
# Local disk status
......
......@@ -374,6 +374,39 @@ class LvmVgStorage(_LvmBase):
(constants.SF_SIZE, "vg_size", _ParseSize),
]
def _RemoveMissing(self, name):
"""Runs "vgreduce --removemissing" on a volume group.
@type name: string
@param name: Volume group name
"""
# Ignoring vgreduce exit code. Older versions exit with an error even tough
# the VG is already consistent. This was fixed in later versions, but we
# cannot depend on it.
result = utils.RunCmd(["vgreduce", "--removemissing", name])
# Keep output in case something went wrong
vgreduce_output = result.output
result = utils.RunCmd(["vgs", "--noheadings", "--nosuffix", name])
if result.failed:
raise errors.StorageError(("Volume group '%s' still not consistent,"
" 'vgreduce' output: %r,"
" 'vgs' output: %r") %
(name, vgreduce_output, result.output))
def Execute(self, name, op):
"""Executes an operation on a virtual volume.
See L{_Base.Execute}.
"""
if op == constants.SO_FIX_CONSISTENCY:
return self._RemoveMissing(name)
return _LvmBase.Execute(self, name, op)
# Lookup table for storage types
_STORAGE_TYPES = {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment