This commit is contained in:
2025-11-18 16:20:26 +03:00
parent 4b3f21d9be
commit e42fbcef39
397 changed files with 17560 additions and 1501 deletions

View File

@@ -113,6 +113,7 @@ func flattenVinsData(d *schema.ResourceData, vinsRecord *vins.RecordVINS) {
d.Set("vxlan_id", vinsRecord.VXLANID)
d.Set("computes", flattenComputes(vinsRecord.Computes))
d.Set("zone_id", vinsRecord.ZoneID)
d.Set("enable_secgroups", vinsRecord.EnableSecGroups)
}
@@ -134,26 +135,28 @@ func flattenLibvirtSettings(libvirtSettings vins.LibvirtSettings) []map[string]i
func flattenVinsVNFDev(vd vins.VNFDev) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
temp := map[string]interface{}{
"ckey": vd.CKey,
"meta": flattens.FlattenMeta(vd.Meta),
"account_id": vd.AccountID,
"capabilities": vd.Capabilities,
"config": flattenVinsConfig(vd.Config),
"config_saved": vd.ConfigSaved,
"custom_precfg": vd.CustomPreConfig,
"description": vd.Description,
"gid": vd.GID,
"guid": vd.GUID,
"id": vd.ID,
"interfaces": flattenVinsListInterfaces(vd.Interfaces),
"lock_status": vd.LockStatus,
"milestones": vd.Milestones,
"name": vd.Name,
"status": vd.Status,
"tech_status": vd.TechStatus,
"type": vd.Type,
"vnc_password": vd.VNCPassword,
"vins": vd.VINS,
"ckey": vd.CKey,
"meta": flattens.FlattenMeta(vd.Meta),
"account_id": vd.AccountID,
"capabilities": vd.Capabilities,
"config": flattenVinsConfig(vd.Config),
"config_saved": vd.ConfigSaved,
"custom_precfg": vd.CustomPreConfig,
"description": vd.Description,
"gid": vd.GID,
"guid": vd.GUID,
"id": vd.ID,
"interfaces": flattenVinsListInterfaces(vd.Interfaces),
"live_migration_job_id": vd.LiveMigrationJobID,
"lock_status": vd.LockStatus,
"milestones": vd.Milestones,
"name": vd.Name,
"status": vd.Status,
"tech_status": vd.TechStatus,
"type": vd.Type,
"vnc_password": vd.VNCPassword,
"vins": vd.VINS,
"zone_id": vd.ZoneID,
}
res = append(res, temp)
return res
@@ -203,6 +206,7 @@ func flattenVinsRecordDHCP(rv vins.RecordDHCP) []map[string]interface{} {
"status": rv.Status,
"tech_status": rv.TechStatus,
"type": rv.Type,
"zone_id": rv.ZoneID,
}
res = append(res, temp)
return res
@@ -225,9 +229,11 @@ func flattenVinsRecordGW(rg vins.RecordGW) []map[string]interface{} {
"owner_id": rg.OwnerID,
"owner_type": rg.OwnerType,
"pure_virtual": rg.PureVirtual,
"routes": flattenVinsRoutes(rg.Routes),
"status": rg.Status,
"tech_status": rg.TechStatus,
"type": rg.Type,
"zone_id": rg.ZoneID,
}
res = append(res, temp)
return res
@@ -250,9 +256,11 @@ func flattenVinsRecordNAT(rn vins.RecordNAT) []map[string]interface{} {
"owner_id": rn.OwnerID,
"owner_type": rn.OwnerType,
"pure_virtual": rn.PureVirtual,
"routes": flattenVinsRoutes(rn.Routes),
"status": rn.Status,
"tech_status": rn.TechStatus,
"type": rn.Type,
"zone_id": rn.ZoneID,
}
res = append(res, temp)
return res
@@ -425,6 +433,7 @@ func flattenVinsListInterfaces(i vins.ListInterfaces) []map[string]interface{} {
"conn_type": v.ConnType,
"def_gw": v.DefGW,
"enabled": v.Enabled,
"enable_secgroups": v.EnableSecGroups,
"flipgroup_id": v.FLIPGroupID,
"guid": v.GUID,
"ip_address": v.IPAddress,
@@ -439,6 +448,7 @@ func flattenVinsListInterfaces(i vins.ListInterfaces) []map[string]interface{} {
"pci_slot": v.PCISlot,
"bus_number": v.BusNumber,
"qos": flattenVinsQOS(v.QOS),
"security_groups": v.SecGroups,
"sdn_interface_id": v.SDNInterfaceID,
"target": v.Target,
"type": v.Type,
@@ -463,6 +473,7 @@ func flattenVinsList(vl *vins.ListVINS) []map[string]interface{} {
"deleted_by": v.DeletedBy,
"deleted_time": v.DeletedTime,
"description": v.Description,
"enable_secgroups": v.EnableSecGroups,
"external_ip": v.ExternalIP,
"extnet_id": v.ExtnetId,
"free_ips": v.FreeIPs,

View File

@@ -115,6 +115,12 @@ func resourceVinsCreate(ctx context.Context, d *schema.ResourceData, m interface
}
}
if d.Get("enable_secgroups").(bool) {
if err := resourceVinsEnableSecgroups(ctx, d, m, vinsID); err != nil {
warnings.Add(err)
}
}
return append(warnings.Get(), resourceVinsRead(ctx, d, m)...)
}
@@ -257,6 +263,13 @@ func resourceVinsUpdate(ctx context.Context, d *schema.ResourceData, m interface
}
}
if d.HasChanges("name", "desc", "enable_secgroups") {
vinsID := uint64(d.Get("vins_id").(int))
if err := utilityUpdateVINS(ctx, d, m, vinsID); err != nil {
return diag.FromErr(err)
}
}
if d.HasChange("enable") {
if err := resourceVinsChangeEnabled(ctx, d, m); err != nil {
warnings.Add(err)
@@ -424,6 +437,21 @@ func resourceVinsIpReserve(ctx context.Context, d *schema.ResourceData, m interf
return errs
}
func resourceVinsEnableSecgroups(ctx context.Context, d *schema.ResourceData, m interface{}, vinsID uint64) error {
c := m.(*controller.ControllerCfg)
req := vins.UpdateRequest{
VINSID: vinsID,
EnableSecGroups: true,
}
_, err := c.CloudBroker().VINS().Update(ctx, req)
if err != nil {
return err
}
return nil
}
func resourceVinsNatRuleAdd(ctx context.Context, d *schema.ResourceData, m interface{}, vinsId uint64) []error {
var errs []error
c := m.(*controller.ControllerCfg)

View File

@@ -166,6 +166,10 @@ func dataSourceVinsSchemaMake() map[string]*schema.Schema {
Computed: true,
Description: "enabled",
},
"enable_secgroups": {
Type: schema.TypeBool,
Computed: true,
},
"flipgroup_id": {
Type: schema.TypeInt,
Computed: true,
@@ -294,6 +298,13 @@ func dataSourceVinsSchemaMake() map[string]*schema.Schema {
Type: schema.TypeString,
Computed: true,
},
"security_groups": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
},
},
"target": {
Type: schema.TypeString,
Computed: true,
@@ -315,6 +326,10 @@ func dataSourceVinsSchemaMake() map[string]*schema.Schema {
},
},
},
"live_migration_job_id": {
Type: schema.TypeInt,
Computed: true,
},
"lock_status": {
Type: schema.TypeString,
Computed: true,
@@ -357,6 +372,10 @@ func dataSourceVinsSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
},
},
"zone_id": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
@@ -756,6 +775,10 @@ func dataSourceVinsSchemaMake() map[string]*schema.Schema {
Computed: true,
Description: "type",
},
"zone_id": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
@@ -911,6 +934,42 @@ func dataSourceVinsSchemaMake() map[string]*schema.Schema {
Computed: true,
Description: "pure virtual",
},
"routes": {
Type: schema.TypeList,
Computed: true,
Description: "routes",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"compute_ids": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
},
},
"route_id": {
Type: schema.TypeInt,
Computed: true,
},
"guid": {
Type: schema.TypeString,
Computed: true,
},
"destination": {
Type: schema.TypeString,
Computed: true,
},
"netmask": {
Type: schema.TypeString,
Computed: true,
},
"gateway": {
Type: schema.TypeString,
Computed: true,
},
},
},
},
"status": {
Type: schema.TypeString,
Computed: true,
@@ -926,6 +985,10 @@ func dataSourceVinsSchemaMake() map[string]*schema.Schema {
Computed: true,
Description: "type",
},
"zone_id": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
@@ -1095,6 +1158,42 @@ func dataSourceVinsSchemaMake() map[string]*schema.Schema {
Computed: true,
Description: "pure virtual",
},
"routes": {
Type: schema.TypeList,
Computed: true,
Description: "routes",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"compute_ids": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
},
},
"route_id": {
Type: schema.TypeInt,
Computed: true,
},
"guid": {
Type: schema.TypeString,
Computed: true,
},
"destination": {
Type: schema.TypeString,
Computed: true,
},
"netmask": {
Type: schema.TypeString,
Computed: true,
},
"gateway": {
Type: schema.TypeString,
Computed: true,
},
},
},
},
"status": {
Type: schema.TypeString,
Computed: true,
@@ -1110,6 +1209,10 @@ func dataSourceVinsSchemaMake() map[string]*schema.Schema {
Computed: true,
Description: "type",
},
"zone_id": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
@@ -1188,6 +1291,11 @@ func dataSourceVinsListSchemaMake() map[string]*schema.Schema {
Optional: true,
Description: "Page size",
},
"zone_id": {
Type: schema.TypeInt,
Optional: true,
Description: "Zone ID",
},
"items": {
Type: schema.TypeList,
Computed: true,
@@ -1249,6 +1357,10 @@ func dataSourceVinsListSchemaMake() map[string]*schema.Schema {
Type: schema.TypeString,
Computed: true,
},
"enable_secgroups": {
Type: schema.TypeBool,
Computed: true,
},
"external_ip": {
Type: schema.TypeString,
Computed: true,
@@ -1386,7 +1498,7 @@ func dataSourceVinsListSchemaMake() map[string]*schema.Schema {
},
"entry_count": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
Description: "entry count",
},
}
@@ -1898,6 +2010,12 @@ func resourceVinsSchemaMake() map[string]*schema.Schema {
Computed: true,
Description: "zone id",
},
"enable_secgroups": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: "enable security groups",
},
"gid": {
Type: schema.TypeInt,
Optional: true,
@@ -2276,6 +2394,10 @@ func resourceVinsSchemaMake() map[string]*schema.Schema {
Computed: true,
Description: "enabled",
},
"enable_secgroups": {
Type: schema.TypeBool,
Computed: true,
},
"flipgroup_id": {
Type: schema.TypeInt,
Computed: true,
@@ -2372,9 +2494,8 @@ func resourceVinsSchemaMake() map[string]*schema.Schema {
Description: "pci slot",
},
"bus_number": {
Type: schema.TypeInt,
Computed: true,
Description: "bus number",
Type: schema.TypeInt,
Computed: true,
},
"qos": {
Type: schema.TypeList,
@@ -2401,6 +2522,17 @@ func resourceVinsSchemaMake() map[string]*schema.Schema {
},
},
},
"sdn_interface_id": {
Type: schema.TypeString,
Computed: true,
},
"security_groups": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
},
},
"target": {
Type: schema.TypeString,
Computed: true,
@@ -2422,6 +2554,10 @@ func resourceVinsSchemaMake() map[string]*schema.Schema {
},
},
},
"live_migration_job_id": {
Type: schema.TypeInt,
Computed: true,
},
"lock_status": {
Type: schema.TypeString,
Computed: true,
@@ -2464,6 +2600,10 @@ func resourceVinsSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
},
},
"zone_id": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
@@ -2751,6 +2891,47 @@ func resourceVinsSchemaMake() map[string]*schema.Schema {
Computed: true,
Description: "prune virtual",
},
"routes": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"compute_ids": {
Type: schema.TypeList,
Computed: true,
Description: "compute ids",
Elem: &schema.Schema{
Type: schema.TypeInt,
},
},
"route_id": {
Type: schema.TypeInt,
Computed: true,
Description: "route id",
},
"guid": {
Type: schema.TypeString,
Computed: true,
Description: "guid",
},
"destination": {
Type: schema.TypeString,
Computed: true,
Description: "destination",
},
"netmask": {
Type: schema.TypeString,
Computed: true,
Description: "net mask",
},
"gateway": {
Type: schema.TypeString,
Computed: true,
Description: "gateway",
},
},
},
},
"status": {
Type: schema.TypeString,
Computed: true,
@@ -2766,6 +2947,10 @@ func resourceVinsSchemaMake() map[string]*schema.Schema {
Computed: true,
Description: "type",
},
"zone_id": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
@@ -2921,6 +3106,42 @@ func resourceVinsSchemaMake() map[string]*schema.Schema {
Computed: true,
Description: "pure virtual",
},
"routes": {
Type: schema.TypeList,
Computed: true,
Description: "routes",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"compute_ids": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
},
},
"route_id": {
Type: schema.TypeInt,
Computed: true,
},
"guid": {
Type: schema.TypeString,
Computed: true,
},
"destination": {
Type: schema.TypeString,
Computed: true,
},
"netmask": {
Type: schema.TypeString,
Computed: true,
},
"gateway": {
Type: schema.TypeString,
Computed: true,
},
},
},
},
"status": {
Type: schema.TypeString,
Computed: true,
@@ -2936,6 +3157,10 @@ func resourceVinsSchemaMake() map[string]*schema.Schema {
Computed: true,
Description: "type",
},
"zone_id": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
@@ -3105,6 +3330,42 @@ func resourceVinsSchemaMake() map[string]*schema.Schema {
Computed: true,
Description: "pure virtual",
},
"routes": {
Type: schema.TypeList,
Computed: true,
Description: "routes",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"compute_ids": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
},
},
"route_id": {
Type: schema.TypeInt,
Computed: true,
},
"guid": {
Type: schema.TypeString,
Computed: true,
},
"destination": {
Type: schema.TypeString,
Computed: true,
},
"netmask": {
Type: schema.TypeString,
Computed: true,
},
"gateway": {
Type: schema.TypeString,
Computed: true,
},
},
},
},
"status": {
Type: schema.TypeString,
Computed: true,
@@ -3120,6 +3381,10 @@ func resourceVinsSchemaMake() map[string]*schema.Schema {
Computed: true,
Description: "type",
},
"zone_id": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},

View File

@@ -63,3 +63,27 @@ func utilityVinsCheckPresence(ctx context.Context, d *schema.ResourceData, m int
return vins, nil
}
func utilityUpdateVINS(ctx context.Context, d *schema.ResourceData, m interface{}, vinsID uint64) error {
c := m.(*controller.ControllerCfg)
req := vins.UpdateRequest{
VINSID: vinsID,
}
if d.HasChange("name") {
req.Name = d.Get("name").(string)
}
if d.HasChange("desc") {
req.Desc = d.Get("desc").(string)
}
if d.HasChange("enable_secgroups") {
req.EnableSecGroups = d.Get("enable_secgroups").(bool)
}
_, err := c.CloudBroker().VINS().Update(ctx, req)
if err != nil {
return err
}
return nil
}

View File

@@ -78,6 +78,9 @@ func utilityVinsListCheckPresence(ctx context.Context, d *schema.ResourceData, m
if includeDeleted, ok := d.GetOk("include_deleted"); ok {
req.IncludeDeleted = includeDeleted.(bool)
}
if zoneID, ok := d.GetOk("zone_id"); ok {
req.ZoneID = uint64(zoneID.(int))
}
log.Debugf("utilityVinsListCheckPresence")
vinsList, err := c.CloudBroker().VINS().List(ctx, req)