Skip to content

Commit

Permalink
Update Storage and Disk tabs based on provisioner - TO CONTINUE
Browse files Browse the repository at this point in the history
Signed-off-by: Francesco Torchia <francesco.torchia@suse.com>
  • Loading branch information
torchiaf committed Sep 10, 2024
1 parent e8bf9c8 commit bf1340d
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 14 deletions.
47 changes: 39 additions & 8 deletions pkg/harvester/edit/harvesterhci.io.host/HarvesterDisk.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,11 @@ export default {
csiDrivers: this.$store.dispatch(`${ inStore }/findAll`, { type: CSI_DRIVER }),
longhornV2DataEngine: this.$store.dispatch(`${ inStore }/find`, { type: LONGHORN.SETTINGS, id: LONGHORN_V2_DATA_ENGINE }),
});
this.longhornVersion = hash.longhornV2DataEngine.value === 'true' ? 'v2' : 'v1';
},
data() {
return {

Check warning on line 62 in pkg/harvester/edit/harvesterhci.io.host/HarvesterDisk.vue

View workflow job for this annotation

GitHub Actions / lint

Unexpected line break after this opening brace
longhornVersion: 'v1',
provisioner: {
label: this.t(`harvester.storage.storageClass.${ LONGHORN_DRIVER }.label`, { version: 1 }),
value: LONGHORN_DRIVER,
}
provisioner: this.value.provisioner || LONGHORN_DRIVER, // TODO fix provisioner souce field
};

Check warning on line 64 in pkg/harvester/edit/harvesterhci.io.host/HarvesterDisk.vue

View workflow job for this annotation

GitHub Actions / lint

Unexpected line break before this closing brace
},
Expand Down Expand Up @@ -195,12 +189,43 @@ export default {
return this.blockDevice.isFormatting;
},
longhornVersion() {
const inStore = this.$store.getters['currentProduct'].inStore;
const v2DataEngine = this.$store.getters[`${ inStore }/byId`](LONGHORN.SETTINGS, LONGHORN_V2_DATA_ENGINE) || {};
return v2DataEngine.value === 'true' ? 'v2' : 'v1';
},
isLvm() {
return this.provisioner === LVM_DRIVER;
},
isLonghornV1() {
return this.provisioner === LONGHORN_DRIVER && this.longhornVersion === 'v1';
},
isLonghornV2() {
return this.provisioner === LONGHORN_DRIVER && this.longhornVersion === 'v2';
},
provisionersLabelKeys() {
return {
[LONGHORN_DRIVER]: `harvester.storage.storageClass.longhorn.${ this.longhornVersion }.label`,
[LVM_DRIVER]: 'harvester.storage.storageClass.lvm.label'

Check warning on line 214 in pkg/harvester/edit/harvesterhci.io.host/HarvesterDisk.vue

View workflow job for this annotation

GitHub Actions / lint

Missing space before value for computed key 'LVM_DRIVER'
};
},
showLonghornOptions() {
return this.isCorrupted || (
this.value.isNew &&
!this.isFormatted &&
this.isLonghornV1
);
},
showLVMOptions() {
return this.isLvm;
}
},
methods: {
Expand Down Expand Up @@ -316,7 +341,7 @@ export default {
/>
</div>
</div>
<div v-if="(value.isNew && !isFormatted) || isCorrupted" class="row mt-10">
<div v-if="showLonghornOptions" class="row mt-10">
<div class="col span-6">
<RadioGroup
v-model="value.forceFormatted"
Expand All @@ -340,6 +365,12 @@ export default {
</RadioGroup>
</div>
</div>
<div v-if="showLVMOptions" class="row mt-10">
<div class="col span-6">
ciao lvm
</div>
</div>
</div>
</template>
Expand Down
18 changes: 14 additions & 4 deletions pkg/harvester/edit/harvesterhci.io.storage/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ export default {
key: '',
values: [],
},
longhornVersion: 'v1'
};
},
Expand All @@ -105,8 +104,6 @@ export default {
csiDrivers: this.$store.dispatch(`${ inStore }/findAll`, { type: CSI_DRIVER }),
longhornV2DataEngine: this.$store.dispatch(`${ inStore }/find`, { type: LONGHORN.SETTINGS, id: LONGHORN_V2_DATA_ENGINE }),
});
this.longhornVersion = hash.longhornV2DataEngine.value === 'true' ? 'v2' : 'v1';
},
computed: {
Expand Down Expand Up @@ -147,11 +144,24 @@ export default {
[LVM_DRIVER]: 'harvester.storage.storageClass.lvm.label'

Check warning on line 144 in pkg/harvester/edit/harvesterhci.io.storage/index.vue

View workflow job for this annotation

GitHub Actions / lint

Missing space before value for computed key 'LVM_DRIVER'
};
},
longhornVersion() {
const inStore = this.$store.getters['currentProduct'].inStore;
const v2DataEngine = this.$store.getters[`${ inStore }/byId`](LONGHORN.SETTINGS, LONGHORN_V2_DATA_ENGINE) || {};
return v2DataEngine.value === 'true' ? 'v2' : 'v1';
},
},
watch: {
provisionerWatch() {
this.$set(this.value, 'parameters', {});
const parameters = {};
if (this.isLonghornV2) {
parameters.migratable = false;
}
this.$set(this.value, 'parameters', parameters);
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { LONGHORN } from '@shell/config/types';
import { clone } from '@shell/utils/object';
import { uniq } from '@shell/utils/array';
const LONGHORN_V2_DATA_ENGINE = 'longhorn-system/v2-data-engine';
const DEFAULT_PARAMETERS = [
'numberOfReplicas',
'staleReplicaTimeout',
Expand Down Expand Up @@ -41,17 +43,22 @@ export default {
},
data() {
const inStore = this.$store.getters['currentProduct'].inStore;
const v2DataEngine = this.$store.getters[`${ inStore }/byId`](LONGHORN.SETTINGS, LONGHORN_V2_DATA_ENGINE) || {};
const longhornVersion = v2DataEngine.value === 'true' ? 'v2' : 'v1';
if (this.realMode === _CREATE) {
this.$set(this.value, 'parameters', {
numberOfReplicas: '3',
staleReplicaTimeout: '30',
diskSelector: null,
nodeSelector: null,
migratable: 'true',
migratable: longhornVersion === 'v2' ? 'false' : 'true',
});
}
return {};
return { longhornVersion };
},
computed: {
Expand Down Expand Up @@ -229,6 +236,7 @@ export default {
:label="t('harvester.storage.parameters.migratable.label')"
:mode="mode"
:options="migratableOptions"
:disabled="longhornVersion === 'v2'"
/>
</div>
</div>
Expand Down

0 comments on commit bf1340d

Please sign in to comment.