@@ -2361,11 +2361,11 @@ func (c RestClient) LunCloneCreate(
23612361
23622362 params .SetInfo (lunInfo )
23632363
2364- lunCreateCreated , _ , err := c .api .San .LunCreate (params , c .authInfo )
2364+ lunCreateCreated , lunCreateAccepted , err := c .api .San .LunCreate (params , c .authInfo )
23652365 if err != nil {
23662366 return err
23672367 }
2368- if lunCreateCreated == nil {
2368+ if lunCreateCreated == nil && lunCreateAccepted == nil {
23692369 return fmt .Errorf ("unexpected response from LUN create" )
23702370 }
23712371
@@ -2376,7 +2376,7 @@ func (c RestClient) LunCloneCreate(
23762376// LunCreate creates a LUN
23772377func (c RestClient ) LunCreate (
23782378 ctx context.Context , lunPath string , sizeInBytes int64 , osType string , qosPolicyGroup QosPolicyGroup ,
2379- spaceReserved , spaceAllocated bool ,
2379+ spaceReserved , spaceAllocated * bool ,
23802380) error {
23812381 if strings .Contains (lunPath , failureLUNCreate ) {
23822382 return errors .New ("injected error" )
@@ -2392,24 +2392,39 @@ func (c RestClient) LunCreate(
23922392 OsType : utils .Ptr (osType ),
23932393 Space : & models.LunInlineSpace {
23942394 Size : utils .Ptr (sizeInBytes ),
2395- Guarantee : & models.LunInlineSpaceInlineGuarantee {
2396- Requested : utils .Ptr (spaceReserved ),
2397- },
2398- ScsiThinProvisioningSupportEnabled : utils .Ptr (spaceAllocated ),
23992395 },
2400- QosPolicy : & models.LunInlineQosPolicy {
2396+ }
2397+
2398+ // Set spaceReserved if present.
2399+ if spaceReserved != nil {
2400+ lunInfo .Space .Guarantee = & models.LunInlineSpaceInlineGuarantee {
2401+ Requested : spaceReserved ,
2402+ }
2403+ }
2404+
2405+ // Set spaceAllocated if present.
2406+ if spaceAllocated != nil {
2407+ lunInfo .Space .ScsiThinProvisioningSupportEnabled = spaceAllocated
2408+ }
2409+
2410+ // Set QosPolicy name if present.
2411+ if qosPolicyGroup .Name != "" {
2412+ lunInfo .QosPolicy = & models.LunInlineQosPolicy {
24012413 Name : utils .Ptr (qosPolicyGroup .Name ),
2402- },
2414+ }
24032415 }
2416+
24042417 lunInfo .Svm = & models.LunInlineSvm {UUID : utils .Ptr (c .svmUUID )}
24052418
24062419 params .SetInfo (lunInfo )
24072420
2408- lunCreateCreated , _ , err := c .api .San .LunCreate (params , c .authInfo )
2421+ lunCreateCreated , lunCreateAccepted , err := c .api .San .LunCreate (params , c .authInfo )
24092422 if err != nil {
24102423 return err
24112424 }
2412- if lunCreateCreated == nil {
2425+
2426+ // If both response parameter is nil, then it is unexpected.
2427+ if lunCreateCreated == nil && lunCreateAccepted == nil {
24132428 return fmt .Errorf ("unexpected response from LUN create" )
24142429 }
24152430
@@ -2505,11 +2520,13 @@ func (c RestClient) LunDelete(
25052520 params .HTTPClient = c .httpClient
25062521 params .UUID = lunUUID
25072522
2508- lunDeleteResult , _ , err := c .api .San .LunDelete (params , c .authInfo )
2523+ lunDeleteResult , lunDeleteAccepted , err := c .api .San .LunDelete (params , c .authInfo )
25092524 if err != nil {
25102525 return fmt .Errorf ("could not delete lun; %v" , err )
25112526 }
2512- if lunDeleteResult == nil {
2527+
2528+ // If both of the response parameters are nil, then it is unexpected.
2529+ if lunDeleteResult == nil && lunDeleteAccepted == nil {
25132530 return fmt .Errorf ("could not delete lun: %v" , "unexpected result" )
25142531 }
25152532
@@ -2566,11 +2583,13 @@ func (c RestClient) LunSetComment(
25662583
25672584 params .SetInfo (lunInfo )
25682585
2569- lunModifyOK , _ , err := c .api .San .LunModify (params , c .authInfo )
2586+ lunModifyOK , lunModifyAccepted , err := c .api .San .LunModify (params , c .authInfo )
25702587 if err != nil {
25712588 return err
25722589 }
2573- if lunModifyOK == nil {
2590+
2591+ // If both of the response parameters are nil, then it is unexpected.
2592+ if lunModifyOK == nil && lunModifyAccepted == nil {
25742593 return fmt .Errorf ("unexpected response from LUN modify" )
25752594 }
25762595
@@ -2645,11 +2664,13 @@ func (c RestClient) LunSetAttribute(
26452664 }
26462665 params .Info = attrInfo
26472666
2648- lunAttrCreateOK , _ , err := c .api .San .LunAttributeCreate (params , c .authInfo )
2667+ lunAttrCreateOK , lunAttrCreateAccepted , err := c .api .San .LunAttributeCreate (params , c .authInfo )
26492668 if err != nil {
26502669 return err
26512670 }
2652- if lunAttrCreateOK == nil {
2671+
2672+ // If both the response parameters are nil, then it is unexpected.
2673+ if lunAttrCreateOK == nil && lunAttrCreateAccepted == nil {
26532674 return fmt .Errorf ("unexpected response from LUN attribute create" )
26542675 }
26552676 return nil
@@ -2712,11 +2733,13 @@ func (c RestClient) LunSetQosPolicyGroup(
27122733
27132734 params .SetInfo (lunInfo )
27142735
2715- lunModifyOK , _ , err := c .api .San .LunModify (params , c .authInfo )
2736+ lunModifyOK , lunModifyAccepted , err := c .api .San .LunModify (params , c .authInfo )
27162737 if err != nil {
27172738 return err
27182739 }
2719- if lunModifyOK == nil {
2740+
2741+ // If both the response parameters are nil, then it is unexpected.
2742+ if lunModifyOK == nil && lunModifyAccepted == nil {
27202743 return fmt .Errorf ("unexpected response from LUN modify" )
27212744 }
27222745
@@ -2753,11 +2776,13 @@ func (c RestClient) LunRename(
27532776
27542777 params .SetInfo (lunInfo )
27552778
2756- lunModifyOK , _ , err := c .api .San .LunModify (params , c .authInfo )
2779+ lunModifyOK , lunModifyAccepted , err := c .api .San .LunModify (params , c .authInfo )
27572780 if err != nil {
27582781 return err
27592782 }
2760- if lunModifyOK == nil {
2783+
2784+ // If both the response parameters are nil, then it is unexpected.
2785+ if lunModifyOK == nil && lunModifyAccepted == nil {
27612786 return fmt .Errorf ("unexpected response from LUN modify" )
27622787 }
27632788
@@ -3031,11 +3056,13 @@ func (c RestClient) LunSetSize(
30313056
30323057 params .SetInfo (lunInfo )
30333058
3034- lunModifyOK , _ , err := c .api .San .LunModify (params , c .authInfo )
3059+ lunModifyOK , lunModifyAccepted , err := c .api .San .LunModify (params , c .authInfo )
30353060 if err != nil {
30363061 return 0 , err
30373062 }
3038- if lunModifyOK == nil {
3063+
3064+ // If both the response parameters are nil, then it is unexpected.
3065+ if lunModifyOK == nil && lunModifyAccepted == nil {
30393066 return 0 , fmt .Errorf ("unexpected response from LUN modify" )
30403067 }
30413068
0 commit comments