Skip to content

Commit 8636b98

Browse files
kayrusjtopjian
authored andcommitted
Networking V2: add description to the network data source (terraform-provider-openstack#536)
1 parent 838a6fc commit 8636b98

3 files changed

Lines changed: 17 additions & 4 deletions

File tree

‎openstack/data_source_openstack_networking_network_v2.go‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ func dataSourceNetworkingNetworkV2() *schema.Resource {
3232
Type: schema.TypeString,
3333
Optional: true,
3434
},
35+
"description": &schema.Schema{
36+
Type: schema.TypeString,
37+
Optional: true,
38+
},
3539
"status": &schema.Schema{
3640
Type: schema.TypeString,
3741
Optional: true,
@@ -78,10 +82,11 @@ func dataSourceNetworkingNetworkV2Read(d *schema.ResourceData, meta interface{})
7882
}
7983

8084
listOpts = networks.ListOpts{
81-
ID: d.Get("network_id").(string),
82-
Name: d.Get("name").(string),
83-
TenantID: d.Get("tenant_id").(string),
84-
Status: status,
85+
ID: d.Get("network_id").(string),
86+
Name: d.Get("name").(string),
87+
Description: d.Get("description").(string),
88+
TenantID: d.Get("tenant_id").(string),
89+
Status: status,
8590
}
8691

8792
if v, ok := d.GetOkExists("external"); ok {
@@ -159,6 +164,7 @@ func dataSourceNetworkingNetworkV2Read(d *schema.ResourceData, meta interface{})
159164
d.SetId(network.ID)
160165

161166
d.Set("name", network.Name)
167+
d.Set("description", network.Description)
162168
d.Set("admin_state_up", strconv.FormatBool(network.AdminStateUp))
163169
d.Set("shared", strconv.FormatBool(network.Shared))
164170
d.Set("external", network.External)

‎openstack/data_source_openstack_networking_network_v2_test.go‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ func TestAccOpenStackNetworkingNetworkV2DataSource_basic(t *testing.T) {
2222
testAccCheckNetworkingNetworkV2DataSourceID("data.openstack_networking_network_v2.net"),
2323
resource.TestCheckResourceAttr(
2424
"data.openstack_networking_network_v2.net", "name", "tf_test_network"),
25+
resource.TestCheckResourceAttr(
26+
"data.openstack_networking_network_v2.net", "description", "my network description"),
2527
resource.TestCheckResourceAttr(
2628
"data.openstack_networking_network_v2.net", "admin_state_up", "true"),
2729
),
@@ -138,6 +140,7 @@ func testAccCheckNetworkingNetworkV2DataSourceID(n string) resource.TestCheckFun
138140
const testAccOpenStackNetworkingNetworkV2DataSource_network = `
139141
resource "openstack_networking_network_v2" "net" {
140142
name = "tf_test_network"
143+
description = "my network description"
141144
admin_state_up = "true"
142145
}
143146
@@ -154,6 +157,7 @@ var testAccOpenStackNetworkingNetworkV2DataSource_basic = fmt.Sprintf(`
154157
155158
data "openstack_networking_network_v2" "net" {
156159
name = "${openstack_networking_network_v2.net.name}"
160+
description = "${openstack_networking_network_v2.net.description}"
157161
}
158162
`, testAccOpenStackNetworkingNetworkV2DataSource_network)
159163

‎website/docs/d/networking_network_v2.html.markdown‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ data "openstack_networking_network_v2" "network" {
2828

2929
* `name` - (Optional) The name of the network.
3030

31+
* `description` - (Optional) Human-readable description of the network.
32+
3133
* `status` - (Optional) The status of the network.
3234

3335
* `external` - (Optional) The external routing facility of the network.
@@ -46,6 +48,7 @@ are exported:
4648

4749
* `admin_state_up` - (Optional) The administrative state of the network.
4850
* `name` - See Argument Reference above.
51+
* `description` - See Argument Reference above.
4952
* `region` - See Argument Reference above.
5053
* `external` - See Argument Reference above.
5154
* `shared` - (Optional) Specifies whether the network resource can be accessed

0 commit comments

Comments
 (0)