Skip to content

Commit

Permalink
feat(dedicated): [wip] make everything working, seems to be finished
Browse files Browse the repository at this point in the history
ref: MANAGER-15833
Signed-off-by: Jean-Baptiste Delon <[email protected]>
  • Loading branch information
JayBeeDe committed Nov 14, 2024
1 parent 8aa4af7 commit e857963
Show file tree
Hide file tree
Showing 5 changed files with 137 additions and 117 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
export const MOUNT_POINTS = 'defghijklmnopqrstuvwxyza';
export const MAX_MOUNT_POINTS = 24;

export const TEMPLATE_OS_HARDWARE_RAID_ENUM = {
raid0: 'raid0',
raid1: 'raid1',
raid5: 'raid5',
raid6: 'raid6',
raid7: 'raid7',
raid10: 'raid10',
raid50: 'raid50',
raid60: 'raid60',
};

export const TEMPLATE_OS_SOFTWARE_RAID_LIST = {
1: ['0'],
2: ['0', '1'],
Expand All @@ -25,6 +14,5 @@ export const TEMPLATE_OS_SOFTWARE_RAID_LIST = {
export default {
MOUNT_POINTS,
MAX_MOUNT_POINTS,
TEMPLATE_OS_HARDWARE_RAID_ENUM,
TEMPLATE_OS_SOFTWARE_RAID_LIST,
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@ import forEachRight from 'lodash/forEachRight';
import range from 'lodash/range';
import set from 'lodash/set';
import some from 'lodash/some';
import Inputs from '../../inputs/inputs.class';
import { INPUTS_RULES } from '../../inputs/constants';
import {
MOUNT_POINTS,
MAX_MOUNT_POINTS,
TEMPLATE_OS_HARDWARE_RAID_ENUM,
TEMPLATE_OS_SOFTWARE_RAID_LIST,
} from './server-installation-ovh.constants';

Expand Down Expand Up @@ -94,6 +92,8 @@ export default class ServerInstallationOvhCtrl {
warningRaid6: '6',
warningRaid7: '7',
warningRaid10: '10',
warningRaid50: '50',
warningRaid60: '60',
warningNone: 'none',
warningSwap: 'swap',
warningReiserfs: 'reiserfs',
Expand Down Expand Up @@ -149,6 +149,8 @@ export default class ServerInstallationOvhCtrl {
// STEP2 SELECT
selectPartitionScheme: null, // select hight priority partition scheme
partitionSchemeModels: null, // detail of partitionScheme selected
storage: [],
customizations: {},
nbDiskUse: null, // if nbPhysicalDisk > 2 user can select nb disk to use
// dirtyPartition: true if variable partition size
// has been customized(change to false in loadPartition())
Expand Down Expand Up @@ -1696,38 +1698,38 @@ export default class ServerInstallationOvhCtrl {
}
if (nbOfDisk >= 8) {
this.$scope.informations.hardwareRaid.availableRaids.push(
TEMPLATE_OS_HARDWARE_RAID_ENUM.raid60,
this.$scope.constants.warningRaid60,
);
}
if (nbOfDisk >= 7) {
this.$scope.informations.hardwareRaid.availableRaids.push(
TEMPLATE_OS_HARDWARE_RAID_ENUM.raid7,
this.$scope.constants.warningRaid7,
);
}
if (nbOfDisk >= 6) {
this.$scope.informations.hardwareRaid.availableRaids.push(
TEMPLATE_OS_HARDWARE_RAID_ENUM.raid50,
this.$scope.constants.warningRaid50,
);
}
if (nbOfDisk >= 4) {
this.$scope.informations.hardwareRaid.availableRaids.push(
TEMPLATE_OS_HARDWARE_RAID_ENUM.raid6,
this.$scope.constants.warningRaid6,
);
this.$scope.informations.hardwareRaid.availableRaids.push(
TEMPLATE_OS_HARDWARE_RAID_ENUM.raid10,
this.$scope.constants.warningRaid10,
);
}
if (nbOfDisk >= 3) {
this.$scope.informations.hardwareRaid.availableRaids.push(
TEMPLATE_OS_HARDWARE_RAID_ENUM.raid5,
this.$scope.constants.warningRaid5,
);
}
if (nbOfDisk >= 2) {
this.$scope.informations.hardwareRaid.availableRaids.push(
TEMPLATE_OS_HARDWARE_RAID_ENUM.raid1,
this.$scope.constants.warningRaid1,
);
this.$scope.informations.hardwareRaid.availableRaids.push(
TEMPLATE_OS_HARDWARE_RAID_ENUM.raid0,
this.$scope.constants.warningRaid0,
);
}
}
Expand All @@ -1743,31 +1745,31 @@ export default class ServerInstallationOvhCtrl {
this.$scope.installation.hardwareRaid.disks = null;

switch (this.$scope.installation.hardwareRaid.raid) {
case TEMPLATE_OS_HARDWARE_RAID_ENUM.raid60:
case this.$scope.constants.warningRaid60:
minDisks = 8;
minDisksPerArray = 4;
break;
case TEMPLATE_OS_HARDWARE_RAID_ENUM.raid50:
case this.$scope.constants.warningRaid50:
minDisks = 6;
minDisksPerArray = 3;
break;
case TEMPLATE_OS_HARDWARE_RAID_ENUM.raid10:
case this.$scope.constants.warningRaid10:
minDisksPerArray = 2;
minDisks = 4;
break;
case TEMPLATE_OS_HARDWARE_RAID_ENUM.raid7:
case this.$scope.constants.warningRaid7:
minDisks = 7;
break;
case TEMPLATE_OS_HARDWARE_RAID_ENUM.raid6:
case this.$scope.constants.warningRaid6:
minDisks = 4;
break;
case TEMPLATE_OS_HARDWARE_RAID_ENUM.raid5:
case this.$scope.constants.warningRaid5:
minDisks = 3;
break;
case TEMPLATE_OS_HARDWARE_RAID_ENUM.raid1:
case this.$scope.constants.warningRaid1:
minDisks = 2;
break;
case TEMPLATE_OS_HARDWARE_RAID_ENUM.raid0:
case this.$scope.constants.warningRaid0:
minDisks = 2;
break;
default:
Expand All @@ -1793,17 +1795,17 @@ export default class ServerInstallationOvhCtrl {
this.$scope.installation.hardwareRaid.arrays = null;

switch (this.$scope.installation.hardwareRaid.raid) {
case TEMPLATE_OS_HARDWARE_RAID_ENUM.raid60:
case this.$scope.constants.warningRaid60:
maxNumberArray = this.$scope.installation.hardwareRaid.disks / 4;
minNumberArray = 2;
isMultipleArrays = true;
break;
case TEMPLATE_OS_HARDWARE_RAID_ENUM.raid50:
case this.$scope.constants.warningRaid50:
maxNumberArray = this.$scope.installation.hardwareRaid.disks / 3;
minNumberArray = 2;
isMultipleArrays = true;
break;
case TEMPLATE_OS_HARDWARE_RAID_ENUM.raid10:
case this.$scope.constants.warningRaid10:
maxNumberArray = this.$scope.installation.hardwareRaid.disks / 2;
minNumberArray = 2;
isMultipleArrays = true;
Expand Down Expand Up @@ -1845,31 +1847,31 @@ export default class ServerInstallationOvhCtrl {
this.$scope.installation.hardwareRaid.totalSpace =
this.$scope.installation.hardwareRaid.disks * diskSize;
switch (this.$scope.installation.hardwareRaid.raid) {
case TEMPLATE_OS_HARDWARE_RAID_ENUM.raid60:
case this.$scope.constants.warningRaid60:
this.$scope.installation.hardwareRaid.availableSpace =
(nbOfDisks - 2 * grappe) * diskSize;
break;
case TEMPLATE_OS_HARDWARE_RAID_ENUM.raid50:
case this.$scope.constants.warningRaid50:
this.$scope.installation.hardwareRaid.availableSpace =
(nbOfDisks - grappe) * diskSize;
break;
case TEMPLATE_OS_HARDWARE_RAID_ENUM.raid10:
case this.$scope.constants.warningRaid10:
this.$scope.installation.hardwareRaid.availableSpace =
grappe * diskSize;
break;
case TEMPLATE_OS_HARDWARE_RAID_ENUM.raid7:
case this.$scope.constants.warningRaid7:
this.$scope.installation.hardwareRaid.availableSpace =
(nbOfDisks - 3) * diskSize;
break;
case TEMPLATE_OS_HARDWARE_RAID_ENUM.raid6:
case this.$scope.constants.warningRaid6:
this.$scope.installation.hardwareRaid.availableSpace =
(nbOfDisks - 2) * diskSize;
break;
case TEMPLATE_OS_HARDWARE_RAID_ENUM.raid5:
case this.$scope.constants.warningRaid5:
this.$scope.installation.hardwareRaid.availableSpace =
(nbOfDisks - 1) * diskSize;
break;
case TEMPLATE_OS_HARDWARE_RAID_ENUM.raid1:
case this.$scope.constants.warningRaid1:
this.$scope.installation.hardwareRaid.availableSpace = diskSize;
break;
default:
Expand Down Expand Up @@ -2016,26 +2018,11 @@ export default class ServerInstallationOvhCtrl {

startInstall() {
this.$scope.loader.loading = true;
const inputs = new Inputs(this.$scope.installation.inputs);
// console.log('startInstall');
// console.log(this.$scope.installation.partitionSchemeModels);
this.Server.startInstallation(
this.$stateParams.productId,
this.$scope.informations.gabaritName,
this.$scope.installation.selectPartitionScheme,
{
customHostname: this.$scope.installation.options.customHostname,
softRaidDevices:
this.$scope.informations.nbDisk > 2 &&
this.$scope.installation.nbDiskUse > 1
? this.$scope.installation.nbDiskUse
: null,
noRaid:
this.$scope.installation.nbDiskUse === 1 &&
!this.$scope.informations.raidController,
diskGroupId: this.$scope.installation.diskGroup.diskGroupId || null,
},
inputs.answersHash2userMetadata(this.$scope.installation.input),
this.$scope.installation.storage,
this.$scope.installation.customizations,
).then(
(task) => {
set(task, 'id', task.taskId);
Expand All @@ -2058,30 +2045,109 @@ export default class ServerInstallationOvhCtrl {
);
}

// setHardwareRaid(
// schemeNameFilterList = [this.$scope.installation.selectPartitionScheme],
// ) {
// const disks = this.prepareDiskList();
// // console.log('setHardwareRaid');
getCustomizations() {
const customizations = {};
Object.values(this.$scope.installation.inputs).forEach((input) => {
if (
input.type !== 'keyValue' &&
this.$scope.installation.input[input.name]
) {
customizations[input.name.toString()] = this.$scope.installation.input[
input.name
].toString();
} else if (
input.type === 'keyValue' &&
this.$scope.installation.input[input.name].length > 0
) {
customizations[input.name.toString()] = {};
this.$scope.installation.input[input.name].forEach((keyValueItem) => {
customizations[input.name.toString()][
keyValueItem.key.toString()
] = keyValueItem.value.toString();
});
}
});
this.$scope.installation.customizations = customizations;
}

getStoragePartitioningLayout() {
this.$scope.installation.partitionSchemeModels.sort(
(a, b) => a.order - b.order,
);
const layout = [];
angular.forEach(
this.$scope.installation.partitionSchemeModels,
(partition) => {
const newPartition = {
fileSystem: partition.fileSystem,
mountPoint: partition.mountPoint,
size: partition.partitionSize,
raidLevel: Number(partition.raid), // jbd: to be improved
extras: {},
};
if (
partition.volumeName &&
this.$scope.installation.selectDistribution.lvmReady &&
partition.fileSystem !== this.$scope.constants.warningZFS &&
partition.fileSystem !== this.$scope.constants.warningSwap
) {
newPartition.extras = {
lv: {
name: partition.volumeName,
},
};
}
if (
partition.volumeName &&
partition.fileSystem === this.$scope.constants.warningZFS
) {
newPartition.extras = {
zp: {
name: partition.volumeName,
},
};
}
layout.push(newPartition);
},
);
return layout;
}

// schemeNameFilterList.forEach((schemeNameFilter) => {
// console.log(this.$stateParams.productId);
// console.log(this.$scope.informations.gabaritName);
// console.log(schemeNameFilter);
// console.log(disks);
// console.log(this.$scope.installation.hardwareRaid.raid);
// console.log('----');
// console.log(this.$scope.installation.hardwareRaid);
// });
// }
setStorage() {
const storage = {
diskGroupId: this.$scope.installation.diskGroup.diskGroupId || null,
hardwareRaid: [],
partitioning: {
disks:
this.$scope.informations.nbDisk > 2 &&
this.$scope.installation.nbDiskUse > 1
? this.$scope.installation.nbDiskUse
: 0,
layout: [],
},
};
if (this.$scope.installation.hardwareRaid.raid) {
const disks = this.prepareDiskList();
storage.hardwareRaid.push({
arrays: this.$scope.installation.hardwareRaid.arrays,
disks: disks.length,
raidLevel: Number(this.$scope.installation.hardwareRaid.raid), // jbd: to be improved
});
}
if (this.$scope.installation.customInstall) {
storage.partitioning.layout = this.getStoragePartitioningLayout();
} else {
storage.partitioning.schemeName = this.$scope.installation.selectPartitionScheme;
}
this.$scope.installation.storage.push(storage);
}

install() {
this.trackClick(
`dedicated::dedicated::${this.serverType}::system-install::public-catalog::install`,
);
// if (this.$scope.installation.hardwareRaid.raid) {
// this.setHardwareRaid();
// }
this.getCustomizations();
this.setStorage();
this.startInstall();
}

Expand Down
Loading

0 comments on commit e857963

Please sign in to comment.