1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-16 22:50:10 +03:00

B #664: Block vCenter VMs to be imported on MarketPlace (#995)

Signed-off-by: Frederick Borges <fborges@opennebula.io>
This commit is contained in:
Frederick Borges 2021-03-18 14:39:40 +01:00 committed by GitHub
parent c236c1e292
commit c0cc160906
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 70 additions and 21 deletions

View File

@ -198,7 +198,10 @@ define(function(require) {
this.imagesTable.resetResourceTableSelect();
this.templatesTable.resetResourceTableSelect();
this.vmsTable.resetResourceTableSelect();
this.servicesTable.resetResourceTableSelect();
// Only try to refresh the servicesTable when oneflow running
if ($('#serviceMarketPlaceError').attr("oneflow_running") === "true"){
this.servicesTable.resetResourceTableSelect();
}
this.marketPlacesTable.resetResourceTableSelect();
this.marketPlacesServiceTable.resetResourceTableSelect();
this.marketPlacesTableAdvanced.resetResourceTableSelect();
@ -361,10 +364,12 @@ define(function(require) {
var success_func = function (){
$("#serviceMarketPlaceError").hide();
$("#serviceMarketPlaceError").attr("oneflow_running", true);
};
var error_func = function (){
$("#serviceMarketPlaceError").show();
$("#serviceMarketPlaceError").attr("oneflow_running", false);
};
OpenNebulaAction.list({options: undefined, success: success_func, error: error_func}, "DOCUMENT", "service_template");
@ -413,20 +418,46 @@ define(function(require) {
extra_param: { name : marketPlaceJSON.NAME }
}
OpenNebula.VM.save_as_template({
data: template,
success: function(_, templateId) {
Notifier.notifyMessage(Locale.tr("VM Template") + ' ' + marketPlaceJSON.NAME + ' ' + Locale.tr("saved successfully"))
OpenNebula.VM.show({
data : {
id: marketPlaceJSON['ORIGIN_ID']
},
timeout: true,
success: function (_, vmTemplate) {
if (vmTemplate &&
vmTemplate.VM &&
vmTemplate.VM.USER_TEMPLATE &&
vmTemplate.VM.USER_TEMPLATE.HYPERVISOR &&
vmTemplate.VM.USER_TEMPLATE.HYPERVISOR !== "vcenter"){
OpenNebula.VM.save_as_template({
data: template,
success: function(_, templateId) {
Notifier.notifyMessage(Locale.tr("VM Template") + ' ' + marketPlaceJSON.NAME + ' ' + Locale.tr("saved successfully"));
var newTemplate = $.extend(marketPlaceJSON, { ORIGIN_ID: String(templateId) });
Sunstone.runAction("MarketPlaceApp.import_vm_template", marketplaceIdSelected, newTemplate);
},
error: function(request, response) {
Sunstone.hideFormPanelLoading(TAB_ID);
Notifier.onError(request, response);
}
});
}
else
Notifier.notifyError(
Locale.tr("Import error: Can't import vCenter VMs to a marketplace, only vCenter VM templates.")
);
var newTemplate = $.extend(marketPlaceJSON, { ORIGIN_ID: String(templateId) })
Sunstone.runAction("MarketPlaceApp.import_vm_template", marketplaceIdSelected, newTemplate);
},
error: function(request, response) {
Sunstone.hideFormPanelLoading(TAB_ID)
Sunstone.hideFormPanelLoading(TAB_ID);
Notifier.onError(request, response);
}
})
});
break;
case 'vmtemplate':

View File

@ -441,17 +441,27 @@ define(function(require) {
data : {
id: resourceId
},
success: function(){
Sunstone.showTab(MARKETPLACEAPPS_TAB_ID);
Sunstone.showFormPanel(
MARKETPLACEAPPS_TAB_ID,
CREATE_APP_DIALOG_ID,
"export_vm",
function(formPanelInstance, context) {
formPanelInstance.setVMId(resourceId);
$("#marketplaceapps-tab-wizardForms #TYPE").val("vm").change();
}
);
success: function(_, vmTemplate){
if (vmTemplate &&
vmTemplate.VM &&
vmTemplate.VM.USER_TEMPLATE &&
vmTemplate.VM.USER_TEMPLATE.HYPERVISOR &&
vmTemplate.VM.USER_TEMPLATE.HYPERVISOR !== "vcenter"){
Sunstone.showTab(MARKETPLACEAPPS_TAB_ID);
Sunstone.showFormPanel(
MARKETPLACEAPPS_TAB_ID,
CREATE_APP_DIALOG_ID,
"export_vm",
function(formPanelInstance, context) {
formPanelInstance.setVMId(resourceId);
$("#marketplaceapps-tab-wizardForms #TYPE").val("vm").change();
}
);
}
else
Notifier.notifyError(
Locale.tr("Import error: Can't import vCenter VMs to a marketplace, only vCenter VM templates.")
);
},
error: function(error){
Notifier.onError("VM: " +error);

View File

@ -206,5 +206,13 @@ define(function(require) {
Sunstone.runAction(RESOURCE + ".update_template", resourceId, template_str);
});
if (this.element &&
this.element.USER_TEMPLATE &&
this.element.USER_TEMPLATE.HYPERVISOR &&
this.element.USER_TEMPLATE.HYPERVISOR === "vcenter")
$('button[href="VM.upload_marketplace_dialog"]').attr('disabled','disabled');
else
$('button[href="VM.upload_marketplace_dialog"]').removeAttr('disabled');
}
});