Skip to content

Commit

Permalink
Merge pull request #176 from NetApp/integration/main
Browse files Browse the repository at this point in the history
Integration/main
  • Loading branch information
wenjun666 authored Aug 17, 2023
2 parents 680007b + dff08f3 commit c4723b9
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 22 deletions.
13 changes: 10 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 23.8.1
NEW FEATURES:
* resource/cvo_gcp: support LDM/flashCache on both single and HA.

BUG FIXES:
* resource/connector_gcp: fix gcp config flags backward compatible issue.

## 23.8.0
BUG FIXES:
* resource/volume: fix documentation name for volume and add an example for creating on_prem volume.
Expand Down Expand Up @@ -107,15 +114,15 @@ NEW FEATURES:

NEW ENHANCEMENTS:
* resource/connector_azure: display the deployed virtual machine principal_id in state file on the connector azure creation.
* resource/cvo_azure: add availability_zone_node1 and availability_zone_node2 to support HA deployment.
* resoruce/cvo_azure: add new support value "Premium_ZRS" in paramter storage_type.
* resource/cvo_azure: add `availability_zone_node1` and `availability_zone_node2` to support HA deployment.
* resoruce/cvo_azure: add new support value "Premium_ZRS" in paramter `storage_type`.

## 22.9.1
NEW FEATURES:
* resource/connector_snapmirror: support fsx as a source for snapmirror relationship with fsx/onprem.

NEW ENHANCEMENTS:
* resource/cvo_azure: add availability_zone parameter for single node deployment.
* resource/cvo_azure: add `availability_zone` parameter for single node deployment.
* Use sensitive flag on the password of each resource.

BUG FIXES:
Expand Down
8 changes: 6 additions & 2 deletions cloudmanager/cvo_aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,12 @@ type cvoList struct {

// cvoResult the users input for creating a cvo
type cvoResult struct {
PublicID string `json:"publicId"`
SvmName string `json:"svmName"`
PublicID string `json:"publicId"`
Name string `json:"name"`
TenantID string `json:"tenantId"`
SvmName string `json:"svmName"`
CreatorUserEmail string `json:"creatorUserEmail"`
OntapClusterProperties ontapClusterProperties `json:"ontapClusterProperties"`
}

// tenantResult the users input for creating a cvo
Expand Down
39 changes: 37 additions & 2 deletions cloudmanager/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ type workingEnvironmentOntapClusterPropertiesResponse struct {
MonitoringProperties interface{} `json:"monitoringProperties"`
Name string `json:"name"`
OntapClusterProperties ontapClusterProperties `json:"ontapClusterProperties"`
ProviderProperties interface{} `json:"providerProperties"`
ProviderProperties providerProperties `json:"providerProperties"`
PublicID string `json:"publicId"`
ReplicationProperties interface{} `json:"replicationProperties"`
ReservedSize interface{} `json:"reservedSize"`
Expand All @@ -68,6 +68,11 @@ type workingEnvironmentOntapClusterPropertiesResponse struct {
}

type ontapClusterProperties struct {
AggregateCount int `json:"aggregateCount"`
VolumeCount int `json:"volumeCount"`
FlashCache bool `json:"flashCache"`
SpaceReportingLogical bool `json:"spaceReportingLogical"`
KeystoneSubscription bool `json:"keystoneSubscription"`
BroadcastDomainInfo []broadcastDomainInfo `json:"broadcastDomainInfo"`
CanConfigureCapacityTier bool `json:"canConfigureCapacityTier"`
CapacityTierInfo capacityTierInfo `json:"capacityTierInfo"`
Expand All @@ -91,6 +96,25 @@ type ontapClusterProperties struct {
WritingSpeedState string `json:"writingSpeedState"`
}

// commond fields of GCP properties and Azure properties
type providerProperties struct {
RegionName string `json:"regionrName"`
InstanceType string `json:"instanceType"`
NumOfNics int `json:"numOfNics"`
}

type gcpProperties struct {
Name string `json:"name"`
RegionName string `json:"regionrName"`
ZoneName []string `json:"zoneName"`
InstanceType string `json:"instanceType"`
SubnetCidr string `json:"subnetCidr"`
NumOfNics int `json:"numOfNics"`
Labels interface{} `json:"labels"`
ProjectName string `json:"projectName"`
DeploymentName string `json:"deploymentName"`
}

type haProperties struct {
FailoverMode interface{} `json:"failoverMode"`
MediatorStatus interface{} `json:"mediatorStatus"`
Expand Down Expand Up @@ -1172,10 +1196,14 @@ func updateCVOLicenseInstanceType(d *schema.ResourceData, meta interface{}, clie
if c, ok := d.GetOk("license_type"); ok {
request.LicenseType = c.(string)
}

if request.LicenseType == "capacity-paygo" && d.Get("is_ha").(bool) {
log.Print("Set licenseType as default value ha-capacity-paygo")
request.LicenseType = "ha-capacity-paygo"
}
// Update license type and instance type
id := d.Id()
baseURL := fmt.Sprintf("/working-environments/%s/license-instance-type", id)
log.Printf("Update license and instance type: %#v", request)
updateErr := client.callCMUpdateAPI("PUT", request, baseURL, id, "updateCVOLicenseInstanceType", clientID)
if updateErr != nil {
return updateErr
Expand Down Expand Up @@ -1296,6 +1324,13 @@ func (c *Client) setOCCMConfig(request configValuesUpdateRequest, clientID strin
log.Print("setOCCMConfig: set OCCM configuration")

hostType := "CloudManagerHost"
if c.Token == "" {
accesTokenResult, err := c.getAccessToken()
if err != nil {
return err
}
c.Token = accesTokenResult.Token
}

baseURL := "/occm/api/occm/config"
params := structs.Map(request)
Expand Down
21 changes: 17 additions & 4 deletions cloudmanager/resource_netapp_cloudmanager_connector_gcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,25 +158,21 @@ func resourceOCCMGCP() *schema.Resource {
Type: schema.TypeBool,
Optional: true,
Default: false,
ForceNew: true,
},
"gcp_serial_port_enable": {
Type: schema.TypeBool,
Optional: true,
Default: true,
ForceNew: true,
},
"gcp_enable_os_login": {
Type: schema.TypeBool,
Optional: true,
Default: true,
ForceNew: true,
},
"gcp_enable_os_login_sk": {
Type: schema.TypeBool,
Optional: true,
Default: true,
ForceNew: true,
},
},
}
Expand Down Expand Up @@ -506,11 +502,28 @@ func resourceOCCMGCPUpdate(d *schema.ResourceData, meta interface{}) error {
}
occmDetails.Company = d.Get("company").(string)
clientID := d.Get("client_id").(string)
client.AccountID = d.Get("account_id").(string)

instance, err := client.getVMInstance(occmDetails, clientID)
if err != nil {
return err
}
occmConfig := configValuesUpdateRequest{}
if o, ok := d.GetOk("gcp_block_project_ssh_keys"); ok {
occmConfig.GcpBlockProjectSSHKeys = o.(bool)
}
if o, ok := d.GetOk("gcp_serial_port_enable"); ok {
occmConfig.GcpSerialPortEnable = o.(bool)
}
if o, ok := d.GetOk("gcp_enable_os_login"); ok {
occmConfig.GcpEnableOsLogin = o.(bool)
}
if o, ok := d.GetOk("gcp_enable_os_login_sk"); ok {
occmConfig.GcpEnableOsLoginSk = o.(bool)
}
if err := client.setOCCMConfig(occmConfig, clientID); err != nil {
return fmt.Errorf("error set occm config: %s", err)
}

if d.HasChange("tags") {
tagItems := instance["tags"].(map[string]interface{})
Expand Down
35 changes: 26 additions & 9 deletions cloudmanager/resource_netapp_cloudmanager_cvo_gcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package cloudmanager
import (
"fmt"
"log"
"regexp"
"strings"

"github.com/hashicorp/terraform/helper/schema"
Expand Down Expand Up @@ -171,6 +172,7 @@ func resourceCVOGCP() *schema.Resource {
"writing_speed_state": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validation.StringInSlice([]string{"NORMAL", "HIGH"}, true),
DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
return strings.EqualFold(old, new)
Expand Down Expand Up @@ -434,10 +436,15 @@ func resourceCVOGCPCreate(d *schema.ResourceData, meta interface{}) error {
if c, ok := d.GetOk("enable_compliance"); ok {
cvoDetails.EnableCompliance = c.(bool)
}
// In GCP HA, HIGH write speed and FlashCache are coupled together both needs to be activated, one cannot be activated without the other.
// In both single and HA case, flash_cache only can be set when the selected instance_type
if c, ok := d.GetOk("flash_cache"); ok {
cvoDetails.FlashCache = c.(bool)
match, _ := regexp.MatchString("^n2-standard-(16|32|48|64)$", cvoDetails.VsaMetadata.InstanceType)
if !match {
return fmt.Errorf("instance_type has to be one of n2-standard-16,32,48,64")
}
}

if c, ok := d.GetOk("zone"); ok {
cvoDetails.Region = c.(string)
}
Expand Down Expand Up @@ -480,6 +487,8 @@ func resourceCVOGCPCreate(d *schema.ResourceData, meta interface{}) error {
}
if c, ok := d.GetOk("writing_speed_state"); ok {
cvoDetails.WritingSpeedState = strings.ToUpper(c.(string))
} else {
cvoDetails.WritingSpeedState = "NORMAL"
}

if c, ok := d.GetOk("nss_account"); ok {
Expand Down Expand Up @@ -626,6 +635,7 @@ func resourceCVOGCPCreate(d *schema.ResourceData, meta interface{}) error {
log.Printf("createCVOGCP %s result %#v client_id %s", cvoDetails.Name, res, clientID)
d.SetId(res.PublicID)
d.Set("svm_name", res.SvmName)
d.Set("writing_speed_state", res.OntapClusterProperties.WritingSpeedState)
log.Printf("Created cvo: %v", res)

// Add SVMs on GCP CVO HA
Expand Down Expand Up @@ -654,13 +664,9 @@ func resourceCVOGCPRead(d *schema.ResourceData, meta interface{}) error {
return err
}
d.Set("svm_name", resp.SvmName)
if c, ok := d.GetOk("writing_speed_state"); ok {
if strings.EqualFold(c.(string), resp.OntapClusterProperties.WritingSpeedState) {
d.Set("writing_speed_state", c.(string))
} else {
d.Set("writing_speed_state", resp.OntapClusterProperties.WritingSpeedState)
}
}
d.Set("writing_speed_state", resp.OntapClusterProperties.WritingSpeedState)
d.Set("instance_type", resp.ProviderProperties.InstanceType)

return nil
}

Expand Down Expand Up @@ -713,6 +719,18 @@ func resourceCVOGCPUpdate(d *schema.ResourceData, meta interface{}) error {
}
}

instanceType := d.Get("instance_type").(string)
// In both single and HA case, flash_cache only can be set when the selected instance_type
if _, ok := d.GetOk("flash_cache"); ok {
match, _ := regexp.MatchString("^n2-standard-(16|32|48|64)$", instanceType)
if !match {
return fmt.Errorf("instance_type has to be one of n2-standard-16,32,48,64")
}
if d.Get("is_ha").(bool) && d.Get("writing_speed_state").(string) == "" {
return fmt.Errorf("in HA, writing_speed_state has to be set when flash_cache is set")
}
}

// check if license_type and instance type are changed
if d.HasChange("instance_type") || d.HasChange("license_type") {
respErr := updateCVOLicenseInstanceType(d, meta, clientID)
Expand Down Expand Up @@ -741,7 +759,6 @@ func resourceCVOGCPUpdate(d *schema.ResourceData, meta interface{}) error {
if respErr != nil {
return respErr
}

return nil
}

Expand Down
7 changes: 5 additions & 2 deletions website/docs/r/cvo_gcp.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ resource "netapp-cloudmanager_cvo_gcp" "cl-cvo-gcp" {
svm_password = "netapp1!"
client_id = netapp-cloudmanager_connector_gcp.cm-gcp.client_id
workspace_id = "workspace-IDz6Nnwl"
license_type = "capacity-paygo"
gcp_label {
label_key = "abcd"
label_value = "ABCD"
Expand All @@ -49,6 +50,7 @@ resource "netapp-cloudmanager_cvo_gcp" "cl-cvo-gcp" {
svm_password = "netapp1!"
client_id = netapp-cloudmanager_connector_gcp.cm-gcp.client_id
workspace_id = "workspace-IDz6Nnwl"
license_type = "capacity-paygo"
gcp_label {
label_key = "abcd"
label_value = "ABCD"
Expand Down Expand Up @@ -82,6 +84,7 @@ resource "netapp-cloudmanager_cvo_gcp" "cl-cvo-gcp-ha" {
gcp_volume_type = "pd-ssd"
capacity_package_name = "Professional"
instance_type = "n2-standard-16"
license_type = "ha-capacity-paygo"
mediator_zone = "us-east4-c"
node1_zone = "us-east4-a"
node2_zone = "us-east4-b"
Expand Down Expand Up @@ -131,8 +134,8 @@ The following arguments are supported:
* `saas_subscription_id` - (Optional) SaaS Subscription ID. It is needed if the subscription is not paygo type.
* `nss_account` - (Optional) The NetApp Support Site account ID to use with this Cloud Volumes ONTAP system. If the license type is BYOL and an NSS account isn't provided, Cloud Manager tries to use the first existing NSS account.
* `writing_speed_state` - (Optional) The write speed setting for Cloud Volumes ONTAP: ['NORMAL','HIGH']. The default is 'NORMAL'. For single node system, HIGH write speed is supported with all machine types. For HA, Flash Cache, high write speed, and a higher maximum transmission unit (MTU) of 8,896 bytes are available through the High write speed option with the n2-standard-16, n2-standard-32, n2-standard-48, and n2-standard-64 instance types.
* `flash_cache` - (Optional) Enable Flash Cache. In GCP HA (version 9.13.0), HIGH write speed and FlashCache are coupled together both needs to be activated, one cannot be activated without the other.
* `firewall_rule` - (Optional) The name of the firewall rule for a single node cluster. If not provided, Cloud Manager generates the rule.
* `flash_cache` - (Optional) Enable Flash Cache. In GCP HA (version 9.13.0), HIGH write speed and FlashCache are coupled together both needs to be activated, one cannot be activated without the other. For GCP single (version 9.13.1) is supported. Only the instance_type is one of the followings: n2-standard-16,32,48,64
* `firewall_rule` - (Optional) The name of the firewall rule for a single node cluster. If not provided, the rule will be generated automatically.
* `firewall_tag_name_rule` - (Optional) Target tag of the firewall when creating a CVO with an existing firewall. It is used for a single node cluster.
* `firewall_ip_ranges` - (Optional) Define the allowed inbound traffic for the generated policy. It is used when selecting create a new firewall. Recommanded set false: Allow traffice within the selected VPC only. Allow inbound traffic only from the cluster node VPCs.
* `backup_volumes_to_cbs` - (Optional) Automatically enable back up of all volumes to Google Cloud buckets [true, false].
Expand Down

0 comments on commit c4723b9

Please sign in to comment.