This is an automated email from the ASF dual-hosted git repository. pearl11594 pushed a commit to branch add-additional-params-netOff in repository https://gitbox.apache.org/repos/asf/cloudstack-terraform-provider.git
commit 01059a566a0fd7dcbd345509970783ed7afcf334 Author: Pearl Dsilva <pearl1...@gmail.com> AuthorDate: Mon Aug 25 14:59:04 2025 -0400 Add support for additional optional parameters for creating network offerings --- cloudstack/resource_cloudstack_network_offering.go | 147 +++++++++++++++++++++ 1 file changed, 147 insertions(+) diff --git a/cloudstack/resource_cloudstack_network_offering.go b/cloudstack/resource_cloudstack_network_offering.go index a418b14..3a3063e 100644 --- a/cloudstack/resource_cloudstack_network_offering.go +++ b/cloudstack/resource_cloudstack_network_offering.go @@ -50,6 +50,85 @@ func resourceCloudStackNetworkOffering() *schema.Resource { Type: schema.TypeString, Required: true, }, + "domain_id": { + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Optional: true, + Description: "the ID of the containing domain(s), null for public offerings", + }, + "network_rate": { + Type: schema.TypeInt, + Optional: true, + Description: "data transfer rate in megabits per second allowed", + }, + "network_mode": { + Type: schema.TypeString, + Optional: true, + Description: "Indicates the mode with which the network will operate. Valid option: NATTED or ROUTED", + }, + "max_connections": { + Type: schema.TypeInt, + Optional: true, + Description: "maximum number of concurrent connections supported by the network offering", + }, + "conserve_mode": { + Type: schema.TypeBool, + Optional: true, + Description: "true if the network offering is IP conserve mode enabled", + }, + "enable": { + Type: schema.TypeBool, + Optional: true, + Description: "set to true if the offering is to be enabled during creation. Default is false", + }, + "for_vpc": { + Type: schema.TypeBool, + Optional: true, + Description: "true if network offering is meant to be used for VPC, false otherwise.", + }, + "for_nsx": { + Type: schema.TypeBool, + Optional: true, + Description: "true if network offering is meant to be used for NSX, false otherwise", + }, + "internet_protocol": { + Type: schema.TypeString, + Optional: true, + 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", + }, + "routing_mode": { + Type: schema.TypeString, + Optional: true, + Description: "the routing mode for the network offering. Supported types are: Static or Dynamic.", + }, + "specify_vlan": { + Type: schema.TypeBool, + Optional: true, + Description: "true if network offering supports vlans, false otherwise", + }, + "supported_services": { + Type: schema.TypeSet, + Elem: &schema.Schema{Type: schema.TypeString}, + Optional: true, + Description: "the list of supported services", + }, + "service_provider_list": { + Type: schema.TypeMap, + Optional: true, + Description: "provider to service mapping. If not specified, the provider for the service will be mapped to the default provider on the physical network", + }, + "specify_ip_ranges": { + Type: schema.TypeBool, + Optional: true, + Description: "true if network offering supports specifying ip ranges; defaulted to false if not specified", + }, + "specify_as_number": { + Type: schema.TypeBool, + Optional: true, + Description: "true if network offering supports choosing AS number", + }, }, } } @@ -69,6 +148,74 @@ func resourceCloudStackNetworkOfferingCreate(d *schema.ResourceData, meta interf p.SetSpecifyipranges(true) } + if v, ok := d.GetOk("domain_id"); ok { + p.SetDomainid(v.([]string)) + } + + if v, ok := d.GetOk("network_rate"); ok { + p.SetNetworkrate(v.(int)) + } + + if v, ok := d.GetOk("network_mode"); ok { + p.SetNetworkmode(v.(string)) + } + + if v, ok := d.GetOk("max_connections"); ok { + p.SetMaxconnections(v.(int)) + } + + if v, ok := d.GetOk("conserve_mode"); ok { + p.SetConservemode(v.(bool)) + } + + if v, ok := d.GetOk("enable"); ok { + p.SetEnable(v.(bool)) + } + + if v, ok := d.GetOk("for_vpc"); ok { + p.SetForvpc(v.(bool)) + } + + if v, ok := d.GetOk("for_nsx"); ok { + p.SetFornsx(v.(bool)) + } + + if v, ok := d.GetOk("internet_protocol"); ok { + p.SetInternetprotocol(v.(string)) + } + + if v, ok := d.GetOk("routing_mode"); ok { + p.SetRoutingmode(v.(string)) + } + + if v, ok := d.GetOk("specify_vlan"); ok { + p.SetSpecifyvlan(v.(bool)) + } + + var supported_services []string + if v, ok := d.GetOk("supported_services"); ok { + for _, supported_service := range v.(*schema.Set).List() { + supported_services = append(supported_services, supported_service.(string)) + } + } + p.SetSupportedservices(supported_services) + + if v, ok := d.GetOk("service_provider_list"); ok { + m := make(map[string]string) + for key, value := range v.(map[string]interface{}) { + m[key] = value.(string) + } + p.SetServiceproviderlist(m) + } + + if v, ok := d.GetOk("specify_ip_ranges"); ok { + p.SetSpecifyipranges(v.(bool)) + } + + if v, ok := d.GetOk("specify_as_number"); ok { + p.SetSpecifyasnumber(v.(bool)) + } + log.Printf("[DEBUG] Creating Network Offering %s", name) n, err := cs.NetworkOffering.CreateNetworkOffering(p)