1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-01-25 06:03:36 +03:00

Bug 3195 remove OPENNEBULA_MANAGED attribute (#3407)

* B #3195: remove OPENNEBULA_MANAGED attribute

Signed-off-by: Jorge Lobo <jlobo@opennebula.systems>

* B #3195: remove OPENNEBULA_MANAGED attribute

Signed-off-by: Jorge Lobo <jlobo@opennebula.systems>
(cherry picked from commit b7a136f2a278db22db15937b6ac8233b7430eeab)
This commit is contained in:
Jorge Lobo 2019-06-06 13:15:42 +02:00 committed by Tino Vazquez
parent 7dc16bf2ac
commit 2d5c9fbf15
No known key found for this signature in database
GPG Key ID: 2FE9C32E94AEABBE
2 changed files with 59 additions and 6 deletions

View File

@ -15,13 +15,21 @@
/* -------------------------------------------------------------------------- */
define(function(require) {
var OpenNebulaAction = require('./action');
var Config = require('sunstone-config');
var OpenNebulaAction = require("./action");
var Config = require("sunstone-config");
var RESOURCE = "VMTEMPLATE";
window.lastInfoVmTemplate = {};
var Template = {
"resource": RESOURCE,
"setLastResource": function(info={}){
var data = {};
if(info && info.data){
data.data = info.data;
window.lastInfoVmTemplate = data;
}
},
"create" : function(params) {
OpenNebulaAction.create(params, RESOURCE);
},
@ -37,6 +45,7 @@ define(function(require) {
OpenNebulaAction.list(params, RESOURCE);
},
"show" : function(params) {
Template.setLastResource(params);
OpenNebulaAction.show(params, RESOURCE);
},
"chown" : function(params) {
@ -91,7 +100,7 @@ define(function(require) {
},
"isNetworkChangeEnabled": function(template) {
if (template.VMTEMPLATE.TEMPLATE.SUNSTONE &&
template.VMTEMPLATE.TEMPLATE.SUNSTONE.NETWORK_SELECT == 'NO') {
template.VMTEMPLATE.TEMPLATE.SUNSTONE.NETWORK_SELECT == "NO") {
return false;
} else {
return true;
@ -158,7 +167,7 @@ define(function(require) {
return cost;
}
}
};
return Template;
})
});

View File

@ -206,7 +206,51 @@ define(function(require) {
Sunstone.runAction(this.resource+".create", {"vmtemplate": templateJSON});
return false;
} else if (this.action == "update") {
Sunstone.runAction(this.resource+".update", this.resourceId, TemplateUtils.templateToString(templateJSON));
var actionUpdate = this.resource + ".update";
var resourceId = this.resourceId;
if(
window &&
window.lastInfoVmTemplate &&
window.lastInfoVmTemplate.data &&
templateJSON &&
templateJSON.DISK &&
templateJSON.HYPERVISOR &&
templateJSON.HYPERVISOR === "vcenter"
){
params = {
data: window.lastInfoVmTemplate.data,
success: function(request, response){
if(response){
var template = response.VMTEMPLATE && response.VMTEMPLATE.TEMPLATE;
if(template && template.DISK){
var lastDisk = template.DISK;
var newDisk = templateJSON.DISK[0];
var setNewdisk = function(){
if(lastDisk.OPENNEBULA_MANAGED && lastDisk.OPENNEBULA_MANAGED === "NO" ){
newDisk.LAST_IMAGE_DISK = (lastDisk && lastDisk.IMAGE_ID) || (lastDisk && lastDisk.IMAGE);
delete newDisk.OPENNEBULA_MANAGED;
}
};
if(lastDisk && lastDisk.LAST_IMAGE_DISK){
if(lastDisk.LAST_IMAGE_DISK === newDisk.IMAGE || lastDisk.LAST_IMAGE_DISK === newDisk.IMAGE_ID){
newDisk.OPENNEBULA_MANAGED = "NO";
delete newDisk.LAST_IMAGE_DISK;
}else{
setNewdisk();
}
}else{
setNewdisk();
}
templateJSON.DISK = [newDisk];
Sunstone.runAction(actionUpdate, resourceId, TemplateUtils.templateToString(templateJSON));
}
}
}
};
OpenNebulaAction.show(params,OpenNebulaTemplate.resource);
}else{
Sunstone.runAction(actionUpdate, resourceId, TemplateUtils.templateToString(templateJSON));
}
return false;
}
}