1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-21 14:50:08 +03:00

B #5238: Sunstone not to override unmodified templates (#1752)

on VM instantiation
This commit is contained in:
Frederick Borges 2022-02-04 11:37:51 +01:00 committed by GitHub
parent 518f636186
commit d25c48f5ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -190,15 +190,18 @@ define(function(require) {
});
}
function diffValues(finder, inElement){
function diffValues(newValues, oldValues){
var diff = [];
if(finder && inElement){
var Template = Array.isArray(inElement)? inElement: [inElement];
var Finder = Array.isArray(finder)? finder: [finder];
var x = Template.map(function(internalTemplate){return JSON.stringify(internalTemplate);});
Finder.forEach(function(fnd) {
if($.inArray(JSON.stringify(fnd),x) === -1){
diff.push(fnd);
if(oldValues && newValues){
oldValues = Array.isArray(oldValues)? oldValues: [oldValues];
newValues = Array.isArray(newValues)? newValues: [newValues];
var oldValuesString = oldValues.map(function(internalValue){
return JSON.stringify(internalValue);
});
newValues.forEach(function (newValue){
if($.inArray(JSON.stringify(newValue),oldValuesString) === -1){
diff.push(newValue);
}
});
}