Skip to content

Commit d97329a

Browse files
Abhishekism9450bhati-pradeepabhimutantMatthew Machivenyika
authored
Feat/1.7.0 (#486)
Co-authored-by: Pradeepsingh Bhati <pradeep.bhati@nutanix.com> Co-authored-by: Abhishek <abhishek.chaudhary@nutanix.com> Co-authored-by: Matthew Machivenyika <matthew.machivenyika@fis-he.ch>
1 parent d57a46e commit d97329a

33 files changed

+1001
-120
lines changed

CHANGELOG.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,47 @@
1+
## 1.7.0 (August 12, 2022)
2+
3+
[Full Changelog](https://github.com/nutanix/terraform-provider-nutanix/compare/v1.6.1...v1.7.0)
4+
5+
**New Feature:**
6+
- Added a resource for user groups. [\#477] (https://github.com/nutanix/terraform-provider-nutanix/pull/477)
7+
8+
New Resource :
9+
- nutanix_user_groups
10+
11+
**Merged pull request:**
12+
13+
- Feature user groups [\#477] (https://github.com/nutanix/terraform-provider-nutanix/pull/477) ([abhimutant](https://github.com/abhimutant))
14+
- Fix checksum issue in image resource [\#481] (https://github.com/nutanix/terraform-provider-nutanix/pull/481) ([bhatipradeep](https://github.com/bhatipradeep))
15+
- Fix image resource issues [\#480] (https://github.com/nutanix/terraform-provider-nutanix/pull/480) ([bhatipradeep](https://github.com/bhatipradeep))
16+
- Add field to set time zone for cluster created using foundation [\#484] (https://github.com/nutanix/terraform-provider-nutanix/pull/484) ([bhatipradeep](https://github.com/bhatipradeep))
17+
- fixed the issue and added testcase for sysprep custom key values guest customisation [\#478] (https://github.com/nutanix/terraform-provider-nutanix/pull/478) ([abhimutant](https://github.com/abhimutant))
18+
- Changes in karbon cluster documentation for storage config [\#479] (https://github.com/nutanix/terraform-provider-nutanix/pull/479) ([abhimutant](https://github.com/abhimutant))
19+
- Enable tests for protection rules based datasources and resources [\#366] (https://github.com/nutanix/terraform-provider-nutanix/pull/366) ([bhatipradeep](https://github.com/bhatipradeep))
20+
- Add uuid to address_groups data source [\#472] (https://github.com/nutanix/terraform-provider-nutanix/pull/472) ([mcguppy](https://github.com/mcguppy))
21+
22+
23+
**Fixed bugs:**
24+
25+
- Terraform provider crashes when using guest_customization_sysprep_custom_key_values [\#441] (https://github.com/nutanix/terraform-provider-nutanix/issues/441)
26+
- Nutanix terraform- Karbon clusters, the storage_class_config is not been displayed. [\#417] (https://github.com/nutanix/terraform-provider-nutanix/issues/417)
27+
- Checksum is not considered while uploading image from local using nutanix_image resource. [\#469] (https://github.com/nutanix/terraform-provider-nutanix/issues/469)
28+
- Not able to update image_type of PC image [\#454] (https://github.com/nutanix/terraform-provider-nutanix/issues/454)
29+
- Image gets deleted from PC if nutanix_image update errors out [\#453] (https://github.com/nutanix/terraform-provider-nutanix/issues/453)
30+
31+
**Closed issues:**
32+
33+
- Support for User Groups [\#475] (https://github.com/nutanix/terraform-provider-nutanix/issues/475)
34+
- Resizing disk identified in plan, but not actually done during apply [\#463] (https://github.com/nutanix/terraform-provider-nutanix/issues/463)
35+
- uuid of address_groups are not available [\#461] (https://github.com/nutanix/terraform-provider-nutanix/issues/461)
36+
- ntx provider have ENTITY_READ_ERROR when try to recreate a VM deleted manually [\#451] (https://github.com/nutanix/terraform-provider-nutanix/issues/451)
37+
- Allow project definiation by name and not just ID [\#406] (https://github.com/nutanix/terraform-provider-nutanix/issues/406)
38+
- Upload images to Foundation VM from a remote server using nutanix_foundation_image resource [\#455] (https://github.com/nutanix/terraform-provider-nutanix/issues/455)
39+
- Change catagories from list to dictionary for more straightforward use [\#407] (https://github.com/nutanix/terraform-provider-nutanix/issues/407)
40+
- VM creation fails when boot_type = LEGACY [\#304] (https://github.com/nutanix/terraform-provider-nutanix/issues/304)
41+
- Add attributes to set timezone during cluster creation using image_nodes [\#449] (https://github.com/nutanix/terraform-provider-nutanix/issues/449)
42+
- Enable multi-pc tests [\#448] (https://github.com/nutanix/terraform-provider-nutanix/issues/448)
43+
44+
145
## 1.6.1 (July 7, 2022)
246

347
[Full Changelog](https://github.com/nutanix/terraform-provider-nutanix/compare/v1.5.0...v1.6.1)

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Terraform provider plugin to integrate with Nutanix Enterprise Cloud
44

5-
NOTE: The latest version of the Nutanix provider is [v1.6.1](https://github.com/nutanix/terraform-provider-nutanix/releases/tag/v1.6.1)
5+
NOTE: The latest version of the Nutanix provider is [v1.7.0](https://github.com/nutanix/terraform-provider-nutanix/releases/tag/v1.7.0)
66

77
Modules based on Terraform Nutanix Provider can be found here : [Modules](https://github.com/nutanix/terraform-provider-nutanix/tree/master/modules)
88
## Build, Quality Status
@@ -42,10 +42,14 @@ The Terraform Nutanix provider is designed to work with Nutanix Prism Central an
4242
4343
> For the 1.6.1 release of the provider it will have N-2 compatibility with the Prism Central APIs. This release was tested against Prism Central versions pc2022.4 pc2022.1.0.2 and pc2021.9.0.4.
4444
45+
> For the 1.7.0 release of the provider it will have N-2 compatibility with the Prism Central APIs. This release was tested against Prism Central versions pc2022.6, pc2022.4 and pc2022.1.0.2.
46+
4547
### note
4648
With v1.6.1 release of flow networking feature in provider, IAMv2 setups would be mandate.
4749
Also, there is known issue for access_control_policies resource where update would be failing. We are continuously tracking the issue internally.
4850

51+
with v1.7.0 release of user groups feature in provider, pc version should be minimum 2022.1 to support organisational and saml user group.
52+
4953
## Foundation
5054
> For the 1.5.0-beta release of the provider it will have N-1 compatibility with the Foundation. This release was tested against Foundation versions v5.2 and v5.1.1
5155
@@ -152,6 +156,7 @@ From foundation getting released in 1.5.0-beta, provider configuration will acco
152156
* nutanix_pbr
153157
* nutanix_static_routes
154158
* nutanix_floating_ip
159+
* nutanix_user_groups
155160

156161
## Data Sources
157162

client/foundation/foundation_structs.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ type Clusters struct {
8282
CvmDNSServers string `json:"cvm_dns_servers,omitempty"`
8383
ClusterInitNow *bool `json:"cluster_init_now"`
8484
HypervisorNtpServers string `json:"hypervisor_ntp_servers,omitempty"`
85+
Timezone string `json:"timezone,omitempty"`
8586
}
8687

8788
// EOS metadata struct used in node imaging when importing cluster config got from install.nutanix.com

client/v3/v3_service.go

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ type Service interface {
3333
GetImage(uuid string) (*ImageIntentResponse, error)
3434
ListImage(getEntitiesRequest *DSMetadata) (*ImageListIntentResponse, error)
3535
UpdateImage(uuid string, body *ImageIntentInput) (*ImageIntentResponse, error)
36-
UploadImage(uuid, filepath string) error
36+
UploadImage(uuid string, filepath string, checksum *Checksum) error
3737
CreateOrUpdateCategoryKey(body *CategoryKey) (*CategoryKeyStatus, error)
3838
ListCategories(getEntitiesRequest *CategoryListMetadata) (*CategoryKeyListResponse, error)
3939
DeleteCategoryKey(name string) error
@@ -89,9 +89,12 @@ type Service interface {
8989
DeleteUser(uuid string) (*DeleteResponse, error)
9090
ListUser(getEntitiesRequest *DSMetadata) (*UserListResponse, error)
9191
ListAllUser(filter string) (*UserListResponse, error)
92+
CreateUserGroup(ctx context.Context, body *UserGroupIntentInput) (*UserGroupIntentResponse, error)
9293
GetUserGroup(userUUID string) (*UserGroupIntentResponse, error)
9394
ListUserGroup(getEntitiesRequest *DSMetadata) (*UserGroupListResponse, error)
9495
ListAllUserGroup(filter string) (*UserGroupListResponse, error)
96+
UpdateUserGroup(ctx context.Context, uuid string, body *UserGroupIntentInput) (*UserGroupIntentResponse, error)
97+
DeleteUserGroup(ctx context.Context, uuid string) (*DeleteResponse, error)
9598
GetPermission(permissionUUID string) (*PermissionIntentResponse, error)
9699
ListPermission(getEntitiesRequest *DSMetadata) (*PermissionListResponse, error)
97100
ListAllPermission(filter string) (*PermissionListResponse, error)
@@ -375,7 +378,7 @@ func (op Operations) CreateImage(body *ImageIntentInput) (*ImageIntentResponse,
375378
*
376379
* @param uuid @param filepath
377380
*/
378-
func (op Operations) UploadImage(uuid, filepath string) error {
381+
func (op Operations) UploadImage(uuid, filepath string, checksum *Checksum) error {
379382
ctx := context.Background()
380383

381384
path := fmt.Sprintf("/images/%s/file", uuid)
@@ -392,6 +395,11 @@ func (op Operations) UploadImage(uuid, filepath string) error {
392395
return fmt.Errorf("error: Creating request %s", err)
393396
}
394397

398+
if checksum != nil && *checksum != (Checksum{}) {
399+
req.Header.Add("X-Nutanix-Checksum-Type", *checksum.ChecksumAlgorithm)
400+
req.Header.Add("X-Nutanix-Checksum-Bytes", *checksum.ChecksumValue)
401+
}
402+
395403
err = op.client.Do(ctx, req, nil)
396404

397405
return err
@@ -1857,6 +1865,17 @@ func (op Operations) GetUserGroup(userGroupUUID string) (*UserGroupIntentRespons
18571865
return User, op.client.Do(ctx, req, User)
18581866
}
18591867

1868+
func (op Operations) CreateUserGroup(ctx context.Context, body *UserGroupIntentInput) (*UserGroupIntentResponse, error) {
1869+
req, err := op.client.NewRequest(ctx, http.MethodPost, "/user_groups", body)
1870+
userGroupResponse := new(UserGroupIntentResponse)
1871+
1872+
if err != nil {
1873+
return nil, err
1874+
}
1875+
1876+
return userGroupResponse, op.client.Do(ctx, req, userGroupResponse)
1877+
}
1878+
18601879
/*ListUserGroup gets a list of UserGroups.
18611880
*
18621881
* @param metadata allows create filters to get specific data - *DSMetadata.
@@ -1876,6 +1895,31 @@ func (op Operations) ListUserGroup(getEntitiesRequest *DSMetadata) (*UserGroupLi
18761895
return UserGroupList, op.client.Do(ctx, req, UserGroupList)
18771896
}
18781897

1898+
func (op Operations) UpdateUserGroup(ctx context.Context, uuid string, body *UserGroupIntentInput) (*UserGroupIntentResponse, error) {
1899+
path := fmt.Sprintf("/user_groups/%s", uuid)
1900+
req, err := op.client.NewRequest(ctx, http.MethodPut, path, body)
1901+
userGroupResponse := new(UserGroupIntentResponse)
1902+
1903+
if err != nil {
1904+
return nil, err
1905+
}
1906+
1907+
return userGroupResponse, op.client.Do(ctx, req, userGroupResponse)
1908+
}
1909+
1910+
func (op Operations) DeleteUserGroup(ctx context.Context, uuid string) (*DeleteResponse, error) {
1911+
path := fmt.Sprintf("/user_groups/%s", uuid)
1912+
1913+
req, err := op.client.NewRequest(ctx, http.MethodDelete, path, nil)
1914+
deleteResponse := new(DeleteResponse)
1915+
1916+
if err != nil {
1917+
return nil, err
1918+
}
1919+
1920+
return deleteResponse, op.client.Do(ctx, req, deleteResponse)
1921+
}
1922+
18791923
// ListAllUserGroup ...
18801924
func (op Operations) ListAllUserGroup(filter string) (*UserGroupListResponse, error) {
18811925
entities := make([]*UserGroupIntentResponse, 0)

client/v3/v3_service_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -987,7 +987,7 @@ func TestOperations_UploadImageError(t *testing.T) {
987987
op := Operations{
988988
client: tt.fields.client,
989989
}
990-
if err := op.UploadImage(tt.args.UUID, tt.args.filepath); (err != nil) != tt.wantErr {
990+
if err := op.UploadImage(tt.args.UUID, tt.args.filepath, nil); (err != nil) != tt.wantErr {
991991
t.Errorf("Operations.UploadImage() error = %v, wantErr %v", err, tt.wantErr)
992992
}
993993
})
@@ -1037,7 +1037,7 @@ func TestOperations_UploadImage(t *testing.T) {
10371037
op := Operations{
10381038
client: tt.fields.client,
10391039
}
1040-
if err := op.UploadImage(tt.args.UUID, tt.args.filepath); err != nil {
1040+
if err := op.UploadImage(tt.args.UUID, tt.args.filepath, nil); err != nil {
10411041
t.Errorf("Operations.UploadImage() error = %v", err)
10421042
}
10431043
})

client/v3/v3_structs.go

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1681,7 +1681,6 @@ type Metadata struct {
16811681
//CategoriesMapping map[string][]string `json:"categories_mapping,omitempty" mapstructure:"categories_mapping,omitempty"`
16821682
//EntityVersion *string `json:"entity_version,omitempty" mapstructure:"entity_version,omitempty"`
16831683
//UseCategoriesMapping *bool `json:"use_categories_mapping,omitempty" mapstructure:"use_categories_mapping,omitempty"`
1684-
16851684
}
16861685

16871686
// NetworkSecurityRuleIntentInput An intentful representation of a network_security_rule
@@ -2255,20 +2254,33 @@ type UserGroupSpec struct {
22552254
Resources *UserGroupResources `json:"resources,omitempty"` // User Group Resource Definition
22562255
}
22572256

2257+
type SamlUserGroup struct {
2258+
IdpUUID *string `json:"idpUuid,omitempty"`
2259+
Name *string `json:"name,omitempty"`
2260+
}
2261+
22582262
// User Group Resource Definition
22592263
type UserGroupResources struct {
22602264
AccessControlPolicyReferenceList []*Reference `json:"access_control_policy_reference_list,omitempty"` // List of ACP references.
22612265
DirectoryServiceUserGroup *DirectoryServiceUserGroup `json:"directory_service_user_group,omitempty"` // A Directory Service user group.
22622266
DisplayName *string `json:"display_name,omitempty"` // The display name for the user group.
22632267
ProjectsReferenceList []*Reference `json:"projects_reference_list,omitempty"` // A list of projects the user group is part of.
22642268
UserGroupType *string `json:"user_group_type,omitempty"`
2269+
DirectoryServiceOU *DirectoryServiceUserGroup `json:"directory_service_ou,omitempty"`
2270+
SamlUserGroup *SamlUserGroup `json:"saml_user_group,omitempty"`
22652271
}
22662272

22672273
// User group status definition.
22682274
type UserGroupStatus struct {
2269-
MessageList []MessageResource `json:"message_list,omitempty"`
2270-
Resources *UserGroupResources `json:"resources,omitempty"` // User Group Resource Definition.
2271-
State *string `json:"state,omitempty"` // The state of the entity.
2275+
MessageList []MessageResource `json:"message_list,omitempty"`
2276+
Resources *UserGroupResources `json:"resources,omitempty"` // User Group Resource Definition.
2277+
State *string `json:"state,omitempty"` // The state of the entity.
2278+
ExecutionContext *ExecutionContext `json:"execution_context,omitempty"`
2279+
}
2280+
2281+
type UserGroupIntentInput struct {
2282+
Metadata *Metadata `json:"metadata,omitempty"`
2283+
Spec *UserGroupSpec `json:"spec,omitempty"`
22722284
}
22732285

22742286
// A Directory Service user group.
@@ -2601,6 +2613,7 @@ type AddressGroupResponse struct {
26012613
}
26022614

26032615
type AddressGroupListEntry struct {
2616+
UUID *string `json:"uuid,omitempty"`
26042617
AddressGroup *AddressGroupInput `json:"address_group,omitempty"`
26052618
AssociatedPoliciesList []*ReferenceValues `json:"associated_policies_list,omitempty"`
26062619
}

examples/user_groups/main.tf

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
terraform{
2+
required_providers {
3+
nutanix = {
4+
source = "nutanix/nutanix"
5+
version = "1.7.0"
6+
}
7+
}
8+
}
9+
10+
#definig nutanix configuration
11+
provider "nutanix"{
12+
username = var.nutanix_username
13+
password = var.nutanix_password
14+
endpoint = var.nutanix_endpoint
15+
port = 9440
16+
insecure = true
17+
}
18+
19+
# Add a User group to the system.
20+
21+
# Add Directory Service user group.
22+
resource "nutanix_user_groups" "t1" {
23+
directory_service_user_group{
24+
distinguished_name = "<distinguished name of the user group>"
25+
}
26+
}
27+
28+
# Add Directory Service organizational unit.
29+
resource "nutanix_user_groups" "t1" {
30+
directory_service_ou{
31+
distinguished_name = "<distinguished name of the organizational group>"
32+
}
33+
}
34+
35+
# Add SAML Service user group.
36+
resource "nutanix_user_groups" "t1" {
37+
saml_user_group{
38+
name = "<group name>"
39+
idp_uuid = "<idp uuid of user group>"
40+
}
41+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#define values to the variables to be used in terraform file
2+
nutanix_username = "admin"
3+
nutanix_password = "password"
4+
nutanix_endpoint = "10.xx.xx.xx"
5+
nutanix_port = 9440

examples/user_groups/variables.tf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#define the type of variables to be used in terraform file
2+
variable "nutanix_username" {
3+
type = string
4+
}
5+
variable "nutanix_password" {
6+
type = string
7+
}
8+
variable "nutanix_endpoint" {
9+
type = string
10+
}
11+
variable "nutanix_port" {
12+
type = string
13+
}

nutanix/data_source_nutanix_address_groups.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,31 +58,35 @@ func dataSourceNutanixAddressGroups() *schema.Resource {
5858
Computed: true,
5959
Elem: &schema.Resource{
6060
Schema: map[string]*schema.Schema{
61+
"uuid": {
62+
Type: schema.TypeString,
63+
Computed: true,
64+
},
6165
"address_group": {
6266
Type: schema.TypeList,
6367
Computed: true,
6468
Elem: &schema.Resource{
6569
Schema: map[string]*schema.Schema{
6670
"name": {
6771
Type: schema.TypeString,
68-
Required: true,
72+
Computed: true,
6973
},
7074
"description": {
7175
Type: schema.TypeString,
72-
Optional: true,
76+
Computed: true,
7377
},
7478
"ip_address_block_list": {
7579
Type: schema.TypeList,
76-
Required: true,
80+
Computed: true,
7781
Elem: &schema.Resource{
7882
Schema: map[string]*schema.Schema{
7983
"ip": {
8084
Type: schema.TypeString,
81-
Required: true,
85+
Computed: true,
8286
},
8387
"prefix_length": {
8488
Type: schema.TypeInt,
85-
Required: true,
89+
Computed: true,
8690
},
8791
},
8892
},
@@ -158,6 +162,7 @@ func flattenAddressGroup(entries []*v3.AddressGroupListEntry) interface{} {
158162
},
159163
},
160164
"associated_policies_list": flattenReferenceList(entry.AssociatedPoliciesList),
165+
"uuid": entry.UUID,
161166
}
162167
}
163168
return entities

0 commit comments

Comments
 (0)