-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UplinkHostSwitchProfile support (#939)
Signed-off-by: graysonwu <[email protected]>
- Loading branch information
Showing
8 changed files
with
1,022 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* Copyright © 2023 VMware, Inc. All Rights Reserved. | ||
SPDX-License-Identifier: MPL-2.0 */ | ||
|
||
package nsxt | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
"github.com/vmware/vsphere-automation-sdk-go/services/nsxt/infra" | ||
) | ||
|
||
func dataSourceNsxtUplinkHostSwitchProfile() *schema.Resource { | ||
return &schema.Resource{ | ||
Read: dataSourceNsxtUplinkHostSwitchProfileRead, | ||
|
||
Schema: map[string]*schema.Schema{ | ||
"id": getDataSourceIDSchema(), | ||
"gateway_path": getPolicyPathSchema(false, false, "Gateway path"), | ||
"path": getPathSchema(), | ||
"display_name": getDisplayNameSchema(), | ||
"description": getDescriptionSchema(), | ||
}, | ||
} | ||
} | ||
|
||
func dataSourceNsxtUplinkHostSwitchProfileRead(d *schema.ResourceData, m interface{}) error { | ||
connector := getPolicyConnector(m) | ||
|
||
gwPath := d.Get("gateway_path").(string) | ||
query := make(map[string]string) | ||
if len(gwPath) > 0 { | ||
query["parent_path"] = fmt.Sprintf("%s*", gwPath) | ||
} | ||
|
||
_, err := policyDataSourceResourceReadWithValidation(d, connector, getSessionContext(d, m), infra.HostSwitchProfiles_LIST_HOSTSWITCH_PROFILE_TYPE_POLICYUPLINKHOSTSWITCHPROFILE, query, false) | ||
if err == nil { | ||
return nil | ||
} | ||
|
||
return fmt.Errorf("UplinkHostSwitchProfile with name '%s' was not found", d.Get("display_name").(string)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.