From 04739efc86a35a035718f79786b975428ff32516 Mon Sep 17 00:00:00 2001 From: Kobi Samoray Date: Wed, 24 Jan 2024 11:50:28 +0200 Subject: [PATCH] Upgrade NSX Golang SDK To have NSX v4.1.2 functionality Signed-off-by: Kobi Samoray --- api/infra/ip_address_block.go | 6 +++--- api/infra/ip_pools/ip_subnets_client.go | 6 +++--- api/infra/segments/segment_configuration_state.go | 8 ++++---- go.mod | 6 +++--- go.sum | 12 ++++++------ nsxt/data_source_nsxt_policy_ip_block.go | 2 +- nsxt/data_source_nsxt_policy_project.go | 2 +- nsxt/data_source_nsxt_policy_project_test.go | 2 +- nsxt/data_source_nsxt_policy_segment_realization.go | 2 +- nsxt/resource_nsxt_policy_ip_block.go | 4 ++-- nsxt/resource_nsxt_policy_ip_block_test.go | 4 ++-- nsxt/resource_nsxt_policy_ip_pool_block_subnet.go | 2 +- nsxt/resource_nsxt_policy_ip_pool_static_subnet.go | 2 +- nsxt/resource_nsxt_policy_project.go | 6 +++--- 14 files changed, 32 insertions(+), 32 deletions(-) diff --git a/api/infra/ip_address_block.go b/api/infra/ip_address_block.go index dcc8389ef..b71657282 100644 --- a/api/infra/ip_address_block.go +++ b/api/infra/ip_address_block.go @@ -32,7 +32,7 @@ func NewIpBlocksClient(sessionContext utl.SessionContext, connector vapiProtocol return &IpAddressBlockClientContext{Client: client, ClientType: sessionContext.ClientType, ProjectID: sessionContext.ProjectID} } -func (c IpAddressBlockClientContext) Get(ipBlockIdParam string) (model0.IpAddressBlock, error) { +func (c IpAddressBlockClientContext) Get(ipBlockIdParam string, ignoreIpblockUsageParam *bool) (model0.IpAddressBlock, error) { var obj model0.IpAddressBlock var err error @@ -40,14 +40,14 @@ func (c IpAddressBlockClientContext) Get(ipBlockIdParam string) (model0.IpAddres case utl.Local: client := c.Client.(client0.IpBlocksClient) - obj, err = client.Get(ipBlockIdParam) + obj, err = client.Get(ipBlockIdParam, ignoreIpblockUsageParam) if err != nil { return obj, err } case utl.Multitenancy: client := c.Client.(client1.IpBlocksClient) - obj, err = client.Get(utl.DefaultOrgID, c.ProjectID, ipBlockIdParam) + obj, err = client.Get(utl.DefaultOrgID, c.ProjectID, ipBlockIdParam, ignoreIpblockUsageParam) if err != nil { return obj, err } diff --git a/api/infra/ip_pools/ip_subnets_client.go b/api/infra/ip_pools/ip_subnets_client.go index d17a6aead..ee7d1ee0e 100644 --- a/api/infra/ip_pools/ip_subnets_client.go +++ b/api/infra/ip_pools/ip_subnets_client.go @@ -59,18 +59,18 @@ func (c StructValueClientContext) Get(ipPoolIdParam string, ipSubnetIdParam stri return obj, err } -func (c StructValueClientContext) Delete(ipPoolIdParam string, ipSubnetIdParam string) error { +func (c StructValueClientContext) Delete(ipPoolIdParam string, ipSubnetIdParam string, ignoreIpAllocationsParam *bool) error { var err error switch c.ClientType { case utl.Local: client := c.Client.(client0.IpSubnetsClient) - err = client.Delete(ipPoolIdParam, ipSubnetIdParam) + err = client.Delete(ipPoolIdParam, ipSubnetIdParam, ignoreIpAllocationsParam) case utl.Multitenancy: client := c.Client.(client1.IpSubnetsClient) - err = client.Delete(utl.DefaultOrgID, c.ProjectID, ipPoolIdParam, ipSubnetIdParam) + err = client.Delete(utl.DefaultOrgID, c.ProjectID, ipPoolIdParam, ipSubnetIdParam, ignoreIpAllocationsParam) default: err = errors.New("invalid infrastructure for model") diff --git a/api/infra/segments/segment_configuration_state.go b/api/infra/segments/segment_configuration_state.go index db9d4a4c6..f98c8b2a5 100644 --- a/api/infra/segments/segment_configuration_state.go +++ b/api/infra/segments/segment_configuration_state.go @@ -37,7 +37,7 @@ func NewStateClient(sessionContext utl.SessionContext, connector vapiProtocolCli return &SegmentConfigurationStateClientContext{Client: client, ClientType: sessionContext.ClientType, ProjectID: sessionContext.ProjectID} } -func (c SegmentConfigurationStateClientContext) Get(segmentsIdParam string, cursorParam *string, edgePathParam *string, enforcementPointPathParam *string, includeMarkForDeleteObjectsParam *bool, includedFieldsParam *string, pageSizeParam *int64, sortAscendingParam *bool, sortByParam *string) (model0.SegmentConfigurationState, error) { +func (c SegmentConfigurationStateClientContext) Get(segmentsIdParam string, cursorParam *string, edgePathParam *string, enforcementPointPathParam *string, includeMarkForDeleteObjectsParam *bool, includedFieldsParam *string, pageSizeParam *int64, sortAscendingParam *bool, sortByParam *string, sourceParam *string, statsTypeParam *string, transportNodeIdParam *string) (model0.SegmentConfigurationState, error) { var obj model0.SegmentConfigurationState var err error @@ -45,14 +45,14 @@ func (c SegmentConfigurationStateClientContext) Get(segmentsIdParam string, curs case utl.Local: client := c.Client.(client0.StateClient) - obj, err = client.Get(segmentsIdParam, cursorParam, edgePathParam, enforcementPointPathParam, includeMarkForDeleteObjectsParam, includedFieldsParam, pageSizeParam, sortAscendingParam, sortByParam) + obj, err = client.Get(segmentsIdParam, cursorParam, edgePathParam, enforcementPointPathParam, includeMarkForDeleteObjectsParam, includedFieldsParam, pageSizeParam, sortAscendingParam, sortByParam, sourceParam, statsTypeParam, transportNodeIdParam) if err != nil { return obj, err } case utl.Global: client := c.Client.(client1.StateClient) - gmObj, err1 := client.Get(segmentsIdParam, cursorParam, edgePathParam, enforcementPointPathParam, includeMarkForDeleteObjectsParam, includedFieldsParam, pageSizeParam, sortAscendingParam, sortByParam) + gmObj, err1 := client.Get(segmentsIdParam, cursorParam, edgePathParam, enforcementPointPathParam, includeMarkForDeleteObjectsParam, includedFieldsParam, pageSizeParam, sortAscendingParam, sortByParam, sourceParam, statsTypeParam, transportNodeIdParam) if err1 != nil { return obj, err1 } @@ -62,7 +62,7 @@ func (c SegmentConfigurationStateClientContext) Get(segmentsIdParam string, curs case utl.Multitenancy: client := c.Client.(client2.StateClient) - obj, err = client.Get(utl.DefaultOrgID, c.ProjectID, segmentsIdParam, cursorParam, edgePathParam, enforcementPointPathParam, includeMarkForDeleteObjectsParam, includedFieldsParam, pageSizeParam, sortAscendingParam, sortByParam) + obj, err = client.Get(utl.DefaultOrgID, c.ProjectID, segmentsIdParam, cursorParam, edgePathParam, enforcementPointPathParam, includeMarkForDeleteObjectsParam, includedFieldsParam, pageSizeParam, sortAscendingParam, sortByParam, sourceParam, statsTypeParam, transportNodeIdParam) if err != nil { return obj, err } diff --git a/go.mod b/go.mod index b026959c8..25148b9ab 100644 --- a/go.mod +++ b/go.mod @@ -9,9 +9,9 @@ require ( github.com/vmware/go-vmware-nsxt v0.0.0-20220328155605-f49a14c1ef5f github.com/vmware/vsphere-automation-sdk-go/lib v0.7.0 github.com/vmware/vsphere-automation-sdk-go/runtime v0.7.0 - github.com/vmware/vsphere-automation-sdk-go/services/nsxt v0.11.0 - github.com/vmware/vsphere-automation-sdk-go/services/nsxt-gm v0.8.0 - github.com/vmware/vsphere-automation-sdk-go/services/nsxt-mp v0.5.0 + github.com/vmware/vsphere-automation-sdk-go/services/nsxt v0.12.0 + github.com/vmware/vsphere-automation-sdk-go/services/nsxt-gm v0.9.0 + github.com/vmware/vsphere-automation-sdk-go/services/nsxt-mp v0.6.0 golang.org/x/exp v0.0.0-20230801115018-d63ba01acd4b ) diff --git a/go.sum b/go.sum index 1e8556c6a..ebc19b610 100644 --- a/go.sum +++ b/go.sum @@ -136,12 +136,12 @@ github.com/vmware/vsphere-automation-sdk-go/lib v0.7.0 h1:pT+oqJ8FD5eUBQkl+e7LZw github.com/vmware/vsphere-automation-sdk-go/lib v0.7.0/go.mod h1:f3+6YVZpNcK2pYyiQ94BoHWmjMj9BnYav0vNFuTiDVM= github.com/vmware/vsphere-automation-sdk-go/runtime v0.7.0 h1:pSBxa9Agh6bgW8Hr0A1eQxuwnxGTnuAVox8iQb023hg= github.com/vmware/vsphere-automation-sdk-go/runtime v0.7.0/go.mod h1:qdzEFm2iK3dvlmm99EYYNxs70HbzuiHyENFD24Ps8fQ= -github.com/vmware/vsphere-automation-sdk-go/services/nsxt v0.11.0 h1:JLHgS3ffV52HXc9hXFDiFOqSwKv39hKiJIcEsGJ5S60= -github.com/vmware/vsphere-automation-sdk-go/services/nsxt v0.11.0/go.mod h1:upLH9b9zpG86P0wwO4+gREf0lBXr8gYcs7P1FRZ9n30= -github.com/vmware/vsphere-automation-sdk-go/services/nsxt-gm v0.8.0 h1:jA01sHGXq1CLewDTN1EuowpaIrNIOm3yVYcbVAVBXGE= -github.com/vmware/vsphere-automation-sdk-go/services/nsxt-gm v0.8.0/go.mod h1:gcEvyczWPFMZX2gkBiBVpOwvUGSNXSpxU19Sx9aiouY= -github.com/vmware/vsphere-automation-sdk-go/services/nsxt-mp v0.5.0 h1:+b0V9ePiSnyHiqXNlgxfdmS0MWX6JEAzSPOWARUTOzQ= -github.com/vmware/vsphere-automation-sdk-go/services/nsxt-mp v0.5.0/go.mod h1:ugk9I4YM62SSAox57l5NAVBCRIkPQ1RNLb3URxyTADc= +github.com/vmware/vsphere-automation-sdk-go/services/nsxt v0.12.0 h1:+kcDO69bfIB87KZUAYQ4AqrXlnZhpZz+QwzIB+TseqU= +github.com/vmware/vsphere-automation-sdk-go/services/nsxt v0.12.0/go.mod h1:upLH9b9zpG86P0wwO4+gREf0lBXr8gYcs7P1FRZ9n30= +github.com/vmware/vsphere-automation-sdk-go/services/nsxt-gm v0.9.0 h1:vaWjTOvt9vPKZjA8ojTRC1o92Rm9ScR/GwWEd6JLMOk= +github.com/vmware/vsphere-automation-sdk-go/services/nsxt-gm v0.9.0/go.mod h1:gcEvyczWPFMZX2gkBiBVpOwvUGSNXSpxU19Sx9aiouY= +github.com/vmware/vsphere-automation-sdk-go/services/nsxt-mp v0.6.0 h1:+jS0YH9dEp8rC00SsaY5feFpVgp4Lu0YBnBe3T7zfqo= +github.com/vmware/vsphere-automation-sdk-go/services/nsxt-mp v0.6.0/go.mod h1:ugk9I4YM62SSAox57l5NAVBCRIkPQ1RNLb3URxyTADc= github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/zclconf/go-cty v1.14.0 h1:/Xrd39K7DXbHzlisFP9c4pHao4yyf+/Ug9LEz+Y/yhc= diff --git a/nsxt/data_source_nsxt_policy_ip_block.go b/nsxt/data_source_nsxt_policy_ip_block.go index a25d83185..62af64b64 100644 --- a/nsxt/data_source_nsxt_policy_ip_block.go +++ b/nsxt/data_source_nsxt_policy_ip_block.go @@ -36,7 +36,7 @@ func dataSourceNsxtPolicyIPBlockRead(d *schema.ResourceData, m interface{}) erro var obj model.IpAddressBlock if objID != "" { // Get by id - objGet, err := client.Get(objID) + objGet, err := client.Get(objID, nil) if err != nil { return handleDataSourceReadError(d, "IpAddressBlock", objID, err) } diff --git a/nsxt/data_source_nsxt_policy_project.go b/nsxt/data_source_nsxt_policy_project.go index 2bc4a76d1..90c1e3ead 100644 --- a/nsxt/data_source_nsxt_policy_project.go +++ b/nsxt/data_source_nsxt_policy_project.go @@ -70,7 +70,7 @@ func dataSourceNsxtPolicyProjectRead(d *schema.ResourceData, m interface{}) erro var obj model.Project if objID != "" { // Get by id - objGet, err := client.Get(defaultOrgID, objID) + objGet, err := client.Get(defaultOrgID, objID, nil) if err != nil { return handleDataSourceReadError(d, "Project", objID, err) } diff --git a/nsxt/data_source_nsxt_policy_project_test.go b/nsxt/data_source_nsxt_policy_project_test.go index 7de54055e..9e34cf14b 100644 --- a/nsxt/data_source_nsxt_policy_project_test.go +++ b/nsxt/data_source_nsxt_policy_project_test.go @@ -87,7 +87,7 @@ func testAccDataSourceNsxtPolicyProjectDeleteByName(name string) error { } for _, objInList := range objList.Results { if *objInList.DisplayName == name { - err := client.Delete(defaultOrgID, *objInList.Id) + err := client.Delete(defaultOrgID, *objInList.Id, nil) if err != nil { return handleDeleteError("Project", *objInList.Id, err) } diff --git a/nsxt/data_source_nsxt_policy_segment_realization.go b/nsxt/data_source_nsxt_policy_segment_realization.go index 6f9aafb3c..0e7dde479 100644 --- a/nsxt/data_source_nsxt_policy_segment_realization.go +++ b/nsxt/data_source_nsxt_policy_segment_realization.go @@ -77,7 +77,7 @@ func dataSourceNsxtPolicySegmentRealizationRead(d *schema.ResourceData, m interf Pending: pendingStates, Target: targetStates, Refresh: func() (interface{}, string, error) { - state, err := client.Get(segmentID, nil, nil, &enforcementPointPath, nil, nil, nil, nil, nil) + state, err := client.Get(segmentID, nil, nil, &enforcementPointPath, nil, nil, nil, nil, nil, nil, nil, nil) if err != nil { return state, model.SegmentConfigurationState_STATE_ERROR, logAPIError("Error while waiting for realization of segment", err) } diff --git a/nsxt/resource_nsxt_policy_ip_block.go b/nsxt/resource_nsxt_policy_ip_block.go index 716b3db0b..7f0ff0fb6 100644 --- a/nsxt/resource_nsxt_policy_ip_block.go +++ b/nsxt/resource_nsxt_policy_ip_block.go @@ -46,7 +46,7 @@ func resourceNsxtPolicyIPBlock() *schema.Resource { func resourceNsxtPolicyIPBlockExists(sessionContext utl.SessionContext, id string, connector client.Connector) (bool, error) { client := infra.NewIpBlocksClient(sessionContext, connector) - _, err := client.Get(id) + _, err := client.Get(id, nil) if err == nil { return true, nil } @@ -67,7 +67,7 @@ func resourceNsxtPolicyIPBlockRead(d *schema.ResourceData, m interface{}) error return fmt.Errorf("Error obtaining IP Block ID") } - block, err := client.Get(id) + block, err := client.Get(id, nil) if err != nil { return handleReadError(d, "IP Block", id, err) } diff --git a/nsxt/resource_nsxt_policy_ip_block_test.go b/nsxt/resource_nsxt_policy_ip_block_test.go index 6e776bb92..298463c54 100644 --- a/nsxt/resource_nsxt_policy_ip_block_test.go +++ b/nsxt/resource_nsxt_policy_ip_block_test.go @@ -158,7 +158,7 @@ func testAccNSXPolicyIPBlockCheckExists(resourceName string) resource.TestCheckF return fmt.Errorf("NSX Policy IP Block resource ID not set in resources ") } - _, err := client.Get(resourceID) + _, err := client.Get(resourceID, nil) if err != nil { return fmt.Errorf("Error while retrieving policy IP Block ID %s. Error: %v", resourceID, err) } @@ -177,7 +177,7 @@ func testAccNSXPolicyIPBlockCheckDestroy(state *terraform.State) error { } resourceID := rs.Primary.Attributes["id"] - _, err := client.Get(resourceID) + _, err := client.Get(resourceID, nil) if err == nil { return fmt.Errorf("Policy IP Block %s still exists", resourceID) } diff --git a/nsxt/resource_nsxt_policy_ip_pool_block_subnet.go b/nsxt/resource_nsxt_policy_ip_pool_block_subnet.go index 82250c1ea..6a38b0762 100644 --- a/nsxt/resource_nsxt_policy_ip_pool_block_subnet.go +++ b/nsxt/resource_nsxt_policy_ip_pool_block_subnet.go @@ -209,7 +209,7 @@ func resourceNsxtPolicyIPPoolBlockSubnetDelete(d *schema.ResourceData, m interfa } log.Printf("[INFO] Deleting Block Subnet with ID %s", id) - err := client.Delete(poolID, id) + err := client.Delete(poolID, id, nil) if err != nil { return handleDeleteError("Block Subnet", id, err) } diff --git a/nsxt/resource_nsxt_policy_ip_pool_static_subnet.go b/nsxt/resource_nsxt_policy_ip_pool_static_subnet.go index 516f2b1d1..60b57cbf8 100644 --- a/nsxt/resource_nsxt_policy_ip_pool_static_subnet.go +++ b/nsxt/resource_nsxt_policy_ip_pool_static_subnet.go @@ -247,7 +247,7 @@ func resourceNsxtPolicyIPPoolStaticSubnetDelete(d *schema.ResourceData, m interf } log.Printf("[INFO] Deleting Static Subnet with ID %s", id) - err := client.Delete(poolID, id) + err := client.Delete(poolID, id, nil) if err != nil { return handleDeleteError("Static Subnet", id, err) } diff --git a/nsxt/resource_nsxt_policy_project.go b/nsxt/resource_nsxt_policy_project.go index cc9903979..9933ce5f7 100644 --- a/nsxt/resource_nsxt_policy_project.go +++ b/nsxt/resource_nsxt_policy_project.go @@ -62,7 +62,7 @@ func resourceNsxtPolicyProject() *schema.Resource { func resourceNsxtPolicyProjectExists(id string, connector client.Connector, isGlobalManager bool) (bool, error) { var err error client := infra.NewProjectsClient(connector) - _, err = client.Get(defaultOrgID, id) + _, err = client.Get(defaultOrgID, id, nil) if err == nil { return true, nil @@ -146,7 +146,7 @@ func resourceNsxtPolicyProjectRead(d *schema.ResourceData, m interface{}) error var obj model.Project client := infra.NewProjectsClient(connector) var err error - obj, err = client.Get(defaultOrgID, id) + obj, err = client.Get(defaultOrgID, id, nil) if err != nil { return handleReadError(d, "Project", id, err) } @@ -197,7 +197,7 @@ func resourceNsxtPolicyProjectDelete(d *schema.ResourceData, m interface{}) erro connector := getPolicyConnector(m) var err error client := infra.NewProjectsClient(connector) - err = client.Delete(defaultOrgID, id) + err = client.Delete(defaultOrgID, id, nil) if err != nil { return handleDeleteError("Project", id, err)