@@ -12,7 +12,6 @@ import { PRODUCT_NAME as HARVESTER_PRODUCT } from '../../../../config/harvester'
1212import ImagePercentageBar from ' @shell/components/formatter/ImagePercentageBar' ;
1313import { Banner } from ' @components/Banner' ;
1414import isEmpty from ' lodash/isEmpty' ;
15- import { STORAGE_CLASS } from ' @shell/config/types' ;
1615
1716const IMAGE_METHOD = {
1817 NEW : ' new' ,
@@ -33,7 +32,6 @@ export default {
3332
3433 async fetch () {
3534 await this .$store .dispatch (' harvester/findAll' , { type: HCI .IMAGE });
36- await this .$store .dispatch (' harvester/findAll' , { type: STORAGE_CLASS });
3735
3836 const value = await this .$store .dispatch (' harvester/create' , {
3937 type: HCI .UPGRADE ,
@@ -65,7 +63,6 @@ export default {
6563 sourceType: UPLOAD ,
6664 uploadController: null ,
6765 uploadResult: null ,
68- storageClassValue: null ,
6966 imageValue: null ,
7067 enableLogging: true ,
7168 IMAGE_METHOD ,
@@ -183,38 +180,6 @@ export default {
183180 });
184181 },
185182
186- async createImageStorageClass (imageName = ' ' ) {
187- // delete related SC if existed
188- await this .deleteImageStorageClass (imageName);
189-
190- const storageClassPayload = {
191- apiVersion: ' storage.k8s.io/v1' ,
192- type: STORAGE_CLASS ,
193- metadata: { name: imageName },
194- volumeBindingMode: ' Immediate' ,
195- reclaimPolicy: ' Delete' ,
196- allowVolumeExpansion: true , // must be boolean type
197- provisioner: ' driver.longhorn.io' ,
198- };
199-
200- this .storageClassValue = await this .$store .dispatch (' harvester/create' , storageClassPayload);
201-
202- if (this .storageClassValue && this .storageClassValue .save ) {
203- await this .storageClassValue .save ();
204- }
205- },
206-
207- async deleteImageStorageClass (imageName = ' ' ) {
208- const inStore = this .$store .getters [' currentProduct' ].inStore ;
209- const storageClasses = this .$store .getters [` ${ inStore } /all` ](STORAGE_CLASS );
210-
211- const targetSC = storageClasses .find ((sc ) => sc .id === imageName);
212-
213- if (targetSC && targetSC .remove ) {
214- await targetSC .remove ();
215- }
216- },
217-
218183 async initImageValue () {
219184 this .imageValue = await this .$store .dispatch (' harvester/create' , {
220185 type: HCI .IMAGE ,
@@ -263,10 +228,8 @@ export default {
263228 return ;
264229 }
265230
266- // create related image storage class first
267- await this .createImageStorageClass (imageDisplayName);
268231 this .imageValue .spec .sourceType = DOWNLOAD ;
269- this .imageValue .spec .targetStorageClassName = imageDisplayName ;
232+ this .imageValue .spec .targetStorageClassName = ' longhorn-static ' ;
270233
271234 res = await this .imageValue .save ();
272235
@@ -295,8 +258,6 @@ export default {
295258 } catch (e) {
296259 this .errors = [e? .message ] || exceptionToErrorsArray (e);
297260 buttonCb (false );
298- // if anything failed, delete the created image storage class
299- await this .deleteImageStorageClass (imageDisplayName);
300261 }
301262 },
302263
@@ -325,9 +286,7 @@ export default {
325286 this .imageValue .spec .url = ' ' ;
326287
327288 try {
328- // before uploading image, we need to create related image storage class first
329- await this .createImageStorageClass (fileName);
330- this .imageValue .spec .targetStorageClassName = fileName;
289+ this .imageValue .spec .targetStorageClassName = ' longhorn-static' ;
331290
332291 const res = await this .imageValue .save ();
333292
@@ -345,8 +304,6 @@ export default {
345304 } else {
346305 this .errors = exceptionToErrorsArray (e);
347306 }
348- // if upload failed, delete the created image storage class
349- await this .deleteImageStorageClass (fileName);
350307 this .file = {};
351308 this .uploadImageId = ' ' ;
352309 }
@@ -367,13 +324,10 @@ export default {
367324
368325 if (image && imageDisplayName) {
369326 this .$store .dispatch (' harvester/promptModal' , {
370- resources: [image],
371- component: ' ConfirmRelatedToRemoveDialog' ,
372- needConfirmation: false ,
373- warningMessage: this .$store .getters [' i18n/t' ](' harvester.modal.osImage.message' , { name: imageDisplayName }),
374- extraActionAfterRemove: async () => {
375- await this .deleteImageStorageClass (imageDisplayName);
376- }
327+ resources: [image],
328+ component: ' ConfirmRelatedToRemoveDialog' ,
329+ needConfirmation: false ,
330+ warningMessage: this .$store .getters [' i18n/t' ](' harvester.modal.osImage.message' , { name: imageDisplayName }),
377331 });
378332 this .deleteImageId = ' ' ;
379333 }
0 commit comments