Skip to content

Commit d84ee43

Browse files
committed
Sync bitbucket and GitHub
1 parent a193124 commit d84ee43

File tree

5 files changed

+71
-51
lines changed

5 files changed

+71
-51
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 22.10.0
2+
* resource/active_directory: ([#76](https://github.com/NetApp/terraform-provider-netapp-gcp/issues/76))
3+
14
## 22.8.1
25
BUG FIXES:
36
* resource/storage_pool: Fix creation error with shared vpc. ([#69](https://github.com/NetApp/terraform-provider-netapp-gcp/issues/69))

gcp/active_directory.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ type operateActiveDirectoryRequest struct {
2727
AesEncryption bool `structs:"aesEncryption"`
2828
Label string `structs:"label"`
2929
AdName string `structs:"adName"`
30+
ManagedAD bool `structs:"managedAD"`
3031
}
3132

3233
// operateActiveDirectoryResult returns the api response for creating/updating an active directory
@@ -60,6 +61,7 @@ type listActiveDirectoryResult struct {
6061
AesEncryption bool `json:"aesEncryption"`
6162
Label string `json:"label"`
6263
AdName string `json:"adName"`
64+
ManagedAD bool `structs:"managedAD"`
6365
}
6466

6567
type listActiveDirectoryAPIResult struct {
Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package gcp
22

33
import (
4-
"fmt"
5-
64
"github.com/hashicorp/terraform/helper/schema"
75
)
86

@@ -27,7 +25,7 @@ func dataSourceGCPActiveDirectory() *schema.Resource {
2725
Type: schema.TypeString,
2826
Optional: true,
2927
},
30-
"netbios": {
28+
"net_bios": {
3129
Type: schema.TypeString,
3230
Optional: true,
3331
},
@@ -47,50 +45,52 @@ func dataSourceGCPActiveDirectory() *schema.Resource {
4745
Type: schema.TypeString,
4846
Computed: true,
4947
},
48+
"aes_encryption": {
49+
Type: schema.TypeBool,
50+
Optional: true,
51+
},
52+
"backup_operators": {
53+
Type: schema.TypeSet,
54+
Elem: &schema.Schema{
55+
Type: schema.TypeString,
56+
},
57+
Optional: true,
58+
},
59+
"security_operators": {
60+
Type: schema.TypeSet,
61+
Elem: &schema.Schema{
62+
Type: schema.TypeString,
63+
},
64+
Optional: true,
65+
},
66+
"allow_local_nfs_users_with_ldap": {
67+
Type: schema.TypeBool,
68+
Optional: true,
69+
},
70+
"kdc_ip": {
71+
Type: schema.TypeString,
72+
Optional: true,
73+
},
74+
"ldap_signing": {
75+
Type: schema.TypeBool,
76+
Optional: true,
77+
},
78+
"connection_type": {
79+
Type: schema.TypeString,
80+
Optional: true,
81+
},
82+
"ad_server": {
83+
Type: schema.TypeString,
84+
Optional: true,
85+
},
86+
"managed_ad": {
87+
Type: schema.TypeBool,
88+
Optional: true,
89+
},
5090
},
5191
}
5292
}
5393

5494
func dataSourceGCPActiveDirectoryRead(d *schema.ResourceData, meta interface{}) error {
55-
client := meta.(*Client)
56-
activeDirectory := listActiveDirectoryRequest{}
57-
activeDirectory.Region = d.Get("region").(string)
58-
var res listActiveDirectoryResult
59-
res, err := client.listActiveDirectoryForRegion(activeDirectory)
60-
if err != nil {
61-
return err
62-
}
63-
d.SetId(res.UUID)
64-
65-
if err := d.Set("uuid", res.UUID); err != nil {
66-
return fmt.Errorf("Error reading active directory UUID: %s", err)
67-
}
68-
if err := d.Set("domain", res.Domain); err != nil {
69-
return fmt.Errorf("Error reading active directory domain: %s", err)
70-
}
71-
72-
if err := d.Set("netbios", res.NetBIOS); err != nil {
73-
return fmt.Errorf("Error reading active directory netbios: %s", err)
74-
}
75-
76-
if err := d.Set("organizational_unit", res.OrganizationalUnit); err != nil {
77-
return fmt.Errorf("Error reading active directory organizational_unit: %s", err)
78-
}
79-
80-
if err := d.Set("site", res.Site); err != nil {
81-
return fmt.Errorf("Error reading active directory site: %s", err)
82-
}
83-
84-
if err := d.Set("username", res.Username); err != nil {
85-
return fmt.Errorf("Error reading active directory username: %s", err)
86-
}
87-
88-
if err := d.Set("dns_server", res.DNS); err != nil {
89-
return fmt.Errorf("Error reading active directory dns_server: %s", err)
90-
}
91-
92-
if err := d.Set("region", res.Region); err != nil {
93-
return fmt.Errorf("Error reading active directory region: %s", err)
94-
}
95-
return nil
95+
return resourceGCPActiveDirectoryRead(d, meta)
9696
}

gcp/resource_netapp_gcp_active_directory.go

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,11 @@ func resourceGCPActiveDirectory() *schema.Resource {
100100
Type: schema.TypeString,
101101
Optional: true,
102102
},
103+
"managed_ad": {
104+
Type: schema.TypeBool,
105+
Optional: true,
106+
Default: false,
107+
},
103108
},
104109
}
105110
}
@@ -162,6 +167,8 @@ func resourceGCPActiveDirectoryCreate(d *schema.ResourceData, meta interface{})
162167
activeDirectory.AdName = v.(string)
163168
}
164169

170+
activeDirectory.ManagedAD = d.Get("managed_ad").(bool)
171+
165172
res, err := client.createActiveDirectory(&activeDirectory)
166173
if err != nil {
167174
log.Print("Error creating active directory")
@@ -176,18 +183,20 @@ func resourceGCPActiveDirectoryCreate(d *schema.ResourceData, meta interface{})
176183

177184
func resourceGCPActiveDirectoryRead(d *schema.ResourceData, meta interface{}) error {
178185
client := meta.(*Client)
179-
id := d.Id()
180186
activeDirectory := listActiveDirectoryRequest{}
181187
activeDirectory.Region = d.Get("region").(string)
182188
var res listActiveDirectoryResult
183189
res, err := client.listActiveDirectoryForRegion(activeDirectory)
184190
if err != nil {
185191
return err
186192
}
187-
if res.UUID != id {
188-
return fmt.Errorf("Expected active directory with id: %v, Response contained active directory with id: %v",
189-
d.Get("uuid").(string), res.UUID)
190-
}
193+
// Disabling, since it would fail for call from dataSourceGCPVolumeRead
194+
// Unclear if this sanity check is required
195+
// if res.UUID != d.id {
196+
// return fmt.Errorf("Expected active directory with id: %v, Response contained active directory with id: %v",
197+
// d.Get("uuid").(string), res.UUID)
198+
// }
199+
d.SetId(res.UUID)
191200
d.Set("uuid", res.UUID)
192201

193202
if err := d.Set("domain", res.Domain); err != nil {
@@ -250,6 +259,9 @@ func resourceGCPActiveDirectoryRead(d *schema.ResourceData, meta interface{}) er
250259
return fmt.Errorf("Error reading active directory ad_server: %s", err)
251260
}
252261

262+
if err := d.Set("managed_ad", res.ManagedAD); err != nil {
263+
return fmt.Errorf("Error reading active directory managed_ad: %s", err)
264+
}
253265
return nil
254266
}
255267

@@ -340,6 +352,8 @@ func resourceGCPActiveDirectoryUpdate(d *schema.ResourceData, meta interface{})
340352
activeDirectory.AdName = v.(string)
341353
}
342354

355+
activeDirectory.ManagedAD = d.Get("managed_ad").(bool)
356+
343357
err := client.updateActiveDirectory(activeDirectory)
344358
if err != nil {
345359
return err

website/docs/r/active_directory.html.markdown

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ Creates a new Active Directory connection for a given region. Only one connectio
2929
resource "netapp-gcp_active_directory" "gcp-active-directory" {
3030
provider = netapp-gcp
3131
region = "us-west2"
32-
username = "test_user"
33-
password = "netapp"
32+
username = "test_user"
33+
password = "netapp"
3434
domain = "example.com"
3535
dns_server = "10.0.0.0"
3636
net_bios = "cvsserver"
@@ -52,6 +52,7 @@ AD connection specific settings:
5252
* `net_bios` - (Required) NetBIOS prefix name of the server that will be created. A random 5-digit suffix is appended automatically (e.g. -A579).
5353
* `aes_encryption` - (Optional) Enables AES-128 and AES-256 encryption for Kerberos-based communication with Active Directory. Default is false.
5454
* `ldap_signing` - (Optional) Enables LDAP siging. Default is false.
55+
* `managed_ad` - (Optional) Flags this configuration as Google ManagedAD configuration. Please see https://cloud.google.com/architecture/partners/netapp-cloud-volumes/managing-active-directory-connections?hl=en_US#connect_to_managed_microsoft_ad
5556

5657
User credentials for Domain join:
5758
* `username` - (Required) Username of an account permitted to create computer objects in your Active Directory.

0 commit comments

Comments
 (0)