Skip to content

Commit ccf683b

Browse files
author
Sander van Harmelen
committed
Add support for network domains
Fixes hashicorp#3248
1 parent 6bd40a7 commit ccf683b

2 files changed

Lines changed: 25 additions & 1 deletion

File tree

‎builtin/providers/cloudstack/resource_cloudstack_vpc.go‎

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ func resourceCloudStackVPC() *schema.Resource {
4040
ForceNew: true,
4141
},
4242

43+
"network_domain": &schema.Schema{
44+
Type: schema.TypeString,
45+
Optional: true,
46+
ForceNew: true,
47+
},
48+
4349
"project": &schema.Schema{
4450
Type: schema.TypeString,
4551
Optional: true,
@@ -79,7 +85,19 @@ func resourceCloudStackVPCCreate(d *schema.ResourceData, meta interface{}) error
7985
}
8086

8187
// Create a new parameter struct
82-
p := cs.VPC.NewCreateVPCParams(d.Get("cidr").(string), displaytext.(string), name, vpcofferingid, zoneid)
88+
p := cs.VPC.NewCreateVPCParams(
89+
d.Get("cidr").(string),
90+
displaytext.(string),
91+
name,
92+
vpcofferingid,
93+
zoneid,
94+
)
95+
96+
// If there is a network domain supplied, make sure to add it to the request
97+
if networkDomain, ok := d.GetOk("network_domain"); ok {
98+
// Set the network domain
99+
p.SetNetworkdomain(networkDomain.(string))
100+
}
83101

84102
// If there is a project supplied, we retrieve and set the project id
85103
if project, ok := d.GetOk("project"); ok {
@@ -122,6 +140,7 @@ func resourceCloudStackVPCRead(d *schema.ResourceData, meta interface{}) error {
122140
d.Set("name", v.Name)
123141
d.Set("display_text", v.Displaytext)
124142
d.Set("cidr", v.Cidr)
143+
d.Set("network_domain", v.Networkdomain)
125144

126145
// Get the VPC offering details
127146
o, _, err := cs.VPC.GetVPCOfferingByID(v.Vpcofferingid)

‎builtin/providers/cloudstack/resource_cloudstack_vpc_test.go‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ func testAccCheckCloudStackVPCAttributes(
7676
return fmt.Errorf("Bad VPC CIDR: %s", vpc.Cidr)
7777
}
7878

79+
if vpc.Networkdomain != "terraform-domain" {
80+
return fmt.Errorf("Bad network domain: %s", vpc.Networkdomain)
81+
}
82+
7983
return nil
8084
}
8185
}
@@ -107,6 +111,7 @@ resource "cloudstack_vpc" "foo" {
107111
display_text = "terraform-vpc-text"
108112
cidr = "%s"
109113
vpc_offering = "%s"
114+
network_domain = "terraform-domain"
110115
zone = "%s"
111116
}`,
112117
CLOUDSTACK_VPC_CIDR_1,

0 commit comments

Comments
 (0)