bddvlpr commented on code in PR #299:
URL: 
https://github.com/apache/cloudstack-terraform-provider/pull/299#discussion_r3558736253


##########
cloudstack/resource_cloudstack_storage_network_ip_range.go:
##########
@@ -0,0 +1,169 @@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+
+package cloudstack
+
+import (
+       "fmt"
+       "log"
+
+       "github.com/apache/cloudstack-go/v2/cloudstack"
+       "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
+)
+
+func resourceCloudStackStorageNetworkIpRange() *schema.Resource {
+       return &schema.Resource{
+               Create: resourceCloudStackStorageNetworkIpRangeCreate,
+               Read:   resourceCloudStackStorageNetworkIpRangeRead,
+               Update: resourceCloudStackStorageNetworkIpRangeUpdate,
+               Delete: resourceCloudStackStorageNetworkIpRangeDelete,
+               Importer: &schema.ResourceImporter{
+                       State: schema.ImportStatePassthrough,
+               },
+               Schema: map[string]*schema.Schema{
+                       "gateway": {
+                               Description: "the gateway for the storage 
network IP range",
+                               Type:        schema.TypeString,
+                               Required:    true,
+                               ForceNew:    true,
+                       },
+                       "netmask": {
+                               Description: "the netmask for the storage 
network IP range",
+                               Type:        schema.TypeString,
+                               Required:    true,
+                       },
+                       "pod_id": {
+                               Description: "the Pod ID for the storage 
network IP range",
+                               Type:        schema.TypeString,
+                               Required:    true,
+                               ForceNew:    true,
+                       },
+                       "start_ip": {
+                               Description: "the beginning IP address in the 
storage network IP range",
+                               Type:        schema.TypeString,
+                               Required:    true,
+                       },
+                       "end_ip": {
+                               Description: "the ending IP address in the 
storage network IP range",
+                               Type:        schema.TypeString,
+                               Optional:    true,
+                               Computed:    true,
+                       },
+                       "vlan": {
+                               Description: "the optional VLAN of the storage 
network IP range",
+                               Type:        schema.TypeInt,
+                               Optional:    true,
+                       },
+                       "network_id": {
+                               Description: "the network id of the storage 
network IP range",
+                               Type:        schema.TypeString,
+                               Computed:    true,
+                       },
+               },
+       }
+}
+
+func resourceCloudStackStorageNetworkIpRangeCreate(d *schema.ResourceData, 
meta interface{}) error {
+       cs := meta.(*cloudstack.CloudStackClient)
+
+       p := cs.Network.NewCreateStorageNetworkIpRangeParams(
+               d.Get("gateway").(string),
+               d.Get("netmask").(string),
+               d.Get("pod_id").(string),
+               d.Get("start_ip").(string),
+       )
+
+       if v, ok := d.GetOk("end_ip"); ok {
+               p.SetEndip(v.(string))
+       }
+       if v, ok := d.GetOk("vlan"); ok {
+               p.SetVlan(v.(int))
+       }
+
+       r, err := cs.Network.CreateStorageNetworkIpRange(p)
+       if err != nil {
+               return fmt.Errorf("Error creating storage network IP range: 
%s", err)
+       }
+
+       d.SetId(r.Id)
+
+       return resourceCloudStackStorageNetworkIpRangeRead(d, meta)
+}
+
+func resourceCloudStackStorageNetworkIpRangeRead(d *schema.ResourceData, meta 
interface{}) error {
+       cs := meta.(*cloudstack.CloudStackClient)
+
+       r, count, err := cs.Network.GetStorageNetworkIpRangeByID(d.Id())
+       if err != nil {
+               if count == 0 {
+                       log.Printf("[DEBUG] Storage network IP range %s does no 
longer exist", d.Id())

Review Comment:
   Skipping cause of kit.



##########
cloudstack/resource_cloudstack_storage_network_ip_range.go:
##########
@@ -0,0 +1,169 @@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+
+package cloudstack
+
+import (
+       "fmt"
+       "log"
+
+       "github.com/apache/cloudstack-go/v2/cloudstack"
+       "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
+)
+
+func resourceCloudStackStorageNetworkIpRange() *schema.Resource {
+       return &schema.Resource{
+               Create: resourceCloudStackStorageNetworkIpRangeCreate,
+               Read:   resourceCloudStackStorageNetworkIpRangeRead,
+               Update: resourceCloudStackStorageNetworkIpRangeUpdate,
+               Delete: resourceCloudStackStorageNetworkIpRangeDelete,
+               Importer: &schema.ResourceImporter{
+                       State: schema.ImportStatePassthrough,
+               },
+               Schema: map[string]*schema.Schema{
+                       "gateway": {
+                               Description: "the gateway for the storage 
network IP range",
+                               Type:        schema.TypeString,
+                               Required:    true,
+                               ForceNew:    true,
+                       },
+                       "netmask": {
+                               Description: "the netmask for the storage 
network IP range",
+                               Type:        schema.TypeString,
+                               Required:    true,
+                       },
+                       "pod_id": {
+                               Description: "the Pod ID for the storage 
network IP range",
+                               Type:        schema.TypeString,
+                               Required:    true,
+                               ForceNew:    true,
+                       },
+                       "start_ip": {
+                               Description: "the beginning IP address in the 
storage network IP range",
+                               Type:        schema.TypeString,
+                               Required:    true,
+                       },
+                       "end_ip": {
+                               Description: "the ending IP address in the 
storage network IP range",
+                               Type:        schema.TypeString,
+                               Optional:    true,
+                               Computed:    true,
+                       },
+                       "vlan": {
+                               Description: "the optional VLAN of the storage 
network IP range",
+                               Type:        schema.TypeInt,
+                               Optional:    true,
+                       },
+                       "network_id": {
+                               Description: "the network id of the storage 
network IP range",
+                               Type:        schema.TypeString,
+                               Computed:    true,
+                       },
+               },
+       }
+}
+
+func resourceCloudStackStorageNetworkIpRangeCreate(d *schema.ResourceData, 
meta interface{}) error {
+       cs := meta.(*cloudstack.CloudStackClient)
+
+       p := cs.Network.NewCreateStorageNetworkIpRangeParams(
+               d.Get("gateway").(string),
+               d.Get("netmask").(string),
+               d.Get("pod_id").(string),
+               d.Get("start_ip").(string),
+       )
+
+       if v, ok := d.GetOk("end_ip"); ok {
+               p.SetEndip(v.(string))
+       }
+       if v, ok := d.GetOk("vlan"); ok {
+               p.SetVlan(v.(int))
+       }
+
+       r, err := cs.Network.CreateStorageNetworkIpRange(p)
+       if err != nil {
+               return fmt.Errorf("Error creating storage network IP range: 
%s", err)
+       }
+
+       d.SetId(r.Id)
+
+       return resourceCloudStackStorageNetworkIpRangeRead(d, meta)
+}
+
+func resourceCloudStackStorageNetworkIpRangeRead(d *schema.ResourceData, meta 
interface{}) error {
+       cs := meta.(*cloudstack.CloudStackClient)
+
+       r, count, err := cs.Network.GetStorageNetworkIpRangeByID(d.Id())
+       if err != nil {
+               if count == 0 {
+                       log.Printf("[DEBUG] Storage network IP range %s does no 
longer exist", d.Id())

Review Comment:
   Skipping cause of nit.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to