Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Protection rule and Recovery plan(DR Runbook) resources and datasources #216

Merged
merged 29 commits into from
Jan 22, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
947506e
updated client for protection rules and recovery plans
Dec 3, 2020
22357e5
added files protection rules and recovery plan
Dec 3, 2020
9ee5a03
deleted dr runbook for rebase
Dec 3, 2020
972c87d
Merge branch 'v1.2.0-beta' into dr-runbook-2
Dec 3, 2020
7d8f17b
changed typemap to typelist
Dec 4, 2020
72f395c
chore: added testify for validate diff
Dec 4, 2020
600d828
test: added other validation diff and fixes the diff because of type …
Dec 4, 2020
ae558f9
fixes linter
Dec 4, 2020
d065440
fixes linter
Dec 4, 2020
8686891
refactor: refactorized to make it compatible
Dec 4, 2020
32d49ce
fixes linter error
Dec 4, 2020
711c2ca
added other parameters of doc for network mapping in schema
Dec 7, 2020
aacd551
docs: added docs for resource and datasource(s) of protection rule an…
Dec 7, 2020
49659ce
added other parameters of doc for network mapping in schema
Dec 7, 2020
d8fdf8a
refactor
Dec 10, 2020
2ae0bd7
deleted to make it easy for git merge
Dec 16, 2020
90e17b3
merged
Dec 16, 2020
affa47d
feat: added filterbyname for protection rules and recovery plans
Dec 16, 2020
9f21497
make fmt
Dec 16, 2020
bcdb38f
fixes linter
Dec 16, 2020
a9baf11
fix: added instatiates to avoid nil exception error
Dec 17, 2020
b7135e3
fix: added validation for any entity reference
Dec 17, 2020
00ca1ca
change schema for categories entity info list and added testacc for t…
Dec 18, 2020
0627647
deleted printing logs
Dec 18, 2020
e483f18
fix: changed to only optional for any reference of entity info list
Dec 22, 2020
e44050d
test: updated testacc so it can repeat same steps to see if it works …
Dec 22, 2020
7e0ee7a
fixes linter code
Dec 22, 2020
623113c
git merge
Jan 22, 2021
afb0809
test: complete testacc for protection rules and recovery plan with ne…
Jan 22, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor
  • Loading branch information
Edgar López committed Dec 10, 2020
commit d8fdf8a175ef77fc9b45a5ab36e4f880ba2a1659
7 changes: 3 additions & 4 deletions nutanix/resource_nutanix_protection_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,12 @@ func resourceNutanixProtectionRule() *schema.Resource {
"num_snapshots": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
"rollup_retention_policy_multiple": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
"rollup_retention_policy_snapshot_interval_type": {
Type: schema.TypeString,
Expand Down Expand Up @@ -636,9 +638,7 @@ func expandSnapshotScheduleList(d interface{}) []*v3.SnapshotScheduleList {
az.SnapshotType = v1.(string)
}
if v1, ok1 := v["remote_snapshot_retention_policy"].([]interface{}); ok1 && len(v1) > 0 {
fmt.Println("entro remote snapshot")
az.RemoteSnapshotRetentionPolicy = expandRetentionPolicy(v1[0])
utils.PrintToJSON(az.RemoteSnapshotRetentionPolicy, "")
}
snapshots = append(snapshots, az)
}
Expand All @@ -663,9 +663,8 @@ func expandRetentionPolicy(d interface{}) *v3.SnapshotRetentionPolicy {
log.Printf("[DEGUG] rrp.Multiple: %+v", rrp.Multiple)
flagRollup = true
}
if v1, ok := v["f"]; ok && v1.(string) != "" {
if v1, ok := v["rollup_retention_policy_snapshot_interval_type"]; ok && v1.(string) != "" {
rrp.SnapshotIntervalType = v1.(string)
log.Printf("[DEGUG] rrp.SnapshotIntervalType: %+v", rrp.SnapshotIntervalType)
flagRollup = true
}
if flagRollup {
Expand Down
51 changes: 26 additions & 25 deletions nutanix/resource_nutanix_recovery_plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,8 @@ func resourceNutanixRecoveryPlan() *schema.Resource {
},
"name": {
Type: schema.TypeString,
Required: true,
Optional: true,
Computed: true,
},
},
},
Expand Down Expand Up @@ -510,7 +511,8 @@ func resourceNutanixRecoveryPlan() *schema.Resource {
},
"name": {
Type: schema.TypeString,
Required: true,
Optional: true,
Computed: true,
},
},
},
Expand Down Expand Up @@ -604,7 +606,7 @@ func resourceNutanixRecoveryPlan() *schema.Resource {
},
},
"cluster_reference_list": {
Type: schema.TypeList,
Type: schema.TypeSet,
Optional: true,
Computed: true,
Elem: &schema.Resource{
Expand Down Expand Up @@ -1069,23 +1071,24 @@ func expandZoneNetworkMappingList(d []interface{}) []*v3.AvailabilityZoneNetwork
for _, networkMap := range d {
netMap := &v3.AvailabilityZoneNetworkMappingList{}
v4 := networkMap.(map[string]interface{})
log.Printf("print map network map : %+v", v4)
if v5, ok1 := v4["availability_zone_url"]; ok1 && v5.(string) != "" {
netMap.AvailabilityZoneURL = v5.(string)
}
if v5, ok1 := v4["recovery_network"].([]interface{}); ok1 && len(v5) > 0 {
netMap.RecoveryNetwork = expandRecoveryNetwork(v5[0].([]interface{}))
netMap.RecoveryNetwork = expandRecoveryNetwork(v5)
}
if v5, ok1 := v4["test_network"].([]interface{}); ok1 && len(v5) > 0 {
netMap.RecoveryNetwork = expandRecoveryNetwork(v5[0].([]interface{}))
if v5, ok1 := v4["test_network"].([]interface{}); ok1 && len(v5) > 0 && len(v5) > 0 {
netMap.TestNetwork = expandRecoveryNetwork(v5)
}
if v5, ok1 := v4["recovery_ip_assignment_list"].([]interface{}); ok1 && len(v5) > 0 {
netMap.RecoveryIPAssignmentList = expandIPAssignmentList(v5[0].([]interface{}))
netMap.RecoveryIPAssignmentList = expandIPAssignmentList(v5)
}
if v5, ok1 := v4["test_ip_assignment_list"].([]interface{}); ok1 && len(v5) > 0 {
netMap.RecoveryIPAssignmentList = expandIPAssignmentList(v5[0].([]interface{}))
if v5, ok1 := v4["test_ip_assignment_list"].([]interface{}); ok1 {
netMap.TestIPAssignmentList = expandIPAssignmentList(v5)
}
if v5, ok1 := v4["cluster_reference_list"].([]interface{}); ok1 && len(v5) > 0 {
netMap.ClusterReferenceList = validateArrayRef(v5[0].([]interface{}), nil)
if v5, ok1 := v4["cluster_reference_list"]; ok1 {
netMap.ClusterReferenceList = validateArrayRef(v5.(*schema.Set), nil)
}
mapping = append(mapping, netMap)
}
Expand All @@ -1095,24 +1098,22 @@ func expandZoneNetworkMappingList(d []interface{}) []*v3.AvailabilityZoneNetwork
func expandRecoveryNetwork(d []interface{}) *v3.Network {
network := &v3.Network{}
for _, v1 := range d {
d := v1.(map[string]interface{})
if v, ok1 := d["name"]; ok1 && v.(string) != "" {
network.Name = v.(string)
}
if v, ok1 := d["virtual_network_reference"].([]interface{}); ok1 {
network.VirtualNetworkReference = validateRefList(v, utils.StringPtr("recovery_plan"))
v := v1.(map[string]interface{})
log.Printf("print map recovery : %+v", v)
if v2, ok1 := v["virtual_network_reference"].([]interface{}); ok1 && len(v2) > 0 {
network.VirtualNetworkReference = validateRefList(v2, nil)
}
if v, ok1 := d["vpc_reference"].([]interface{}); ok1 {
network.VPCReference = validateRefList(v, utils.StringPtr("recovery_plan"))
if v2, ok1 := v["vpc_reference"].([]interface{}); ok1 && len(v2) > 0 {
network.VPCReference = validateRefList(v2, nil)
}
if v, ok1 := d["name"]; ok1 && v.(string) != "" {
network.Name = v.(string)
if v2, ok1 := v["name"]; ok1 && v2.(string) != "" {
network.Name = v2.(string)
}
if v, ok1 := d["subnet_list"].([]interface{}); ok1 {
network.SubnetList = expandSubnetList(v)
if v2, ok1 := v["subnet_list"].([]interface{}); ok1 {
network.SubnetList = expandSubnetList(v2)
}
if v, ok1 := d["use_vpc_reference"].(bool); ok1 {
network.UseVPCReference = utils.BoolPtr(v)
if v2, ok1 := v["use_vpc_reference"].(bool); ok1 && v2 {
network.UseVPCReference = utils.BoolPtr(v2)
}
}

Expand Down