4.12.0
This commit is contained in:
@@ -202,6 +202,10 @@ func DataSourceResgroup() *schema.Resource {
|
||||
|
||||
func aclSchemaMake() map[string]*schema.Schema {
|
||||
res := map[string]*schema.Schema{
|
||||
"email": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"explicit": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
|
||||
@@ -269,6 +269,7 @@ func flattenRgAcl(rgAcls rg.ListACL) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0, len(rgAcls))
|
||||
for _, rgAcl := range rgAcls {
|
||||
temp := map[string]interface{}{
|
||||
"email": rgAcl.Email,
|
||||
"explicit": rgAcl.Explicit,
|
||||
"guid": rgAcl.GUID,
|
||||
"right": rgAcl.Right,
|
||||
|
||||
@@ -130,6 +130,9 @@ func resourceResgroupCreate(ctx context.Context, d *schema.ResourceData, m inter
|
||||
}
|
||||
if _, ok := d.GetOk("def_net"); !ok {
|
||||
if defNetType, ok := d.GetOk("def_net_type"); ok {
|
||||
if defNetType.(string) == "PRIVATE" {
|
||||
return diag.Errorf("resourceResgroupCreate: cannot create RG with def_net_type=\"PRIVATE\": no ViNSes exist in a newly created RG. Use def_net_type=\"PRIVATE\" only when updating an existing RG that already contains a ViNS")
|
||||
}
|
||||
req.DefNet = defNetType.(string) // NOTE: in API default network type is set by "def_net" parameter
|
||||
}
|
||||
} else {
|
||||
@@ -220,6 +223,10 @@ func resourceResgroupCreate(ctx context.Context, d *schema.ResourceData, m inter
|
||||
|
||||
netType := defNetItem["net_type"].(string)
|
||||
|
||||
if netType == "PRIVATE" {
|
||||
return diag.Errorf("resourceResgroupCreate: cannot create RG with def_net net_type=\"PRIVATE\": no ViNSes exist in a newly created RG. Use net_type=\"PRIVATE\" in def_net block only when updating an existing RG that already contains a ViNS")
|
||||
}
|
||||
|
||||
req := rg.SetDefNetRequest{
|
||||
RGID: apiResp,
|
||||
NetType: netType,
|
||||
@@ -504,14 +511,31 @@ func resourceResgroupUpdate(ctx context.Context, d *schema.ResourceData, m inter
|
||||
for _, changedDefNetInterface := range changedDefNet {
|
||||
defNetItem := changedDefNetInterface.(map[string]interface{})
|
||||
netType := defNetItem["net_type"].(string)
|
||||
netID := uint64(defNetItem["net_id"].(int))
|
||||
|
||||
if netType == "PRIVATE" {
|
||||
if netID == 0 {
|
||||
if len(rgData.VINS) == 0 {
|
||||
return diag.Errorf("resourceResgroupUpdate: cannot set def_net net_type=\"PRIVATE\" for RG ID %d: no ViNSes exist in this RG.", rgData.ID)
|
||||
}
|
||||
} else {
|
||||
found := false
|
||||
for _, vinsID := range rgData.VINS {
|
||||
if vinsID == netID {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
return diag.Errorf("resourceResgroupUpdate: cannot set def_net net_type=\"PRIVATE\" for RG ID %d: ViNS ID %d is not found in this RG.", rgData.ID, netID)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
req := rg.SetDefNetRequest{
|
||||
RGID: rgData.ID,
|
||||
NetType: netType,
|
||||
}
|
||||
|
||||
if netID, ok := defNetItem["net_id"]; ok {
|
||||
req.NetID = uint64(netID.(int))
|
||||
NetID: netID,
|
||||
}
|
||||
|
||||
_, err := c.CloudAPI().RG().SetDefNet(ctx, req)
|
||||
|
||||
Reference in New Issue
Block a user