diff --git a/include/DispatchManager.h b/include/DispatchManager.h index 7b25fc8aef..5c79353865 100644 --- a/include/DispatchManager.h +++ b/include/DispatchManager.h @@ -20,6 +20,7 @@ #include "ActionManager.h" #include "HostPool.h" #include "VirtualMachinePool.h" +#include "VirtualRouterPool.h" using namespace std; @@ -36,7 +37,7 @@ class DispatchManager : public ActionListener public: DispatchManager(): - hpool(0), vmpool(0), tm(0), vmm(0), lcm(0), imagem(0) + hpool(0), vmpool(0), vrouterpool(0), tm(0), vmm(0), lcm(0), imagem(0) { am.addListener(this); }; @@ -457,6 +458,11 @@ private: */ VirtualMachinePool * vmpool; + /** + * Pointer to the Virtual Machine Pool, to access hosts + */ + VirtualRouterPool * vrouterpool; + /** * Pointer to TransferManager */ diff --git a/include/VirtualRouter.h b/include/VirtualRouter.h index 7a22c3e8f8..526e09775c 100644 --- a/include/VirtualRouter.h +++ b/include/VirtualRouter.h @@ -47,6 +47,11 @@ public: return vms.add(vmid); } + int del_vmid(int vmid) + { + return vms.del(vmid); + } + bool has_vmids() const { return vms.size() > 0; @@ -105,6 +110,20 @@ public: */ int append_template(const string& tmpl_str, bool keep_restricted, string& error); + /** + * Set the template ID to instantiate new VMs + * + * @param tmpl_id VM Template ID + */ + void set_template_id(int tmpl_id); + + /** + * Get the template ID set with set_template_id + * + * @return VM Template ID, or -1 if it was not found + */ + int get_template_id(); + // ------------------------------------------------------------------------ // Attach and detach NIC // ------------------------------------------------------------------------ diff --git a/src/cli/onevrouter b/src/cli/onevrouter index 9f3d45aae2..d423ab63f7 100755 --- a/src/cli/onevrouter +++ b/src/cli/onevrouter @@ -119,7 +119,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do :options=>instantiate_options+OpenNebulaHelper::TEMPLATE_OPTIONS do exit_code=0 - if args[1] && OpenNebulaHelper.create_template_options_used?(options) + if args[2] && OpenNebulaHelper.create_template_options_used?(options) STDERR.puts "You cannot use both template file and template"<< " creation options." next -1 diff --git a/src/dm/DispatchManager.cc b/src/dm/DispatchManager.cc index 1c05681a19..9e059eb00f 100644 --- a/src/dm/DispatchManager.cc +++ b/src/dm/DispatchManager.cc @@ -173,7 +173,8 @@ void DispatchManager::init_managers() imagem = nd.get_imagem(); - hpool = nd.get_hpool(); - vmpool = nd.get_vmpool(); + hpool = nd.get_hpool(); + vmpool = nd.get_vmpool(); + vrouterpool = nd.get_vrouterpool(); } diff --git a/src/dm/DispatchManagerStates.cc b/src/dm/DispatchManagerStates.cc index e2d4e4c0ba..3ac605c90c 100644 --- a/src/dm/DispatchManagerStates.cc +++ b/src/dm/DispatchManagerStates.cc @@ -205,6 +205,7 @@ void DispatchManager::done_action(int vid) int uid; int gid; string deploy_id; + int vrid = -1; VirtualMachine::LcmState lcm_state; VirtualMachine::VmState dm_state; @@ -244,6 +245,11 @@ void DispatchManager::done_action(int vid) deploy_id = vm->get_deploy_id(); } + if (vm->is_vrouter()) + { + vrid = vm->get_vrouter_id(); + } + vm->unlock(); Quotas::vm_del(uid, gid, tmpl); @@ -254,6 +260,20 @@ void DispatchManager::done_action(int vid) { vmpool->drop_index(deploy_id); } + + if (vrid != -1) + { + VirtualRouter* vr = vrouterpool->get(vrid, true); + + if (vr != 0) + { + vr->del_vmid(vid); + + vrouterpool->update(vr); + + vr->unlock(); + } + } } else { diff --git a/src/rm/RequestManagerVirtualMachine.cc b/src/rm/RequestManagerVirtualMachine.cc index 6c3523b9d8..c46b515069 100644 --- a/src/rm/RequestManagerVirtualMachine.cc +++ b/src/rm/RequestManagerVirtualMachine.cc @@ -535,26 +535,13 @@ void VirtualMachineAction::request_execute(xmlrpc_c::paramList const& paramList, if (vm->is_vrouter() && !VirtualRouter::is_action_supported(action)) { - bool failure = true; + att.resp_msg = "Action \"" + action_st + "\" is not supported for " + "virtual router VMs"; - // Terminate operation is allowed for orphan virtual router VMs. - if ( action == History::TERMINATE_ACTION || - action == History::TERMINATE_HARD_ACTION ) - { - VirtualRouterPool* vrpool = Nebula::instance().get_vrouterpool(); - failure = (vrpool->get(vm->get_vrouter_id(), false) != 0); - } + failure_response(ACTION, att); - if (failure) - { - att.resp_msg = "Action \"" + action_st + "\" is not supported for " - "virtual router VMs"; - - failure_response(ACTION, att); - - vm->unlock(); - return; - } + vm->unlock(); + return; } vm->unlock(); diff --git a/src/rm/RequestManagerVirtualRouter.cc b/src/rm/RequestManagerVirtualRouter.cc index 5417d04e24..daef3792f8 100644 --- a/src/rm/RequestManagerVirtualRouter.cc +++ b/src/rm/RequestManagerVirtualRouter.cc @@ -42,7 +42,6 @@ void VirtualRouterInstantiate::request_execute( PoolObjectAuth vr_perms; Template* extra_attrs; - bool has_vmids; string error; string vr_name, tmp_name; ostringstream oss; @@ -67,11 +66,23 @@ void VirtualRouterInstantiate::request_execute( vr->get_permissions(vr_perms); extra_attrs = vr->get_vm_template(); - has_vmids = vr->has_vmids(); vr_name = vr->get_name(); + if (tmpl_id == -1) + { + tmpl_id = vr->get_template_id(); + } + vr->unlock(); + if (tmpl_id == -1) + { + att.resp_msg = "A template ID was not provided, and the virtual router " + "does not have a default one"; + failure_response(ACTION, att); + return; + } + if ( att.uid != 0 ) { AuthRequest ar(att.uid, att.group_ids); @@ -86,13 +97,6 @@ void VirtualRouterInstantiate::request_execute( } } - if (has_vmids) - { - att.resp_msg = "Virtual router already has VMs. Cannot instantiate new ones"; - failure_response(ACTION, att); - return; - } - VMTemplate * tmpl = tpool->get(tmpl_id,true); if ( tmpl == 0 ) @@ -154,6 +158,8 @@ void VirtualRouterInstantiate::request_execute( vr->add_vmid(*vmid); } + vr->set_template_id(tmpl_id); + vrpool->update(vr); vr->unlock(); diff --git a/src/sunstone/etc/sunstone-views/admin.yaml b/src/sunstone/etc/sunstone-views/admin.yaml index a6bbfc4192..61e5109979 100644 --- a/src/sunstone/etc/sunstone-views/admin.yaml +++ b/src/sunstone/etc/sunstone-views/admin.yaml @@ -251,6 +251,7 @@ tabs: VirtualRouterTemplate.refresh: true VirtualRouterTemplate.create_dialog: true VirtualRouterTemplate.update_dialog: true + VirtualRouterTemplate.instantiate_vms: true VirtualRouterTemplate.rename: true VirtualRouterTemplate.chown: true VirtualRouterTemplate.chgrp: true diff --git a/src/sunstone/etc/sunstone-views/admin_vcenter.yaml b/src/sunstone/etc/sunstone-views/admin_vcenter.yaml index b52dd1d57e..146507daca 100644 --- a/src/sunstone/etc/sunstone-views/admin_vcenter.yaml +++ b/src/sunstone/etc/sunstone-views/admin_vcenter.yaml @@ -251,6 +251,7 @@ tabs: VirtualRouterTemplate.refresh: true VirtualRouterTemplate.create_dialog: true VirtualRouterTemplate.update_dialog: true + VirtualRouterTemplate.instantiate_vms: true VirtualRouterTemplate.rename: true VirtualRouterTemplate.chown: true VirtualRouterTemplate.chgrp: true diff --git a/src/sunstone/etc/sunstone-views/groupadmin.yaml b/src/sunstone/etc/sunstone-views/groupadmin.yaml index c213bc7fe9..6fd771df7d 100644 --- a/src/sunstone/etc/sunstone-views/groupadmin.yaml +++ b/src/sunstone/etc/sunstone-views/groupadmin.yaml @@ -251,6 +251,7 @@ tabs: VirtualRouterTemplate.refresh: true VirtualRouterTemplate.create_dialog: false VirtualRouterTemplate.update_dialog: false + VirtualRouterTemplate.instantiate_vms: false VirtualRouterTemplate.rename: true VirtualRouterTemplate.chown: true VirtualRouterTemplate.chgrp: false diff --git a/src/sunstone/etc/sunstone-views/groupadmin_vcenter.yaml b/src/sunstone/etc/sunstone-views/groupadmin_vcenter.yaml index 647734d53c..de51f2edc5 100644 --- a/src/sunstone/etc/sunstone-views/groupadmin_vcenter.yaml +++ b/src/sunstone/etc/sunstone-views/groupadmin_vcenter.yaml @@ -253,6 +253,7 @@ tabs: VirtualRouterTemplate.refresh: true VirtualRouterTemplate.create_dialog: false VirtualRouterTemplate.update_dialog: false + VirtualRouterTemplate.instantiate_vms: false VirtualRouterTemplate.rename: true VirtualRouterTemplate.chown: true VirtualRouterTemplate.chgrp: false diff --git a/src/sunstone/etc/sunstone-views/user.yaml b/src/sunstone/etc/sunstone-views/user.yaml index 5d897485c6..95b8719f18 100644 --- a/src/sunstone/etc/sunstone-views/user.yaml +++ b/src/sunstone/etc/sunstone-views/user.yaml @@ -252,6 +252,7 @@ tabs: VirtualRouterTemplate.refresh: true VirtualRouterTemplate.create_dialog: true VirtualRouterTemplate.update_dialog: true + VirtualRouterTemplate.instantiate_vms: true VirtualRouterTemplate.rename: true VirtualRouterTemplate.chown: false VirtualRouterTemplate.chgrp: false diff --git a/src/sunstone/public/app/tabs/vrouters-tab.js b/src/sunstone/public/app/tabs/vrouters-tab.js index 092a560099..51ea006adc 100644 --- a/src/sunstone/public/app/tabs/vrouters-tab.js +++ b/src/sunstone/public/app/tabs/vrouters-tab.js @@ -37,7 +37,8 @@ define(function(require) { ]; var _formPanels = [ - require('./vrouters-tab/form-panels/create') + require('./vrouters-tab/form-panels/create'), + require('./vrouters-tab/form-panels/instantiate') ]; var Tab = { diff --git a/src/sunstone/public/app/tabs/vrouters-tab/actions.js b/src/sunstone/public/app/tabs/vrouters-tab/actions.js index b3942e8a25..4184410224 100644 --- a/src/sunstone/public/app/tabs/vrouters-tab/actions.js +++ b/src/sunstone/public/app/tabs/vrouters-tab/actions.js @@ -26,6 +26,7 @@ define(function(require) { var XML_ROOT = "VROUTER"; var TAB_ID = require('./tabId'); var CREATE_DIALOG_ID = require('./form-panels/create/formPanelId'); + var INSTANTIATE_DIALOG_ID = require('./form-panels/instantiate/formPanelId'); var _commonActions = new CommonActions(OpenNebulaResource, RESOURCE, TAB_ID, XML_ROOT, Locale.tr("Virtual Router created")); @@ -33,6 +34,32 @@ define(function(require) { var _actions = { "VirtualRouter.create" : _commonActions.create(CREATE_DIALOG_ID), "VirtualRouter.create_dialog" : _commonActions.showCreate(CREATE_DIALOG_ID), + "VirtualRouter.instantiate_vms" : { + 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) Virtual Router."); + return false; + } + + var vrId = "" + selected_nodes[0]; + + OpenNebulaResource.show({ + data:{ + id: vrId + }, + success: function(request, response){ + Sunstone.resetFormPanel(TAB_ID, INSTANTIATE_DIALOG_ID); + Sunstone.showFormPanel(TAB_ID, INSTANTIATE_DIALOG_ID, "instantiate", + function(formPanelInstance, context) { + formPanelInstance.fill(context, response[XML_ROOT]); + }); + }, + error: Notifier.onError + }); + } + }, "VirtualRouter.list" : _commonActions.list(), "VirtualRouter.show" : _commonActions.show(), "VirtualRouter.refresh" : _commonActions.refresh(), diff --git a/src/sunstone/public/app/tabs/vrouters-tab/buttons.js b/src/sunstone/public/app/tabs/vrouters-tab/buttons.js index 0d41b51680..d6fd031e0a 100644 --- a/src/sunstone/public/app/tabs/vrouters-tab/buttons.js +++ b/src/sunstone/public/app/tabs/vrouters-tab/buttons.js @@ -27,6 +27,11 @@ define(function(require) { type: "create_dialog", layout: "create" }, + "VirtualRouter.instantiate_vms" : { + type: "action", + layout: "main", + text: Locale.tr("Instantiate VMs") + }, "VirtualRouter.chown" : { type: "confirm_with_select", text: Locale.tr("Change owner"), diff --git a/src/sunstone/public/app/tabs/vrouters-tab/form-panels/create/templateSelection.hbs b/src/sunstone/public/app/tabs/vrouters-tab/form-panels/create/templateSelection.hbs new file mode 100644 index 0000000000..7d821cd51c --- /dev/null +++ b/src/sunstone/public/app/tabs/vrouters-tab/form-panels/create/templateSelection.hbs @@ -0,0 +1,50 @@ +{{! -------------------------------------------------------------------------- }} +{{! 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. }} +{{! -------------------------------------------------------------------------- }} + +
+ {{tr "Template"}} +
+ {{{templatesTableHTML}}} +
+
+
+
+ + +
+
+ + +
+
+ + +
+
+
+
+
+
+
\ No newline at end of file diff --git a/src/sunstone/public/app/tabs/vrouters-tab/form-panels/create/wizard.hbs b/src/sunstone/public/app/tabs/vrouters-tab/form-panels/create/wizard.hbs index cd53ba0fb4..ea12bea32f 100644 --- a/src/sunstone/public/app/tabs/vrouters-tab/form-panels/create/wizard.hbs +++ b/src/sunstone/public/app/tabs/vrouters-tab/form-panels/create/wizard.hbs @@ -56,40 +56,6 @@
-
- {{tr "Template"}} -
- {{{templatesTableHTML}}} -
-
- {{!TODO: duplicated html from templates-tab/form-panels/instantiate/html.hbs}} -
-
- - -
-
- - -
-
- - -
-
-
-
-
-
-
+ {{> ./templateSelection}} diff --git a/src/sunstone/public/app/tabs/vrouters-tab/form-panels/instantiate.js b/src/sunstone/public/app/tabs/vrouters-tab/form-panels/instantiate.js new file mode 100644 index 0000000000..7b6e6f885c --- /dev/null +++ b/src/sunstone/public/app/tabs/vrouters-tab/form-panels/instantiate.js @@ -0,0 +1,184 @@ +/* -------------------------------------------------------------------------- */ +/* 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 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'); + + /* + TEMPLATES + */ + + var TemplateHTML = require('hbs!./instantiate/html'); + + /* + 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 VMs"), + 'buttonText': Locale.tr("Instantiate"), + 'resetButton': false + } + }; + + this.templatesTable = new VRouterTemplatesTable( + 'vr_instantiate', + { 'select': true }); + + BaseFormPanel.call(this); + } + + FormPanel.FORM_PANEL_ID = FORM_PANEL_ID; + FormPanel.prototype = Object.create(BaseFormPanel.prototype); + FormPanel.prototype.constructor = FormPanel; + FormPanel.prototype.fill = _fill; + FormPanel.prototype.htmlWizard = _html; + FormPanel.prototype.submitWizard = _submitWizard; + FormPanel.prototype.onShow = _onShow; + FormPanel.prototype.setup = _setup; + + return FormPanel; + + /* + FUNCTION DEFINITIONS + */ + + function _html() { + return TemplateHTML({ + 'formPanelId': this.formPanelId, + 'templatesTableHTML': this.templatesTable.dataTableHTML + }); + } + + function _setup(context) { + var that = this; + + 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: ' '+Locale.tr("Custom Attributes")}); + }, + error: Notifier.onError + }); + }); + + Tips.setup(context); + return false; + } + + function _onShow(context) { + this.templatesTable.refreshResourceTableSelect(); + } + + function _fill(context, element) { + this.setHeader(element); + + this.vrId = element.ID; + + if(element.TEMPLATE.TEMPLATE_ID != undefined){ + this.templatesTable.selectResourceTableSelect( + {ids: element.TEMPLATE.TEMPLATE_ID}); + } + } + + function _submitWizard(context) { + var that = this; + + var tmplId = this.templatesTable.retrieveResourceTableSelect(); + + 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"); + + 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: that.vrId, + 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.onError(request, response); + } + }); + + return false; + } +}); diff --git a/src/sunstone/public/app/tabs/vrouters-tab/form-panels/instantiate/formPanelId.js b/src/sunstone/public/app/tabs/vrouters-tab/form-panels/instantiate/formPanelId.js new file mode 100644 index 0000000000..c93a4a5bf8 --- /dev/null +++ b/src/sunstone/public/app/tabs/vrouters-tab/form-panels/instantiate/formPanelId.js @@ -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 'instantiateVirtualRouterForm'; +}); diff --git a/src/sunstone/public/app/tabs/vrouters-tab/form-panels/instantiate/html.hbs b/src/sunstone/public/app/tabs/vrouters-tab/form-panels/instantiate/html.hbs new file mode 100644 index 0000000000..deba1393a0 --- /dev/null +++ b/src/sunstone/public/app/tabs/vrouters-tab/form-panels/instantiate/html.hbs @@ -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. }} +{{! -------------------------------------------------------------------------- }} + +
+ {{> ../create/templateSelection}} +
\ No newline at end of file diff --git a/src/vrouter/VirtualRouter.cc b/src/vrouter/VirtualRouter.cc index c28000c382..25a731576b 100644 --- a/src/vrouter/VirtualRouter.cc +++ b/src/vrouter/VirtualRouter.cc @@ -19,7 +19,7 @@ #include "Nebula.h" #include "VirtualMachine.h" -static const History::VMAction action[11] = { +static const History::VMAction action[15] = { History::MIGRATE_ACTION, History::LIVE_MIGRATE_ACTION, History::HOLD_ACTION, @@ -30,10 +30,14 @@ static const History::VMAction action[11] = { History::RESCHED_ACTION, History::UNRESCHED_ACTION, History::DISK_SNAPSHOT_CREATE_ACTION, - History::DISK_SNAPSHOT_DELETE_ACTION + History::DISK_SNAPSHOT_DELETE_ACTION, + History::TERMINATE_ACTION, + History::TERMINATE_HARD_ACTION, + History::DELETE_ACTION, + History::DELETE_RECREATE_ACTION }; -const ActionSet VirtualRouter::SUPPORTED_ACTIONS(action, 11); +const ActionSet VirtualRouter::SUPPORTED_ACTIONS(action, 15); /* ************************************************************************ */ /* VirtualRouter :: Constructor/Destructor */ @@ -717,3 +721,27 @@ void VirtualRouter::set_auth_request(int uid, } } +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +void VirtualRouter::set_template_id(int tmpl_id) +{ + replace_template_attribute("TEMPLATE_ID", tmpl_id); +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +int VirtualRouter::get_template_id() +{ + int tmpl_id; + + if (get_template_attribute("TEMPLATE_ID", tmpl_id)) + { + return tmpl_id; + } + else + { + return -1; + } +}