Skip to content

Commit 274e38b

Browse files
committed
zone wizard resources
1 parent aabe35e commit 274e38b

6 files changed

+157
-34
lines changed

cloudstack/resource_cloudstack_physical_network.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func resourceCloudStackPhysicalNetwork() *schema.Resource {
4141
Type: schema.TypeString,
4242
Optional: true,
4343
},
44-
"domainid": {
44+
"domain_id": {
4545
Type: schema.TypeString,
4646
Optional: true,
4747
},
@@ -65,7 +65,7 @@ func resourceCloudStackPhysicalNetwork() *schema.Resource {
6565
Type: schema.TypeString,
6666
Optional: true,
6767
},
68-
"zoneid": {
68+
"zone_id": {
6969
Type: schema.TypeString,
7070
Required: true,
7171
},
@@ -76,11 +76,11 @@ func resourceCloudStackPhysicalNetwork() *schema.Resource {
7676
func resourceCloudStackPhysicalNetworkCreate(d *schema.ResourceData, meta interface{}) error {
7777
cs := meta.(*cloudstack.CloudStackClient)
7878

79-
p := cs.Network.NewCreatePhysicalNetworkParams(d.Get("name").(string), d.Get("zoneid").(string))
79+
p := cs.Network.NewCreatePhysicalNetworkParams(d.Get("name").(string), d.Get("zone_id").(string))
8080
if v, ok := d.GetOk("broadcast_domain_range"); ok {
8181
p.SetBroadcastdomainrange(strings.ToUpper(v.(string)))
8282
}
83-
if v, ok := d.GetOk("domainid"); ok {
83+
if v, ok := d.GetOk("domain_id"); ok {
8484
p.SetDomainid(v.(string))
8585
}
8686
if v, ok := d.GetOk("isolation_methods"); ok {
@@ -115,13 +115,13 @@ func resourceCloudStackPhysicalNetworkRead(d *schema.ResourceData, meta interfac
115115
}
116116

117117
d.Set("broadcast_domain_range", pn.Broadcastdomainrange)
118-
d.Set("domainid", pn.Domainid)
118+
d.Set("domain_id", pn.Domainid)
119119
d.Set("isolation_methods", pn.Isolationmethods)
120120
d.Set("name", pn.Name)
121121
d.Set("network_speed", pn.Networkspeed)
122122
d.Set("tags", pn.Tags)
123123
d.Set("vlan", pn.Vlan)
124-
d.Set("zoneid", pn.Zoneid)
124+
d.Set("zone_id", pn.Zoneid)
125125

126126
return nil
127127
}

cloudstack/resource_cloudstack_physical_network_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ resource "cloudstack_physical_network" "test" {
5656
name = "test01"
5757
network_speed = "1G"
5858
tags = "vlan"
59-
zoneid = cloudstack_zone.test.id
59+
zone_id = cloudstack_zone.test.id
6060
}
6161
`
6262

@@ -76,6 +76,6 @@ resource "cloudstack_physical_network" "test" {
7676
name = "test01"
7777
network_speed = "10G"
7878
tags = "vxlan"
79-
zoneid = cloudstack_zone.test.id
79+
zone_id = cloudstack_zone.test.id
8080
}
8181
`
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
//
2+
// Licensed to the Apache Software Foundation (ASF) under one
3+
// or more contributor license agreements. See the NOTICE file
4+
// distributed with this work for additional information
5+
// regarding copyright ownership. The ASF licenses this file
6+
// to you under the Apache License, Version 2.0 (the
7+
// "License"); you may not use this file except in compliance
8+
// with the License. You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing,
13+
// software distributed under the License is distributed on an
14+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
// KIND, either express or implied. See the License for the
16+
// specific language governing permissions and limitations
17+
// under the License.
18+
//
19+
20+
package cloudstack
21+
22+
import (
23+
"github.com/apache/cloudstack-go/v2/cloudstack"
24+
"github.com/hashicorp/terraform/helper/schema"
25+
)
26+
27+
func resourceCloudStackTrafficType() *schema.Resource {
28+
return &schema.Resource{
29+
Create: resourceCloudStackTrafficTypeCreate,
30+
Read: resourceCloudStackTrafficTypeRead,
31+
Update: resourceCloudStackTrafficTypeUpdate,
32+
Delete: resourceCloudStackTrafficTypeDelete,
33+
Importer: &schema.ResourceImporter{
34+
State: schema.ImportStatePassthrough,
35+
},
36+
Schema: map[string]*schema.Schema{
37+
"hyperv_network_label": {
38+
Type: schema.TypeString,
39+
Optional: true,
40+
Computed: true,
41+
},
42+
"isolation_method": {
43+
Type: schema.TypeString,
44+
Optional: true,
45+
Computed: true,
46+
},
47+
"kvm_network_label": {
48+
Type: schema.TypeString,
49+
Optional: true,
50+
Computed: true,
51+
},
52+
"ovm3_network_label": {
53+
Type: schema.TypeString,
54+
Optional: true,
55+
Computed: true,
56+
},
57+
"physical_network_id": {
58+
Type: schema.TypeString,
59+
Required: true,
60+
},
61+
"traffic_type": {
62+
Type: schema.TypeString,
63+
Required: true,
64+
},
65+
"vlan": {
66+
Type: schema.TypeString,
67+
Optional: true,
68+
Computed: true,
69+
},
70+
"vmware_network_label": {
71+
Type: schema.TypeString,
72+
Optional: true,
73+
Computed: true,
74+
},
75+
"xen_network_label": {
76+
Type: schema.TypeString,
77+
Optional: true,
78+
Computed: true,
79+
},
80+
},
81+
}
82+
}
83+
84+
func resourceCloudStackTrafficTypeCreate(d *schema.ResourceData, meta interface{}) error {
85+
cs := meta.(*cloudstack.CloudStackClient)
86+
87+
p := cs.Usage.NewAddTrafficTypeParams(d.Get("physical_network_id").(string), d.Get("traffic_type").(string))
88+
cs.Usage.AddTrafficType(p)
89+
90+
return resourceCloudStackTrafficTypeRead(d, meta)
91+
}
92+
93+
func resourceCloudStackTrafficTypeRead(d *schema.ResourceData, meta interface{}) error {
94+
return nil
95+
}
96+
97+
func resourceCloudStackTrafficTypeUpdate(d *schema.ResourceData, meta interface{}) error {
98+
return resourceCloudStackTrafficTypeRead(d, meta)
99+
}
100+
101+
func resourceCloudStackTrafficTypeDelete(d *schema.ResourceData, meta interface{}) error {
102+
return nil
103+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//
2+
// Licensed to the Apache Software Foundation (ASF) under one
3+
// or more contributor license agreements. See the NOTICE file
4+
// distributed with this work for additional information
5+
// regarding copyright ownership. The ASF licenses this file
6+
// to you under the Apache License, Version 2.0 (the
7+
// "License"); you may not use this file except in compliance
8+
// with the License. You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing,
13+
// software distributed under the License is distributed on an
14+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
// KIND, either express or implied. See the License for the
16+
// specific language governing permissions and limitations
17+
// under the License.
18+
//
19+
20+
package cloudstack

cloudstack/resource_cloudstack_zone.go

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func resourceCloudStackZone() *schema.Resource {
3737
State: schema.ImportStatePassthrough,
3838
},
3939
Schema: map[string]*schema.Schema{
40-
"allocationstate": {
40+
"allocation_state": {
4141
Type: schema.TypeString,
4242
Optional: true,
4343
Computed: true,
@@ -64,11 +64,11 @@ func resourceCloudStackZone() *schema.Resource {
6464
Type: schema.TypeString,
6565
Optional: true,
6666
},
67-
"domainid": {
67+
"domain_id": {
6868
Type: schema.TypeString,
6969
Optional: true,
7070
},
71-
"guestcidraddress": {
71+
"guest_cidr_address": {
7272
Type: schema.TypeString,
7373
Optional: true,
7474
},
@@ -80,15 +80,15 @@ func resourceCloudStackZone() *schema.Resource {
8080
Type: schema.TypeString,
8181
Optional: true,
8282
},
83-
"ip6dns1": {
83+
"ip6_dns1": {
8484
Type: schema.TypeString,
8585
Optional: true,
8686
},
87-
"ip6dns2": {
87+
"ip6_dns2": {
8888
Type: schema.TypeString,
8989
Optional: true,
9090
},
91-
"localstorageenabled": {
91+
"local_storage_enabled": {
9292
Type: schema.TypeBool,
9393
Optional: true,
9494
Computed: true,
@@ -101,7 +101,7 @@ func resourceCloudStackZone() *schema.Resource {
101101
Type: schema.TypeString,
102102
Required: true,
103103
},
104-
"securitygroupenabled": {
104+
"security_group_enabled": {
105105
Type: schema.TypeBool,
106106
Optional: true,
107107
},
@@ -123,25 +123,25 @@ func resourceCloudStackZoneCreate(d *schema.ResourceData, meta interface{}) erro
123123
if v, ok := d.GetOk("domain"); ok {
124124
p.SetDomain(v.(string))
125125
}
126-
if v, ok := d.GetOk("domainid"); ok {
126+
if v, ok := d.GetOk("domain_id"); ok {
127127
p.SetDomainid(v.(string))
128128
}
129-
if v, ok := d.GetOk("guestcidraddress"); ok {
129+
if v, ok := d.GetOk("guest_cidr_address"); ok {
130130
p.SetGuestcidraddress(v.(string))
131131
}
132132
if v, ok := d.GetOk("internal_dns2"); ok {
133133
p.SetInternaldns2(v.(string))
134134
}
135-
if v, ok := d.GetOk("ip6dns1"); ok {
135+
if v, ok := d.GetOk("ip6_dns1"); ok {
136136
p.SetIp6dns1(v.(string))
137137
}
138-
if v, ok := d.GetOk("ip6dns2"); ok {
138+
if v, ok := d.GetOk("ip6_dns2"); ok {
139139
p.SetIp6dns2(v.(string))
140140
}
141-
if v, ok := d.GetOk("localstorageenabled"); ok {
141+
if v, ok := d.GetOk("local_storage_enabled"); ok {
142142
p.SetLocalstorageenabled(v.(bool))
143143
}
144-
if v, ok := d.GetOk("securitygroupenabled"); ok {
144+
if v, ok := d.GetOk("security_group_enabled"); ok {
145145
p.SetSecuritygroupenabled(v.(bool))
146146
}
147147

@@ -167,22 +167,22 @@ func resourceCloudStackZoneRead(d *schema.ResourceData, meta interface{}) error
167167
return errors.New(fmt.Sprintf("Multiple zones. Invalid zone id: %s", d.Id()))
168168
}
169169

170-
d.Set("allocationstate", z.Allocationstate)
170+
d.Set("allocation_state", z.Allocationstate)
171171
d.Set("description", z.Description)
172172
d.Set("dhcp_provider", z.Dhcpprovider)
173173
d.Set("dns1", z.Dns1)
174174
d.Set("dns2", z.Dns2)
175175
d.Set("domain", z.Domain)
176-
d.Set("domainid", z.Domainid)
177-
d.Set("guestcidraddress", z.Guestcidraddress)
176+
d.Set("domain_id", z.Domainid)
177+
d.Set("guest_cidr_address", z.Guestcidraddress)
178178
d.Set("internal_dns1", z.Internaldns1)
179179
d.Set("internal_dns2", z.Internaldns2)
180-
d.Set("ip6dns1", z.Ip6dns1)
181-
d.Set("ip6dns2", z.Ip6dns2)
182-
d.Set("localstorageenabled", z.Localstorageenabled)
180+
d.Set("ip6_dns1", z.Ip6dns1)
181+
d.Set("ip6_dns2", z.Ip6dns2)
182+
d.Set("local_storage_enabled", z.Localstorageenabled)
183183
d.Set("name", z.Name)
184184
d.Set("network_type", z.Networktype)
185-
d.Set("securitygroupenabled", z.Securitygroupsenabled)
185+
d.Set("security_group_enabled", z.Securitygroupsenabled)
186186

187187
return nil
188188
}
@@ -192,7 +192,7 @@ func resourceCloudStackZoneUpdate(d *schema.ResourceData, meta interface{}) erro
192192

193193
p := cs.Zone.NewUpdateZoneParams(d.Id())
194194

195-
if v, ok := d.GetOk("allocationstate"); ok {
195+
if v, ok := d.GetOk("allocation_state"); ok {
196196
p.SetAllocationstate(v.(string))
197197
}
198198
if v, ok := d.GetOk("dhcp_provider"); ok {
@@ -207,7 +207,7 @@ func resourceCloudStackZoneUpdate(d *schema.ResourceData, meta interface{}) erro
207207
if v, ok := d.GetOk("domain"); ok {
208208
p.SetDomain(v.(string))
209209
}
210-
if v, ok := d.GetOk("guestcidraddress"); ok {
210+
if v, ok := d.GetOk("guest_cidr_address"); ok {
211211
p.SetGuestcidraddress(v.(string))
212212
}
213213

@@ -217,13 +217,13 @@ func resourceCloudStackZoneUpdate(d *schema.ResourceData, meta interface{}) erro
217217
if v, ok := d.GetOk("internal_dns2"); ok {
218218
p.SetInternaldns2(v.(string))
219219
}
220-
if v, ok := d.GetOk("ip6dns1"); ok {
220+
if v, ok := d.GetOk("ip6_dns1"); ok {
221221
p.SetIp6dns1(v.(string))
222222
}
223-
if v, ok := d.GetOk("ip6dns2"); ok {
223+
if v, ok := d.GetOk("ip6_dns2"); ok {
224224
p.SetIp6dns2(v.(string))
225225
}
226-
if v, ok := d.GetOk("localstorageenabled"); ok {
226+
if v, ok := d.GetOk("local_storage_enabled"); ok {
227227
p.SetLocalstorageenabled(v.(bool))
228228
}
229229
if v, ok := d.GetOk("name"); ok {

cloudstack/resource_cloudstack_zone_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,6 @@ resource "cloudstack_zone" "test" {
6666
internal_dns2 = "8.8.8.8"
6767
network_type = "Advanced"
6868
domain = "cloudstack.apache.org"
69-
guestcidraddress = "172.29.2.0/20"
69+
guest_cidr_address = "172.29.2.0/20"
7070
}
7171
`

0 commit comments

Comments
 (0)