Skip to content

Commit

Permalink
feat(netapp): add mount path during volume creation
Browse files Browse the repository at this point in the history
ref: MANAGER-16848

Signed-off-by: Sachin Ramesh <[email protected]>
  • Loading branch information
sachinrameshn committed Feb 18, 2025
1 parent 4c11a52 commit 8380333
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 4 deletions.
12 changes: 11 additions & 1 deletion packages/manager/modules/netapp/src/dashboard/Share.class.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
export default class Share {
constructor({ id, createdAt, description, name, protocol, size, status }) {
constructor({
id,
createdAt,
description,
name,
protocol,
size,
status,
path,
}) {
Object.assign(this, {
id,
createdAt,
Expand All @@ -8,6 +17,7 @@ export default class Share {
protocol,
size,
status,
path,
});
}

Expand Down
3 changes: 3 additions & 0 deletions packages/manager/modules/netapp/src/dashboard/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ export const LABELS = {

export const NETAPP_NAME_PATTERN = /^[a-zA-Z0-9._-]{1,64}$/;

export const MOUNT_PATH_PATTERN = /^[a-zA-Z0-9_]{1,255}$/;

export default {
MINIMUM_VOLUME_SIZE,
COMMIT_IMPRESSION_TRACKING_DATA,
Expand All @@ -110,4 +112,5 @@ export default {
VRACK_ORDER_URLS,
LABELS,
NETAPP_NAME_PATTERN,
MOUNT_PATH_PATTERN,
};
10 changes: 8 additions & 2 deletions packages/manager/modules/netapp/src/dashboard/routing.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,16 @@ export default /* @ngInject */ ($stateProvider) => {
trackClick('configure-network');
return $state.go('netapp.dashboard.network');
},
volumes: /* @ngInject */ ($http, serviceName) =>
volumes: /* @ngInject */ ($http, serviceName, NetAppDashboardService) =>
$http
.get(`/storage/netapp/${serviceName}/share?detail=true`)
.then(({ data }) => data.map((volume) => new Share(volume))),
.then(({ data }) => {
return NetAppDashboardService.getListOfAccessPath(
serviceName,
data,
);
})
.then((volumes) => volumes.map((volume) => new Share(volume))),
availableVolumeSize: /* @ngInject */ (storage, volumes) => {
const storageVolumesSize = volumes.reduce(
(allSizes, volume) => allSizes + volume.size,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MINIMUM_VOLUME_SIZE } from '../../constants';
import { MINIMUM_VOLUME_SIZE, MOUNT_PATH_PATTERN } from '../../constants';

export default class VolumeCreateCtrl {
/* @ngInject */
Expand All @@ -16,6 +16,7 @@ export default class VolumeCreateCtrl {
[this.newVolumeProtocol] = this.protocolList;
this.minimumVolumeSize = MINIMUM_VOLUME_SIZE;
this.availableVolumeSize = this.getAvailableSize();
this.usedMountPaths = this.volumes.map(({ path }) => path?.split('/')[1]);
}

getAvailableSize() {
Expand Down Expand Up @@ -55,6 +56,12 @@ export default class VolumeCreateCtrl {
});
}

isValidMountPath(value) {
return (
MOUNT_PATH_PATTERN.test(value) && !this.usedMountPaths?.includes(value)
);
}

goBack() {
this.trackClick('create::cancel');
return this.goToVolumes();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,19 @@
data-ng-required="true"
/>
</oui-field>
<oui-field
data-label="{{:: 'netapp_volume_mount_path' | translate }}"
data-error-messages="{ pattern: ('netapp_volume_mount_path_format_error' | translate) }"
size="l"
>
<input
class="oui-input"
type="text"
id="mountPath"
name="mountPath"
data-ng-model="$ctrl.newVolume.mountPath"
data-ui-validate="{ pattern: '$ctrl.isValidMountPath($value)' }"
/>
</oui-field>
</form>
</oui-modal>
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
"netapp_volume_create_cancel": "Annuler",
"netapp_volume_create_name": "Nom du volume (optionnel)",
"netapp_volume_create_description": "Description (optionnel)",
"netapp_volume_mount_path": "Mount Path(optionnel)",
"netapp_volume_mount_path_format_error": "Le mount path est déjà utilisé sur un autre volume. Veuillez en saisir un nouveau.",
"netapp_volume_create_protocol": "Protocole",
"netapp_volume_create_protocol_NFS": "NFSv3",
"netapp_volume_create_size": "Taille du volume",
Expand Down

0 comments on commit 8380333

Please sign in to comment.