diff --git a/examples/resources/netapp-ontap_ip_interface/resource.tf b/examples/resources/netapp-ontap_ip_interface/resource.tf index c209c0b0..94c1dac5 100644 --- a/examples/resources/netapp-ontap_ip_interface/resource.tf +++ b/examples/resources/netapp-ontap_ip_interface/resource.tf @@ -1,14 +1,15 @@ resource "netapp-ontap_networking_ip_interface" "ip_interface" { # required to know which system to interface with cx_profile_name = "cluster4" - name = "testme" - svm_name = "ansibleSVM" + name = "testme" + svm_name = "ansibleSVM" ip = { address = "10.10.10.10" netmask = 20 - } + } location = { home_port = "e0c" home_node = "ontap_cluster_1-01" } + service_policy = "default-management" } diff --git a/internal/interfaces/networking_ip_interface.go b/internal/interfaces/networking_ip_interface.go index 7f5ba2c8..39646ac9 100644 --- a/internal/interfaces/networking_ip_interface.go +++ b/internal/interfaces/networking_ip_interface.go @@ -28,10 +28,11 @@ type IPInterfaceGetIP struct { // IPInterfaceResourceBodyDataModelONTAP describes the body data model using go types for mapping. type IPInterfaceResourceBodyDataModelONTAP struct { - Name string `mapstructure:"name"` - SVM IPInterfaceSvmName `mapstructure:"svm,omitempty"` // API errors if body contains svm name when updating. can not use universal 'svm struct' - IP IPInterfaceResourceIP `mapstructure:"ip"` - Location IPInterfaceResourceLocation `mapstructure:"location"` + IP IPInterfaceResourceIP `mapstructure:"ip"` + Location IPInterfaceResourceLocation `mapstructure:"location"` + Name string `mapstructure:"name"` + ServicePolicy IPInterfaceServicePolicy `mapstructure:"service_policy"` + SVM IPInterfaceSvmName `mapstructure:"svm,omitempty"` // API errors if body contains svm name when updating. can not use universal 'svm struct' } // IPInterfaceSvmName describes the svm name specifcally for network ip interface. diff --git a/internal/provider/networking/networking_ip_interface_resource.go b/internal/provider/networking/networking_ip_interface_resource.go index 74496b5a..7e0529b7 100644 --- a/internal/provider/networking/networking_ip_interface_resource.go +++ b/internal/provider/networking/networking_ip_interface_resource.go @@ -3,7 +3,6 @@ package networking import ( "context" "fmt" - "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/connection" "strconv" "strings" @@ -11,10 +10,12 @@ import ( "github.com/hashicorp/terraform-plugin-framework/resource" "github.com/hashicorp/terraform-plugin-framework/resource/schema" "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringdefault" "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/netapp/terraform-provider-netapp-ontap/internal/interfaces" + "github.com/netapp/terraform-provider-netapp-ontap/internal/provider/connection" "github.com/netapp/terraform-provider-netapp-ontap/internal/utils" ) @@ -55,6 +56,7 @@ type IPInterfaceResourceModel struct { SVMName types.String `tfsdk:"svm_name"` IP *IPInterfaceResourceIP `tfsdk:"ip"` Location *IPInterfaceResourceLocation `tfsdk:"location"` + ServicePolicy types.String `tfsdk:"service_policy"` UUID types.String `tfsdk:"id"` } @@ -111,6 +113,18 @@ func (r *IPInterfaceResource) Schema(ctx context.Context, req resource.SchemaReq }, Required: true, }, + "service_policy": schema.StringAttribute{ + MarkdownDescription: "IPInterface service policy", + Optional: true, + Computed: true, + /* + * Default values: + * "default-data-files" if scope is svm + * "default-management" if scope is cluster and IPspace is not Cluster (not yet implemented) + * "default-cluster" if scope is cluster and IPspace is Cluster (not yet implemented) + */ + Default: stringdefault.StaticString("default-data-files"), + }, "id": schema.StringAttribute{ MarkdownDescription: "IPInterface UUID", Computed: true, @@ -192,6 +206,9 @@ func (r *IPInterfaceResource) Read(ctx context.Context, req resource.ReadRequest } ip.Netmask = types.Int64Value(int64(intValue)) data.IP = &ip + + data.ServicePolicy = types.StringValue(restInfo.ServicePolicy.Name) + // Write logs using the tflog package // Documentation: https://terraform.io/plugin/log tflog.Debug(ctx, fmt.Sprintf("read a resource: %#v", data)) @@ -228,6 +245,7 @@ func (r *IPInterfaceResource) Create(ctx context.Context, req resource.CreateReq body.Location.HomeNode = interfaces.IPInterfaceResourceHomeNode{ Name: data.Location.HomeNode.ValueString(), } + body.ServicePolicy.Name = data.ServicePolicy.ValueString() client, err := connection.GetRestClient(errorHandler, r.config, data.CxProfileName) if err != nil { @@ -274,6 +292,7 @@ func (r *IPInterfaceResource) Update(ctx context.Context, req resource.UpdateReq body.Location.HomeNode = interfaces.IPInterfaceResourceHomeNode{ Name: data.Location.HomeNode.ValueString(), } + body.ServicePolicy.Name = data.ServicePolicy.ValueString() client, err := connection.GetRestClient(errorHandler, r.config, data.CxProfileName) if err != nil {