forked from IBM/ibm-spectrum-scale-csi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrest_v2.go
2052 lines (1664 loc) · 77.5 KB
/
rest_v2.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
* Copyright 2019, 2024 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package connectors
import (
"context"
"crypto/tls"
"crypto/x509"
"fmt"
"net/http"
"net/url"
"reflect"
"strconv"
"strings"
"time"
"github.com/IBM/ibm-spectrum-scale-csi/driver/csiplugin/settings"
"github.com/IBM/ibm-spectrum-scale-csi/driver/csiplugin/utils"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"k8s.io/klog/v2"
)
const errConnectionRefused string = "connection refused"
const errNoSuchHost string = "no such host"
const errContextDeadlineExceeded string = "context deadline exceeded"
// Bucket parameters for a AFM cache volume
const (
BucketEndpoint = "endpoint"
BucketName = "bucket"
bucketAccesskey = "accesskey"
bucketSecretkey = "secretkey"
defaultS3Port = "443"
cachevolume = "2"
CacheTempDirName = ".cachevolumetmp"
)
var GetLoggerId = utils.GetLoggerId
type SpectrumRestV2 struct {
HTTPclient *http.Client
Endpoint []string
EndPointIndex int
ClusterConfig settings.Clusters
RequestCalledBy string // "operator" or none
}
func (s *SpectrumRestV2) isStatusOK(statusCode int) bool {
klog.V(4).Infof("rest_v2 isStatusOK. statusCode: %d", statusCode)
if (statusCode == http.StatusOK) ||
(statusCode == http.StatusCreated) ||
(statusCode == http.StatusAccepted) {
return true
}
return false
}
func (s *SpectrumRestV2) checkAsynchronousJob(statusCode int) bool {
klog.V(4).Infof("rest_v2 checkAsynchronousJob. statusCode: %d", statusCode)
if (statusCode == http.StatusAccepted) ||
(statusCode == http.StatusCreated) {
return true
}
return false
}
func (s *SpectrumRestV2) isRequestAccepted(ctx context.Context, response GenericResponse, url string) error {
responseToLog := response
if url == utils.BucketKeysURL && len(responseToLog.Jobs) != 0 &&
!reflect.DeepEqual(responseToLog.Jobs[0].Request, Resprequest{}) && responseToLog.Jobs[0].Request.Data != nil {
accessKey := "accessKey"
secretKey := "secretKey"
var exists bool
if _, exists = responseToLog.Jobs[0].Request.Data[accessKey]; exists {
delete(responseToLog.Jobs[0].Request.Data, accessKey)
}
if _, exists = responseToLog.Jobs[0].Request.Data[secretKey]; exists {
delete(responseToLog.Jobs[0].Request.Data, secretKey)
}
}
klog.V(4).Infof("[%s] rest_v2 isRequestAccepted. url: %s, response: %v", utils.GetLoggerId(ctx), url, responseToLog)
if !s.isStatusOK(response.Status.Code) {
return fmt.Errorf("error %v for url %v", responseToLog, url)
}
if len(response.Jobs) == 0 {
return fmt.Errorf("unable to get Job details for %s, response: %v", url, responseToLog)
}
return nil
}
func (s *SpectrumRestV2) WaitForJobCompletion(ctx context.Context, statusCode int, jobID uint64) error {
klog.V(4).Infof("[%s] rest_v2 waitForJobCompletion. jobID: %d, statusCode: %d", utils.GetLoggerId(ctx), jobID, statusCode)
if s.checkAsynchronousJob(statusCode) {
jobURL := fmt.Sprintf("scalemgmt/v2/jobs/%d?fields=:all:", jobID)
_, err := s.AsyncJobCompletion(ctx, jobURL)
if err != nil {
klog.Errorf("[%s] error in waiting for job completion %v, %v", utils.GetLoggerId(ctx), jobID, err)
return err
}
}
return nil
}
func (s *SpectrumRestV2) WaitForJobCompletionWithResp(ctx context.Context, statusCode int, jobID uint64) (GenericResponse, error) {
klog.V(4).Infof("[%s] rest_v2 WaitForJobCompletionWithResp. jobID: %d, statusCode: %d", utils.GetLoggerId(ctx), jobID, statusCode)
if s.checkAsynchronousJob(statusCode) {
jobURL := fmt.Sprintf("scalemgmt/v2/jobs/%d?fields=:all:", jobID)
response, err := s.AsyncJobCompletion(ctx, jobURL)
if err != nil {
return GenericResponse{}, err
}
return response, nil
}
return GenericResponse{}, nil
}
func (s *SpectrumRestV2) AsyncJobCompletion(ctx context.Context, jobURL string) (GenericResponse, error) {
klog.V(4).Infof("[%s] rest_v2 AsyncJobCompletion. jobURL: %s", utils.GetLoggerId(ctx), jobURL)
jobQueryResponse := GenericResponse{}
var waitTime time.Duration = 2
for {
err := s.doHTTP(ctx, jobURL, "GET", &jobQueryResponse, nil)
if err != nil {
return GenericResponse{}, err
}
if len(jobQueryResponse.Jobs) == 0 {
return GenericResponse{}, fmt.Errorf("unable to get Job details for %s: %v", jobURL, jobQueryResponse)
}
if jobQueryResponse.Jobs[0].Status == "RUNNING" {
time.Sleep(waitTime * time.Second)
if waitTime < 16 {
waitTime = waitTime * 2
}
continue
}
break
}
if jobQueryResponse.Jobs[0].Status == "COMPLETED" || jobQueryResponse.Jobs[0].Status == "UNKNOWN" {
return jobQueryResponse, nil
} else {
klog.Errorf("[%s] Async Job failed: %v", utils.GetLoggerId(ctx), jobQueryResponse)
return GenericResponse{}, fmt.Errorf("%v", jobQueryResponse.Jobs[0].Result.Stderr)
}
}
func NewSpectrumRestV2(ctx context.Context, scaleConfig settings.Clusters) (SpectrumScaleConnector, error) {
klog.V(4).Infof("[%s] rest_v2 NewSpectrumRestV2.", utils.GetLoggerId(ctx))
var rest *SpectrumRestV2
var tr *http.Transport
if scaleConfig.SecureSslMode {
caCertPool := x509.NewCertPool()
if ok := caCertPool.AppendCertsFromPEM(scaleConfig.CacertValue); !ok {
return &SpectrumRestV2{}, fmt.Errorf("parsing CA cert %v failed", scaleConfig.Cacert)
}
tr = &http.Transport{TLSClientConfig: &tls.Config{RootCAs: caCertPool, MinVersion: tls.VersionTLS12}}
klog.V(4).Infof("[%s] created IBM Storage Scale connector with SSL mode for guiHost(s)", utils.GetLoggerId(ctx))
} else {
//#nosec G402 InsecureSkipVerify was requested by user.
tr = &http.Transport{TLSClientConfig: &tls.Config{InsecureSkipVerify: true, MinVersion: tls.VersionTLS12}} //nolint:gosec
klog.V(4).Infof("[%s] created IBM Storage Scale connector without SSL mode for guiHost(s)", utils.GetLoggerId(ctx))
}
rest = &SpectrumRestV2{
HTTPclient: &http.Client{
Transport: tr,
Timeout: time.Second * 60,
},
EndPointIndex: 0, //Use first GUI as primary by default
ClusterConfig: scaleConfig,
}
for i := range scaleConfig.RestAPI {
guiHost := scaleConfig.RestAPI[i].GuiHost
guiPort := scaleConfig.RestAPI[i].GuiPort
if guiPort == 0 {
guiPort = settings.DefaultGuiPort
}
endpoint := fmt.Sprintf("%s://%s:%d/", settings.GuiProtocol, guiHost, guiPort)
rest.Endpoint = append(rest.Endpoint, endpoint)
}
return rest, nil
}
func (s *SpectrumRestV2) GetClusterId(ctx context.Context) (string, error) {
klog.V(4).Infof("[%s] rest_v2 GetClusterId", utils.GetLoggerId(ctx))
getClusterURL := "scalemgmt/v2/cluster"
getClusterResponse := GetClusterResponse{}
err := s.doHTTP(ctx, getClusterURL, "GET", &getClusterResponse, nil)
if err != nil {
klog.Errorf("[%s] Unable to get cluster ID: %v", utils.GetLoggerId(ctx), err)
return "", err
}
cidStr := fmt.Sprintf("%v", getClusterResponse.Cluster.ClusterSummary.ClusterID)
return cidStr, nil
}
// GetClusterSummary function returns the information details of the cluster.
func (s *SpectrumRestV2) GetClusterSummary(ctx context.Context) (ClusterSummary, error) {
klog.V(4).Infof("[%s] rest_v2 GetClusterSummary", utils.GetLoggerId(ctx))
getClusterURL := "scalemgmt/v2/cluster"
getClusterResponse := GetClusterResponse{}
err := s.doHTTP(ctx, getClusterURL, "GET", &getClusterResponse, nil)
if err != nil {
klog.Errorf("[%s] Unable to get cluster summary: %v", utils.GetLoggerId(ctx), err)
return ClusterSummary{}, err
}
return getClusterResponse.Cluster.ClusterSummary, nil
}
func (s *SpectrumRestV2) GetTimeZoneOffset(ctx context.Context) (string, error) {
klog.V(4).Infof("[%s] rest_v2 GetTimeZoneOffset", utils.GetLoggerId(ctx))
getConfigURL := "scalemgmt/v2/config"
getConfigResponse := GetConfigResponse{}
err := s.doHTTP(ctx, getConfigURL, "GET", &getConfigResponse, nil)
if err != nil {
klog.Errorf("[%s] Unable to get cluster configuration: %v", utils.GetLoggerId(ctx), err)
return "", err
}
timezone := fmt.Sprintf("%v", getConfigResponse.Config.ClusterConfig.TimeZoneOffset)
return timezone, nil
}
func (s *SpectrumRestV2) GetScaleVersion(ctx context.Context) (string, error) {
klog.V(4).Infof("[%s] rest_v2 GetScaleVersion", utils.GetLoggerId(ctx))
getVersionURL := "scalemgmt/v2/info"
getVersionResponse := GetInfoResponse_v2{}
err := s.doHTTP(ctx, getVersionURL, "GET", &getVersionResponse, nil)
if err != nil {
klog.Errorf("[%s] unable to get IBM Storage Scale version: [%v]", utils.GetLoggerId(ctx), err)
return "", err
}
if len(getVersionResponse.Info.ServerVersion) == 0 {
return "", fmt.Errorf("unable to get IBM Storage Scale version")
}
return getVersionResponse.Info.ServerVersion, nil
}
func (s *SpectrumRestV2) GetFilesystemMountDetails(ctx context.Context, filesystemName string) (MountInfo, error) {
klog.V(4).Infof("[%s] rest_v2 GetFilesystemMountDetails. filesystemName: %s", utils.GetLoggerId(ctx), filesystemName)
getFilesystemURL := fmt.Sprintf("%s%s", "scalemgmt/v2/filesystems/", filesystemName)
getFilesystemResponse := GetFilesystemResponse_v2{}
err := s.doHTTP(ctx, getFilesystemURL, "GET", &getFilesystemResponse, nil)
if err != nil {
klog.Errorf("[%s] Unable to get filesystem details for %s: %v", utils.GetLoggerId(ctx), filesystemName, err)
return MountInfo{}, err
}
if len(getFilesystemResponse.FileSystems) > 0 {
return getFilesystemResponse.FileSystems[0].Mount, nil
} else {
return MountInfo{}, fmt.Errorf("unable to fetch mount details for %s", filesystemName)
}
}
func (s *SpectrumRestV2) IsFilesystemMountedOnGUINode(ctx context.Context, filesystemName string) (bool, error) {
klog.V(4).Infof("[%s] rest_v2 IsFilesystemMountedOnGUINode. filesystemName: %s", utils.GetLoggerId(ctx), filesystemName)
mountURL := fmt.Sprintf("scalemgmt/v2/filesystems/%s", filesystemName)
mountResponse := GetFilesystemResponse_v2{}
err := s.doHTTP(ctx, mountURL, "GET", &mountResponse, nil)
if err != nil {
klog.Errorf("[%s] Error in getting filesystem mount details for %s: %v", utils.GetLoggerId(ctx), filesystemName, err)
return false, err
}
if len(mountResponse.FileSystems) > 0 {
klog.V(4).Infof("[%s] filesystem [%s] is [%v] on GUI node", utils.GetLoggerId(ctx), filesystemName, mountResponse.FileSystems[0].Mount.Status)
if mountResponse.FileSystems[0].Mount.Status == "mounted" {
return true, nil
} else if mountResponse.FileSystems[0].Mount.Status == "not mounted" {
return false, nil
}
return false, fmt.Errorf("unable to determine mount status of filesystem %s", filesystemName)
} else {
return false, fmt.Errorf("unable to fetch mount details for %s", filesystemName)
}
}
func (s *SpectrumRestV2) ListFilesystems(ctx context.Context) ([]string, error) {
klog.V(4).Infof("[%s] rest_v2 ListFilesystems", utils.GetLoggerId(ctx))
listFilesystemsURL := "scalemgmt/v2/filesystems"
getFilesystemResponse := GetFilesystemResponse_v2{}
err := s.doHTTP(ctx, listFilesystemsURL, "GET", &getFilesystemResponse, nil)
if err != nil {
klog.Errorf("[%s] Error in listing filesystems: %v", utils.GetLoggerId(ctx), err)
return nil, err
}
fsNumber := len(getFilesystemResponse.FileSystems)
filesystems := make([]string, fsNumber)
for i := 0; i < fsNumber; i++ {
filesystems[i] = getFilesystemResponse.FileSystems[i].Name
}
return filesystems, nil
}
func (s *SpectrumRestV2) GetFilesystemMountpoint(ctx context.Context, filesystemName string) (string, error) {
klog.V(4).Infof("[%s] rest_v2 GetFilesystemMountpoint. filesystemName: %s", utils.GetLoggerId(ctx), filesystemName)
getFilesystemURL := fmt.Sprintf("scalemgmt/v2/filesystems/%s", filesystemName)
getFilesystemResponse := GetFilesystemResponse_v2{}
err := s.doHTTP(ctx, getFilesystemURL, "GET", &getFilesystemResponse, nil)
if err != nil {
klog.Errorf("[%s] Error in getting filesystem details for %s: %v", utils.GetLoggerId(ctx), filesystemName, err)
return "", err
}
if len(getFilesystemResponse.FileSystems) > 0 {
return getFilesystemResponse.FileSystems[0].Mount.MountPoint, nil
} else {
return "", fmt.Errorf("unable to fetch mount point for %s", filesystemName)
}
}
func (s *SpectrumRestV2) CopyFsetSnapshotPath(ctx context.Context, filesystemName string, filesetName string, snapshotName string, srcPath string, targetPath string, nodeclass string) (int, uint64, error) {
klog.V(4).Infof("[%s] rest_v2 CopyFsetSnapshotPath. filesystem: %s, fileset: %s, snapshot: %s, srcPath: %s, targetPath: %s, nodeclass: %s", utils.GetLoggerId(ctx), filesystemName, filesetName, snapshotName, srcPath, targetPath, nodeclass)
copySnapReq := CopySnapshotRequest{}
copySnapReq.TargetPath = targetPath
if nodeclass != "" {
copySnapReq.NodeClass = nodeclass
}
formattedSrcPath := strings.ReplaceAll(srcPath, "/", "%2F")
copySnapURL := fmt.Sprintf("scalemgmt/v2/filesystems/%s/filesets/%s/snapshotCopy/%s/path/%s", filesystemName, filesetName, snapshotName, formattedSrcPath)
copySnapResp := GenericResponse{}
err := s.doHTTP(ctx, copySnapURL, "PUT", ©SnapResp, copySnapReq)
if err != nil {
klog.Errorf("[%s] Error in copy snapshot request: %v", utils.GetLoggerId(ctx), err)
return 0, 0, err
}
err = s.isRequestAccepted(ctx, copySnapResp, copySnapURL)
if err != nil {
klog.Errorf("[%s] request not accepted for processing: %v", utils.GetLoggerId(ctx), err)
return 0, 0, err
}
return copySnapResp.Status.Code, copySnapResp.Jobs[0].JobID, nil
}
func (s *SpectrumRestV2) CopyFilesetPath(ctx context.Context, filesystemName string, filesetName string, srcPath string, targetPath string, nodeclass string) (int, uint64, error) {
klog.V(4).Infof("[%s] rest_v2 CopyFilesetPath. filesystem: %s, fileset: %s, srcPath: %s, targetPath: %s, nodeclass: %s", utils.GetLoggerId(ctx), filesystemName, filesetName, srcPath, targetPath, nodeclass)
copyVolReq := CopyVolumeRequest{}
copyVolReq.TargetPath = targetPath
if nodeclass != "" {
copyVolReq.NodeClass = nodeclass
}
formattedSrcPath := strings.ReplaceAll(srcPath, "/", "%2F")
copyVolURL := fmt.Sprintf("scalemgmt/v2/filesystems/%s/filesets/%s/directoryCopy/%s", filesystemName, filesetName, formattedSrcPath)
copyVolResp := GenericResponse{}
err := s.doHTTP(ctx, copyVolURL, "PUT", ©VolResp, copyVolReq)
if err != nil {
klog.Errorf("[%s] Error in copy volume request: %v", utils.GetLoggerId(ctx), err)
return 0, 0, err
}
err = s.isRequestAccepted(ctx, copyVolResp, copyVolURL)
if err != nil {
klog.Errorf("[%s] Request not accepted for processing: %v", utils.GetLoggerId(ctx), err)
return 0, 0, err
}
return copyVolResp.Status.Code, copyVolResp.Jobs[0].JobID, nil
}
func (s *SpectrumRestV2) CopyDirectoryPath(ctx context.Context, filesystemName string, srcPath string, targetPath string, nodeclass string) (int, uint64, error) {
klog.V(4).Infof("[%s] rest_v2 CopyDirectoryPath. filesystem: %s, srcPath: %s, targetPath: %s, nodeclass: %s", utils.GetLoggerId(ctx), filesystemName, srcPath, targetPath, nodeclass)
copyVolReq := CopyVolumeRequest{}
copyVolReq.TargetPath = targetPath
if nodeclass != "" {
copyVolReq.NodeClass = nodeclass
}
formattedSrcPath := strings.ReplaceAll(srcPath, "/", "%2F")
copyVolURL := fmt.Sprintf("scalemgmt/v2/filesystems/%s/directoryCopy/%s", filesystemName, formattedSrcPath)
copyVolResp := GenericResponse{}
err := s.doHTTP(ctx, copyVolURL, "PUT", ©VolResp, copyVolReq)
if err != nil {
klog.Errorf("[%s] Error in copy volume request: %v", utils.GetLoggerId(ctx), err)
return 0, 0, err
}
err = s.isRequestAccepted(ctx, copyVolResp, copyVolURL)
if err != nil {
klog.Errorf("[%s] Request not accepted for processing: %v", utils.GetLoggerId(ctx), err)
return 0, 0, err
}
return copyVolResp.Status.Code, copyVolResp.Jobs[0].JobID, nil
}
func (s *SpectrumRestV2) CreateSnapshot(ctx context.Context, filesystemName string, filesetName string, snapshotName string) error {
loggerId := GetLoggerId(ctx)
klog.V(4).Infof("[%s] rest_v2 CreateSnapshot. filesystem: %s, fileset: %s, snapshot: %v", loggerId, filesystemName, filesetName, snapshotName)
snapshotreq := CreateSnapshotRequest{}
snapshotreq.SnapshotName = snapshotName
createSnapshotURL := fmt.Sprintf("scalemgmt/v2/filesystems/%s/filesets/%s/snapshots", filesystemName, filesetName)
createSnapshotResponse := GenericResponse{}
err := s.doHTTP(ctx, createSnapshotURL, "POST", &createSnapshotResponse, snapshotreq)
if err != nil {
klog.Errorf("[%s] error in create snapshot request: %v", loggerId, err)
return err
}
err = s.isRequestAccepted(ctx, createSnapshotResponse, createSnapshotURL)
if err != nil {
klog.Errorf("[%s] request not accepted for processing: %v", loggerId, err)
return err
}
err = s.WaitForJobCompletion(ctx, createSnapshotResponse.Status.Code, createSnapshotResponse.Jobs[0].JobID)
if err != nil {
if strings.Contains(err.Error(), "EFSSP1102C") { // job failed as snapshot already exists
fmt.Println(err)
return nil
}
klog.Errorf("[%s] unable to create snapshot %s: %v", loggerId, snapshotName, err)
return err
}
return nil
}
func (s *SpectrumRestV2) DeleteSnapshot(ctx context.Context, filesystemName string, filesetName string, snapshotName string) error {
loggerId := GetLoggerId(ctx)
klog.V(4).Infof("[%s] rest_v2 DeleteSnapshot. filesystem: %s, fileset: %s, snapshot: %v", loggerId, filesystemName, filesetName, snapshotName)
deleteSnapshotURL := fmt.Sprintf("scalemgmt/v2/filesystems/%s/filesets/%s/snapshots/%s", filesystemName, filesetName, snapshotName)
deleteSnapshotResponse := GenericResponse{}
err := s.doHTTP(ctx, deleteSnapshotURL, "DELETE", &deleteSnapshotResponse, nil)
if err != nil {
klog.Errorf("[%s] Error in delete snapshot request: %v", loggerId, err)
return err
}
err = s.isRequestAccepted(ctx, deleteSnapshotResponse, deleteSnapshotURL)
if err != nil {
klog.Errorf("[%s] Request not accepted for processing: %v", loggerId, err)
return err
}
err = s.WaitForJobCompletion(ctx, deleteSnapshotResponse.Status.Code, deleteSnapshotResponse.Jobs[0].JobID)
if err != nil {
klog.Errorf("[%s] Unable to delete snapshot %s: %v", loggerId, snapshotName, err)
return err
}
return nil
}
func (s *SpectrumRestV2) GetLatestFilesetSnapshots(ctx context.Context, filesystemName string, filesetName string) ([]Snapshot_v2, error) {
klog.V(4).Infof("[%s] rest_v2 GetLatestFilesetSnapshots. filesystem: %s, fileset: %s", utils.GetLoggerId(ctx), filesystemName, filesetName)
getLatestFilesetSnapshotsURL := fmt.Sprintf("scalemgmt/v2/filesystems/%s/filesets/%s/snapshots/latest", filesystemName, filesetName)
getLatestFilesetSnapshotsResponse := GetSnapshotResponse_v2{}
err := s.doHTTP(ctx, getLatestFilesetSnapshotsURL, "GET", &getLatestFilesetSnapshotsResponse, nil)
if err != nil {
return nil, fmt.Errorf("unable to get latest list of snapshots for fileset [%v]. Error [%v]", filesetName, err)
}
return getLatestFilesetSnapshotsResponse.Snapshots, nil
}
func (s *SpectrumRestV2) UpdateFileset(ctx context.Context, filesystemName string, volType string, filesetName string, opts map[string]interface{}, setAfmAttributes bool) error {
klog.V(4).Infof("[%s] rest_v2 UpdateFileset. filesystem: %s, fileset: %s, volType: %s, opts: %v", utils.GetLoggerId(ctx), filesystemName, filesetName, volType, opts)
filesetreq := CreateFilesetRequest{}
inodeLimit, inodeLimitSpecified := opts[UserSpecifiedInodeLimit]
if inodeLimitSpecified {
filesetreq.MaxNumInodes = inodeLimit.(string)
//filesetreq.AllocInodes = "1024"
}
comment, commentSpecified := opts[FilesetCommentKey]
if commentSpecified {
filesetreq.Comment = fmt.Sprintf("%v", comment)
}
if volType == cachevolume && setAfmAttributes {
afmReadSparseThresholdValue, afmReadSparseThresholdFound := opts[AfmReadSparseThreshold]
if afmReadSparseThresholdFound {
filesetreq.AfmReadSparseThreshold = afmReadSparseThresholdValue.(string)
} else {
filesetreq.AfmReadSparseThreshold = AfmReadSparseThresholdDefault
}
afmNumFlushThreadsValue, afmNumFlushThreadsFound := opts[AfmNumFlushThreads]
if afmNumFlushThreadsFound {
filesetreq.AfmNumFlushThreads = afmNumFlushThreadsValue.(int)
} else {
filesetreq.AfmNumFlushThreads = AfmNumFlushThreadsDefault
}
afmPrefetchThresholdValue, afmPrefetchThresholdFound := opts[AfmPrefetchThreshold]
if afmPrefetchThresholdFound {
filesetreq.AfmPrefetchThreshold = afmPrefetchThresholdValue.(int)
} else {
filesetreq.AfmPrefetchThreshold = AfmPrefetchThresholdDefault
}
afmObjectFastReaddirValue, afmObjectFastReaddirFound := opts[AfmObjectFastReaddir]
if afmObjectFastReaddirFound {
filesetreq.AfmObjectFastReaddir = afmObjectFastReaddirValue.(string)
} else {
filesetreq.AfmObjectFastReaddir = AfmObjectFastReaddirDefault
}
afmFileOpenRefreshIntervalValue, afmFileOpenRefreshIntervalFound := opts[AfmFileOpenRefreshInterval]
if afmFileOpenRefreshIntervalFound {
filesetreq.AfmFileOpenRefreshInterval = afmFileOpenRefreshIntervalValue.(string)
} else {
filesetreq.AfmFileOpenRefreshInterval = AfmFileOpenRefreshIntervalDefault
}
}
updateFilesetURL := fmt.Sprintf("scalemgmt/v2/filesystems/%s/filesets/%s", filesystemName, filesetName)
updateFilesetResponse := GenericResponse{}
err := s.doHTTP(ctx, updateFilesetURL, "PUT", &updateFilesetResponse, filesetreq)
if err != nil {
klog.Errorf("[%s] error in update fileset request: %v", utils.GetLoggerId(ctx), err)
return err
}
err = s.isRequestAccepted(ctx, updateFilesetResponse, updateFilesetURL)
if err != nil {
klog.Errorf("[%s] request not accepted for processing: %v", utils.GetLoggerId(ctx), err)
return err
}
err = s.WaitForJobCompletion(ctx, updateFilesetResponse.Status.Code, updateFilesetResponse.Jobs[0].JobID)
if err != nil {
klog.Errorf("[%s] unable to update fileset %s: %v", utils.GetLoggerId(ctx), filesetName, err)
return err
}
return nil
}
// GetGatewayNode : A gateway node is must for cache fileset,
// return empty and error if no gateway found
func (s *SpectrumRestV2) GetGatewayNode(ctx context.Context) (string, error) {
loggerId := GetLoggerId(ctx)
klog.V(4).Infof("[%s] rest_v2 GetGatewayNode", loggerId)
getNodesURL := "scalemgmt/v2/nodes?fields=roles.gatewayNode"
getNodesResponse := GetNodesResponse_v2{}
err := s.doHTTP(ctx, getNodesURL, "GET", &getNodesResponse, nil)
if err != nil {
return "", fmt.Errorf("failed to get nodes with gateway role, error: %v", err)
}
for _, node := range getNodesResponse.Nodes {
if node.Roles.GatewayNode {
return node.AdminNodename, nil
}
}
return "", nil
}
// ListGatewayNodes : List all the gateway nodes,
// return empty if no gateway found
func (s *SpectrumRestV2) ListGatewayNodes(ctx context.Context) ([]string, error) {
loggerId := GetLoggerId(ctx)
klog.V(4).Infof("[%s] rest_v2 ListGatewayNodes", loggerId)
var gatewayNodes []string
getNodesURL := "scalemgmt/v2/nodes?fields=roles.gatewayNode"
getNodesResponse := GetNodesResponse_v2{}
err := s.doHTTP(ctx, getNodesURL, "GET", &getNodesResponse, nil)
if err != nil {
return gatewayNodes, fmt.Errorf("failed to get nodes with gateway role, error: %v", err)
}
for _, node := range getNodesResponse.Nodes {
if node.Roles.GatewayNode {
gatewayNodes = append(gatewayNodes, node.AdminNodename)
}
}
//klog.V(4).Infof("[%s] rest_v2 ListGatewayNodes result gatewayNodes[ %v ]", loggerId, gatewayNodes)
return gatewayNodes, nil
}
func (s *SpectrumRestV2) CreateFileset(ctx context.Context, filesystemName string, filesetName string, opts map[string]interface{}) error {
klog.V(4).Infof("[%s] rest_v2 CreateFileset. filesystem: %s, fileset: %s, opts: %v", utils.GetLoggerId(ctx), filesystemName, filesetName, opts)
filesetreq := CreateFilesetRequest{}
filesetreq.FilesetName = filesetName
comment, commentSpecified := opts[FilesetCommentKey]
if commentSpecified {
filesetreq.Comment = fmt.Sprintf("%v", comment)
} else {
filesetreq.Comment = FilesetComment
}
filesetType, filesetTypeSpecified := opts[UserSpecifiedFilesetType]
inodeLimit, inodeLimitSpecified := opts[UserSpecifiedInodeLimit]
if !filesetTypeSpecified {
filesetType, filesetTypeSpecified = opts[UserSpecifiedFilesetTypeDep]
}
if !inodeLimitSpecified {
inodeLimit, inodeLimitSpecified = opts[UserSpecifiedInodeLimitDep]
}
if filesetTypeSpecified && filesetType.(string) == "dependent" {
/* Add fileset for dependent fileset-name: */
parentFileSetName, parentFileSetNameSpecified := opts[UserSpecifiedParentFset]
if parentFileSetNameSpecified {
filesetreq.InodeSpace = parentFileSetName.(string)
} else {
filesetreq.InodeSpace = "root"
}
} else {
filesetreq.InodeSpace = "new"
if inodeLimitSpecified {
filesetreq.MaxNumInodes = inodeLimit.(string)
filesetreq.AllocInodes = "1024"
}
}
uid, uidSpecified := opts[UserSpecifiedUID]
gid, gidSpecified := opts[UserSpecifiedGID]
permissions, permissionsSpecified := opts[UserSpecifiedPermissions]
volDirBasePath, volDirBasePathSpecified := opts[UserSpecifiedVolDirPath]
if uidSpecified && gidSpecified {
filesetreq.Owner = fmt.Sprintf("%s:%s", uid, gid)
} else if uidSpecified {
filesetreq.Owner = fmt.Sprintf("%s", uid)
}
if permissionsSpecified {
filesetreq.Permissions = fmt.Sprintf("%s", permissions)
}
if volDirBasePathSpecified {
filesetreq.Path = fmt.Sprintf("%s/%s", volDirBasePath, filesetName)
}
createFilesetURL := fmt.Sprintf("scalemgmt/v2/filesystems/%s/filesets", filesystemName)
createFilesetResponse := GenericResponse{}
err := s.doHTTP(ctx, createFilesetURL, "POST", &createFilesetResponse, filesetreq)
if err != nil {
klog.Errorf("[%s] Error in create fileset request: %v", utils.GetLoggerId(ctx), err)
return err
}
err = s.isRequestAccepted(ctx, createFilesetResponse, createFilesetURL)
if err != nil {
klog.Errorf("[%s] Request not accepted for processing: %v", utils.GetLoggerId(ctx), err)
return err
}
err = s.WaitForJobCompletion(ctx, createFilesetResponse.Status.Code, createFilesetResponse.Jobs[0].JobID)
if err != nil {
if strings.Contains(err.Error(), "EFSSP1102C") { // job failed as fileset already exists
fmt.Println(err)
return nil
}
klog.Errorf("[%s] Unable to create fileset %s: %v", utils.GetLoggerId(ctx), filesetName, err)
return err
}
return nil
}
func (s *SpectrumRestV2) SetBucketKeys(ctx context.Context, bucketInfo map[string]string, exportMapName string) error {
loggerID := utils.GetLoggerId(ctx)
klog.V(4).Infof("[%s] rest_v2 SetBucketKeys", loggerID)
keyreq := SetBucketKeysRequest{}
keyreq.BucketName = bucketInfo[BucketName]
keyreq.AccessKey = bucketInfo[bucketAccesskey]
keyreq.SecretKey = bucketInfo[bucketSecretkey]
keyreq.Server = exportMapName
setBucketKeysURL := "scalemgmt/v2/bucket/keys"
setBucketKeysResponse := GenericResponse{}
err := s.doHTTP(ctx, setBucketKeysURL, "PUT", &setBucketKeysResponse, keyreq)
if err != nil {
klog.Errorf("[%s] Failed to set keys for the bucket %s, error: %v", loggerID, bucketInfo[BucketName], err)
return err
}
err = s.isRequestAccepted(ctx, setBucketKeysResponse, setBucketKeysURL)
if err != nil {
klog.Errorf("[%s] The set keys request is not accepted for processing for the bucket %s, error: %v", loggerID, bucketInfo[BucketName], err)
return err
}
err = s.WaitForJobCompletion(ctx, setBucketKeysResponse.Status.Code, setBucketKeysResponse.Jobs[0].JobID)
if err != nil {
klog.Errorf("[%s] Failed to set keys for the bucket %s, error: %v", loggerID, bucketInfo[BucketName], err)
return err
}
return nil
}
func (s *SpectrumRestV2) DeleteBucketKeys(ctx context.Context, bucket string) error {
loggerID := utils.GetLoggerId(ctx)
klog.V(4).Infof("[%s] rest_v2 DeleteBucketKeys", loggerID)
deleteBucketKeysURL := "scalemgmt/v2/bucket/keys/" + bucket
deleteBucketKeysResponse := GenericResponse{}
err := s.doHTTP(ctx, deleteBucketKeysURL, "DELETE", &deleteBucketKeysResponse, nil)
if err != nil {
klog.Errorf("[%s] Failed to delete keys for the bucket %s, error: %v", loggerID, bucket, err)
return err
}
err = s.isRequestAccepted(ctx, deleteBucketKeysResponse, deleteBucketKeysURL)
if err != nil {
klog.Errorf("[%s] The delete keys request is not accepted for processing for the bucket %s, error: %v", loggerID, bucket, err)
return err
}
err = s.WaitForJobCompletion(ctx, deleteBucketKeysResponse.Status.Code, deleteBucketKeysResponse.Jobs[0].JobID)
if err != nil {
klog.Errorf("[%s] Failed to delete keys for the bucket %s, error: %v", loggerID, bucket, err)
return err
}
return nil
}
func (s *SpectrumRestV2) DeleteNodeMappingAFMWithCos(ctx context.Context, exportMapName string) error {
loggerID := utils.GetLoggerId(ctx)
klog.V(4).Infof("[%s] rest_v2 DeleteNodeMappingAFMWithCos", loggerID)
deleteExportMapNameURL := "scalemgmt/v2/nodes/afm/mapping/" + exportMapName
deleteExportMapNameResponse := GenericResponse{}
err := s.doHTTP(ctx, deleteExportMapNameURL, "DELETE", &deleteExportMapNameResponse, nil)
if err != nil {
klog.Errorf("[%s] Failed to delete exportMap %s, error: %v", loggerID, exportMapName, err)
if strings.Contains(deleteExportMapNameResponse.Status.Message, "Invalid value in 'mappingName'") { // error as no exportMap exists
klog.V(6).Infof("[%s] exportMap would have been deleted. So returning success %v", utils.GetLoggerId(ctx), err)
return nil
}
return err
}
err = s.isRequestAccepted(ctx, deleteExportMapNameResponse, deleteExportMapNameURL)
if err != nil {
klog.Errorf("[%s] The delete exportMap request is not accepted for processing for the exportMapName %s, error: %v", loggerID, exportMapName, err)
return err
}
err = s.WaitForJobCompletion(ctx, deleteExportMapNameResponse.Status.Code, deleteExportMapNameResponse.Jobs[0].JobID)
if err != nil {
klog.Errorf("[%s] Failed to delete exportMap %s, error: %v", loggerID, exportMapName, err)
return err
}
return nil
}
func (s *SpectrumRestV2) CreateS3CacheFileset(ctx context.Context, filesystemName string, filesetName string, mode string, opts map[string]interface{}, bucketInfo map[string]string, exportMapName string, parsedEndpointURL *url.URL) error {
loggerID := utils.GetLoggerId(ctx)
klog.V(4).Infof("[%s] rest_v2 CreateS3CacheFileset. filesystem: %s, fileset: %s, mode: %s, opts: %v, exportMapName %v, parsedEndpointURL: %v", loggerID, filesystemName, filesetName, mode, opts, exportMapName, parsedEndpointURL)
filesetreq := CreateS3CacheFilesetRequest{}
filesetreq.FilesetName = filesetName
filesetreq.UseObjectFs = true
filesetreq.Mode = mode
filesetreq.TempDir = CacheTempDirName
var afmTarget string
scheme := parsedEndpointURL.Scheme
port := parsedEndpointURL.Port()
if scheme == "https" {
filesetreq.UseSSLCertVerify = true
afmTarget = scheme + "://" + exportMapName
} else {
afmTarget = "http://" + exportMapName
}
if port == "" {
port = string(defaultS3Port)
}
afmTarget = afmTarget + ":" + port
filesetreq.Endpoint = afmTarget
filesetreq.BucketName = bucketInfo[BucketName]
filesetreq.VerifyKeys = true
filesetreq.MakeActive = true
if opts[UserSpecifiedUid] != nil {
filesetreq.Uid = opts[UserSpecifiedUid].(string)
}
if opts[UserSpecifiedGid] != nil {
filesetreq.Gid = opts[UserSpecifiedGid].(string)
}
if opts[UserSpecifiedPermissions] != nil {
filesetreq.Permission = opts[UserSpecifiedPermissions].(string)
}
if opts[UserSpecifiedVolDirPath] != nil {
filesetreq.Dir = fmt.Sprintf("%s/%s", opts[UserSpecifiedVolDirPath], filesetName)
}
klog.V(4).Infof("[%s] rest_v2 CreateS3CacheFileset. filesetreq: %v", loggerID, filesetreq)
createFilesetURL := fmt.Sprintf("scalemgmt/v2/filesystems/%s/filesets/cos", filesystemName)
createFilesetResponse := GenericResponse{}
err := s.doHTTP(ctx, createFilesetURL, "POST", &createFilesetResponse, filesetreq)
if err != nil {
klog.Errorf("[%s] Failed to create an AFM cache fileset %s, error: %v", loggerID, filesetName, err)
return err
}
err = s.isRequestAccepted(ctx, createFilesetResponse, createFilesetURL)
if err != nil {
klog.Errorf("[%s] The AFM cache fileset creation request for fileset %s is not accepted for processing, error: %v", loggerID, filesetName, err)
return err
}
err = s.WaitForJobCompletion(ctx, createFilesetResponse.Status.Code, createFilesetResponse.Jobs[0].JobID)
if err != nil {
if strings.Contains(err.Error(), "EFSSP1102C") { // job failed as fileset already exists
klog.Infof("The cache fileset exists already, error: %v", err)
return nil
}
klog.Errorf("[%s] Failed to create an AFM cache fileset %s, error: %v", loggerID, filesetName, err)
return err
}
return nil
}
func (s *SpectrumRestV2) CreateNodeMappingAFMWithCos(ctx context.Context, exportMapName string, gatewayNodeName string, bucketInfo map[string]string) error {
loggerID := utils.GetLoggerId(ctx)
klog.V(4).Infof("[%s] rest_v2 CreateNodeMappingAFMWithCos.exportMapName:[%s],gatewayNodeName:[%s]:", loggerID, exportMapName, gatewayNodeName)
exportMapReq := CreateNodeMapAFMCosRequest{}
exportMapReq.MapName = exportMapName
// Extract the hostname without the port
parsedURL, err := url.Parse(bucketInfo[BucketEndpoint])
if err != nil {
return fmt.Errorf("failed to parse endpoint URL %s, error %v", bucketInfo[BucketEndpoint], err)
}
hostname := parsedURL.Hostname()
exportMapReq.ExportMap = append(exportMapReq.ExportMap, hostname+"/"+gatewayNodeName)
exportMapReq.NoServerResolution = true
klog.V(4).Infof("[%s] rest_v2 CreateNodeMappingAFMWithCos. exportMapReq: %v :", loggerID, exportMapReq)
createExportMapURL := "scalemgmt/v2/nodes/afm/mapping"
createExportMapResponse := GenericResponse{}
err = s.doHTTP(ctx, createExportMapURL, "POST", &createExportMapResponse, exportMapReq)
if err != nil {
if strings.Contains(createExportMapResponse.Status.Message, "Mapping "+exportMapName+" already exists") {
klog.V(6).Infof("[%s] Failed to create NodeMappingAFMWithCos exportMapName, exportMap is already exists. So returning success %v", utils.GetLoggerId(ctx), err)
return nil
}
klog.Errorf("[%s] Failed to create NodeMappingAFMWithCos exportMapName: %s, error: %v", loggerID, exportMapName, err)
return err
}
err = s.isRequestAccepted(ctx, createExportMapResponse, createExportMapURL)
if err != nil {
klog.Errorf("[%s] NodeMappingAFMWithCos request for exportMapName %s is not accepted for processing, error: %v", loggerID, exportMapName, err)
return err
}
err = s.WaitForJobCompletion(ctx, createExportMapResponse.Status.Code, createExportMapResponse.Jobs[0].JobID)
if err != nil {
if strings.Contains(err.Error(), "EFSSP1102C") { // job failed as fileset already exists
klog.Infof("The NodeMappingAFMWithCos exists already, error: %v", err)
return nil
}
klog.Errorf("[%s] Failed to create NodeMappingAFMWithCos exportMapName: %s, error: %v", loggerID, exportMapName, err)
return err
}
return nil
}
func (s *SpectrumRestV2) DeleteFileset(ctx context.Context, filesystemName string, filesetName string) error {
klog.V(4).Infof("[%s] rest_v2 DeleteFileset. filesystem: %s, fileset: %s", utils.GetLoggerId(ctx), filesystemName, filesetName)
deleteFilesetURL := fmt.Sprintf("scalemgmt/v2/filesystems/%s/filesets/%s?force_unlink=false", filesystemName, filesetName)
deleteFilesetResponse := GenericResponse{}
err := s.doHTTP(ctx, deleteFilesetURL, "DELETE", &deleteFilesetResponse, nil)
if err != nil {
if strings.Contains(deleteFilesetResponse.Status.Message, "Invalid value in 'fsetName'") { // job failed as dir already exists
klog.V(6).Infof("[%s] Fileset would have been deleted. So returning success %v", utils.GetLoggerId(ctx), err)
return nil
}
klog.Errorf("[%s] Error in delete fileset request: %v", utils.GetLoggerId(ctx), err)
return err
}
err = s.isRequestAccepted(ctx, deleteFilesetResponse, deleteFilesetURL)
if err != nil {
klog.Errorf("Request not accepted for processing: %v", err)
return err
}
err = s.WaitForJobCompletion(ctx, deleteFilesetResponse.Status.Code, deleteFilesetResponse.Jobs[0].JobID)
if err != nil {
klog.Errorf("Unable to delete fileset %s: %v", filesetName, err)
return err
}
return nil
}
func (s *SpectrumRestV2) LinkFileset(ctx context.Context, filesystemName string, filesetName string, linkpath string) error {
klog.V(4).Infof("[%s] rest_v2 LinkFileset. filesystem: %s, fileset: %s, linkpath: %s", utils.GetLoggerId(ctx), filesystemName, filesetName, linkpath)
linkReq := LinkFilesetRequest{}
linkReq.Path = linkpath
linkFilesetURL := fmt.Sprintf("scalemgmt/v2/filesystems/%s/filesets/%s/link", filesystemName, filesetName)
linkFilesetResponse := GenericResponse{}
err := s.doHTTP(ctx, linkFilesetURL, "POST", &linkFilesetResponse, linkReq)
if err != nil {
klog.Errorf("[%s] Error in link fileset request: %v", utils.GetLoggerId(ctx), err)
return err
}
err = s.isRequestAccepted(ctx, linkFilesetResponse, linkFilesetURL)
if err != nil {
klog.Errorf("[%s] Request not accepted for processing: %v", utils.GetLoggerId(ctx), err)
return err
}
err = s.WaitForJobCompletion(ctx, linkFilesetResponse.Status.Code, linkFilesetResponse.Jobs[0].JobID)
if err != nil {
klog.Errorf("[%s] Error in linking fileset %s: %v", utils.GetLoggerId(ctx), filesetName, err)
return err
}
return nil
}
func (s *SpectrumRestV2) UnlinkFileset(ctx context.Context, filesystemName string, filesetName string, force bool) error {
klog.V(4).Infof("[%s] rest_v2 UnlinkFileset. filesystem: %s, fileset: %s", utils.GetLoggerId(ctx), filesystemName, filesetName)
var unlinkFilesetURL string
if force {
unlinkFilesetURL = fmt.Sprintf("scalemgmt/v2/filesystems/%s/filesets/%s/link?force=True", filesystemName, filesetName)
} else {