This commit is contained in:
2025-08-04 16:11:16 +03:00
parent bae25296bb
commit 4b3f21d9be
239 changed files with 6585 additions and 784 deletions

View File

@@ -73,6 +73,7 @@ func flattenVins(d *schema.ResourceData, vinsRecord *vins.RecordVINS) {
d.Set("vxlan_id", vinsRecord.VXLANID)
d.Set("nat_rule", flattenRuleBlock(vinsRecord.VNFs.NAT.Config.Rules))
d.Set("computes", flattenComputes(vinsRecord.Computes))
d.Set("zone_id", vinsRecord.ZoneID)
}
func flattenVinsData(d *schema.ResourceData, vinsRecord *vins.RecordVINS) {
@@ -111,6 +112,7 @@ func flattenVinsData(d *schema.ResourceData, vinsRecord *vins.RecordVINS) {
d.Set("vnfs", flattenVinsRecordVNFs(vinsRecord.VNFs))
d.Set("vxlan_id", vinsRecord.VXLANID)
d.Set("computes", flattenComputes(vinsRecord.Computes))
d.Set("zone_id", vinsRecord.ZoneID)
}
@@ -223,7 +225,6 @@ 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,
@@ -249,7 +250,6 @@ 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,
@@ -439,6 +439,7 @@ func flattenVinsListInterfaces(i vins.ListInterfaces) []map[string]interface{} {
"pci_slot": v.PCISlot,
"bus_number": v.BusNumber,
"qos": flattenVinsQOS(v.QOS),
"sdn_interface_id": v.SDNInterfaceID,
"target": v.Target,
"type": v.Type,
"vnfs": v.VNFs,
@@ -487,6 +488,7 @@ func flattenVinsList(vl *vins.ListVINS) []map[string]interface{} {
"user_managed": v.UserManaged,
"vnfs": flattenVinsVNFs(v.VNFs),
"vxlan_id": v.VXLANID,
"zone_id": v.ZoneID,
}
res = append(res, temp)
}
@@ -529,6 +531,7 @@ func flattenVinsListDeleted(vl *vins.ListVINS) []map[string]interface{} {
"user_managed": v.UserManaged,
"vnfs": flattenVinsVNFs(v.VNFs),
"vxlan_id": v.VXLANID,
"zone_id": v.ZoneID,
}
res = append(res, temp)
}

View File

@@ -84,6 +84,10 @@ func createVinsInAcc(ctx context.Context, d *schema.ResourceData, m interface{},
}
}
if zoneID, ok := d.GetOk("zone_id"); ok {
req.ZoneID = uint64(zoneID.(int))
}
return req, nil
}
@@ -135,6 +139,10 @@ func createVinsInRG(ctx context.Context, d *schema.ResourceData, m interface{},
}
}
if zoneID, ok := d.GetOk("zone_id"); ok {
req.ZoneID = uint64(zoneID.(int))
}
return req, nil
}

View File

@@ -320,6 +320,12 @@ func resourceVinsUpdate(ctx context.Context, d *schema.ResourceData, m interface
}
}
if d.HasChange("zone_id") {
if err := resourceVinsChangeZoneID(ctx, d, m); err != nil {
warnings.Add(err)
}
}
return append(warnings.Get(), dataSourceVinsRead(ctx, d, m)...)
}
@@ -772,6 +778,21 @@ func resourceVinsChangeVnfStartStop(ctx context.Context, d *schema.ResourceData,
return err
}
func resourceVinsChangeZoneID(ctx context.Context, d *schema.ResourceData, m interface{}) error {
c := m.(*controller.ControllerCfg)
vinsId := uint64(d.Get("vins_id").(int))
zoneID := uint64(d.Get("zone_id").(int))
req := vins.MigrateToZoneRequest{
VINSID: vinsId,
ZoneID: zoneID,
}
_, err := c.CloudBroker().VINS().MigrateToZone(ctx, req)
return err
}
func ResourceVins() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,

View File

@@ -290,6 +290,10 @@ func dataSourceVinsSchemaMake() map[string]*schema.Schema {
},
},
},
"sdn_interface_id": {
Type: schema.TypeString,
Computed: true,
},
"target": {
Type: schema.TypeString,
Computed: true,
@@ -907,42 +911,6 @@ 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,
@@ -1127,42 +1095,6 @@ 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,
@@ -1189,6 +1121,10 @@ func dataSourceVinsSchemaMake() map[string]*schema.Schema {
Computed: true,
Description: "vxlan id",
},
"zone_id": {
Type: schema.TypeInt,
Computed: true,
},
}
return rets
@@ -1441,6 +1377,10 @@ func dataSourceVinsListSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
Computed: true,
},
"zone_id": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
@@ -1681,6 +1621,10 @@ func dataSourceVinsListDeletedSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
Computed: true,
},
"zone_id": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
@@ -1948,6 +1892,12 @@ func resourceVinsSchemaMake() map[string]*schema.Schema {
Optional: true,
Computed: true,
},
"zone_id": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
Description: "zone id",
},
"gid": {
Type: schema.TypeInt,
Optional: true,
@@ -2801,47 +2751,6 @@ 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,
@@ -3012,42 +2921,6 @@ 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,
@@ -3232,42 +3105,6 @@ 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,