This commit is contained in:
2025-05-21 16:38:25 +03:00
parent 2c70109d2d
commit 9e68edb2b9
1034 changed files with 73925 additions and 3187 deletions

View File

@@ -359,7 +359,7 @@ func computeListDisksSchemaMake() map[string]*schema.Schema {
Computed: true,
},
"present_to": {
Type: schema.TypeList,
Type: schema.TypeMap,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
@@ -422,6 +422,10 @@ func computeListDisksSchemaMake() map[string]*schema.Schema {
Type: schema.TypeBool,
Computed: true,
},
"size_available": {
Type: schema.TypeFloat,
Computed: true,
},
"size_max": {
Type: schema.TypeInt,
Computed: true,
@@ -966,10 +970,88 @@ func dataSourceComputeSchemaMake() map[string]*schema.Schema {
Computed: true,
},
"vgpus": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
Type: schema.TypeList,
Computed: true,
Description: "List of virtual GPUs",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"id": {
Type: schema.TypeInt,
Computed: true,
},
"gid": {
Type: schema.TypeInt,
Computed: true,
},
"type": {
Type: schema.TypeString,
Computed: true,
},
"mode": {
Type: schema.TypeString,
Computed: true,
},
"status": {
Type: schema.TypeString,
Computed: true,
},
"profile_id": {
Type: schema.TypeInt,
Computed: true,
},
"ram": {
Type: schema.TypeInt,
Computed: true,
},
"last_update_time": {
Type: schema.TypeInt,
Computed: true,
},
"created_time": {
Type: schema.TypeInt,
Computed: true,
},
"deleted_time": {
Type: schema.TypeInt,
Computed: true,
},
"vmid": {
Type: schema.TypeInt,
Computed: true,
},
"pgpuid": {
Type: schema.TypeInt,
Computed: true,
},
"reference_id": {
Type: schema.TypeString,
Computed: true,
},
"account_id": {
Type: schema.TypeInt,
Computed: true,
},
"rg_id": {
Type: schema.TypeInt,
Computed: true,
},
"last_claimed_by": {
Type: schema.TypeInt,
Computed: true,
},
"pci_slot": {
Type: schema.TypeInt,
Computed: true,
},
"bus_number": {
Type: schema.TypeInt,
Computed: true,
},
"guid": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
"virtual_image_id": {
@@ -988,6 +1070,22 @@ func dataSourceComputeSchemaMake() map[string]*schema.Schema {
Type: schema.TypeString,
Computed: true,
},
"loader_type": {
Type: schema.TypeString,
Computed: true,
},
"boot_type": {
Type: schema.TypeString,
Computed: true,
},
"hot_resize": {
Type: schema.TypeBool,
Computed: true,
},
"network_interface_naming": {
Type: schema.TypeString,
Computed: true,
},
}
}

View File

@@ -381,6 +381,22 @@ func itemComputeSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
Computed: true,
},
"loader_type": {
Type: schema.TypeString,
Computed: true,
},
"boot_type": {
Type: schema.TypeString,
Computed: true,
},
"hot_resize": {
Type: schema.TypeBool,
Computed: true,
},
"network_interface_naming": {
Type: schema.TypeString,
Computed: true,
},
}
}

View File

@@ -47,9 +47,9 @@ func flattenDisks(disks []compute.InfoDisk) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
for _, disk := range disks {
temp := map[string]interface{}{
"bus_number": disk.BusNumber,
"disk_id": disk.ID,
"pci_slot": disk.PCISlot,
// "bus_number": disk.BusNumber,
"disk_id": disk.ID,
// "pci_slot": disk.PCISlot,
}
res = append(res, temp)
}
@@ -217,28 +217,32 @@ func flattenComputeList(computes *compute.ListComputes) []map[string]interface{}
"need_reboot": compute.NeedReboot,
"numa_affinity": compute.NumaAffinity,
"numa_node_id": compute.NumaNodeId,
"pinned": compute.Pinned,
"preferred_cpu": compute.PreferredCPU,
"ram": compute.RAM,
"reference_id": compute.ReferenceID,
"registered": compute.Registered,
"res_name": compute.ResName,
"reserved_node_cpus": compute.ReservedNodeCpus,
"rg_id": compute.RGID,
"rg_name": compute.RGName,
"snap_sets": flattenSnapSets(compute.SnapSets),
"stateless_sep_id": compute.StatelessSepID,
"stateless_sep_type": compute.StatelessSepType,
"status": compute.Status,
"tags": flattenTags(compute.Tags),
"tech_status": compute.TechStatus,
"total_disk_size": compute.TotalDiskSize,
"updated_by": compute.UpdatedBy,
"updated_time": compute.UpdatedTime,
"user_managed": compute.UserManaged,
"vgpus": compute.VGPUs,
"vins_connected": compute.VINSConnected,
"virtual_image_id": compute.VirtualImageID,
// "pinned": compute.Pinned,
"preferred_cpu": compute.PreferredCPU,
"ram": compute.RAM,
"reference_id": compute.ReferenceID,
"registered": compute.Registered,
"res_name": compute.ResName,
"reserved_node_cpus": compute.ReservedNodeCpus,
"rg_id": compute.RGID,
"rg_name": compute.RGName,
"snap_sets": flattenSnapSets(compute.SnapSets),
"stateless_sep_id": compute.StatelessSepID,
"stateless_sep_type": compute.StatelessSepType,
"status": compute.Status,
"tags": flattenTags(compute.Tags),
"tech_status": compute.TechStatus,
"total_disk_size": compute.TotalDiskSize,
"updated_by": compute.UpdatedBy,
"updated_time": compute.UpdatedTime,
"user_managed": compute.UserManaged,
"vgpus": compute.VGPUs,
"vins_connected": compute.VINSConnected,
"virtual_image_id": compute.VirtualImageID,
"loader_type": compute.LoaderType,
"boot_type": compute.BootType,
"hot_resize": compute.HotResize,
"network_interface_naming": compute.NetworkInterfaceNaming,
}
res = append(res, temp)
}
@@ -250,17 +254,18 @@ func flattenBootDisk(bootDisk *compute.ItemComputeDisk) []map[string]interface{}
res := make([]map[string]interface{}, 0)
temp := map[string]interface{}{
"disk_name": bootDisk.Name,
"disk_id": bootDisk.ID,
"disk_type": bootDisk.Type,
"sep_id": bootDisk.SepID,
"shareable": bootDisk.Shareable,
"size_max": bootDisk.SizeMax,
"size_used": bootDisk.SizeUsed,
"pool": bootDisk.Pool,
"desc": bootDisk.Description,
"image_id": bootDisk.ImageID,
"size": bootDisk.SizeMax,
"disk_name": bootDisk.Name,
"disk_id": bootDisk.ID,
"disk_type": bootDisk.Type,
"sep_id": bootDisk.SepID,
"shareable": bootDisk.Shareable,
"size_max": bootDisk.SizeMax,
"size_used": bootDisk.SizeUsed,
"pool": bootDisk.Pool,
"desc": bootDisk.Description,
"image_id": bootDisk.ImageID,
"size": bootDisk.SizeMax,
"present_to": bootDisk.PresentTo,
}
res = append(res, temp)
@@ -301,6 +306,7 @@ func flattenComputeDisksDemo(disksList compute.ListComputeDisks, disksBlocks, ex
"image_id": disk.ImageID,
"size": disk.SizeMax,
"permanently": pernamentlyValue,
"present_to": disk.PresentTo,
}
res = append(res, temp)
indexDataDisks++
@@ -415,7 +421,7 @@ func flattenCompute(d *schema.ResourceData, computeRec compute.RecordCompute, pc
if err := d.Set("os_users", parseOsUsers(computeRec.OSUsers)); err != nil {
return err
}
d.Set("pinned", computeRec.Pinned)
// d.Set("pinned", computeRec.Pinned)
d.Set("preferred_cpu", computeRec.PreferredCPU)
d.Set("ram", computeRec.RAM)
d.Set("reference_id", computeRec.ReferenceID)
@@ -434,9 +440,13 @@ func flattenCompute(d *schema.ResourceData, computeRec compute.RecordCompute, pc
d.Set("updated_time", computeRec.UpdatedTime)
d.Set("user_managed", computeRec.UserManaged)
d.Set("vnc_password", computeRec.VNCPassword)
d.Set("vgpus", computeRec.VGPUs)
d.Set("vgpus", flattenVGPUs(computeRec.VGPUs))
d.Set("virtual_image_id", computeRec.VirtualImageID)
d.Set("virtual_image_name", computeRec.VirtualImageName)
d.Set("loader_type", computeRec.LoaderType)
d.Set("boot_type", computeRec.BootType)
d.Set("hot_resize", computeRec.HotResize)
d.Set("network_interface_naming", computeRec.NetworkInterfaceNaming)
d.Set("enabled", false)
if computeRec.Status == status.Enabled {
@@ -561,6 +571,7 @@ func flattenListComputeDisks(disks compute.ListComputeDisks) []map[string]interf
"role": disk.Role,
"sep_id": disk.SepID,
"shareable": disk.Shareable,
"size_available": disk.SizeAvailable,
"size_max": disk.SizeMax,
"size_used": disk.SizeUsed,
"snapshots": flattenSnapshots(disk.Snapshots),
@@ -660,7 +671,7 @@ func flattenDataCompute(d *schema.ResourceData, computeRec compute.RecordCompute
d.Set("natable_vins_network", computeRec.NatableVINSNetwork)
d.Set("natable_vins_network_name", computeRec.NatableVINSNetworkName)
d.Set("os_users", flattenOsUsers(computeRec.OSUsers))
d.Set("pinned", computeRec.Pinned)
// d.Set("pinned", computeRec.Pinned)
d.Set("preferred_CPU", computeRec.PreferredCPU)
d.Set("ram", computeRec.RAM)
d.Set("reference_id", computeRec.ReferenceID)
@@ -680,10 +691,14 @@ func flattenDataCompute(d *schema.ResourceData, computeRec compute.RecordCompute
d.Set("user_managed", computeRec.UserManaged)
d.Set("userdata", string(userdata))
d.Set("vnc_password", computeRec.VNCPassword)
d.Set("vgpus", computeRec.VGPUs)
d.Set("vgpus", flattenVGPUs(computeRec.VGPUs))
d.Set("virtual_image_id", computeRec.VirtualImageID)
d.Set("virtual_image_name", computeRec.VirtualImageName)
d.Set("pci_devices", flattenPCI(*pciList))
d.Set("loader_type", computeRec.LoaderType)
d.Set("boot_type", computeRec.BootType)
d.Set("hot_resize", computeRec.HotResize)
d.Set("network_interface_naming", computeRec.NetworkInterfaceNaming)
}
func flattenPCI(pciList compute.ListPCIDevices) []uint64 {
@@ -821,3 +836,34 @@ func flattenPCIDevice(deviceList []compute.ItemPCIDevice) []map[string]interface
}
return res
}
func flattenVGPUs(vgpus []compute.VGPUItem) []map[string]interface{} {
res := make([]map[string]interface{}, len(vgpus))
for i, vgpu := range vgpus {
res[i] = map[string]interface{}{
"id": int(vgpu.ID),
"gid": int(vgpu.GID),
"type": vgpu.Type,
"mode": vgpu.Mode,
"status": vgpu.Status,
"profile_id": vgpu.ProfileID,
"ram": int(vgpu.RAM),
"last_update_time": int(vgpu.LastUpdateTime),
"created_time": int(vgpu.CreatedTime),
"deleted_time": int(vgpu.DeletedTime),
"vmid": int(vgpu.VMID),
"pgpuid": int(vgpu.PGPuid),
"reference_id": vgpu.ReferenceID,
"account_id": int(vgpu.AccountID),
"rg_id": int(vgpu.RgID),
"last_claimed_by": int(vgpu.LastClaimedBy),
"pci_slot": int(vgpu.PCISlot),
"bus_number": int(vgpu.BusNumber),
"guid": int(vgpu.GUID),
}
}
return res
}

View File

@@ -147,9 +147,11 @@ func networkSubresourceSchemaMake() map[string]*schema.Schema {
},
"mac": {
Type: schema.TypeString,
Computed: true,
Description: "MAC address associated with this connection. MAC address is assigned automatically.",
Type: schema.TypeString,
Optional: true,
Computed: true,
DiffSuppressFunc: networkSubresIPAddreDiffSupperss,
Description: "MAC address associated with this connection. MAC address is assigned automatically.",
},
"weight": {

View File

@@ -171,6 +171,11 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
reqInterface.IPAddr = ipaddr.(string)
}
macaddr, macSet := netInterfaceVal["mac"]
if macSet {
reqInterface.MAC = macaddr.(string)
}
interfaces = append(interfaces, reqInterface)
}
@@ -288,6 +293,38 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
log.Debugf("resourceComputeCreate: new simple Compute ID %d, name %s created", computeId, d.Get("name").(string))
updateReq := compute.UpdateRequest{}
loaderType, loaderTypeOk := d.GetOk("loader_type")
bootType, bootTypeOk := d.GetOk("boot_type")
hotResize, hotResizeOk := d.GetOk("hot_resize")
networkInterfaceNaming, networkInterfaceNamingOk := d.GetOk("network_interface_naming")
if loaderTypeOk {
updateReq.LoaderType = loaderType.(string)
}
if bootTypeOk {
updateReq.BootType = bootType.(string)
}
if hotResizeOk {
updateReq.HotResize = hotResize.(bool)
}
if networkInterfaceNamingOk {
updateReq.NetworkInterfaceNaming = networkInterfaceNaming.(string)
}
if loaderTypeOk || bootTypeOk || hotResizeOk || networkInterfaceNamingOk {
log.Debugf("resourceComputeCreate: change loaderType or bootType or hotResize or networkInterfaceNaming on ComputeID: %d", computeId)
updateReq.ComputeID = computeId
_, err := c.CloudAPI().Compute().Update(ctx, updateReq)
if err != nil {
warnings.Add(err)
}
}
if ars, ok := d.GetOk("pci_devices"); ok {
log.Debugf("resourceComputeCreate: add pci devices on ComputeID: %d", computeId)
addedPciDevices := ars.(*schema.Set).List()
@@ -920,7 +957,18 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
}
}
if d.HasChanges("description", "name", "numa_affinity", "cpu_pin", "hp_backed", "chipset", "auto_start_w_node", "preferred_cpu") {
if d.HasChanges("description",
"name",
"numa_affinity",
"cpu_pin",
"hp_backed",
"chipset",
"auto_start_w_node",
"preferred_cpu",
"loader_type",
"boot_type",
"hot_resize",
"network_interface_naming") {
req := compute.UpdateRequest{
ComputeID: computeRec.ID,
}
@@ -956,6 +1004,22 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
req.HPBacked = d.Get("hp_backed").(bool)
req.AutoStart = d.Get("auto_start_w_node").(bool)
if d.HasChange("loader_type") {
req.LoaderType = d.Get("loader_type").(string)
}
if d.HasChange("boot_type") {
req.BootType = d.Get("boot_type").(string)
}
if d.HasChange("hot_resize") {
req.HotResize = d.Get("hot_resize").(bool)
}
if d.HasChange("network_interface_naming") {
req.NetworkInterfaceNaming = d.Get("network_interface_naming").(string)
}
// Note bene: numa_affinity, cpu_pin and hp_backed are not allowed to be changed for compute in STARTED tech status.
// If STARTED, we need to stop it before update
var isStopRequired bool
@@ -1824,6 +1888,13 @@ func disksSubresourceSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
Computed: true,
},
"present_to": {
Type: schema.TypeMap,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
},
},
}
return rets
}
@@ -1941,6 +2012,13 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
),
Description: "Amount of RAM in MB to allocate to this compute instance.",
},
"boot_type": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validation.StringInSlice([]string{"bios", "uefi"}, false),
Description: "Type of image upload.",
},
"image_id": {
Type: schema.TypeInt,
Optional: true,
@@ -2096,7 +2174,6 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
Type: schema.TypeSet,
Optional: true,
MinItems: 1,
MaxItems: constants.MAX_NETWORKS_PER_COMPUTE,
Elem: &schema.Resource{
Schema: networkSubresourceSchemaMake(),
},
@@ -2171,6 +2248,19 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
Computed: true,
Description: "If true - enable compute, else - disable",
},
"loader_type": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validation.StringInSlice([]string{"linux", "windows", "unknown"}, false),
Description: "Type of image vm.",
},
"hot_resize": {
Type: schema.TypeBool,
Optional: true,
Computed: true,
Description: "Type of image vm.",
},
"pause": {
Type: schema.TypeBool,
Optional: true,
@@ -2230,6 +2320,13 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
Optional: true,
Description: "compute purpose",
},
"network_interface_naming": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validation.StringInSlice([]string{"eth", "ens"}, false),
Description: "Name of netfowrk interface.",
},
"numa_affinity": {
Type: schema.TypeString,
Optional: true,
@@ -2481,10 +2578,88 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
Computed: true,
},
"vgpus": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
Type: schema.TypeList,
Computed: true,
Description: "List of virtual GPUs",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"id": {
Type: schema.TypeInt,
Computed: true,
},
"gid": {
Type: schema.TypeInt,
Computed: true,
},
"type": {
Type: schema.TypeString,
Computed: true,
},
"mode": {
Type: schema.TypeString,
Computed: true,
},
"status": {
Type: schema.TypeString,
Computed: true,
},
"profile_id": {
Type: schema.TypeInt,
Computed: true,
},
"ram": {
Type: schema.TypeInt,
Computed: true,
},
"last_update_time": {
Type: schema.TypeInt,
Computed: true,
},
"created_time": {
Type: schema.TypeInt,
Computed: true,
},
"deleted_time": {
Type: schema.TypeInt,
Computed: true,
},
"vmid": {
Type: schema.TypeInt,
Computed: true,
},
"pgpuid": {
Type: schema.TypeInt,
Computed: true,
},
"reference_id": {
Type: schema.TypeString,
Computed: true,
},
"account_id": {
Type: schema.TypeInt,
Computed: true,
},
"rg_id": {
Type: schema.TypeInt,
Computed: true,
},
"last_claimed_by": {
Type: schema.TypeInt,
Computed: true,
},
"pci_slot": {
Type: schema.TypeInt,
Computed: true,
},
"bus_number": {
Type: schema.TypeInt,
Computed: true,
},
"guid": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
"virtual_image_id": {

View File

@@ -98,14 +98,6 @@ func utilityComputeExtraDisksConfigure(ctx context.Context, d *schema.ResourceDa
if detach_set.Len() > 0 {
computeId, _ := strconv.ParseUint(d.Id(), 10, 64)
stopReq := compute.StopRequest{
ComputeID: computeId,
Force: false,
}
_, err := c.CloudAPI().Compute().Stop(ctx, stopReq)
if err != nil {
return err
}
for _, diskId := range detach_set.List() {
req := compute.DiskDetachRequest{
@@ -120,14 +112,6 @@ func utilityComputeExtraDisksConfigure(ctx context.Context, d *schema.ResourceDa
}
}
req := compute.StartRequest{
ComputeID: computeId,
AltBootID: 0,
}
_, err = c.CloudAPI().Compute().Start(ctx, req)
if err != nil {
return err
}
}
attach_set := new_set.(*schema.Set).Difference(old_set.(*schema.Set))
@@ -180,7 +164,7 @@ func utilityComputeNetworksConfigure(ctx context.Context, d *schema.ResourceData
oldList := oldSet.(*schema.Set).List()
newList := newSet.(*schema.Set).List()
detachMap, changeIpMap, attachMap := differenceNetwork(oldList, newList)
detachMap, changeIpMap, changeMacMap, attachMap := differenceNetwork(oldList, newList)
apiErrCount := 0
var lastSavedError error
@@ -224,7 +208,7 @@ func utilityComputeNetworksConfigure(ctx context.Context, d *schema.ResourceData
needStart := false
if oldSet.(*schema.Set).Len() == len(detachMap) || oldSet.(*schema.Set).Len() == 0 || hasDPDKnetwork(attachMap) {
if oldSet.(*schema.Set).Len() == len(detachMap) || oldSet.(*schema.Set).Len() == 0 || hasDPDKnetwork(attachMap) || len(changeMacMap) != 0 {
computeId, _ := strconv.ParseUint(d.Id(), 10, 64)
if err := utilityComputeStop(ctx, computeId, m); err != nil {
apiErrCount++
@@ -235,6 +219,24 @@ func utilityComputeNetworksConfigure(ctx context.Context, d *schema.ResourceData
}
}
log.Debugf("utilityComputeNetworksConfigure: changeMac set has %d items for Compute ID %s", len(changeMacMap), d.Id())
for _, netData := range changeMacMap {
computeId, _ := strconv.ParseUint(d.Id(), 10, 64)
req := compute.ChangeMACRequest{
ComputeID: computeId,
NewMAC: netData["mac"].(string),
СurrentMAC: netData["old_mac"].(string),
}
_, err := c.CloudAPI().Compute().ChangeMAC(ctx, req)
if err != nil {
log.Errorf("utilityComputeNetworksConfigure: failed to change mac %s to %s from Compute ID %s: %s",
req.СurrentMAC, req.NewMAC, d.Id(), err)
apiErrCount++
lastSavedError = err
}
}
sort.Slice(attachMap, func(i, j int) bool {
weightI := attachMap[i]["weight"].(int)
weightJ := attachMap[j]["weight"].(int)
@@ -246,6 +248,7 @@ func utilityComputeNetworksConfigure(ctx context.Context, d *schema.ResourceData
}
return weightI < weightJ
})
log.Debugf("utilityComputeNetworksConfigure: attach set has %d items for Compute ID %s", len(attachMap), d.Id())
for _, netData := range attachMap {
computeId, _ := strconv.ParseUint(d.Id(), 10, 64)
@@ -259,6 +262,10 @@ func utilityComputeNetworksConfigure(ctx context.Context, d *schema.ResourceData
req.IPAddr = netData["ip_address"].(string)
}
if netData["mac"].(string) != "" {
req.MACAddr = netData["mac"].(string)
}
if req.NetType == "DPDK" {
req.MTU = uint64(netData["mtu"].(int))
}
@@ -378,9 +385,10 @@ func utilityComputeUpdatePciDevices(ctx context.Context, d *schema.ResourceData,
return nil
}
func differenceNetwork(oldList, newList []interface{}) (detachMap, changeIpMap, attachMap []map[string]interface{}) {
func differenceNetwork(oldList, newList []interface{}) (detachMap, changeIpMap, changeMacMap, attachMap []map[string]interface{}) {
attachMap = make([]map[string]interface{}, 0)
changeIpMap = make([]map[string]interface{}, 0)
changeMacMap = make([]map[string]interface{}, 0)
detachMap = make([]map[string]interface{}, 0)
for _, oldNetwork := range oldList {
oldMap := oldNetwork.(map[string]interface{})
@@ -388,15 +396,21 @@ func differenceNetwork(oldList, newList []interface{}) (detachMap, changeIpMap,
for _, newNetwork := range newList {
newMap := newNetwork.(map[string]interface{})
if newMap["net_type"] == oldMap["net_type"] && newMap["net_id"] == oldMap["net_id"] && newMap["weight"] == oldMap["weight"] && (newMap["mtu"] == oldMap["mtu"] || newMap["mtu"].(int) == 0) {
if (newMap["net_type"].(string) == "EXTNET" || newMap["net_type"].(string) == "VINS") && (newMap["ip_address"] != oldMap["ip_address"] && newMap["ip_address"].(string) != "") {
found = true
switch {
case (newMap["net_type"].(string) == "EXTNET" || newMap["net_type"].(string) == "VINS") && (newMap["ip_address"] != oldMap["ip_address"] && newMap["ip_address"].(string) != ""):
changeIpMap = append(changeIpMap, newMap)
found = true
break
} else if newMap["ip_address"] == oldMap["ip_address"] || newMap["ip_address"].(string) == "" {
fallthrough
case newMap["mac"] != oldMap["mac"] && newMap["mac"].(string) != "":
newMap["old_mac"] = oldMap["mac"]
changeMacMap = append(changeMacMap, newMap)
found = true
break
}
}
if found {
break
}
}
if found {
continue
@@ -410,12 +424,8 @@ func differenceNetwork(oldList, newList []interface{}) (detachMap, changeIpMap,
for _, oldNetwork := range oldList {
oldMap := oldNetwork.(map[string]interface{})
if newMap["net_type"] == oldMap["net_type"] && newMap["net_id"] == oldMap["net_id"] && newMap["weight"] == oldMap["weight"] && (newMap["mtu"] == oldMap["mtu"] || newMap["mtu"].(int) == 0) {
if newMap["ip_address"] == oldMap["ip_address"] || newMap["ip_address"].(string) == "" ||
((newMap["net_type"].(string) == "EXTNET" || newMap["net_type"].(string) == "VINS") &&
newMap["ip_address"] != oldMap["ip_address"] && newMap["ip_address"].(string) != "") {
found = true
break
}
found = true
break
}
}
if found {