4.12.2
4.12.2
This commit is contained in:
@@ -89,7 +89,7 @@ func flattenRecordExtnet(d *schema.ResourceData, recNet *extnet.RecordExtNet) {
|
||||
d.Set("ipcidr", recNet.IPCIDR)
|
||||
d.Set("milestones", recNet.Milestones)
|
||||
d.Set("name", recNet.Name)
|
||||
d.Set("network_ids", recNet.NetworkIDs)
|
||||
d.Set("network_ids", flattenNetworkIDs(recNet.NetworkIDs))
|
||||
d.Set("ntp", recNet.NTP)
|
||||
d.Set("ovs_bridge", recNet.OVSBridge)
|
||||
d.Set("pre_reservations_num", recNet.PreReservationsNum)
|
||||
@@ -142,9 +142,13 @@ func flattenRecordExtnetResource(d *schema.ResourceData, recNet *extnet.RecordEx
|
||||
d.Set("default_qos", flattenExtnetDefaultQos(recNet.DefaultQOS))
|
||||
d.Set("vnfs", flattenExtnetVNFS(recNet.VNFs))
|
||||
d.Set("reservations", flattenExtnetReservations(recNet.Reservations))
|
||||
d.Set("pre_reservations", flattenExtnetReservations(recNet.PreReservations))
|
||||
d.Set("routes", flattenStaticRouteList(staticRouteList))
|
||||
d.Set("zone_id", recNet.ZoneID)
|
||||
d.Set("enable_secgroups", recNet.EnableSecGroups)
|
||||
d.Set("sec_vnfdev_id", recNet.SecVNFDevID)
|
||||
d.Set("highly_available", recNet.Redundant)
|
||||
d.Set("mtu", recNet.MTU)
|
||||
}
|
||||
|
||||
func flattenExtnetExcluded(ers extnet.ListReservations) []map[string]interface{} {
|
||||
|
||||
@@ -35,6 +35,8 @@ package extnet
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net"
|
||||
"strconv"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||
@@ -65,6 +67,19 @@ func resourceExtnetCreate(ctx context.Context, d *schema.ResourceData, m interfa
|
||||
VLANID: uint64(d.Get("vlan_id").(int)),
|
||||
}
|
||||
|
||||
var diags diag.Diagnostics
|
||||
|
||||
if _, ipNet, err := net.ParseCIDR(req.IPCIDR); err == nil {
|
||||
normalized := ipNet.String()
|
||||
if normalized != req.IPCIDR {
|
||||
diags = append(diags, diag.Diagnostic{
|
||||
Severity: diag.Warning,
|
||||
Summary: "ipcidr will be normalized by the platform",
|
||||
Detail: fmt.Sprintf("CIDR will be: %q", normalized),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
if gateway, ok := d.GetOk("gateway"); ok {
|
||||
req.Gateway = gateway.(string)
|
||||
}
|
||||
@@ -132,6 +147,10 @@ func resourceExtnetCreate(ctx context.Context, d *schema.ResourceData, m interfa
|
||||
req.SecVNFDevIP = sec_vnfdev_ip.(string)
|
||||
}
|
||||
|
||||
if vnfdev_ip, ok := d.GetOk("vnfdev_ip"); ok {
|
||||
req.PriVNFDevIP = vnfdev_ip.(string)
|
||||
}
|
||||
|
||||
if mtu, ok := d.GetOk("mtu"); ok {
|
||||
req.MTU = uint(mtu.(int))
|
||||
}
|
||||
@@ -170,12 +189,12 @@ func resourceExtnetCreate(ctx context.Context, d *schema.ResourceData, m interfa
|
||||
|
||||
if d.Get("shared_with").(*schema.Set).Len() > 0 {
|
||||
for _, id := range d.Get("shared_with").(*schema.Set).List() {
|
||||
req := extnet.AccessRemoveRequest{
|
||||
req := extnet.AccessAddRequest{
|
||||
NetID: uint64(d.Get("extnet_id").(int)),
|
||||
AccountID: uint64(id.(int)),
|
||||
}
|
||||
|
||||
_, err := c.CloudBroker().ExtNet().AccessRemove(ctx, req)
|
||||
_, err := c.CloudBroker().ExtNet().AccessAdd(ctx, req)
|
||||
if err != nil {
|
||||
w.Add(err)
|
||||
}
|
||||
@@ -208,6 +227,12 @@ func resourceExtnetCreate(ctx context.Context, d *schema.ResourceData, m interfa
|
||||
}
|
||||
}
|
||||
|
||||
if qos, ok := d.GetOk("default_qos"); ok && len(qos.([]interface{})) > 0 {
|
||||
if err := handleDefaultQOSUpdate(ctx, d, c, &extnet.RecordExtNet{ID: netID}); err != nil {
|
||||
w.Add(err)
|
||||
}
|
||||
}
|
||||
|
||||
// for reserve IP extnet must be enabled
|
||||
if d.Get("reserved_ip").(*schema.Set).Len() > 0 {
|
||||
for _, reservedIP := range d.Get("reserved_ip").(*schema.Set).List() {
|
||||
@@ -236,7 +261,9 @@ func resourceExtnetCreate(ctx context.Context, d *schema.ResourceData, m interfa
|
||||
}
|
||||
}
|
||||
|
||||
return resourceExtnetRead(ctx, d, m)
|
||||
diags = append(diags, w.Get()...)
|
||||
|
||||
return append(diags, resourceExtnetRead(ctx, d, m)...)
|
||||
}
|
||||
|
||||
func resourceExtnetRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package extnet
|
||||
|
||||
import (
|
||||
"net"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
|
||||
)
|
||||
@@ -690,7 +692,15 @@ func resourceExtnetSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
// ForceNew: true,
|
||||
Description: "IP network CIDR",
|
||||
Description: "IP network CIDR",
|
||||
ValidateFunc: validation.IsCIDR,
|
||||
DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
|
||||
_, ipnet, err := net.ParseCIDR(new)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
return old == ipnet.String()
|
||||
},
|
||||
},
|
||||
"vlan_id": {
|
||||
Type: schema.TypeInt,
|
||||
@@ -699,10 +709,11 @@ func resourceExtnetSchemaMake() map[string]*schema.Schema {
|
||||
Description: "VLAN ID",
|
||||
},
|
||||
"gateway": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Description: "External network gateway IP address",
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Description: "External network gateway IP address",
|
||||
ValidateFunc: validation.IsIPAddress,
|
||||
},
|
||||
"zone_id": {
|
||||
Type: schema.TypeInt,
|
||||
@@ -720,7 +731,8 @@ func resourceExtnetSchemaMake() map[string]*schema.Schema {
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Type: schema.TypeString,
|
||||
ValidateFunc: validation.IsIPAddress,
|
||||
},
|
||||
Description: "List of DNS addresses",
|
||||
},
|
||||
@@ -729,7 +741,8 @@ func resourceExtnetSchemaMake() map[string]*schema.Schema {
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Type: schema.TypeString,
|
||||
ValidateFunc: validation.IsIPAddress,
|
||||
},
|
||||
Description: "List of NTP addresses",
|
||||
},
|
||||
@@ -738,7 +751,8 @@ func resourceExtnetSchemaMake() map[string]*schema.Schema {
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Type: schema.TypeString,
|
||||
ValidateFunc: validation.IsIPAddress,
|
||||
},
|
||||
Description: "IPs to check network availability",
|
||||
},
|
||||
@@ -754,19 +768,22 @@ func resourceExtnetSchemaMake() map[string]*schema.Schema {
|
||||
Description: "Optional description",
|
||||
},
|
||||
"start_ip": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Start of IP range to be explicitly included",
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Start of IP range to be explicitly included",
|
||||
ValidateFunc: validation.IsIPAddress,
|
||||
},
|
||||
"end_ip": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "End of IP range to be explicitly included",
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "End of IP range to be explicitly included",
|
||||
ValidateFunc: validation.IsIPAddress,
|
||||
},
|
||||
"vnfdev_ip": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "IP to create VNFDev with",
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "IP to create VNFDev with",
|
||||
ValidateFunc: validation.IsIPAddress,
|
||||
},
|
||||
"pre_reservations_num": {
|
||||
Type: schema.TypeInt,
|
||||
@@ -796,7 +813,8 @@ func resourceExtnetSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeSet,
|
||||
Optional: true,
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Type: schema.TypeString,
|
||||
ValidateFunc: validation.IsIPAddress,
|
||||
},
|
||||
Description: "IPs to exclude in current extnet pool",
|
||||
},
|
||||
@@ -806,12 +824,14 @@ func resourceExtnetSchemaMake() map[string]*schema.Schema {
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"ip_start": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ValidateFunc: validation.IsIPAddress,
|
||||
},
|
||||
"ip_end": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ValidateFunc: validation.IsIPAddress,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -881,7 +901,8 @@ func resourceExtnetSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeSet,
|
||||
Optional: true,
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Type: schema.TypeString,
|
||||
ValidateFunc: validation.IsIPAddress,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -893,9 +914,10 @@ func resourceExtnetSchemaMake() map[string]*schema.Schema {
|
||||
Computed: true,
|
||||
},
|
||||
"sec_vnfdev_ip": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
ValidateFunc: validation.IsIPAddress,
|
||||
},
|
||||
"mtu": {
|
||||
Type: schema.TypeInt,
|
||||
@@ -954,6 +976,10 @@ func resourceExtnetSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"sec_vnfdev_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"status": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
@@ -979,6 +1005,10 @@ func resourceExtnetSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"desc": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"domain_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
@@ -1014,6 +1044,50 @@ func resourceExtnetSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"pre_reservations": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"account_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"client_type": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"domain_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"hostname": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"desc": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"ip": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"mac": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"type": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"vm_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"routes": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
|
||||
Reference in New Issue
Block a user