diff --git a/src/sunstone/models/OpenNebulaJSON/MarketPlaceAppJSON.rb b/src/sunstone/models/OpenNebulaJSON/MarketPlaceAppJSON.rb index badc7c4e51..7304bd60ea 100644 --- a/src/sunstone/models/OpenNebulaJSON/MarketPlaceAppJSON.rb +++ b/src/sunstone/models/OpenNebulaJSON/MarketPlaceAppJSON.rb @@ -59,6 +59,7 @@ module OpenNebulaJSON when "enable" then self.enable when "lock" then self.lock(action_hash['params']) when "unlock" then self.unlock(action_hash['params']) + when "vm.import" then self.app_vm_import(action_hash['params']) when "vm-template.import" then self.app_vm_import(action_hash['params']) when "service_template.import" then self.app_service_import(action_hash['params']) else diff --git a/src/sunstone/public/app/sunstone/buttons.hbs b/src/sunstone/public/app/sunstone/buttons.hbs index 3e9188446c..26c2439b9c 100644 --- a/src/sunstone/public/app/sunstone/buttons.hbs +++ b/src/sunstone/public/app/sunstone/buttons.hbs @@ -72,14 +72,9 @@ - - - - + @@ -111,4 +106,3 @@ - diff --git a/src/sunstone/public/app/tabs/images-tab/buttons.js b/src/sunstone/public/app/tabs/images-tab/buttons.js index f2ce05719e..96040c46f4 100644 --- a/src/sunstone/public/app/tabs/images-tab/buttons.js +++ b/src/sunstone/public/app/tabs/images-tab/buttons.js @@ -32,7 +32,7 @@ define(function(require) { }, "Image.upload_marketplace_dialog" : { type: "action", - text: ' '+ Locale.tr("MarketPlace") + text: '' }, "Image.import_dialog" : { type: "create_dialog", diff --git a/src/sunstone/public/app/tabs/marketplaceapps-tab/form-panels/create.js b/src/sunstone/public/app/tabs/marketplaceapps-tab/form-panels/create.js index 6565d88983..c522bbbbd0 100644 --- a/src/sunstone/public/app/tabs/marketplaceapps-tab/form-panels/create.js +++ b/src/sunstone/public/app/tabs/marketplaceapps-tab/form-panels/create.js @@ -27,6 +27,7 @@ define(function(require) { var ImagesTable = require("tabs/images-tab/datatable"); var TemplatesTable = require("tabs/templates-tab/datatable"); var ServicesTable = require("tabs/oneflow-templates-tab/datatable"); + var VMsTable = require("tabs/vms-tab/datatable"); var MarketPlacesTable = require("tabs/marketplaces-tab/datatable"); var Config = require("sunstone-config"); var WizardFields = require("utils/wizard-fields"); @@ -73,6 +74,11 @@ define(function(require) { "title": Locale.tr("Create MarketPlace App from Service"), "buttonText": Locale.tr("Create"), "resetButton": true + }, + "export_vm": { + "title": Locale.tr("Create MarketPlace App from VM"), + "buttonText": Locale.tr("Create"), + "resetButton": true } }; @@ -94,6 +100,10 @@ define(function(require) { FORM_PANEL_ID + "servicesTable", { "select": true }); + this.vmsTable = new VMsTable( + FORM_PANEL_ID + "vmsTable", + { "select": true }); + this.marketPlacesTable = new MarketPlacesTable( FORM_PANEL_ID + "marketPlacesTable", { "select": true, @@ -147,6 +157,7 @@ define(function(require) { FormPanel.prototype.setImageId = _setImageId; FormPanel.prototype.setTemplateId = _setTemplateId; FormPanel.prototype.setServiceId = _setServiceId; + FormPanel.prototype.setVMId = _setVMId; FormPanel.prototype.onShow = _onShow; FormPanel.prototype.setup = _setup; @@ -162,6 +173,7 @@ define(function(require) { "imagesTableHTML": this.imagesTable.dataTableHTML, "templatesTableHTML": this.templatesTable.dataTableHTML, "servicesTableHTML": this.servicesTable.dataTableHTML, + "vmsTableHTML": this.vmsTable.dataTableHTML, "marketPlacesImagesTableHTML": this.marketPlacesTable.dataTableHTML, "marketPlacesServicesTableHTML": this.marketPlacesServiceTable.dataTableHTML }); @@ -178,6 +190,7 @@ define(function(require) { this.imagesTable.resetResourceTableSelect(); this.servicesTable.resetResourceTableSelect(); this.templatesTable.resetResourceTableSelect(); + this.vmsTable.resetResourceTableSelect(); this.marketPlacesTable.resetResourceTableSelect(); this.marketPlacesServiceTable.resetResourceTableSelect(); this.marketPlacesTableAdvanced.resetResourceTableSelect(); @@ -212,6 +225,13 @@ define(function(require) { this.servicesTable.selectResourceTableSelect(selectedResources); } + function _setVMId(serviceId) { + var selectedResources = { + ids : serviceId + }; + + this.vmsTable.selectResourceTableSelect(selectedResources); + } // Set up the create datastore context function _setup(context) { @@ -221,16 +241,13 @@ define(function(require) { this.imagesTable.initialize(); this.templatesTable.initialize(); this.servicesTable.initialize(); + this.vmsTable.initialize(); this.marketPlacesServiceTable.initialize(); this.marketPlacesTable.initialize(); this.marketPlacesTableAdvanced.initialize(); this.marketPlacesTable.idInput().attr("required", ""); this.marketPlacesTableAdvanced.idInput().attr("required", ""); - this.servicesTable.idInput().attr("required", ""); - // this.templatesTable.idInput().attr("required", ""); - - // this.marketPlacesServiceTable.idInput().attr("required", ""); $('#IMPORT_ALL', context).on('change', function(){ if ( @@ -258,17 +275,46 @@ define(function(require) { that.servicesTable.idInput(). removeAttr("required"). removeAttr("wizard_field"); + that.vmsTable.idInput(). + removeAttr("required"). + removeAttr("wizard_field"); $('#importAllCheckBox',context).hide(); $('#servicesTableHTML', context).hide(); $('#templatesTableHTML', context).hide(); $('#imagesTableHTML', context).show(); + $('#vmsTableHTML', context).hide(); $('#serviceMarketPlaceHTML', context).hide(); $('#appMarketPlaceHTML', context).show(); $('#templatesForApp',context).show(); break; + case 'vm': + that.imagesTable.idInput(). + removeAttr("required"). + removeAttr("wizard_field"); + that.templatesTable.idInput(). + removeAttr("required"). + removeAttr("wizard_field"); + that.servicesTable.idInput(). + removeAttr("required"). + removeAttr("wizard_field"); + that.vmsTable.idInput(). + attr("required", ""). + attr("wizard_field", "ORIGIN_ID"); + + $('#importAllCheckBox',context).show(); + + $('#servicesTableHTML', context).hide(); + $('#templatesTableHTML', context).hide(); + $('#imagesTableHTML', context).hide(); + $('#vmsTableHTML', context).show(); + + $('#serviceMarketPlaceHTML', context).hide(); + $('#appMarketPlaceHTML', context).show(); + $('#templatesForApp',context).hide(); + break; case 'vmtemplate': that.templatesTable.idInput(). attr("required", ""). @@ -279,12 +325,16 @@ define(function(require) { that.servicesTable.idInput(). removeAttr("required"). removeAttr("wizard_field"); + that.vmsTable.idInput(). + removeAttr("required"). + removeAttr("wizard_field"); $('#importAllCheckBox',context).show(); $('#servicesTableHTML', context).hide(); $('#templatesTableHTML', context).show(); $('#imagesTableHTML', context).hide(); + $('#vmsTableHTML', context).hide(); $('#serviceMarketPlaceHTML', context).hide(); $('#appMarketPlaceHTML', context).show(); @@ -306,6 +356,7 @@ define(function(require) { $('#servicesTableHTML', context).show(); $('#templatesTableHTML', context).hide(); $('#imagesTableHTML', context).hide(); + $('#vmsTableHTML', context).hide(); $('#serviceMarketPlaceHTML', context).hide(); $('#appMarketPlaceHTML', context).show(); @@ -334,6 +385,7 @@ define(function(require) { Sunstone.runAction("MarketPlaceApp.create", marketPlaceAppObj); break; + case 'vm': case 'vmtemplate': var marketPlaceJSON = {}; $.extend(marketPlaceJSON, WizardFields.retrieve(context)); diff --git a/src/sunstone/public/app/tabs/marketplaceapps-tab/form-panels/create/wizard.hbs b/src/sunstone/public/app/tabs/marketplaceapps-tab/form-panels/create/wizard.hbs index 5327097188..9f74d9f3bd 100644 --- a/src/sunstone/public/app/tabs/marketplaceapps-tab/form-panels/create/wizard.hbs +++ b/src/sunstone/public/app/tabs/marketplaceapps-tab/form-panels/create/wizard.hbs @@ -25,6 +25,7 @@ @@ -56,26 +57,53 @@ -
- {{tr "Select the Service to create the App"}} - {{{servicesTableHTML}}} -
+ + + +
+
+
+ {{tr "Select the Service to create the App"}} + {{{servicesTableHTML}}} +
+
+ +
+
{{tr "Select the VM Template to create the App"}} {{{templatesTableHTML}}}
+
{{tr "Select the Image to create the App"}} {{{imagesTableHTML}}}
+ +
+ {{tr "Select the VM to create the App"}} + {{{vmsTableHTML}}} +
+ + + +
{{tr "Select the Marketplace where the Images will be created"}} {{{marketPlacesServicesTableHTML}}}
+
{{tr "Select the Marketplace where where the App will be created"}} {{{marketPlacesImagesTableHTML}}}
+ + +
{{tr "Templates for the App"}}
diff --git a/src/sunstone/public/app/tabs/oneflow-templates-tab/buttons.js b/src/sunstone/public/app/tabs/oneflow-templates-tab/buttons.js index 9f71f89524..016004095f 100644 --- a/src/sunstone/public/app/tabs/oneflow-templates-tab/buttons.js +++ b/src/sunstone/public/app/tabs/oneflow-templates-tab/buttons.js @@ -32,7 +32,7 @@ define(function(require) { "ServiceTemplate.upload_marketplace_dialog" : { type: "action", layout: "main", - text: " "+ Locale.tr("MarketPlace") + text: "" }, "ServiceTemplate.update_dialog" : { type: "action", diff --git a/src/sunstone/public/app/tabs/templates-tab/buttons.js b/src/sunstone/public/app/tabs/templates-tab/buttons.js index 7cc24bdcbb..b1f968932c 100644 --- a/src/sunstone/public/app/tabs/templates-tab/buttons.js +++ b/src/sunstone/public/app/tabs/templates-tab/buttons.js @@ -40,7 +40,7 @@ define(function(require) { "Template.upload_marketplace_dialog" : { type: "action", layout: "main", - text: ' '+ Locale.tr("MarketPlace") + text: '' }, "Template.update_dialog" : { type: "action", diff --git a/src/sunstone/public/app/tabs/vms-tab/actions.js b/src/sunstone/public/app/tabs/vms-tab/actions.js index 9fac384968..2c9d676996 100644 --- a/src/sunstone/public/app/tabs/vms-tab/actions.js +++ b/src/sunstone/public/app/tabs/vms-tab/actions.js @@ -36,6 +36,8 @@ define(function(require) { var GUAC_DIALOG_ID = require('./dialogs/guac/dialogId'); var SAVE_AS_TEMPLATE_DIALOG_ID = require('./dialogs/saveas-template/dialogId'); var UPDATECONF_FORM_ID = require('./form-panels/updateconf/formPanelId'); + var MARKETPLACEAPPS_TAB_ID = require('tabs/marketplaceapps-tab/tabId'); + var CREATE_APP_DIALOG_ID = require('tabs/marketplaceapps-tab/form-panels/create/formPanelId'); var XML_ROOT = "VM"; var RESOURCE = "VM"; @@ -423,7 +425,42 @@ define(function(require) { Notifier.onError(request, response); }, notify: false + }, + "VM.upload_marketplace_dialog" : { + type: "custom", + call: function(params) { + var selectedNodes = Sunstone.getDataTable(TAB_ID).elements(); + + if (selectedNodes.length !== 1) { + Notifier.notifyMessage(Locale.tr("Please select one (and just one) VM to export.")); + return false; + } + + var resourceId = '' + selectedNodes[0]; + + OpenNebulaVM.show({ + 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(); + } + ); + }, + error: function(error){ + Notifier.onError("VM: " +error); + } + }); + } } + }; return _actions; diff --git a/src/sunstone/public/app/tabs/vms-tab/buttons.js b/src/sunstone/public/app/tabs/vms-tab/buttons.js index e2aacc314e..f7823b75b7 100644 --- a/src/sunstone/public/app/tabs/vms-tab/buttons.js +++ b/src/sunstone/public/app/tabs/vms-tab/buttons.js @@ -34,6 +34,11 @@ define(function(require) { layout: "create", alwaysActive: true }, + "VM.upload_marketplace_dialog" : { + type: "action", + text: '', + custom_classes : "state-dependent" + }, "VM.chown" : { type: "confirm_with_select", text: Locale.tr("Change owner"), @@ -57,25 +62,25 @@ define(function(require) { "VM.migrate" : { type: "action", text: Locale.tr("Migrate"), - layout: "vmsmigration_buttons", + layout: "vmsplanification_buttons", custom_classes : "state-dependent" }, "VM.migrate_poff" : { type: "action", text: Locale.tr("Migrate") + ' ' + Locale.tr("Poweroff") + '', - layout: "vmsmigration_buttons", + layout: "vmsplanification_buttons", custom_classes : "state-dependent" }, "VM.migrate_poff_hard" : { type: "action", text: Locale.tr("Migrate") + ' ' + Locale.tr("Poweroff-hard") + '', - layout: "vmsmigration_buttons", + layout: "vmsplanification_buttons", custom_classes : "state-dependent" }, "VM.migrate_live" : { type: "action", text: Locale.tr("Migrate") + ' ' + Locale.tr("live") + '', - layout: "vmsmigration_buttons", + layout: "vmsplanification_buttons", custom_classes : "state-dependent not_firecracker" }, "VM.hold" : { diff --git a/src/sunstone/public/app/tabs/vms-tab/utils/state-actions.js b/src/sunstone/public/app/tabs/vms-tab/utils/state-actions.js index e9654d6848..3719786c40 100644 --- a/src/sunstone/public/app/tabs/vms-tab/utils/state-actions.js +++ b/src/sunstone/public/app/tabs/vms-tab/utils/state-actions.js @@ -44,7 +44,7 @@ define(function(require) { []; STATE_ACTIONS[OpenNebulaVM.STATES.POWEROFF] = - ["VM.resched", "VM.resume", "VM.resize", "VM.attachdisk", "VM.detachdisk", "VM.attachnic", "VM.detachnic", "VM.disk_saveas", "VM.disk_snapshot_create", "VM.disk_snapshot_revert", "VM.disk_snapshot_delete", "VM.migrate", "VM.undeploy", "VM.undeploy_hard", "VM.save_as_template", "VM.updateconf", "VM.terminate_hard", "VM.recover", "VM.disk_resize", "VM.snapshot_delete"]; + ["VM.resched", "VM.resume", "VM.resize", "VM.attachdisk", "VM.detachdisk", "VM.attachnic", "VM.detachnic", "VM.disk_saveas", "VM.disk_snapshot_create", "VM.disk_snapshot_revert", "VM.disk_snapshot_delete", "VM.migrate", "VM.undeploy", "VM.undeploy_hard", "VM.save_as_template", "VM.updateconf", "VM.terminate_hard", "VM.recover", "VM.disk_resize", "VM.snapshot_delete", "VM.upload_marketplace_dialog"]; STATE_ACTIONS[OpenNebulaVM.STATES.UNDEPLOYED] = ["VM.resume", "VM.resize", "VM.deploy", "VM.updateconf", "VM.terminate_hard", "VM.recover"];