Skip to content

Commit 01059a5

Browse files
committed
Add support for additional optional parameters for creating network offerings
1 parent 4eb6d4b commit 01059a5

File tree

1 file changed

+147
-0
lines changed

1 file changed

+147
-0
lines changed

cloudstack/resource_cloudstack_network_offering.go

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,85 @@ func resourceCloudStackNetworkOffering() *schema.Resource {
5050
Type: schema.TypeString,
5151
Required: true,
5252
},
53+
"domain_id": {
54+
Type: schema.TypeList,
55+
Elem: &schema.Schema{
56+
Type: schema.TypeString,
57+
},
58+
Optional: true,
59+
Description: "the ID of the containing domain(s), null for public offerings",
60+
},
61+
"network_rate": {
62+
Type: schema.TypeInt,
63+
Optional: true,
64+
Description: "data transfer rate in megabits per second allowed",
65+
},
66+
"network_mode": {
67+
Type: schema.TypeString,
68+
Optional: true,
69+
Description: "Indicates the mode with which the network will operate. Valid option: NATTED or ROUTED",
70+
},
71+
"max_connections": {
72+
Type: schema.TypeInt,
73+
Optional: true,
74+
Description: "maximum number of concurrent connections supported by the network offering",
75+
},
76+
"conserve_mode": {
77+
Type: schema.TypeBool,
78+
Optional: true,
79+
Description: "true if the network offering is IP conserve mode enabled",
80+
},
81+
"enable": {
82+
Type: schema.TypeBool,
83+
Optional: true,
84+
Description: "set to true if the offering is to be enabled during creation. Default is false",
85+
},
86+
"for_vpc": {
87+
Type: schema.TypeBool,
88+
Optional: true,
89+
Description: "true if network offering is meant to be used for VPC, false otherwise.",
90+
},
91+
"for_nsx": {
92+
Type: schema.TypeBool,
93+
Optional: true,
94+
Description: "true if network offering is meant to be used for NSX, false otherwise",
95+
},
96+
"internet_protocol": {
97+
Type: schema.TypeString,
98+
Optional: true,
99+
Description: "The internet protocol of network offering. Options are ipv4 and dualstack. Default is ipv4. dualstack will create a network offering that supports both IPv4 and IPv6",
100+
},
101+
"routing_mode": {
102+
Type: schema.TypeString,
103+
Optional: true,
104+
Description: "the routing mode for the network offering. Supported types are: Static or Dynamic.",
105+
},
106+
"specify_vlan": {
107+
Type: schema.TypeBool,
108+
Optional: true,
109+
Description: "true if network offering supports vlans, false otherwise",
110+
},
111+
"supported_services": {
112+
Type: schema.TypeSet,
113+
Elem: &schema.Schema{Type: schema.TypeString},
114+
Optional: true,
115+
Description: "the list of supported services",
116+
},
117+
"service_provider_list": {
118+
Type: schema.TypeMap,
119+
Optional: true,
120+
Description: "provider to service mapping. If not specified, the provider for the service will be mapped to the default provider on the physical network",
121+
},
122+
"specify_ip_ranges": {
123+
Type: schema.TypeBool,
124+
Optional: true,
125+
Description: "true if network offering supports specifying ip ranges; defaulted to false if not specified",
126+
},
127+
"specify_as_number": {
128+
Type: schema.TypeBool,
129+
Optional: true,
130+
Description: "true if network offering supports choosing AS number",
131+
},
53132
},
54133
}
55134
}
@@ -69,6 +148,74 @@ func resourceCloudStackNetworkOfferingCreate(d *schema.ResourceData, meta interf
69148
p.SetSpecifyipranges(true)
70149
}
71150

151+
if v, ok := d.GetOk("domain_id"); ok {
152+
p.SetDomainid(v.([]string))
153+
}
154+
155+
if v, ok := d.GetOk("network_rate"); ok {
156+
p.SetNetworkrate(v.(int))
157+
}
158+
159+
if v, ok := d.GetOk("network_mode"); ok {
160+
p.SetNetworkmode(v.(string))
161+
}
162+
163+
if v, ok := d.GetOk("max_connections"); ok {
164+
p.SetMaxconnections(v.(int))
165+
}
166+
167+
if v, ok := d.GetOk("conserve_mode"); ok {
168+
p.SetConservemode(v.(bool))
169+
}
170+
171+
if v, ok := d.GetOk("enable"); ok {
172+
p.SetEnable(v.(bool))
173+
}
174+
175+
if v, ok := d.GetOk("for_vpc"); ok {
176+
p.SetForvpc(v.(bool))
177+
}
178+
179+
if v, ok := d.GetOk("for_nsx"); ok {
180+
p.SetFornsx(v.(bool))
181+
}
182+
183+
if v, ok := d.GetOk("internet_protocol"); ok {
184+
p.SetInternetprotocol(v.(string))
185+
}
186+
187+
if v, ok := d.GetOk("routing_mode"); ok {
188+
p.SetRoutingmode(v.(string))
189+
}
190+
191+
if v, ok := d.GetOk("specify_vlan"); ok {
192+
p.SetSpecifyvlan(v.(bool))
193+
}
194+
195+
var supported_services []string
196+
if v, ok := d.GetOk("supported_services"); ok {
197+
for _, supported_service := range v.(*schema.Set).List() {
198+
supported_services = append(supported_services, supported_service.(string))
199+
}
200+
}
201+
p.SetSupportedservices(supported_services)
202+
203+
if v, ok := d.GetOk("service_provider_list"); ok {
204+
m := make(map[string]string)
205+
for key, value := range v.(map[string]interface{}) {
206+
m[key] = value.(string)
207+
}
208+
p.SetServiceproviderlist(m)
209+
}
210+
211+
if v, ok := d.GetOk("specify_ip_ranges"); ok {
212+
p.SetSpecifyipranges(v.(bool))
213+
}
214+
215+
if v, ok := d.GetOk("specify_as_number"); ok {
216+
p.SetSpecifyasnumber(v.(bool))
217+
}
218+
72219
log.Printf("[DEBUG] Creating Network Offering %s", name)
73220
n, err := cs.NetworkOffering.CreateNetworkOffering(p)
74221

0 commit comments

Comments
 (0)