760
761
event_action=action,
761
762
event_description=description)
764
def storage_layout_issues(self):
765
"""Return any errors with the storage layout.
767
Checks that the node has / mounted. If / is mounted on bcache check
768
that /boot is mounted and is not on bcache."""
770
if obj.type == "physical":
772
elif obj.type == "partition":
773
return on_bcache(obj.partition_table.block_device)
774
for parent in obj.virtualblockdevice.get_parents():
775
if((parent.type != "physical" and on_bcache(parent)) or
776
(parent.get_effective_filesystem().fstype in
777
[FILESYSTEM_TYPE.BCACHE_CACHE,
778
FILESYSTEM_TYPE.BCACHE_BACKING])):
784
root_on_bcache = False
787
for block_device in self.blockdevice_set.all():
788
if block_device.is_boot_disk():
790
pt = block_device.get_partitiontable()
792
for partition in pt.partitions.all():
793
fs = partition.get_effective_filesystem()
796
if fs.mount_point == '/':
798
if on_bcache(block_device):
799
root_on_bcache = True
801
# If / is mounted and its not on bcache the system
804
elif (fs.mount_point == '/boot' and
805
not on_bcache(block_device)):
808
fs = block_device.get_effective_filesystem()
811
if fs.mount_point == '/':
813
if on_bcache(block_device):
814
root_on_bcache = True
816
# If / is mounted and its not on bcache the system
819
elif fs.mount_point == '/boot' and not on_bcache(block_device):
823
issues.append("Node must have boot disk.")
825
issues.append("Node must have / mounted.")
826
if root_mounted and root_on_bcache and not boot_mounted:
827
issues.append("Because / is on a bcache volume you must create "
828
"/boot on a non-bcache volume")
763
831
def on_network(self):
764
832
"""Return true if the node is connected to a managed network."""
765
833
for interface in self.interface_set.all():
772
840
def _start_deployment(self):
773
841
"""Mark a node as being deployed."""
774
842
if self.on_network() is False:
775
raise ValidationError("Node must be configured to use a network")
843
raise ValidationError(
845
["Node must be configured to use a network"]})
846
storage_layout_issues = self.storage_layout_issues()
847
if len(storage_layout_issues) > 0:
848
raise ValidationError({"storage": storage_layout_issues})
776
849
self.status = NODE_STATUS.DEPLOYING