@@ -83,6 +83,8 @@ type StorageClassParameters struct {
8383 encryptInTransit string
8484 // tags
8585 scTags * config.TagConfig
86+ // NsgOcids
87+ nsgOcids []string
8688}
8789
8890type SecretParameters struct {
@@ -659,6 +661,22 @@ func extractStorageClassParameters(ctx context.Context, d *FSSControllerDriver,
659661 log = log .With ("mountTargetSubnetOcid" , mountTargetSubnetOcid )
660662 log .Info ("Mount Target Ocid not provided, to be created" )
661663 storageClassParameters .mountTargetSubnetOcid = mountTargetSubnetOcid
664+
665+ nsgOcidsStr , ok := parameters ["nsgOcids" ]
666+ if ! ok {
667+ log .Infof ("No NSG Ocids provided to associate with new mount target creation" )
668+ } else {
669+ var nsgOcids []string
670+ err := json .Unmarshal ([]byte (nsgOcidsStr ), & nsgOcids )
671+ if err != nil {
672+ log .Errorf ("Failed to parse nsgOcids provided in storage class. Please provide valid input." )
673+ dimensionsMap [metrics .ComponentDimension ] = util .GetMetricDimensionForComponent (util .ErrValidation , util .CSIStorageType )
674+ metrics .SendMetricData (d .metricPusher , metrics .MTProvision , time .Since (startTime ).Seconds (), dimensionsMap )
675+ return log , nil , nil , status .Errorf (codes .InvalidArgument , "Failed to parse nsgOcids provided in storage class. Please provide valid input." ), true
676+ }
677+ log .With ("nsgOcids" , nsgOcids )
678+ storageClassParameters .nsgOcids = nsgOcids
679+ }
662680 } else {
663681 storageClassParameters .mountTargetOcid = mountTargetOcid
664682 log = log .With ("mountTargetOcid" , mountTargetOcid )
@@ -775,6 +793,7 @@ func provisionMountTarget(ctx context.Context, log *zap.SugaredLogger, c client.
775793 SubnetId : & storageClassParameters .mountTargetSubnetOcid ,
776794 FreeformTags : storageClassParameters .scTags .FreeformTags ,
777795 DefinedTags : storageClassParameters .scTags .DefinedTags ,
796+ NsgIds : storageClassParameters .nsgOcids ,
778797 }
779798 return fssClient .CreateMountTarget (ctx , createMountTargetDetails )
780799}
0 commit comments