Skip to content

Commit

Permalink
Implement Lvm edit page
Browse files Browse the repository at this point in the history
Signed-off-by: Francesco Torchia <[email protected]>
  • Loading branch information
torchiaf committed Sep 12, 2024
1 parent 567af7c commit 8f79581
Show file tree
Hide file tree
Showing 4 changed files with 142 additions and 34 deletions.
3 changes: 1 addition & 2 deletions pkg/harvester/config/harvester-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,5 @@ export const ADD_ONS = {
NVIDIA_DRIVER_TOOLKIT_CONTROLLER: 'nvidia-driver-toolkit',
RANCHER_LOGGING: 'rancher-logging',
RANCHER_MONITORING: 'rancher-monitoring',
VM_IMPORT_CONTROLLER: 'vm-import-controller',
HARVESTER_CSI_DRIVER_LVM: 'harvester-csi-driver-lvm'
VM_IMPORT_CONTROLLER: 'vm-import-controller'
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
<script>
import KeyValue from '@shell/components/form/KeyValue';
import LabeledSelect from '@shell/components/form/LabeledSelect';
import { LabeledInput } from '@components/Form/LabeledInput';
import RadioGroup from '@components/Form/Radio/RadioGroup';
import { allHash } from '@shell/utils/promise';
import { _CREATE, _VIEW } from '@shell/config/query-params';

Check warning on line 9 in pkg/harvester/edit/harvesterhci.io.storage/provisioners/lvm.driver.harvesterhci.io.vue

View workflow job for this annotation

GitHub Actions / lint

'_CREATE' is defined but never used

Check warning on line 9 in pkg/harvester/edit/harvesterhci.io.storage/provisioners/lvm.driver.harvesterhci.io.vue

View workflow job for this annotation

GitHub Actions / lint

'_VIEW' is defined but never used
import { LONGHORN } from '@shell/config/types';

Check warning on line 10 in pkg/harvester/edit/harvesterhci.io.storage/provisioners/lvm.driver.harvesterhci.io.vue

View workflow job for this annotation

GitHub Actions / lint

'LONGHORN' is defined but never used
import { clone } from '@shell/utils/object';
import { uniq } from '@shell/utils/array';

Check warning on line 12 in pkg/harvester/edit/harvesterhci.io.storage/provisioners/lvm.driver.harvesterhci.io.vue

View workflow job for this annotation

GitHub Actions / lint

'uniq' is defined but never used
import { LONGHORN_VERSION_V1, LONGHORN_VERSION_V2 } from '@shell/models/persistentvolume';

Check warning on line 13 in pkg/harvester/edit/harvesterhci.io.storage/provisioners/lvm.driver.harvesterhci.io.vue

View workflow job for this annotation

GitHub Actions / lint

'LONGHORN_VERSION_V1' is defined but never used

Check warning on line 13 in pkg/harvester/edit/harvesterhci.io.storage/provisioners/lvm.driver.harvesterhci.io.vue

View workflow job for this annotation

GitHub Actions / lint

'LONGHORN_VERSION_V2' is defined but never used
import { HCI } from '../../../types';
const DEFAULT_PARAMETERS = [
'type',
'vgName'
];
export default {
components: {
KeyValue,
LabeledSelect,
LabeledInput,

Check warning on line 25 in pkg/harvester/edit/harvesterhci.io.storage/provisioners/lvm.driver.harvesterhci.io.vue

View workflow job for this annotation

GitHub Actions / lint

The "LabeledInput" component has been registered but not used
RadioGroup,

Check warning on line 26 in pkg/harvester/edit/harvesterhci.io.storage/provisioners/lvm.driver.harvesterhci.io.vue

View workflow job for this annotation

GitHub Actions / lint

The "RadioGroup" component has been registered but not used
},
props: {
value: {
type: Object,
required: true
},
mode: {
type: String,
required: true
},
realMode: {
type: String,
required: true
},
},
async fetch() {
const inStore = this.$store.getters['currentProduct'].inStore;
await allHash({

Check warning on line 47 in pkg/harvester/edit/harvesterhci.io.storage/provisioners/lvm.driver.harvesterhci.io.vue

View workflow job for this annotation

GitHub Actions / lint

Unexpected line break after this opening brace
lvmVolumeGroups: this.$store.dispatch(`${ inStore }/findAll`, { type: HCI.LVM_VOLUME_GROUP }),
});
},
data() {
return {
volumeGroupTypes: ['striped', 'dm-thin'],
volumeGroupType: null,
volumeGroup: null,
nodeName: 'harvester-node-0'
};
},
computed: {
volumeGroups() {
const inStore = this.$store.getters['currentProduct'].inStore;
const lvmVolumeGroups = this.$store.getters[`${ inStore }/all`](HCI.LVM_VOLUME_GROUP) || [];
return lvmVolumeGroups
.filter(group => group.spec.nodeName === this.nodeName)
.map(g => g.spec.vgName);
},
parameters: {
get() {
const parameters = clone(this.value?.parameters) || {};
DEFAULT_PARAMETERS.map((key) => {
delete parameters[key];
});
return parameters;
},
set(value) {
Object.assign(this.value.parameters, value);
}
},
},
};
</script>
<template>
<div>
<div class="row mt-10">
<div class="col span-6">
<LabeledSelect
v-model="volumeGroup"
:label="t('harvester.storage.parameters.lvmVolumeGroup.label')"
:options="volumeGroups"
:mode="mode"
:required="true"
>
<template #no-options="{ searching }">
<span v-if="!searching" class="text-muted">
{{ t('harvester.storage.parameters.diskSelector.no-options', null, true) }}
</span>
</template>
</LabeledSelect>
</div>
<div class="col span-6">
<LabeledSelect
v-model="volumeGroupType"
:label="t('harvester.storage.parameters.lvmVolumeGroupType.label')"
:options="volumeGroupTypes"
:mode="mode"
:required="true"
>
<template #no-options="{ searching }">
<span v-if="!searching" class="text-muted">
{{ t('harvester.storage.parameters.nodeSelector.no-options', null, true) }}
</span>
</template>
</LabeledSelect>
</div>
</div>
<KeyValue
v-model="parameters"
:add-label="t('storageClass.longhorn.addLabel')"
:read-allowed="false"
:mode="mode"
class="mt-10"
/>
</div>
</template>
<style lang="scss" scoped>
.labeled-input.compact-input {
padding: 7px 10px;
}
</style>

Check failure on line 137 in pkg/harvester/edit/harvesterhci.io.storage/provisioners/lvm.driver.harvesterhci.io.vue

View workflow job for this annotation

GitHub Actions / lint

Too many blank lines at the end of file. Max of 0 allowed
32 changes: 0 additions & 32 deletions pkg/harvester/edit/harvesterhci.io.storage/provisioners/lvm.vue

This file was deleted.

4 changes: 4 additions & 0 deletions pkg/harvester/l10n/en-us.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1079,6 +1079,10 @@ harvester:
no-options: No available tags, please add in the `Host > Storage` page
migratable:
label: Migratable
lvmVolumeGroupType:
label: Volume Group Type
lvmVolumeGroup:
label: Volume Group Name
allowedTopologies:
title: Allowed Topologies
tooltip: Allowed Topologies helps scheduling virtual machines on hosts which match all of below expressions.
Expand Down

0 comments on commit 8f79581

Please sign in to comment.