system: return the mounted and unmounted block devices (as long as xfs or ext4)
This commit is contained in:
@@ -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 -->
|
||||
|
||||
Reference in New Issue
Block a user