mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-22 18:50:08 +03:00
Feature #4530: VR template instantiate action
This commit is contained in:
parent
fcf5b771c7
commit
996be92e96
@ -251,7 +251,7 @@ tabs:
|
||||
VirtualRouterTemplate.refresh: true
|
||||
VirtualRouterTemplate.create_dialog: true
|
||||
VirtualRouterTemplate.update_dialog: true
|
||||
VirtualRouterTemplate.instantiate_vms: true
|
||||
VirtualRouterTemplate.instantiate_dialog: true
|
||||
VirtualRouterTemplate.rename: true
|
||||
VirtualRouterTemplate.chown: true
|
||||
VirtualRouterTemplate.chgrp: true
|
||||
|
@ -251,7 +251,7 @@ tabs:
|
||||
VirtualRouterTemplate.refresh: true
|
||||
VirtualRouterTemplate.create_dialog: true
|
||||
VirtualRouterTemplate.update_dialog: true
|
||||
VirtualRouterTemplate.instantiate_vms: true
|
||||
VirtualRouterTemplate.instantiate_dialog: true
|
||||
VirtualRouterTemplate.rename: true
|
||||
VirtualRouterTemplate.chown: true
|
||||
VirtualRouterTemplate.chgrp: true
|
||||
|
@ -251,7 +251,7 @@ tabs:
|
||||
VirtualRouterTemplate.refresh: true
|
||||
VirtualRouterTemplate.create_dialog: false
|
||||
VirtualRouterTemplate.update_dialog: false
|
||||
VirtualRouterTemplate.instantiate_vms: false
|
||||
VirtualRouterTemplate.instantiate_dialog: false
|
||||
VirtualRouterTemplate.rename: true
|
||||
VirtualRouterTemplate.chown: true
|
||||
VirtualRouterTemplate.chgrp: false
|
||||
|
@ -253,7 +253,7 @@ tabs:
|
||||
VirtualRouterTemplate.refresh: true
|
||||
VirtualRouterTemplate.create_dialog: false
|
||||
VirtualRouterTemplate.update_dialog: false
|
||||
VirtualRouterTemplate.instantiate_vms: false
|
||||
VirtualRouterTemplate.instantiate_dialog: false
|
||||
VirtualRouterTemplate.rename: true
|
||||
VirtualRouterTemplate.chown: true
|
||||
VirtualRouterTemplate.chgrp: false
|
||||
|
@ -252,7 +252,7 @@ tabs:
|
||||
VirtualRouterTemplate.refresh: true
|
||||
VirtualRouterTemplate.create_dialog: true
|
||||
VirtualRouterTemplate.update_dialog: true
|
||||
VirtualRouterTemplate.instantiate_vms: true
|
||||
VirtualRouterTemplate.instantiate_dialog: true
|
||||
VirtualRouterTemplate.rename: true
|
||||
VirtualRouterTemplate.chown: false
|
||||
VirtualRouterTemplate.chgrp: false
|
||||
|
@ -27,16 +27,16 @@ define(function(require) {
|
||||
type: "create_dialog",
|
||||
layout: "create"
|
||||
},
|
||||
"ServiceTemplate.instantiate_dialog" : {
|
||||
type: "action",
|
||||
layout: "main",
|
||||
text: Locale.tr("Instantiate")
|
||||
},
|
||||
"ServiceTemplate.update_dialog" : {
|
||||
type: "action",
|
||||
layout: "main",
|
||||
text: Locale.tr("Update")
|
||||
},
|
||||
"ServiceTemplate.instantiate_dialog" : {
|
||||
type: "action",
|
||||
layout: "main",
|
||||
text: Locale.tr("Instantiate")
|
||||
},
|
||||
"ServiceTemplate.chown" : {
|
||||
type: "confirm_with_select",
|
||||
text: Locale.tr("Change owner"),
|
||||
|
@ -36,7 +36,8 @@ define(function(require) {
|
||||
];
|
||||
|
||||
var _formPanels = [
|
||||
require('./vrouter-templates-tab/form-panels/create')
|
||||
require('./vrouter-templates-tab/form-panels/create'),
|
||||
require('./vrouter-templates-tab/form-panels/instantiate')
|
||||
];
|
||||
|
||||
var Tab = {
|
||||
|
@ -24,7 +24,7 @@ define(function(require) {
|
||||
|
||||
var CREATE_DIALOG_ID = require('tabs/vrouter-templates-tab/form-panels/create/formPanelId');
|
||||
var CLONE_DIALOG_ID = require('tabs/templates-tab/dialogs/clone/dialogId');
|
||||
var INSTANTIATE_DIALOG_ID = undefined;
|
||||
var INSTANTIATE_DIALOG_ID = require('./form-panels/instantiate/formPanelId');
|
||||
var IMPORT_DIALOG_ID = undefined;
|
||||
|
||||
var CONFIRM_DIALOG_ID = require('utils/dialogs/generic-confirm/dialogId');
|
||||
@ -39,10 +39,29 @@ define(function(require) {
|
||||
'TAB_ID' : TAB_ID,
|
||||
'CREATE_DIALOG_ID' : CREATE_DIALOG_ID,
|
||||
'CLONE_DIALOG_ID' : CLONE_DIALOG_ID,
|
||||
'INSTANTIATE_DIALOG_ID' : INSTANTIATE_DIALOG_ID,
|
||||
'INSTANTIATE_DIALOG_ID' : undefined,
|
||||
'IMPORT_DIALOG_ID' : IMPORT_DIALOG_ID,
|
||||
'CONFIRM_DIALOG_ID' : CONFIRM_DIALOG_ID,
|
||||
});
|
||||
|
||||
actions["VirtualRouterTemplate.instantiate_dialog"] = {
|
||||
type: "custom",
|
||||
call: function() {
|
||||
var selected_nodes = Sunstone.getDataTable(TAB_ID).elements();
|
||||
if (selected_nodes.length != 1) {
|
||||
Notifier.notifyMessage("Please select one (and just one) template to instantiate.");
|
||||
return false;
|
||||
}
|
||||
|
||||
var templateId = "" + selected_nodes[0];
|
||||
|
||||
Sunstone.resetFormPanel(TAB_ID, INSTANTIATE_DIALOG_ID);
|
||||
Sunstone.showFormPanel(TAB_ID, INSTANTIATE_DIALOG_ID, "instantiate",
|
||||
function(formPanelInstance, context) {
|
||||
formPanelInstance.setTemplateId(context, templateId);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
return actions;
|
||||
});
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
define(function(require) {
|
||||
var TemplateButtons = require('tabs/templates-tab/buttons');
|
||||
var Locale = require('utils/locale');
|
||||
|
||||
var Buttons = {
|
||||
"VirtualRouterTemplate.refresh" : TemplateButtons["Template.refresh"],
|
||||
@ -23,6 +24,11 @@ define(function(require) {
|
||||
// "VirtualRouterTemplate.import_dialog" : TemplateButtons["Template.import_dialog"],
|
||||
"VirtualRouterTemplate.update_dialog" : TemplateButtons["Template.update_dialog"],
|
||||
// "VirtualRouterTemplate.instantiate_vms" : TemplateButtons["Template.instantiate_vms"],
|
||||
"VirtualRouterTemplate.instantiate_dialog" : {
|
||||
type: "action",
|
||||
layout: "main",
|
||||
text: Locale.tr("Instantiate")
|
||||
},
|
||||
"VirtualRouterTemplate.chown" : TemplateButtons["Template.chown"],
|
||||
"VirtualRouterTemplate.chgrp" : TemplateButtons["Template.chgrp"],
|
||||
"VirtualRouterTemplate.clone_dialog" : TemplateButtons["Template.clone_dialog"],
|
||||
|
@ -0,0 +1,199 @@
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* Copyright 2002-2016, OpenNebula Project, OpenNebula Systems */
|
||||
/* */
|
||||
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
|
||||
/* not use this file except in compliance with the License. You may obtain */
|
||||
/* a copy of the License at */
|
||||
/* */
|
||||
/* http://www.apache.org/licenses/LICENSE-2.0 */
|
||||
/* */
|
||||
/* Unless required by applicable law or agreed to in writing, software */
|
||||
/* distributed under the License is distributed on an "AS IS" BASIS, */
|
||||
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
|
||||
/* See the License for the specific language governing permissions and */
|
||||
/* limitations under the License. */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
define(function(require) {
|
||||
/*
|
||||
DEPENDENCIES
|
||||
*/
|
||||
|
||||
var BaseFormPanel = require('utils/form-panels/form-panel');
|
||||
var Sunstone = require('sunstone');
|
||||
var Locale = require('utils/locale');
|
||||
var Tips = require('utils/tips');
|
||||
var UserInputs = require('utils/user-inputs');
|
||||
var WizardFields = require('utils/wizard-fields');
|
||||
var NicsSection = require('utils/nics-section');
|
||||
var OpenNebulaVirtualRouter = require('opennebula/virtualrouter');
|
||||
var OpenNebulaTemplate = require('opennebula/template');
|
||||
var OpenNebulaAction = require('opennebula/action');
|
||||
var Notifier = require('utils/notifier');
|
||||
var Config = require('sunstone-config');
|
||||
|
||||
/*
|
||||
TEMPLATES
|
||||
*/
|
||||
|
||||
var TemplateWizardHTML = require('hbs!./instantiate/wizard');
|
||||
|
||||
/*
|
||||
CONSTANTS
|
||||
*/
|
||||
|
||||
var FORM_PANEL_ID = require('./instantiate/formPanelId');
|
||||
var TAB_ID = require('../tabId');
|
||||
|
||||
/*
|
||||
CONSTRUCTOR
|
||||
*/
|
||||
|
||||
function FormPanel() {
|
||||
this.formPanelId = FORM_PANEL_ID;
|
||||
this.tabId = TAB_ID;
|
||||
this.actions = {
|
||||
'instantiate': {
|
||||
'title': Locale.tr("Instantiate Virtual Router Template"),
|
||||
'buttonText': Locale.tr("Instantiate"),
|
||||
'resetButton': false
|
||||
}
|
||||
};
|
||||
|
||||
BaseFormPanel.call(this);
|
||||
}
|
||||
|
||||
FormPanel.FORM_PANEL_ID = FORM_PANEL_ID;
|
||||
FormPanel.prototype = Object.create(BaseFormPanel.prototype);
|
||||
FormPanel.prototype.constructor = FormPanel;
|
||||
FormPanel.prototype.setTemplateId = _setTemplateId;
|
||||
FormPanel.prototype.htmlWizard = _htmlWizard;
|
||||
FormPanel.prototype.submitWizard = _submitWizard;
|
||||
FormPanel.prototype.onShow = _onShow;
|
||||
FormPanel.prototype.setup = _setup;
|
||||
|
||||
return FormPanel;
|
||||
|
||||
/*
|
||||
FUNCTION DEFINITIONS
|
||||
*/
|
||||
|
||||
function _htmlWizard() {
|
||||
return TemplateWizardHTML({
|
||||
'formPanelId': this.formPanelId
|
||||
});
|
||||
}
|
||||
|
||||
function _setup(context) {
|
||||
var that = this;
|
||||
|
||||
NicsSection.insert({},
|
||||
$(".nicsContext", context),
|
||||
{ floatingIP: true,
|
||||
forceIPv4:true,
|
||||
management: true,
|
||||
securityGroups: Config.isFeatureEnabled("secgroups")});
|
||||
|
||||
$(".vr_attributes #name", context).on("input", function(){
|
||||
$('#vm_name', context).val("vr-"+$(this).val()+"-%i");
|
||||
});
|
||||
|
||||
Tips.setup(context);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function _submitWizard(context) {
|
||||
var that = this;
|
||||
|
||||
var virtual_router_json = WizardFields.retrieve($(".vr_attributes", context));
|
||||
|
||||
var nics = NicsSection.retrieve($(".nicsContext", context));
|
||||
if (nics.length > 0) {
|
||||
virtual_router_json.NIC = nics;
|
||||
}
|
||||
|
||||
virtual_router_json = {
|
||||
"virtual_router" : virtual_router_json
|
||||
};
|
||||
|
||||
var vm_name = $('#vm_name', context).val();
|
||||
var n_times = parseInt($('#vm_n_times', context).val());
|
||||
|
||||
if (isNaN(n_times)){
|
||||
n_times = 1;
|
||||
}
|
||||
|
||||
var hold = $('#hold', context).prop("checked");
|
||||
|
||||
OpenNebulaVirtualRouter.create({
|
||||
data : virtual_router_json,
|
||||
timeout: true,
|
||||
success: function (request, response) {
|
||||
|
||||
var tmpl = WizardFields.retrieve($(".template_user_inputs", context));
|
||||
|
||||
var extra_info = {
|
||||
'n_vms': n_times,
|
||||
'template_id': that.templateId,
|
||||
'vm_name': vm_name,
|
||||
'hold': hold,
|
||||
'template': tmpl
|
||||
};
|
||||
|
||||
Notifier.notifyCustom(Locale.tr("Virtual Router created"), " ID: " + response.VROUTER.ID, false);
|
||||
|
||||
OpenNebulaVirtualRouter.instantiate({
|
||||
data:{
|
||||
id: response.VROUTER.ID,
|
||||
extra_param: extra_info
|
||||
},
|
||||
timeout: true,
|
||||
success: function(request, response){
|
||||
OpenNebulaAction.clear_cache("VM");
|
||||
|
||||
Sunstone.resetFormPanel(TAB_ID, that.formPanelId);
|
||||
Sunstone.hideFormPanel(TAB_ID);
|
||||
},
|
||||
error: function(request, response) {
|
||||
Sunstone.hideFormPanelLoading(TAB_ID);
|
||||
|
||||
Notifier.notifyError(Locale.tr(
|
||||
"Failed to create VMs. Virtual Router may need to be deleted manually."));
|
||||
Notifier.onError(request, response);
|
||||
}
|
||||
});
|
||||
},
|
||||
error: function(request, response) {
|
||||
Sunstone.hideFormPanelLoading(TAB_ID);
|
||||
Notifier.onError(request, response);
|
||||
},
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function _onShow(context) {
|
||||
}
|
||||
|
||||
function _setTemplateId(context, templateId){
|
||||
this.templateId = templateId;
|
||||
|
||||
var inputs_div = $(".template_user_inputs", context);
|
||||
inputs_div.empty();
|
||||
|
||||
OpenNebulaTemplate.show({
|
||||
data : {
|
||||
id: templateId
|
||||
},
|
||||
timeout: true,
|
||||
success: function (request, template_json) {
|
||||
UserInputs.vmTemplateInsert(
|
||||
inputs_div,
|
||||
template_json,
|
||||
{text_header: '<i class="fa fa-gears"></i> '+Locale.tr("Custom Attributes")});
|
||||
},
|
||||
error: Notifier.onError
|
||||
});
|
||||
}
|
||||
});
|
@ -0,0 +1,19 @@
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* Copyright 2002-2016, OpenNebula Project, OpenNebula Systems */
|
||||
/* */
|
||||
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
|
||||
/* not use this file except in compliance with the License. You may obtain */
|
||||
/* a copy of the License at */
|
||||
/* */
|
||||
/* http://www.apache.org/licenses/LICENSE-2.0 */
|
||||
/* */
|
||||
/* Unless required by applicable law or agreed to in writing, software */
|
||||
/* distributed under the License is distributed on an "AS IS" BASIS, */
|
||||
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
|
||||
/* See the License for the specific language governing permissions and */
|
||||
/* limitations under the License. */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
define(function(require){
|
||||
return 'instantiateVirtualRouterTemplateForm';
|
||||
});
|
@ -14,31 +14,30 @@
|
||||
{{! limitations under the License. }}
|
||||
{{! -------------------------------------------------------------------------- }}
|
||||
|
||||
<fieldset>
|
||||
<fieldset class="table_wrapper" style="display:none">
|
||||
<legend>{{tr "Template"}}</legend>
|
||||
<div class="row">
|
||||
{{{templatesTableHTML}}}
|
||||
<div class="row selectTemplateTable">
|
||||
</div>
|
||||
</fieldset>
|
||||
<div class="row nameContainer">
|
||||
<div class="medium-4 columns">
|
||||
<label for="vm_name">
|
||||
<label>
|
||||
{{tr "Virtual machine name"}}
|
||||
<span class="tip">
|
||||
{{tr "When creating multiple VMs, %i is replaces by the VM number in the set"}}.
|
||||
</span>
|
||||
<input type="text" name="vm_name" id="vm_name" />
|
||||
</label>
|
||||
<input type="text" name="vm_name" id="vm_name" />
|
||||
</div>
|
||||
<div class="medium-4 columns">
|
||||
<label for="vm_n_times">
|
||||
<label>
|
||||
{{tr "Number of VM instances"}}
|
||||
<input type="number" name="vm_n_times" id="vm_n_times" value="1" min="1">
|
||||
</label>
|
||||
<input type="number" name="vm_n_times" id="vm_n_times" value="1" min="1">
|
||||
</div>
|
||||
<div class="medium-4 columns">
|
||||
<input type="checkbox" name="hold" id="hold"/>
|
||||
<label for="hold">
|
||||
<label>
|
||||
<input type="checkbox" name="hold" id="hold"/>
|
||||
{{tr "Start on hold"}}
|
||||
</label>
|
||||
</div>
|
@ -19,32 +19,30 @@
|
||||
<div class="vr_attributes">
|
||||
<div class="row">
|
||||
<div class="medium-6 columns">
|
||||
<label for="name" >
|
||||
<label>
|
||||
{{tr "Name"}}
|
||||
<input type="text" wizard_field="NAME" required name="name" id="name"/>
|
||||
</label>
|
||||
<input type="text" wizard_field="NAME" required name="name" id="name"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="medium-6 columns">
|
||||
<label for="DESCRIPTION" >
|
||||
<label>
|
||||
{{tr "Description"}}
|
||||
<textarea type="text" wizard_field="DESCRIPTION" id="DESCRIPTION" name="DESCRIPTION"/>
|
||||
</label>
|
||||
<textarea type="text" wizard_field="DESCRIPTION" id="DESCRIPTION" name="DESCRIPTION"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="medium-6 columns">
|
||||
<label for="keepalived_id" >
|
||||
<label>
|
||||
{{tr "Keepalive service ID"}}
|
||||
<input type="text" wizard_field="KEEPALIVED_ID" name="keepalived_id" id="keepalived_id"/>
|
||||
</label>
|
||||
<input type="text" wizard_field="KEEPALIVED_ID" name="keepalived_id" id="keepalived_id"/>
|
||||
</div>
|
||||
<div class="medium-6 columns">
|
||||
<label for="keepalived_password" >
|
||||
<label>
|
||||
{{tr "Keepalive password"}}
|
||||
<input type="text" wizard_field="KEEPALIVED_PASSWORD" name="keepalived_password" id="keepalived_password"/>
|
||||
</label>
|
||||
<input type="text" wizard_field="KEEPALIVED_PASSWORD" name="keepalived_password" id="keepalived_password"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
@ -19,26 +19,16 @@ define(function(require) {
|
||||
DEPENDENCIES
|
||||
*/
|
||||
|
||||
// require('foundation.tab');
|
||||
var BaseFormPanel = require('utils/form-panels/form-panel');
|
||||
var InstantiateTemplateFormPanel = require('tabs/vrouter-templates-tab/form-panels/instantiate');
|
||||
var Sunstone = require('sunstone');
|
||||
var Locale = require('utils/locale');
|
||||
var Tips = require('utils/tips');
|
||||
var UserInputs = require('utils/user-inputs');
|
||||
var WizardFields = require('utils/wizard-fields');
|
||||
var NicsSection = require('utils/nics-section');
|
||||
var VRouterTemplatesTable = require('tabs/vrouter-templates-tab/datatable');
|
||||
var OpenNebulaVirtualRouter = require('opennebula/virtualrouter');
|
||||
var OpenNebulaTemplate = require('opennebula/template');
|
||||
var OpenNebulaAction = require('opennebula/action');
|
||||
var Notifier = require('utils/notifier');
|
||||
var Config = require('sunstone-config');
|
||||
|
||||
/*
|
||||
TEMPLATES
|
||||
*/
|
||||
|
||||
var TemplateWizardHTML = require('hbs!./create/wizard');
|
||||
var TemplateAdvancedHTML = require('hbs!./create/advanced');
|
||||
|
||||
/*
|
||||
@ -53,6 +43,8 @@ define(function(require) {
|
||||
*/
|
||||
|
||||
function FormPanel() {
|
||||
InstantiateTemplateFormPanel.call(this);
|
||||
|
||||
this.formPanelId = FORM_PANEL_ID;
|
||||
this.tabId = TAB_ID;
|
||||
this.actions = {
|
||||
@ -66,16 +58,12 @@ define(function(require) {
|
||||
this.templatesTable = new VRouterTemplatesTable(
|
||||
'vr_create',
|
||||
{ 'select': true });
|
||||
|
||||
BaseFormPanel.call(this);
|
||||
}
|
||||
|
||||
FormPanel.FORM_PANEL_ID = FORM_PANEL_ID;
|
||||
FormPanel.prototype = Object.create(BaseFormPanel.prototype);
|
||||
FormPanel.prototype = Object.create(InstantiateTemplateFormPanel.prototype);
|
||||
FormPanel.prototype.constructor = FormPanel;
|
||||
FormPanel.prototype.htmlWizard = _htmlWizard;
|
||||
FormPanel.prototype.htmlAdvanced = _htmlAdvanced;
|
||||
FormPanel.prototype.submitWizard = _submitWizard;
|
||||
FormPanel.prototype.submitAdvanced = _submitAdvanced;
|
||||
FormPanel.prototype.onShow = _onShow;
|
||||
FormPanel.prototype.setup = _setup;
|
||||
@ -86,50 +74,25 @@ define(function(require) {
|
||||
FUNCTION DEFINITIONS
|
||||
*/
|
||||
|
||||
function _htmlWizard() {
|
||||
return TemplateWizardHTML({
|
||||
'formPanelId': this.formPanelId,
|
||||
'templatesTableHTML': this.templatesTable.dataTableHTML
|
||||
});
|
||||
}
|
||||
|
||||
function _htmlAdvanced() {
|
||||
return TemplateAdvancedHTML({formPanelId: this.formPanelId});
|
||||
}
|
||||
|
||||
function _setup(context) {
|
||||
var that = this;
|
||||
InstantiateTemplateFormPanel.prototype.setup.call(this, context);
|
||||
|
||||
NicsSection.insert({},
|
||||
$(".nicsContext", context),
|
||||
{ floatingIP: true,
|
||||
forceIPv4:true,
|
||||
management: true,
|
||||
securityGroups: Config.isFeatureEnabled("secgroups")});
|
||||
$(".selectTemplateTable", context).html(this.templatesTable.dataTableHTML);
|
||||
$(".table_wrapper", context).show();
|
||||
|
||||
this.templatesTable.initialize();
|
||||
|
||||
this.templatesTable.idInput().attr("required", "");
|
||||
|
||||
this.templatesTable.idInput().on("change", function(){
|
||||
var templateId = $(this).val();
|
||||
|
||||
var inputs_div = $(".template_user_inputs", context);
|
||||
inputs_div.empty();
|
||||
|
||||
OpenNebulaTemplate.show({
|
||||
data : {
|
||||
id: templateId
|
||||
},
|
||||
timeout: true,
|
||||
success: function (request, template_json) {
|
||||
UserInputs.vmTemplateInsert(
|
||||
inputs_div,
|
||||
template_json,
|
||||
{text_header: '<i class="fa fa-gears"></i> '+Locale.tr("Custom Attributes")});
|
||||
},
|
||||
error: Notifier.onError
|
||||
});
|
||||
var template_id = $(this).val();
|
||||
that.setTemplateId(context, template_id);
|
||||
});
|
||||
|
||||
$(".vr_attributes #name", context).on("input", function(){
|
||||
@ -141,76 +104,6 @@ define(function(require) {
|
||||
return false;
|
||||
}
|
||||
|
||||
function _submitWizard(context) {
|
||||
var virtual_router_json = WizardFields.retrieve($(".vr_attributes", context));
|
||||
|
||||
var nics = NicsSection.retrieve($(".nicsContext", context));
|
||||
if (nics.length > 0) {
|
||||
virtual_router_json.NIC = nics;
|
||||
}
|
||||
|
||||
var tmplId = this.templatesTable.retrieveResourceTableSelect();
|
||||
|
||||
if (this.action == "create") {
|
||||
virtual_router_json = {
|
||||
"virtual_router" : virtual_router_json
|
||||
};
|
||||
|
||||
var vm_name = $('#vm_name', context).val();
|
||||
var n_times = parseInt($('#vm_n_times', context).val());
|
||||
|
||||
if (isNaN(n_times)){
|
||||
n_times = 1;
|
||||
}
|
||||
|
||||
var hold = $('#hold', context).prop("checked");
|
||||
|
||||
OpenNebulaVirtualRouter.create({
|
||||
data : virtual_router_json,
|
||||
timeout: true,
|
||||
success: function (request, response) {
|
||||
|
||||
var tmpl = WizardFields.retrieve($(".template_user_inputs", context));
|
||||
|
||||
var extra_info = {
|
||||
'n_vms': n_times,
|
||||
'template_id': tmplId,
|
||||
'vm_name': vm_name,
|
||||
'hold': hold,
|
||||
'template': tmpl
|
||||
};
|
||||
|
||||
OpenNebulaVirtualRouter.instantiate({
|
||||
data:{
|
||||
id: response.VROUTER.ID,
|
||||
extra_param: extra_info
|
||||
},
|
||||
timeout: true,
|
||||
success: function(request, response){
|
||||
OpenNebulaAction.clear_cache("VM");
|
||||
|
||||
Sunstone.resetFormPanel(TAB_ID, FORM_PANEL_ID);
|
||||
Sunstone.hideFormPanel(TAB_ID);
|
||||
},
|
||||
error: function(request, response) {
|
||||
Sunstone.hideFormPanelLoading(TAB_ID);
|
||||
|
||||
Notifier.notifyError(Locale.tr(
|
||||
"Failed to create VMs. Virtual Router may need to be deleted manually."));
|
||||
Notifier.onError(request, response);
|
||||
}
|
||||
});
|
||||
},
|
||||
error: function(request, response) {
|
||||
Sunstone.hideFormPanelLoading(TAB_ID);
|
||||
Notifier.onError(request, response);
|
||||
},
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function _submitAdvanced(context) {
|
||||
if (this.action == "create") {
|
||||
var template = $('textarea#template', context).val();
|
||||
@ -222,5 +115,6 @@ define(function(require) {
|
||||
|
||||
function _onShow(context) {
|
||||
this.templatesTable.refreshResourceTableSelect();
|
||||
InstantiateTemplateFormPanel.prototype.onShow.call(this, context);
|
||||
}
|
||||
});
|
||||
|
@ -84,14 +84,16 @@ define(function(require) {
|
||||
|
||||
function _html() {
|
||||
return TemplateHTML({
|
||||
'formPanelId': this.formPanelId,
|
||||
'templatesTableHTML': this.templatesTable.dataTableHTML
|
||||
'formPanelId': this.formPanelId
|
||||
});
|
||||
}
|
||||
|
||||
function _setup(context) {
|
||||
var that = this;
|
||||
|
||||
$(".selectTemplateTable", context).html(this.templatesTable.dataTableHTML);
|
||||
$(".table_wrapper", context).show();
|
||||
|
||||
this.templatesTable.initialize();
|
||||
|
||||
this.templatesTable.idInput().attr("required", "");
|
||||
|
@ -15,5 +15,5 @@
|
||||
{{! -------------------------------------------------------------------------- }}
|
||||
|
||||
<form data-abide novalidate id="{{formPanelId}}Wizard" class="custom creation">
|
||||
{{> ../create/templateSelection}}
|
||||
{{> tabs/vrouter-templates-tab/form-panels/instantiate/templateSelection}}
|
||||
</form>
|
Loading…
x
Reference in New Issue
Block a user