bhouse-nexthop commented on code in PR #282:
URL: 
https://github.com/apache/cloudstack-terraform-provider/pull/282#discussion_r2912482625


##########
cloudstack/resource_cloudstack_network.go:
##########
@@ -471,3 +536,61 @@ func parseCIDR(d *schema.ResourceData, specifyiprange 
bool) (map[string]string,
 
        return m, nil
 }
+
+func parseCIDRv6(d *schema.ResourceData, specifyiprange bool) 
(map[string]string, error) {
+       m := make(map[string]string, 4)
+
+       cidr := d.Get("ip6cidr").(string)
+       _, ipnet, err := net.ParseCIDR(cidr)
+       if err != nil {
+               return nil, fmt.Errorf("Unable to parse cidr %s: %s", cidr, err)
+       }
+
+       if gateway, ok := d.GetOk("ip6gateway"); ok {
+               m["ip6gateway"] = gateway.(string)
+       } else {
+               // Default gateway to network address + 1 (e.g., 2001:db8::1)
+               ip16 := ipnet.IP.To16()
+               if ip16 == nil {
+                       return nil, fmt.Errorf("cidr not valid for ipv6")
+               }
+               gwip := make(net.IP, len(ip16))
+               copy(gwip, ip16)
+               gwip[len(ip16)-1] = 1
+               m["ip6gateway"] = gwip.String()
+       }
+
+       if startipv6, ok := d.GetOk("startipv6"); ok {
+               m["startipv6"] = startipv6.(string)
+       } else if specifyiprange {
+               ip16 := ipnet.IP.To16()
+               if ip16 == nil {
+                       return nil, fmt.Errorf("cidr not valid for ipv6")
+               }
+
+               myip := make(net.IP, len(ip16))
+               copy(myip, ip16)
+               myip[len(ip16)-1] = 2
+               m["startipv6"] = myip.String()
+       }

Review Comment:
   fixed in 1645a83



-- 
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