-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #497 from HewlettPackard/portname_relative_value
Portname relative value
- Loading branch information
Showing
5 changed files
with
158 additions
and
42 deletions.
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
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,35 @@ | ||
--- | ||
layout: "oneview" | ||
page_title: "Oneview: Uplink port relative value" | ||
sidebar_current: "docs-relative_value" | ||
description: |- | ||
Gets relative value of a given port name | ||
--- | ||
|
||
# oneview\_relative value | ||
|
||
Use this data source to get the relative value for a given port name | ||
|
||
## Example Usage | ||
|
||
```hcl | ||
data "oneview_relative_value" "rv"{ | ||
port_name="Q2:1" | ||
interconnect_type_name="Virtual Connect SE 40Gb F8 Module for Synergy" | ||
} | ||
output "oneview_relative_value" { | ||
value = "${oneview_relative_value.rv.port_num}" | ||
} | ||
``` | ||
|
||
## Argument Reference | ||
|
||
* `port_name` - (Required) The name of the enclsoure. | ||
* `interconnect_type_name`- (Required)" The name of interconnect type | ||
|
||
## Attributes Reference | ||
|
||
* `port_name` - (Required) The name of the enclsoure. | ||
* `interconnect_type_name`- (Required)" The name of interconnect type | ||
* `port_num` - The relative value corresponding to the port name |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// (C) Copyright 2021 Hewlett Packard Enterprise Development LP | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// You may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software distributed | ||
// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR | ||
// CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations under the License. | ||
|
||
package oneview | ||
|
||
import ( | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
) | ||
|
||
func dataSourceRelativeValue() *schema.Resource { | ||
return &schema.Resource{ | ||
Read: dataSourceRelativeValueRead, | ||
|
||
Schema: map[string]*schema.Schema{ | ||
"port_name": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
}, | ||
"interconnect_type_name": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
}, | ||
"port_num": { | ||
Type: schema.TypeInt, | ||
Computed: true, | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
func dataSourceRelativeValueRead(d *schema.ResourceData, meta interface{}) error { | ||
config := meta.(*Config) | ||
|
||
portName := d.Get("port_name").(string) | ||
interconnectTypeName := d.Get("interconnect_type_name").(string) | ||
interconnectType, _ := config.ovClient.GetInterconnectTypeByName(interconnectTypeName) | ||
portNum, err := config.ovClient.GetRelativeValue(portName, interconnectType.URI) | ||
|
||
if err != nil { | ||
d.SetId("") | ||
return err | ||
} | ||
|
||
d.SetId(portName) | ||
|
||
d.Set("port_name", portName) | ||
d.Set("port_num", portNum) | ||
d.Set("interrconnect_type", interconnectType) | ||
|
||
return nil | ||
} |
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