Merge "Fix storage related consistency checks"
This commit is contained in:
commit
38f7697bdc
|
@ -354,6 +354,22 @@ def _check_host(partition, ihost, idisk):
|
|||
(idisk.uuid, ihost.hostname))
|
||||
|
||||
|
||||
def _check_disk(idisk):
|
||||
"""Semantic check for valid disk"""
|
||||
# Check if the disk is not already assigned for storage function"
|
||||
if idisk.istor_uuid:
|
||||
raise wsme.exc.ClientSideError(_(
|
||||
"Cannot create partition on a disk that is assigned as "
|
||||
"a storage volume."))
|
||||
|
||||
# Check if the disk is not assigned as a physical volume to a
|
||||
# volume group.
|
||||
if idisk.ipv_uuid:
|
||||
raise wsme.exc.ClientSideError(_(
|
||||
"Cannot create partition on a disk that is already "
|
||||
"assigned as a physical volume to a volume group."))
|
||||
|
||||
|
||||
def _partition_pre_patch_checks(partition_obj, patch_obj, host_obj):
|
||||
"""Check current vs. updated parameters."""
|
||||
# Reject operation if we are upgrading the system.
|
||||
|
@ -479,6 +495,9 @@ def _semantic_checks(operation, partition):
|
|||
# being changed for an existing host/disk pairing. If so => reject request.
|
||||
_check_for_outstanding_requests(partition, idisk)
|
||||
|
||||
# Make sure the disk on which we create the partition is valid.
|
||||
_check_disk(idisk)
|
||||
|
||||
# Semantic checks based on operation.
|
||||
if operation == constants.PARTITION_CMD_CREATE:
|
||||
############
|
||||
|
|
|
@ -683,6 +683,15 @@ def _check_device(new_pv, ihost):
|
|||
raise wsme.exc.ClientSideError(_("Disk already assigned to a "
|
||||
"storage volume."))
|
||||
|
||||
# semantic check: Make sure that partitions do not exist on the
|
||||
# disk
|
||||
partitions = pecan.request.dbapi.partition_get_by_idisk(
|
||||
new_pv['disk_or_part_uuid'])
|
||||
if partitions:
|
||||
raise wsme.exc.ClientSideError(_(
|
||||
"Cannot assign disk to a physical volume because disk "
|
||||
"contains other partitions."))
|
||||
|
||||
# semantic check: whether idisk_uuid belongs to another host
|
||||
if new_pv_device.forihostid != new_pv['forihostid']:
|
||||
raise wsme.exc.ClientSideError(_("Disk is attached to a different "
|
||||
|
|
|
@ -615,6 +615,19 @@ def _check_disk(stor):
|
|||
raise wsme.exc.ClientSideError(_(
|
||||
"Can not associate to a rootfs disk"))
|
||||
|
||||
# semantic check: whether disk has any partitions created
|
||||
partitions = pecan.request.dbapi.partition_get_by_idisk(idisk_uuid)
|
||||
if partitions:
|
||||
raise wsme.exc.ClientSideError(_(
|
||||
"Cannot assign storage function to a disk that contains "
|
||||
"other partitions."))
|
||||
|
||||
# semantic check: whether disk is already associated to a PV
|
||||
if idisk.ipv_uuid:
|
||||
raise wsme.exc.ClientSideError(_(
|
||||
"Cannot assign storage function to a disk already assigned "
|
||||
"as a physical volume to a volume group."))
|
||||
|
||||
return idisk_uuid
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue