Skip to content

Commit

Permalink
Merge pull request #50 from NetApp/integration/main
Browse files Browse the repository at this point in the history
Integration/main
  • Loading branch information
wenjun666 authored Jun 3, 2021
2 parents d3c5d89 + e9c697d commit 452ad98
Show file tree
Hide file tree
Showing 12 changed files with 87 additions and 16 deletions.
4 changes: 3 additions & 1 deletion cloudmanager/aggregate.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type createAggregateRequest struct {
ProviderVolumeType string `structs:"providerVolumeType,omitempty"`
CapacityTier string `structs:"capacityTier,omitempty"`
Iops int `structs:"iops,omitempty"`
Throughput int `structs:"throughput,omitempty"`
}

// diskSize struct
Expand Down Expand Up @@ -72,6 +73,7 @@ type providerVolume struct {
DiskType string `json:"diskType"`
Encrypted bool `json:"encrypted"`
Iops int `json:"iops"`
Throughput int `json:"throughput"`
}

type disk struct {
Expand Down Expand Up @@ -168,7 +170,6 @@ func (c *Client) createAggregate(request *createAggregateRequest) (aggregateResu
return aggregateResult{}, err
}
baseURL = fmt.Sprintf("%s/aggregates", rootURL)

statusCode, response, onCloudRequestID, err := c.CallAPIMethod("POST", baseURL, params, c.Token, hostType)
if err != nil {
log.Print("createAggregate request failed")
Expand Down Expand Up @@ -319,6 +320,7 @@ func flattenProviderVolumes(v []providerVolume) interface{} {
vol["disk_type"] = volume.DiskType
vol["encrypted"] = volume.Encrypted
vol["iops"] = volume.Iops
vol["throughput"] = volume.Throughput
vol["size"] = flattenCapacity(volume.Size)

volumes = append(volumes, vol)
Expand Down
4 changes: 4 additions & 0 deletions cloudmanager/data_source_netapp_cloudmanager_volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ func dataSourceCVOVolume() *schema.Resource {
Type: schema.TypeInt,
Optional: true,
},
"throughput": {
Type: schema.TypeInt,
Optional: true,
},
"provider_volume_type": {
Type: schema.TypeString,
Optional: true,
Expand Down
4 changes: 3 additions & 1 deletion cloudmanager/occm_aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,9 @@ func (c *Client) getAWSInstance(occmDetails createOCCMDetails, id string) (strin
if err != nil {
return "", err
}

log.Print("getAWSInstance result:")
log.Printf("%#v", res)
log.Printf("user input id: %#v", id)
for _, instanceID := range res {
if instanceID == id {
return instanceID, nil
Expand Down
19 changes: 18 additions & 1 deletion cloudmanager/resource_netapp_cloudmanager_aggregate.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ func resourceAggregate() *schema.Resource {
Optional: true,
ForceNew: true,
},
"throughput": {
Type: schema.TypeInt,
Optional: true,
ForceNew: true,
},
},
}
}
Expand Down Expand Up @@ -110,7 +115,7 @@ func resourceAggregateCreate(d *schema.ResourceData, meta interface{}) error {
if a, ok := d.GetOk("home_node"); ok {
aggregate.HomeNode = a.(string)
}
if a, ok := d.GetOk("provider_yolume_type"); ok {
if a, ok := d.GetOk("provider_volume_type"); ok {
aggregate.ProviderVolumeType = a.(string)
if aggregate.ProviderVolumeType == "io1" {
if a, ok := d.GetOk("iops"); ok {
Expand All @@ -119,6 +124,18 @@ func resourceAggregateCreate(d *schema.ResourceData, meta interface{}) error {
log.Printf("CreateAggregate: provider_volume_type is io1, but iops is not configured.")
}
}
if aggregate.ProviderVolumeType == "gp3" {
if a, ok := d.GetOk("iops"); ok {
aggregate.Iops = a.(int)
} else {
log.Printf("CreateAggregate: provider_volume_type is gp3, but iops is not configured.")
}
if a, ok := d.GetOk("throughput"); ok {
aggregate.Throughput = a.(int)
} else {
log.Printf("CreateAggregate: provider_volume_type is gp3, but throughput is not configured.")
}
}
}
if a, ok := d.GetOk("capacity_tier"); ok {
if a.(string) != "NONE" {
Expand Down
10 changes: 10 additions & 0 deletions cloudmanager/resource_netapp_cloudmanager_snapmirror.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,16 @@ func resourceCVOSnapMirror() *schema.Resource {
Type: schema.TypeString,
Required: true,
},
"iops": {
Type: schema.TypeInt,
Optional: true,
ForceNew: true,
},
"throughput": {
Type: schema.TypeInt,
Optional: true,
ForceNew: true,
},
},
}
}
Expand Down
17 changes: 15 additions & 2 deletions cloudmanager/resource_netapp_cloudmanager_volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ func resourceCVOVolume() *schema.Resource {
Type: schema.TypeInt,
Optional: true,
},
"throughput": {
Type: schema.TypeInt,
Optional: true,
},
"provider_volume_type": {
Type: schema.TypeString,
Required: true,
Expand Down Expand Up @@ -191,6 +195,9 @@ func resourceCVOVolumeCreate(d *schema.ResourceData, meta interface{}) error {
if v, ok := d.GetOk("iops"); ok {
quote.Iops = v.(int)
}
if v, ok := d.GetOk("throughput"); ok {
quote.Throughput = v.(int)
}
if v, ok := d.GetOk("aggregate_name"); ok {
quote.AggregateName = v.(string)
createAggregateifNotExists = false
Expand Down Expand Up @@ -288,6 +295,9 @@ func resourceCVOVolumeCreate(d *schema.ResourceData, meta interface{}) error {
if v, ok := d.GetOk("iops"); ok {
volume.Iops = v.(int)
}
if v, ok := d.GetOk("throughput"); ok {
volume.Throughput = v.(int)
}
if volumeProtocol == "cifs" {
exist, err := client.checkCifsExists(volume.WorkingEnvironmentID, volume.SvmName)
if err != nil {
Expand Down Expand Up @@ -623,8 +633,11 @@ func resourceVolumeCustomizeDiff(diff *schema.ResourceDiff, v interface{}) error
}
}
providerVolumeType := diff.Get("provider_volume_type")
if _, ok := diff.GetOk("iops"); !ok && providerVolumeType == "io1" {
return fmt.Errorf("iops is required when provider_volume_type is io1")
if _, ok := diff.GetOk("iops"); !ok && (providerVolumeType == "io1" || providerVolumeType == "gp3") {
return fmt.Errorf("iops is required when provider_volume_type is io1 or gp3")
}
if _, ok := diff.GetOk("throughput"); !ok && providerVolumeType == "gp3" {
return fmt.Errorf("throughput is required when provider_volume_type is gp3")
}
capacityTier := diff.Get("capacity_tier")
if _, ok := diff.GetOk("tiering_policy"); !ok && capacityTier == "S3" {
Expand Down
26 changes: 23 additions & 3 deletions cloudmanager/snapmirror.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ type replicationVolume struct {
DestinationSvmName string `structs:"destinationSvmName,omitempty"`
DestinationProviderVolumeType string `structs:"destinationProviderVolumeType,omitempty"`
DestinationCapacityTier string `structs:"destinationCapacityTier,omitempty"`
Iops int `structs:"iops,omitempty"`
Throughput int `structs:"throughput,omitempty"`
}

type interclusterlif struct {
Expand Down Expand Up @@ -132,7 +134,7 @@ func (c *Client) buildSnapMirrorCreate(snapMirror snapMirrorRequest, sourceWorki
}

if destWorkingEnvironmentType != "ON_PREM" {
quote := c.buildQuoteRequest(snapMirror, volDestQuote, snapMirror.ReplicationVolume.DestinationVolumeName, snapMirror.ReplicationVolume.DestinationSvmName, snapMirror.ReplicationRequest.DestinationWorkingEnvironmentID)
quote := c.buildQuoteRequest(snapMirror, volDestQuote, snapMirror.ReplicationRequest.SourceWorkingEnvironmentID, snapMirror.ReplicationVolume.DestinationVolumeName, snapMirror.ReplicationVolume.DestinationSvmName, snapMirror.ReplicationRequest.DestinationWorkingEnvironmentID)

quoteResponse, err := c.quoteVolume(quote)
if err != nil {
Expand All @@ -146,6 +148,12 @@ func (c *Client) buildSnapMirrorCreate(snapMirror snapMirrorRequest, sourceWorki
snapMirror.ReplicationVolume.AdvancedMode = false
snapMirror.ReplicationVolume.DestinationAggregateName = quoteResponse["aggregateName"].(string)
}
if quote.Iops != 0 {
snapMirror.ReplicationVolume.Iops = quote.Iops
}
if quote.Throughput != 0 {
snapMirror.ReplicationVolume.Throughput = quote.Throughput
}
}

var sourceInterclusterLifIps []string
Expand All @@ -170,7 +178,7 @@ func (c *Client) buildSnapMirrorCreate(snapMirror snapMirrorRequest, sourceWorki
return snapMirror, nil
}

func (c *Client) buildQuoteRequest(snapMirror snapMirrorRequest, vol volumeResponse, name string, svm string, workingEnvironmentID string) quoteRequest {
func (c *Client) buildQuoteRequest(snapMirror snapMirrorRequest, vol volumeResponse, sourceWorkingEnvironmentID string, name string, svm string, workingEnvironmentID string) quoteRequest {
var quote quoteRequest

quote.Name = name
Expand All @@ -182,11 +190,23 @@ func (c *Client) buildQuoteRequest(snapMirror snapMirrorRequest, vol volumeRespo
quote.EnableCompression = vol.EnableCompression
quote.VerifyNameUniqueness = true
quote.ReplicationFlow = true
quote.Iops = vol.Iops
quote.WorkingEnvironmentID = workingEnvironmentID
quote.SvmName = svm
quote.CapacityTier = snapMirror.ReplicationVolume.DestinationCapacityTier

aggregate, err := c.getAggregate(aggregateRequest{WorkingEnvironmentID: sourceWorkingEnvironmentID}, vol.AggregateName)
if err != nil {
log.Printf("Error getting aggregate. aggregate name = %v", vol.AggregateName)
}

// Iops and Throughput values are the same if the volumes under the same aggregate
if aggregate.ProviderVolumes[0].DiskType == "gp3" || aggregate.ProviderVolumes[0].DiskType == "io1" || aggregate.ProviderVolumes[0].DiskType == "io2" {
quote.Iops = aggregate.ProviderVolumes[0].Iops
}
if aggregate.ProviderVolumes[0].DiskType == "gp3" {
quote.Throughput = aggregate.ProviderVolumes[0].Throughput
}

if snapMirror.ReplicationVolume.DestinationProviderVolumeType == "" {
quote.ProviderVolumeType = vol.ProviderVolumeType
} else {
Expand Down
3 changes: 2 additions & 1 deletion cloudmanager/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ type volumeRequest struct {
AutoVsaCapacityManagement bool `structs:"autoVsaCapacityManagement"`
DiskSize size `structs:"diskSize,omitempty"`
Iops int `structs:"iops,omitempty"`
Throughput int `structs:"throughput,omitempty"`
WorkingEnvironmentType string `structs:"workingEnvironmentType,omitempty"`
ShareInfo shareInfoRequest `structs:"shareInfo,omitempty"`
ShareInfoUpdate shareInfoUpdateRequest `structs:"shareInfo,omitempty"`
Expand All @@ -50,7 +51,6 @@ type volumeResponse struct {
CapacityTier string `json:"capacityTier,omitempty"`
TieringPolicy string `json:"tieringPolicy,omitempty"`
ProviderVolumeType string `json:"providerVolumeType"`
Iops int `json:"iops"`
ShareInfo []shareInfoResponse `json:"shareInfo"`
MountPoint string `json:"mountPoint"`
IscsiEnabled bool `json:"iscsiEnabled"`
Expand Down Expand Up @@ -85,6 +85,7 @@ type quoteRequest struct {
TieringPolicy string `structs:"tieringPolicy,omitempty"`
VerifyNameUniqueness bool `structs:"verifyNameUniqueness"`
Iops int `structs:"iops,omitempty"`
Throughput int `structs:"throughput,omitempty"`
WorkingEnvironmentType string `structs:"workingEnvironmentType"`
}

Expand Down
2 changes: 1 addition & 1 deletion website/docs/d/volume.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ The following attributes are exported in addition to the arguments listed above:
* `svm_name` - The name of the SVM.
* `size` - The volume size, supported with decimal numbers.
* `size_unit` - ['Byte' or 'KB' or 'MB' or 'GB' or 'TB'].
* `provider_volume_type` - The underlying cloud provider volume type. For AWS: ["gp2", "io1", "st1", "sc1"]. For Azure: ['Premium_LRS','Standard_LRS','StandardSSD_LRS']. For GCP: ['pd-ssd','pd-standard']
* `provider_volume_type` - The underlying cloud provider volume type. For AWS: ['gp3', 'gp2', 'io1', 'st1', 'sc1']. For Azure: ['Premium_LRS','Standard_LRS','StandardSSD_LRS']. For GCP: ['pd-ssd','pd-standard']
* `enable_thin_provisioning` - Enable thin provisioning. The default is 'true'.
* `enable_compression` - Enable compression. The default is 'true'.
* `enable_deduplication` - Enable deduplication. The default is 'true'.
Expand Down
5 changes: 3 additions & 2 deletions website/docs/r/aggregate.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@ The following arguments are supported:
* `disk_size_size` - (Optional) The required size of the disks. For GB, the unit can be: [100 or 500]. For TB, the unit can be: [1,2,4,8,16]. The default is '1'
* `disk_size_unit` - (Optional) The disk size unit ['GB' or 'TB']. The default is 'TB'
* `home_node` - (Optional) The home node that the new aggregate should belong to. The default is the first node.
* `provider_volume_type` - (Optional) The cloud provider volume type. For AWS: ["gp2", "io1", "st1", "sc1"]. For Azure: ['Premium_LRS','Standard_LRS','StandardSSD_LRS']. For GCP: ['pd-ssd','pd-standard']
* `provider_volume_type` - (Optional) The cloud provider volume type. For AWS: ['gp3', 'gp2', 'io1', 'st1', 'sc1']. For Azure: ['Premium_LRS','Standard_LRS','StandardSSD_LRS']. For GCP: ['pd-ssd','pd-standard']
* `capacity_tier` - (Optional) The aggregate's capacity tier for tiering cold data to object storage: ['S3', 'Blob', 'cloudStorage']. The default values for each cloud provider are as follows: Amazon => 'S3', Azure => 'Blob', GCP => 'cloudStorage'. If NONE, the capacity tier won't be set on aggregate creation.
* `iops` - (Optional) Provisioned IOPS. Needed only when providerVolumeType is "io1"
* `iops` - (Optional) Provisioned IOPS. Needed only when 'providerVolumeType' is 'io1' or 'gp3'
* `throughput` - (Optional) Required only when 'providerVolumeType' is 'gp3'.

## Attributes Reference

Expand Down
7 changes: 4 additions & 3 deletions website/docs/r/cvo_volume.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,13 @@ The following arguments are supported:
* `svm_name` - (Optional) The name of the SVM. The default SVM name is used, if a name isn't provided.
* `size` - (Required) The volume size, supported with decimal numbers.
* `size_unit` - (Required) ['Byte' or 'KB' or 'MB' or 'GB' or 'TB'].
* `provider_volume_type` - (Required) The underlying cloud provider volume type. For AWS: ["gp2", "io1", "st1", "sc1"]. For Azure: ['Premium_LRS','Standard_LRS','StandardSSD_LRS']. For GCP: ['pd-ssd','pd-standard']
* `provider_volume_type` - (Required) The underlying cloud provider volume type. For AWS: ['gp3', 'gp2', 'io1', 'st1', 'sc1']. For Azure: ['Premium_LRS','Standard_LRS','StandardSSD_LRS']. For GCP: ['pd-ssd','pd-standard']
* `client_id` - (Required) The client ID of the Cloud Manager Connector. You can find the ID from a previous create Connector action as shown in the example, or from the Connector tab on [https://cloudmanager.netapp.com](https://cloudmanager.netapp.com).
* `enable_thin_provisioning` - (Optional) Enable thin provisioning. The default is 'true'.
* `enable_compression` - (Optional) Enable compression. The default is 'true'.
* `enable_deduplication` - (Optional) Enable deduplication. The default is 'true'.
* `aggregate_name ` - (Optional) The aggregate in which the volume will be created. If not provided, Cloud Manager chooses the best aggregate for you.
* `volume_protocol` - (Optional) The protocol for the volume: ["nfs", "cifs", "iscsi"]. This affects the provided parameters. The default is 'nfs'
* `volume_protocol` - (Optional) The protocol for the volume: ['nfs', 'cifs', 'iscsi']. This affects the provided parameters. The default is 'nfs'
* `working_environment_id` - (Optional) The public ID of the working environment where the volume will be created. The ID can be optional if working_environment_name is provided. You can find the ID from the previous create Cloud Volumes ONTAP action as shown in the example, or from the Information page of the Cloud Volumes ONTAP working environment on [https://cloudmanager.netapp.com](https://cloudmanager.netapp.com).
* `working_environment_name` - (Optional) The working environment name where the aggregate will be created. It will be ignored if working_environment_id is provided.
* `capacity_tier` - (Optional) The volume's capacity tier for tiering cold data to object storage: ['S3', 'Blob', 'cloudStorage']. The default values for each cloud provider are as follows: Amazon => 'S3', Azure => 'Blob', GCP => 'cloudStorage'. If none, the capacity tier won't be set on volume creation.
Expand All @@ -96,7 +96,8 @@ The following arguments are supported:
* `export_policy_ip` - (Optional) Custom export policy list of IPs. (NFS protocol parameters)
* `export_policy_nfs_version` - (Optional) Export policy protocol. (NFS protocol parameters)
* `snapshot_policy_name` - (Optional) Snapshot policy name. The default is 'default'. (NFS protocol parameters)
* `iops` - (Optional) Provisioned IOPS. Needed only when provider_volume_type is "io1"
* `iops` - (Optional) Provisioned IOPS. Needed only when 'provider_volume_type' is 'io1' or 'gp3'
* `throughput` - (Optional) Required only when 'provider_volume_type' is 'gp3'.
* `share_name` (Optional) Share name. (CIFS protocol parameters)
* `permission` (Optional) CIFS share permission type. (CIFS protocol parameters)
* `users` (Optional) List of users with the permission. (CIFS protocol parameters)
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/snapmirror.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ The following arguments are supported:
* `schedule` - (Optional) Schedule name. The default is '1hour'.
* `max_transfer_rate` - (Required) Maximum transfer rate limit (KB/s). Use 0 for no limit, otherwise use number between 1024 and 2,147,482,624. The default is 100000.
* `destination_aggregate_name` - (Optional) The aggregate in which the volume will be created. If not provided, Cloud Manager chooses the best aggregate for you.
* `provider_volume_type` - (Optional) The underlying cloud provider volume type. For AWS: ["gp2", "io1", "st1", "sc1"]. For Azure: ['Premium_LRS','Standard_LRS','StandardSSD_LRS']. For GCP: ['pd-ssd','pd-standard']
* `provider_volume_type` - (Optional) The underlying cloud provider volume type. For AWS: ['gp3', 'gp2', 'io1', 'st1', 'sc1']. For Azure: ['Premium_LRS','Standard_LRS','StandardSSD_LRS']. For GCP: ['pd-ssd','pd-standard']
* `capacity_tier` - (Optional) The volume's capacity tier for tiering cold data to object storage: ['S3', 'Blob', 'cloudStorage']. The default values for each cloud provider are as follows: Amazon => 'S3', Azure => 'Blob', GCP => 'cloudStorage'. If none, the capacity tier won't be set on volume creation.

## Attributes Reference
Expand Down

0 comments on commit 452ad98

Please sign in to comment.