This is an automated email from the ASF dual-hosted git repository.

dahn pushed a commit to branch main
in repository 
https://gitbox.apache.org/repos/asf/cloudstack-terraform-provider.git


The following commit(s) were added to refs/heads/main by this push:
     new 17de0ab  Add support for additional optional parameters for creating 
network offerings (#205)
17de0ab is described below

commit 17de0ab9e738a71d4510f96fc1fd92692967ac70
Author: Pearl Dsilva <[email protected]>
AuthorDate: Fri Aug 29 05:23:51 2025 -0400

    Add support for additional optional parameters for creating network 
offerings (#205)
---
 .../data_source_cloudstack_network_offering.go     | 109 ++++++++-
 ...data_source_cloudstack_network_offering_test.go | 175 ++++++++++++++
 cloudstack/resource_cloudstack_network_offering.go | 257 +++++++++++++++++++--
 website/docs/r/network_offering.html.markdown      |  32 ++-
 4 files changed, 557 insertions(+), 16 deletions(-)

diff --git a/cloudstack/data_source_cloudstack_network_offering.go 
b/cloudstack/data_source_cloudstack_network_offering.go
index fff5f56..fe82ebe 100644
--- a/cloudstack/data_source_cloudstack_network_offering.go
+++ b/cloudstack/data_source_cloudstack_network_offering.go
@@ -54,6 +54,64 @@ func dataSourceCloudstackNetworkOffering() *schema.Resource {
                                Type:     schema.TypeString,
                                Computed: true,
                        },
+                       "network_rate": {
+                               Type:     schema.TypeInt,
+                               Computed: true,
+                       },
+                       "network_mode": {
+                               Type:     schema.TypeString,
+                               Computed: true,
+                       },
+                       "conserve_mode": {
+                               Type:     schema.TypeBool,
+                               Computed: true,
+                       },
+                       "enable": {
+                               Type:     schema.TypeBool,
+                               Computed: true,
+                       },
+                       "for_vpc": {
+                               Type:     schema.TypeBool,
+                               Computed: true,
+                       },
+                       "for_nsx": {
+                               Type:     schema.TypeBool,
+                               Computed: true,
+                       },
+                       "specify_vlan": {
+                               Type:     schema.TypeBool,
+                               Computed: true,
+                       },
+                       "specify_ip_ranges": {
+                               Type:     schema.TypeBool,
+                               Computed: true,
+                       },
+                       "specify_as_number": {
+                               Type:     schema.TypeBool,
+                               Computed: true,
+                       },
+                       "internet_protocol": {
+                               Type:     schema.TypeString,
+                               Computed: true,
+                       },
+                       "routing_mode": {
+                               Type:     schema.TypeString,
+                               Computed: true,
+                       },
+                       "max_connections": {
+                               Type:     schema.TypeInt,
+                               Computed: true,
+                       },
+                       "supported_services": {
+                               Type:     schema.TypeSet,
+                               Computed: true,
+                               Elem:     &schema.Schema{Type: 
schema.TypeString},
+                       },
+                       "service_provider_list": {
+                               Type:     schema.TypeMap,
+                               Computed: true,
+                               Elem:     &schema.Schema{Type: 
schema.TypeString},
+                       },
                },
        }
 }
@@ -91,7 +149,12 @@ func datasourceCloudStackNetworkOfferingRead(d 
*schema.ResourceData, meta interf
        }
        log.Printf("[DEBUG] Selected network offerings: %s\n", 
networkOffering.Displaytext)
 
-       return networkOfferingDescriptionAttributes(d, networkOffering)
+       fullNetworkOffering, _, err := 
cs.NetworkOffering.GetNetworkOfferingByName(networkOffering.Name)
+       if err != nil {
+               return fmt.Errorf("Error retrieving full network offering 
details: %s", err)
+       }
+
+       return networkOfferingDescriptionAttributes(d, fullNetworkOffering)
 }
 
 func networkOfferingDescriptionAttributes(d *schema.ResourceData, 
networkOffering *cloudstack.NetworkOffering) error {
@@ -100,6 +163,50 @@ func networkOfferingDescriptionAttributes(d 
*schema.ResourceData, networkOfferin
        d.Set("display_text", networkOffering.Displaytext)
        d.Set("guest_ip_type", networkOffering.Guestiptype)
        d.Set("traffic_type", networkOffering.Traffictype)
+       d.Set("network_rate", networkOffering.Networkrate)
+
+       // Only set if CloudStack supports these fields (4.20.0+)
+       if networkOffering.Networkmode != "" {
+               d.Set("network_mode", networkOffering.Networkmode)
+       }
+
+       d.Set("conserve_mode", networkOffering.Conservemode)
+       d.Set("enable", networkOffering.State == "Enabled")
+       d.Set("for_vpc", networkOffering.Forvpc)
+       d.Set("for_nsx", networkOffering.Fornsx)
+       d.Set("specify_vlan", networkOffering.Specifyvlan)
+       d.Set("specify_ip_ranges", networkOffering.Specifyipranges)
+       d.Set("specify_as_number", networkOffering.Specifyasnumber)
+       d.Set("internet_protocol", networkOffering.Internetprotocol)
+
+       // Only set if CloudStack supports this field (4.20.0+)
+       if networkOffering.Routingmode != "" {
+               d.Set("routing_mode", networkOffering.Routingmode)
+       }
+
+       if networkOffering.Maxconnections > 0 {
+               d.Set("max_connections", networkOffering.Maxconnections)
+       }
+
+       // Set supported services
+       if len(networkOffering.Service) > 0 {
+               services := make([]string, len(networkOffering.Service))
+               for i, service := range networkOffering.Service {
+                       services[i] = service.Name
+               }
+               d.Set("supported_services", services)
+       }
+
+       // Set service provider list
+       if len(networkOffering.Service) > 0 {
+               serviceProviders := make(map[string]string)
+               for _, service := range networkOffering.Service {
+                       if len(service.Provider) > 0 {
+                               serviceProviders[service.Name] = 
service.Provider[0].Name
+                       }
+               }
+               d.Set("service_provider_list", serviceProviders)
+       }
 
        return nil
 }
diff --git a/cloudstack/data_source_cloudstack_network_offering_test.go 
b/cloudstack/data_source_cloudstack_network_offering_test.go
index d8d235d..48d5ab5 100644
--- a/cloudstack/data_source_cloudstack_network_offering_test.go
+++ b/cloudstack/data_source_cloudstack_network_offering_test.go
@@ -37,6 +37,83 @@ func TestAccNetworkOfferingDataSource_basic(t *testing.T) {
                                Config: 
testNetworkOfferingDataSourceConfig_basic,
                                Check: resource.ComposeTestCheckFunc(
                                        
resource.TestCheckResourceAttrPair(datasourceName, "name", resourceName, 
"name"),
+                                       
resource.TestCheckResourceAttrPair(datasourceName, "display_text", 
resourceName, "display_text"),
+                                       
resource.TestCheckResourceAttrPair(datasourceName, "guest_ip_type", 
resourceName, "guest_ip_type"),
+                                       
resource.TestCheckResourceAttrPair(datasourceName, "traffic_type", 
resourceName, "traffic_type"),
+                               ),
+                       },
+               },
+       })
+}
+
+func TestAccNetworkOfferingDataSource_withAdditionalParams(t *testing.T) {
+       resourceName := "cloudstack_network_offering.net-off-resource"
+       datasourceName := "data.cloudstack_network_offering.net-off-data-source"
+
+       resource.Test(t, resource.TestCase{
+               PreCheck:  func() { testAccPreCheck(t) },
+               Providers: testAccProviders,
+               Steps: []resource.TestStep{
+                       {
+                               Config: 
testNetworkOfferingDataSourceConfig_withAdditionalParams,
+                               Check: resource.ComposeTestCheckFunc(
+                                       
resource.TestCheckResourceAttrPair(datasourceName, "name", resourceName, 
"name"),
+                                       
resource.TestCheckResourceAttrPair(datasourceName, "display_text", 
resourceName, "display_text"),
+                                       
resource.TestCheckResourceAttrPair(datasourceName, "guest_ip_type", 
resourceName, "guest_ip_type"),
+                                       
resource.TestCheckResourceAttrPair(datasourceName, "traffic_type", 
resourceName, "traffic_type"),
+                                       
resource.TestCheckResourceAttrPair(datasourceName, "network_rate", 
resourceName, "network_rate"),
+                                       
resource.TestCheckResourceAttrPair(datasourceName, "conserve_mode", 
resourceName, "conserve_mode"),
+                                       
resource.TestCheckResourceAttrPair(datasourceName, "for_vpc", resourceName, 
"for_vpc"),
+                                       
resource.TestCheckResourceAttrPair(datasourceName, "specify_vlan", 
resourceName, "specify_vlan"),
+                                       
resource.TestCheckResourceAttrPair(datasourceName, "enable", resourceName, 
"enable"),
+                               ),
+                       },
+               },
+       })
+}
+
+func TestAccNetworkOfferingDataSource_withServices(t *testing.T) {
+       resourceName := "cloudstack_network_offering.net-off-resource"
+       datasourceName := "data.cloudstack_network_offering.net-off-data-source"
+
+       resource.Test(t, resource.TestCase{
+               PreCheck:  func() { testAccPreCheck(t) },
+               Providers: testAccProviders,
+               Steps: []resource.TestStep{
+                       {
+                               Config: 
testNetworkOfferingDataSourceConfig_withServices,
+                               Check: resource.ComposeTestCheckFunc(
+                                       
resource.TestCheckResourceAttrPair(datasourceName, "name", resourceName, 
"name"),
+                                       
resource.TestCheckResourceAttrPair(datasourceName, "supported_services.#", 
resourceName, "supported_services.#"),
+                                       
resource.TestCheckResourceAttrPair(datasourceName, "service_provider_list.%", 
resourceName, "service_provider_list.%"),
+                                       
resource.TestCheckResourceAttrPair(datasourceName, 
"service_provider_list.Dhcp", resourceName, "service_provider_list.Dhcp"),
+                                       
resource.TestCheckResourceAttrPair(datasourceName, "service_provider_list.Dns", 
resourceName, "service_provider_list.Dns"),
+                                       
resource.TestCheckResourceAttrPair(datasourceName, "enable", resourceName, 
"enable"),
+                                       
resource.TestCheckResourceAttrPair(datasourceName, "max_connections", 
resourceName, "max_connections"),
+                               ),
+                       },
+               },
+       })
+}
+
+func TestAccNetworkOfferingDataSource_allOptionalParams(t *testing.T) {
+       resourceName := "cloudstack_network_offering.net-off-resource"
+       datasourceName := "data.cloudstack_network_offering.net-off-data-source"
+
+       resource.Test(t, resource.TestCase{
+               PreCheck:  func() { testAccPreCheck(t) },
+               Providers: testAccProviders,
+               Steps: []resource.TestStep{
+                       {
+                               Config: 
testNetworkOfferingDataSourceConfig_allOptionalParams,
+                               Check: resource.ComposeTestCheckFunc(
+                                       
resource.TestCheckResourceAttrPair(datasourceName, "name", resourceName, 
"name"),
+                                       
resource.TestCheckResourceAttrPair(datasourceName, "display_text", 
resourceName, "display_text"),
+                                       
resource.TestCheckResourceAttrPair(datasourceName, "for_nsx", resourceName, 
"for_nsx"),
+                                       
resource.TestCheckResourceAttrPair(datasourceName, "specify_as_number", 
resourceName, "specify_as_number"),
+                                       
resource.TestCheckResourceAttrPair(datasourceName, "internet_protocol", 
resourceName, "internet_protocol"),
+                                       
resource.TestCheckResourceAttr(datasourceName, "enable", "true"),
+                                       
resource.TestCheckResourceAttr(datasourceName, "for_nsx", "false"),
                                ),
                        },
                },
@@ -62,3 +139,101 @@ resource "cloudstack_network_offering" "net-off-resource"{
        ]
   }
   `
+
+const testNetworkOfferingDataSourceConfig_withAdditionalParams = `
+resource "cloudstack_network_offering" "net-off-resource"{
+  name              = "TestNetworkDisplayAdvanced01"
+  display_text      = "TestNetworkDisplayAdvanced01"
+  guest_ip_type     = "Isolated"
+  traffic_type      = "Guest"
+  network_rate      = 100
+  conserve_mode     = true
+  enable            = true
+  for_vpc           = false
+  specify_vlan      = true
+  supported_services = ["Dhcp", "Dns", "Firewall", "Lb", "SourceNat"]
+  service_provider_list = {
+    Dhcp      = "VirtualRouter"
+    Dns       = "VirtualRouter"
+    Firewall  = "VirtualRouter"
+    Lb        = "VirtualRouter"
+    SourceNat = "VirtualRouter"
+  }
+}
+
+data "cloudstack_network_offering" "net-off-data-source"{
+  filter{
+    name = "name"
+    value = "TestNetworkDisplayAdvanced01"
+  }
+  depends_on = [
+    cloudstack_network_offering.net-off-resource
+  ]
+}
+`
+
+const testNetworkOfferingDataSourceConfig_withServices = `
+resource "cloudstack_network_offering" "net-off-resource"{
+  name              = "TestNetworkServices01"
+  display_text      = "TestNetworkServices01"
+  guest_ip_type     = "Isolated"
+  traffic_type      = "Guest"
+  enable            = true
+  supported_services = ["Dhcp", "Dns", "Firewall", "Lb", "SourceNat", 
"StaticNat", "PortForwarding"]
+  service_provider_list = {
+    Dhcp           = "VirtualRouter"
+    Dns            = "VirtualRouter"
+    Firewall       = "VirtualRouter"
+    Lb             = "VirtualRouter"
+    SourceNat      = "VirtualRouter"
+    StaticNat      = "VirtualRouter"
+    PortForwarding = "VirtualRouter"
+  }
+}
+
+data "cloudstack_network_offering" "net-off-data-source"{
+  filter{
+    name = "name"
+    value = "TestNetworkServices01"
+  }
+  depends_on = [
+    cloudstack_network_offering.net-off-resource
+  ]
+}
+`
+
+const testNetworkOfferingDataSourceConfig_allOptionalParams = `
+resource "cloudstack_network_offering" "net-off-resource"{
+  name              = "TestNetworkDisplayAll01"
+  display_text      = "TestNetworkDisplayAll01"
+  guest_ip_type     = "Isolated"
+  traffic_type      = "Guest"
+  network_rate      = 200
+  conserve_mode     = true
+  enable            = true
+  for_vpc           = false
+  for_nsx           = false
+  specify_vlan      = true
+  specify_as_number = false
+  internet_protocol = "IPv4"
+  max_connections   = 1000
+  supported_services = ["Dhcp", "Dns", "Firewall", "Lb", "SourceNat"]
+  service_provider_list = {
+    Dhcp      = "VirtualRouter"
+    Dns       = "VirtualRouter"
+    Firewall  = "VirtualRouter"
+    Lb        = "VirtualRouter"
+    SourceNat = "VirtualRouter"
+  }
+}
+
+data "cloudstack_network_offering" "net-off-data-source"{
+  filter{
+    name = "name"
+    value = "TestNetworkDisplayAll01"
+  }
+  depends_on = [
+    cloudstack_network_offering.net-off-resource
+  ]
+}
+`
diff --git a/cloudstack/resource_cloudstack_network_offering.go 
b/cloudstack/resource_cloudstack_network_offering.go
index a418b14..d6adf4b 100644
--- a/cloudstack/resource_cloudstack_network_offering.go
+++ b/cloudstack/resource_cloudstack_network_offering.go
@@ -50,6 +50,100 @@ 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",
+                               ForceNew:    true,
+                       },
+                       "network_rate": {
+                               Type:        schema.TypeInt,
+                               Optional:    true,
+                               Description: "data transfer rate in megabits 
per second allowed",
+                               ForceNew:    true,
+                       },
+                       "network_mode": {
+                               Type:        schema.TypeString,
+                               Optional:    true,
+                               Description: "Indicates the mode with which the 
network will operate. Valid option: NATTED or ROUTED",
+                               ForceNew:    true,
+                       },
+                       "max_connections": {
+                               Type:        schema.TypeInt,
+                               Optional:    true,
+                               Description: "maximum number of concurrent 
connections supported by the network offering",
+                               ForceNew:    true,
+                       },
+                       "conserve_mode": {
+                               Type:        schema.TypeBool,
+                               Optional:    true,
+                               Description: "true if the network offering is 
IP conserve mode enabled",
+                               ForceNew:    true,
+                       },
+                       "enable": {
+                               Type:        schema.TypeBool,
+                               Optional:    true,
+                               Description: "set to true if the offering is to 
be enabled during creation. Default is false",
+                               ForceNew:    true,
+                       },
+                       "for_vpc": {
+                               Type:        schema.TypeBool,
+                               Optional:    true,
+                               Description: "true if network offering is meant 
to be used for VPC, false otherwise.",
+                               ForceNew:    true,
+                       },
+                       "for_nsx": {
+                               Type:        schema.TypeBool,
+                               Optional:    true,
+                               Description: "true if network offering is meant 
to be used for NSX, false otherwise",
+                               ForceNew:    true,
+                       },
+                       "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",
+                               ForceNew:    true,
+                       },
+                       "routing_mode": {
+                               Type:        schema.TypeString,
+                               Optional:    true,
+                               Description: "the routing mode for the network 
offering. Supported types are: Static or Dynamic.",
+                               ForceNew:    true,
+                       },
+                       "specify_vlan": {
+                               Type:        schema.TypeBool,
+                               Optional:    true,
+                               Description: "true if network offering supports 
vlans, false otherwise",
+                               ForceNew:    true,
+                       },
+                       "supported_services": {
+                               Type:        schema.TypeSet,
+                               Elem:        &schema.Schema{Type: 
schema.TypeString},
+                               Optional:    true,
+                               Description: "the list of supported services",
+                               ForceNew:    true,
+                       },
+                       "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",
+                               ForceNew:    true,
+                       },
+                       "specify_ip_ranges": {
+                               Type:        schema.TypeBool,
+                               Optional:    true,
+                               Description: "true if network offering supports 
specifying ip ranges; defaulted to false if not specified",
+                               ForceNew:    true,
+                       },
+                       "specify_as_number": {
+                               Type:        schema.TypeBool,
+                               Optional:    true,
+                               Description: "true if network offering supports 
choosing AS number",
+                               ForceNew:    true,
+                       },
                },
        }
 }
@@ -69,6 +163,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)
 
@@ -106,7 +268,7 @@ func resourceCloudStackNetworkOfferingUpdate(d 
*schema.ResourceData, meta interf
 
        }
 
-       // Check if the display text is changed and if so, update the virtual 
machine
+       // Check if the display text is changed and if so, update the network 
offering
        if d.HasChange("display_text") {
                log.Printf("[DEBUG] Display text changed for %s, starting 
update", name)
 
@@ -114,7 +276,7 @@ func resourceCloudStackNetworkOfferingUpdate(d 
*schema.ResourceData, meta interf
                p := cs.NetworkOffering.NewUpdateNetworkOfferingParams()
 
                // Set the new display text
-               p.SetName(d.Get("display_text").(string))
+               p.SetDisplaytext(d.Get("display_text").(string))
 
                // Update the display text
                _, err := cs.NetworkOffering.UpdateNetworkOffering(p)
@@ -125,34 +287,34 @@ func resourceCloudStackNetworkOfferingUpdate(d 
*schema.ResourceData, meta interf
 
        }
 
-       // Check if the guest ip type is changed and if so, update the virtual 
machine
-       if d.HasChange("guest_ip_type") {
-               log.Printf("[DEBUG] Guest ip type changed for %s, starting 
update", name)
+       // Check if maxconnections is changed and if so, update the network 
offering
+       if d.HasChange("max_connections") {
+               log.Printf("[DEBUG] Max connections changed for %s, starting 
update", name)
 
                // Create a new parameter struct
                p := cs.NetworkOffering.NewUpdateNetworkOfferingParams()
 
-               // Set the new guest ip type
-               p.SetName(d.Get("guest_ip_type").(string))
+               // Set the new max connections
+               p.SetMaxconnections(d.Get("max_connections").(int))
 
-               // Update the guest ip type
+               // Update the max connections
                _, err := cs.NetworkOffering.UpdateNetworkOffering(p)
                if err != nil {
                        return fmt.Errorf(
-                               "Error updating the guest ip type for network 
offering %s: %s", name, err)
+                               "Error updating the max connections for network 
offering %s: %s", name, err)
                }
 
        }
 
-       // Check if the traffic type is changed and if so, update the virtual 
machine
-       if d.HasChange("traffic_type") {
-               log.Printf("[DEBUG] Traffic type changed for %s, starting 
update", name)
+       // Check if the domain id is changed and if so, update the network 
offering
+       if d.HasChange("domain_id") {
+               log.Printf("[DEBUG] Domain id changed for %s, starting update", 
name)
 
                // Create a new parameter struct
                p := cs.NetworkOffering.NewUpdateNetworkOfferingParams()
 
-               // Set the new traffic type
-               p.SetName(d.Get("traffic_type").(string))
+               // Set the new domain id
+               p.SetDomainid(d.Get("domain_id").(string))
 
                // Update the traffic type
                _, err := cs.NetworkOffering.UpdateNetworkOffering(p)
@@ -203,5 +365,72 @@ func resourceCloudStackNetworkOfferingRead(d 
*schema.ResourceData, meta interfac
        d.Set("guest_ip_type", n.Guestiptype)
        d.Set("traffic_type", n.Traffictype)
 
+       if _, ok := d.GetOk("network_rate"); ok {
+               d.Set("network_rate", n.Networkrate)
+       }
+       if _, ok := d.GetOk("network_mode"); ok {
+               // Only set if CloudStack supports and returns this field 
(4.20.0+)
+               // Older versions may not support network_mode
+               if n.Networkmode != "" {
+                       d.Set("network_mode", n.Networkmode)
+               }
+       }
+       if _, ok := d.GetOk("conserve_mode"); ok {
+               d.Set("conserve_mode", n.Conservemode)
+       }
+       if _, ok := d.GetOk("enable"); ok {
+               d.Set("enable", n.State == "Enabled")
+       }
+       if _, ok := d.GetOk("for_vpc"); ok {
+               d.Set("for_vpc", n.Forvpc)
+       }
+       if _, ok := d.GetOk("for_nsx"); ok {
+               d.Set("for_nsx", n.Fornsx)
+       }
+       if _, ok := d.GetOk("specify_vlan"); ok {
+               d.Set("specify_vlan", n.Specifyvlan)
+       }
+       if _, ok := d.GetOk("specify_ip_ranges"); ok {
+               d.Set("specify_ip_ranges", n.Specifyipranges)
+       }
+       if _, ok := d.GetOk("specify_as_number"); ok {
+               d.Set("specify_as_number", n.Specifyasnumber)
+       }
+       if _, ok := d.GetOk("internet_protocol"); ok {
+               d.Set("internet_protocol", n.Internetprotocol)
+       }
+       if _, ok := d.GetOk("routing_mode"); ok {
+               // Only set if CloudStack supports and returns this field 
(4.20.0+)
+               // Older versions may not support routing_mode
+               if n.Routingmode != "" {
+                       d.Set("routing_mode", n.Routingmode)
+               }
+       }
+       if _, ok := d.GetOk("max_connections"); ok {
+               log.Printf("[DEBUG] Max connections configured: %d, CloudStack 
returned: %d", d.Get("max_connections").(int), n.Maxconnections)
+
+               if n.Maxconnections > 0 {
+                       d.Set("max_connections", n.Maxconnections)
+               }
+       }
+
+       if _, ok := d.GetOk("supported_services"); ok && len(n.Service) > 0 {
+               services := make([]string, len(n.Service))
+               for i, service := range n.Service {
+                       services[i] = service.Name
+               }
+               d.Set("supported_services", services)
+       }
+
+       if _, ok := d.GetOk("service_provider_list"); ok && len(n.Service) > 0 {
+               serviceProviders := make(map[string]string)
+               for _, service := range n.Service {
+                       if len(service.Provider) > 0 {
+                               serviceProviders[service.Name] = 
service.Provider[0].Name
+                       }
+               }
+               d.Set("service_provider_list", serviceProviders)
+       }
+
        return nil
 }
diff --git a/website/docs/r/network_offering.html.markdown 
b/website/docs/r/network_offering.html.markdown
index 1ef9a87..8449299 100644
--- a/website/docs/r/network_offering.html.markdown
+++ b/website/docs/r/network_offering.html.markdown
@@ -16,8 +16,24 @@ A `cloudstack_network_offering` resource manages a network 
offering within Cloud
 resource "cloudstack_network_offering" "example" {
     name = "example-network-offering"
     display_text = "Example Network Offering"
-    guest_ip_type = "Shared"
+    guest_ip_type = "Isolated"
     traffic_type = "Guest"
+    network_rate = 100
+    network_mode = "NATTED"
+    conserve_mode = true
+    enable = true
+    for_vpc = false
+    specify_vlan = true
+    specify_ip_ranges = true
+    max_connections = 256
+    supported_services = ["Dhcp", "Dns", "Firewall", "Lb", "SourceNat"]
+    service_provider_list = {
+        Dhcp = "VirtualRouter"
+        Dns = "VirtualRouter"
+        Firewall = "VirtualRouter"
+        Lb = "VirtualRouter"
+        SourceNat = "VirtualRouter"
+    }
 }
 ```
 
@@ -30,6 +46,20 @@ The following arguments are supported:
 * `display_text` - (Required) The display text of the network offering.
 * `guest_ip_type` - (Required) The type of IP address allocation for the 
network offering. Possible values are "Shared" or "Isolated".
 * `traffic_type` - (Required) The type of traffic for the network offering. 
Possible values are "Guest" or "Management".
+* `network_rate` - (Optional) The network rate in Mbps for the network 
offering.
+* `network_mode` - (Optional) The network mode. Possible values are "DHCP" or 
"NATTED".
+* `conserve_mode` - (Optional) Whether to enable conserve mode. Defaults to 
`false`.
+* `enable` - (Optional) Whether to enable the network offering. Defaults to 
`false`.
+* `for_vpc` - (Optional) Whether this network offering is for VPC. Defaults to 
`false`.
+* `for_nsx` - (Optional) Whether this network offering is for NSX. Defaults to 
`false`.
+* `specify_vlan` - (Optional) Whether to allow specifying VLAN ID. Defaults to 
`false`.
+* `specify_ip_ranges` - (Optional) Whether to allow specifying IP ranges. 
Defaults to `false`.
+* `specify_as_number` - (Optional) Whether to allow specifying AS number. 
Defaults to `false`.
+* `internet_protocol` - (Optional) The internet protocol. Possible values are 
"IPv4" or "IPv6". Defaults to "IPv4".
+* `routing_mode` - (Optional) The routing mode. Possible values are "Static" 
or "Dynamic".
+* `max_connections` - (Optional) The maximum number of concurrent connections 
supported by the network offering.
+* `supported_services` - (Optional) A list of supported services for this 
network offering.
+* `service_provider_list` - (Optional) A map of service providers for the 
supported services.
 
 ## Attributes Reference
 

Reply via email to