system: return the mounted and unmounted block devices (as long as xfs or ext4)

This commit is contained in:
Girish Ramakrishnan
2025-09-23 17:30:09 +02:00
parent 8668ff8939
commit f92cdf36f5
7 changed files with 43 additions and 38 deletions
+18 -24
View File
@@ -27,8 +27,8 @@ const systemModel = SystemModel.create();
const provisionModel = ProvisionModel.create();
const storageProviders = Array.from(STORAGE_PROVIDERS);
const blockDevices = ref([]);
const disk = ref('');
const ext4BlockDevices = ref([]);
const xfsBlockDevices = ref([]);
const gcsKeyFileName = ref('');
const gcsFileParseError = ref('');
@@ -67,28 +67,21 @@ function onGcsKeyChange(event) {
}
async function getBlockDevices() {
let error, result;
let error, blockDevices;
if (props.provisioning) [error, result] = await provisionModel.blockDevices();
else [error, result] = await systemModel.blockDevices();
if (props.provisioning) [error, blockDevices] = await provisionModel.blockDevices();
else [error, blockDevices] = await systemModel.blockDevices();
if (error) return console.error(error);
// amend label for UI
result.forEach(d => {
d.label = d.path;
// pre-select current if set
if (d.path === providerConfig.value.mountOptionDiskPath || ('/dev/disk/by-uuid/' + d.uuid) === providerConfig.value.mountOptionDiskPath) {
disk.value = d.path;
}
});
// only offer non /, /boot or /home disks
// only offer xfs and ext4 disks
blockDevices.value = result
.filter(d => { return d.mountpoint !== '/' && d.mountpoint !== '/home' && d.mountpoint !== '/boot'; })
.filter(d => { return d.type === 'xfs' || d.type === 'ext4'; });
ext4BlockDevices.value = [];
xfsBlockDevices.value = [];
for (const blockDevice of blockDevices) {
if (blockDevice.mountpoints.some((mountpoint) => mountpoint === '/' || mountpoint.startsWith('/home') || mountpoint.startsWith('/boot'))) continue;
blockDevice.label = blockDevice.path; // // amend label for UI
if (blockDevice.type === 'ext4') ext4BlockDevices.value.push(blockDevice);
else if (blockDevice.type === 'xfs') xfsBlockDevices.value.push(blockDevice);
}
}
watch(provider, (newProvider) => {
@@ -153,14 +146,15 @@ onMounted(async () => {
<!-- EXT4/XFS -->
<FormGroup v-if="provider === 'xfs' || provider === 'ext4'">
<label for="mountOptionDiskPathInput">{{ $t('backups.configureBackupStorage.diskPath') }}</label>
<TextInput id="mountOptionDiskPathInput" v-model="providerConfig.mountOptionDiskPath" placeholder="/dev/disk/by-uuid/uuid" required />
<label for="blockDevicePath">{{ $t('backups.configureBackupStorage.diskPath') }}</label>
<SingleSelect id="blockDevicePath" v-if="provider === 'ext4'" v-model="providerConfig.mountOptionDiskPath" :options="ext4BlockDevices" option-label="label" option-key="path"/>
<SingleSelect id="blockDevicePath" v-if="provider === 'xfs'" v-model="providerConfig.mountOptionDiskPath" :options="xfsBlockDevices" option-label="label" option-key="path"/>
</FormGroup>
<!-- Disk -->
<!-- Disk -->
<FormGroup v-if="provider === 'disk'">
<label class="control-label">{{ $t('backups.configureBackupStorage.diskPath') }}</label>
<SingleSelect v-model="disk" :options="providerConfig.blockDevices" option-label="label" option-key="path" required />
<TextInput id="mountOptionDiskPathInput" v-model="providerConfig.mountOptionDiskPath" placeholder="/dev/disk/by-uuid/uuid" required />
</FormGroup>
<!-- SSHFS -->
+3 -2
View File
@@ -163,6 +163,7 @@ async function openVolumeDialog(volume) {
const ext4BlockDevices = [], xfsBlockDevices = [];
for (const blockDevice of blockDevices) {
if (blockDevice.mountpoints.some((mountpoint) => mountpoint === '/' || mountpoint.startsWith('/home') || mountpoint.startsWith('/boot'))) continue;
blockDevice.label = blockDevice.path; // // amend label for UI
if (blockDevice.type === 'ext4') ext4BlockDevices.push(blockDevice);
else if (blockDevice.type === 'xfs') xfsBlockDevices.push(blockDevice);
@@ -295,8 +296,8 @@ onMounted(async () =>{
<FormGroup v-if="volumeDialogData.mountType === 'ext4' || volumeDialogData.mountType === 'xfs'">
<label for="volumeDiskPath">{{ $t('volumes.addVolumeDialog.diskPath') }}</label>
<SingleSelect id="volumeMountType" v-if="volumeDialogData.mountType === 'ext4'" v-model="volumeDialogData.diskPath" :options="volumeDialogData.ext4BlockDevices" option-label="label" option-key="path" :disabled="volumeDialogData.mode === 'edit'"/>
<SingleSelect id="volumeMountType" v-if="volumeDialogData.mountType === 'xfs'" v-model="volumeDialogData.diskPath" :options="volumeDialogData.xfsBlockDevices" option-label="label" option-key="path" :disabled="volumeDialogData.mode === 'edit'"/>
<SingleSelect id="volumeDiskPath" v-if="volumeDialogData.mountType === 'ext4'" v-model="volumeDialogData.diskPath" :options="volumeDialogData.ext4BlockDevices" option-label="label" option-key="path" :disabled="volumeDialogData.mode === 'edit'"/>
<SingleSelect id="volumeDiskPath" v-if="volumeDialogData.mountType === 'xfs'" v-model="volumeDialogData.diskPath" :options="volumeDialogData.xfsBlockDevices" option-label="label" option-key="path" :disabled="volumeDialogData.mode === 'edit'"/>
</FormGroup>
<FormGroup v-if="volumeDialogData.mountType === 'cifs' || volumeDialogData.mountType === 'nfs' || volumeDialogData.mountType === 'sshfs'">