1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-01-11 05:17:41 +03:00

Feature #4215: Virtual Router pool in Sunstone

This commit is contained in:
Carlos Martín 2015-11-30 17:02:45 +01:00
parent 64ebcdd5c3
commit cca441ef0d
25 changed files with 1120 additions and 3 deletions

View File

@ -18,6 +18,7 @@ enabled_tabs:
- datastores-tab - datastores-tab
- vnets-tab - vnets-tab
- secgroups-tab - secgroups-tab
- vrouters-tab
- zones-tab - zones-tab
- marketplace-tab - marketplace-tab
- oneflow-dashboard - oneflow-dashboard
@ -426,6 +427,25 @@ tabs:
SecurityGroup.chmod: true SecurityGroup.chmod: true
SecurityGroup.clone_dialog: true SecurityGroup.clone_dialog: true
SecurityGroup.delete: true SecurityGroup.delete: true
vrouters-tab:
panel_tabs:
virtual_router_info_tab: true
table_columns:
- 0 # Checkbox
- 1 # ID
- 2 # Owner
- 3 # Group
- 4 # Name
actions:
VirtualRouter.refresh: true
VirtualRouter.create_dialog: true
VirtualRouter.update_dialog: true
VirtualRouter.rename: true
VirtualRouter.chown: true
VirtualRouter.chgrp: true
VirtualRouter.chmod: true
VirtualRouter.clone_dialog: true
VirtualRouter.delete: true
marketplace-tab: marketplace-tab:
panel_tabs: panel_tabs:
marketplace_info_tab: true marketplace_info_tab: true

View File

@ -18,6 +18,7 @@ enabled_tabs:
#- datastores-tab #- datastores-tab
- vnets-tab - vnets-tab
#- secgroups-tab #- secgroups-tab
- vrouters-tab
- zones-tab - zones-tab
#- marketplace-tab #- marketplace-tab
- oneflow-dashboard - oneflow-dashboard
@ -426,6 +427,25 @@ tabs:
SecurityGroup.chmod: true SecurityGroup.chmod: true
SecurityGroup.clone_dialog: true SecurityGroup.clone_dialog: true
SecurityGroup.delete: true SecurityGroup.delete: true
vrouters-tab:
panel_tabs:
virtual_router_info_tab: true
table_columns:
- 0 # Checkbox
- 1 # ID
- 2 # Owner
- 3 # Group
- 4 # Name
actions:
VirtualRouter.refresh: true
VirtualRouter.create_dialog: true
VirtualRouter.update_dialog: true
VirtualRouter.rename: true
VirtualRouter.chown: true
VirtualRouter.chgrp: true
VirtualRouter.chmod: true
VirtualRouter.clone_dialog: true
VirtualRouter.delete: true
marketplace-tab: marketplace-tab:
panel_tabs: panel_tabs:
marketplace_info_tab: true marketplace_info_tab: true

View File

@ -18,6 +18,7 @@ enabled_tabs:
- datastores-tab - datastores-tab
- vnets-tab - vnets-tab
- secgroups-tab - secgroups-tab
- vrouters-tab
#- zones-tab #- zones-tab
- marketplace-tab - marketplace-tab
- oneflow-dashboard - oneflow-dashboard
@ -427,6 +428,25 @@ tabs:
SecurityGroup.chmod: true SecurityGroup.chmod: true
SecurityGroup.clone_dialog: true SecurityGroup.clone_dialog: true
SecurityGroup.delete: true SecurityGroup.delete: true
vrouters-tab:
panel_tabs:
virtual_router_info_tab: true
table_columns:
- 0 # Checkbox
- 1 # ID
- 2 # Owner
- 3 # Group
- 4 # Name
actions:
VirtualRouter.refresh: true
VirtualRouter.create_dialog: true
VirtualRouter.update_dialog: true
VirtualRouter.rename: true
VirtualRouter.chown: true
VirtualRouter.chgrp: true
VirtualRouter.chmod: true
VirtualRouter.clone_dialog: true
VirtualRouter.delete: true
marketplace-tab: marketplace-tab:
panel_tabs: panel_tabs:
marketplace_info_tab: true marketplace_info_tab: true

View File

@ -32,6 +32,7 @@ require 'OpenNebulaJSON/DatastoreJSON'
require 'OpenNebulaJSON/ZoneJSON' require 'OpenNebulaJSON/ZoneJSON'
require 'OpenNebulaJSON/SecurityGroupJSON' require 'OpenNebulaJSON/SecurityGroupJSON'
require 'OpenNebulaJSON/VdcJSON' require 'OpenNebulaJSON/VdcJSON'
require 'OpenNebulaJSON/VirtualRouterJSON'
module OpenNebula module OpenNebula
class Error class Error

View File

@ -30,4 +30,5 @@ module OpenNebulaJSON
class ZonePoolJSON < OpenNebula::ZonePool; include JSONUtils; end class ZonePoolJSON < OpenNebula::ZonePool; include JSONUtils; end
class SecurityGroupPoolJSON < OpenNebula::SecurityGroupPool; include JSONUtils; end class SecurityGroupPoolJSON < OpenNebula::SecurityGroupPool; include JSONUtils; end
class VdcPoolJSON < OpenNebula::VdcPool; include JSONUtils; end class VdcPoolJSON < OpenNebula::VdcPool; include JSONUtils; end
class VirtualRouterPoolJSON < OpenNebula::VirtualRouterPool; include JSONUtils; end
end end

View File

@ -0,0 +1,91 @@
# -------------------------------------------------------------------------- #
# Copyright 2002-2015, 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. #
#--------------------------------------------------------------------------- #
require 'OpenNebulaJSON/JSONUtils'
module OpenNebulaJSON
class VirtualRouterJSON < OpenNebula::VirtualRouter
include JSONUtils
def create(template_json)
vrouter_hash = parse_json(template_json, 'virtual_router')
if OpenNebula.is_error?(vrouter_hash)
return vrouter_hash
end
if vrouter_hash['virtual_router_raw']
template = vrouter_hash['virtual_router_raw']
else
template = template_to_str(vrouter_hash)
end
self.allocate(template)
end
def perform_action(template_json)
action_hash = parse_json(template_json, 'action')
if OpenNebula.is_error?(action_hash)
return action_hash
end
rc = case action_hash['perform']
when "update" then self.update(action_hash['params'])
when "chown" then self.chown(action_hash['params'])
when "chmod" then self.chmod_json(action_hash['params'])
when "clone" then self.clone(action_hash['params'])
when "rename" then self.rename(action_hash['params'])
else
error_msg = "#{action_hash['perform']} action not " <<
" available for this resource"
OpenNebula::Error.new(error_msg)
end
end
def update(params=Hash.new)
super(params['template_raw'])
end
def chown(params=Hash.new)
super(params['owner_id'].to_i,params['group_id'].to_i)
end
def chmod_json(params=Hash.new)
if params['octet']
self.chmod_octet(params['octet'])
else
self.chmod((params['owner_u']||-1),
(params['owner_m']||-1),
(params['owner_a']||-1),
(params['group_u']||-1),
(params['group_m']||-1),
(params['group_a']||-1),
(params['other_u']||-1),
(params['other_m']||-1),
(params['other_a']||-1))
end
end
def clone(params=Hash.new)
super(params['name'])
end
def rename(params=Hash.new)
super(params['name'])
end
end
end

View File

@ -65,6 +65,7 @@ class SunstoneServer < CloudServer
when "zone" then ZonePoolJSON.new(client) when "zone" then ZonePoolJSON.new(client)
when "security_group" then SecurityGroupPoolJSON.new(client, user_flag) when "security_group" then SecurityGroupPoolJSON.new(client, user_flag)
when "vdc" then VdcPoolJSON.new(client) when "vdc" then VdcPoolJSON.new(client)
when "vrouter" then VirtualRouterPoolJSON.new(client, user_flag)
else else
error = Error.new("Error: #{kind} resource not supported") error = Error.new("Error: #{kind} resource not supported")
return [404, error.to_json] return [404, error.to_json]
@ -122,6 +123,7 @@ class SunstoneServer < CloudServer
when "zone" then ZoneJSON.new(Zone.build_xml, @client) when "zone" then ZoneJSON.new(Zone.build_xml, @client)
when "security_group" then SecurityGroupJSON.new(SecurityGroup.build_xml, @client) when "security_group" then SecurityGroupJSON.new(SecurityGroup.build_xml, @client)
when "vdc" then VdcJSON.new(Vdc.build_xml, @client) when "vdc" then VdcJSON.new(Vdc.build_xml, @client)
when "vrouter" then VirtualRouterJSON.new(VirtualRouter.build_xml, @client)
else else
error = Error.new("Error: #{kind} resource not supported") error = Error.new("Error: #{kind} resource not supported")
return [404, error.to_json] return [404, error.to_json]
@ -443,6 +445,7 @@ class SunstoneServer < CloudServer
when "zone" then ZoneJSON.new_with_id(id, @client) when "zone" then ZoneJSON.new_with_id(id, @client)
when "security_group" then SecurityGroupJSON.new_with_id(id, @client) when "security_group" then SecurityGroupJSON.new_with_id(id, @client)
when "vdc" then VdcJSON.new_with_id(id, @client) when "vdc" then VdcJSON.new_with_id(id, @client)
when "vrouter" then VirtualRouterJSON.new_with_id(id, @client)
else else
error = Error.new("Error: #{kind} resource not supported") error = Error.new("Error: #{kind} resource not supported")
return error return error

View File

@ -133,6 +133,7 @@ require.config({
'tabs/datastores-tab', 'tabs/datastores-tab',
'tabs/vnets-tab', 'tabs/vnets-tab',
'tabs/secgroups-tab', 'tabs/secgroups-tab',
'tabs/vrouters-tab',
'tabs/zones-tab', 'tabs/zones-tab',
'tabs/marketplace-tab', 'tabs/marketplace-tab',
'tabs/oneflow-dashboard', 'tabs/oneflow-dashboard',

View File

@ -39,7 +39,8 @@ define(function(require) {
User = require('./opennebula/user'), User = require('./opennebula/user'),
Vdc = require('./opennebula/vdc'), Vdc = require('./opennebula/vdc'),
Vm = require('./opennebula/vm'), Vm = require('./opennebula/vm'),
Zone = require('./opennebula/zone') Zone = require('./opennebula/zone'),
VirtualRouter = require('./opennebula/virtualrouter');
if (typeof(csrftoken) != "undefined") { if (typeof(csrftoken) != "undefined") {
$.ajaxPrefilter(function(options, originalOptions, jqXHR) { $.ajaxPrefilter(function(options, originalOptions, jqXHR) {
@ -88,8 +89,9 @@ define(function(require) {
'User': User, 'User': User,
'Vdc': Vdc, 'Vdc': Vdc,
'VM': Vm, 'VM': Vm,
'Zone': Zone 'Zone': Zone,
} 'VirtualRouter': VirtualRouter
};
return OpenNebula; return OpenNebula;
}); });

View File

@ -0,0 +1,66 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2015, 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) {
var OpenNebulaAction = require('./action');
var RESOURCE = "VROUTER";
var VirtualRouter = {
"resource" : RESOURCE,
"create" : function(params) {
OpenNebulaAction.create(params, RESOURCE);
},
"del" : function(params) {
OpenNebulaAction.del(params, RESOURCE);
},
"list" : function(params) {
OpenNebulaAction.list(params, RESOURCE);
},
"show" : function(params) {
OpenNebulaAction.show(params, RESOURCE);
},
"chown" : function(params) {
OpenNebulaAction.chown(params, RESOURCE);
},
"chgrp" : function(params) {
OpenNebulaAction.chgrp(params, RESOURCE);
},
"chmod" : function(params) {
var action_obj = params.data.extra_param;
OpenNebulaAction.simple_action(params, RESOURCE, "chmod", action_obj);
},
"update": function(params) {
var action_obj = {"template_raw" : params.data.extra_param};
OpenNebulaAction.simple_action(params, RESOURCE, "update", action_obj);
},
"clone" : function(params) {
var name = params.data.extra_param ? params.data.extra_param : "";
var action_obj = {"name" : name};
OpenNebulaAction.simple_action(params, RESOURCE, "clone", action_obj);
},
"rename" : function(params) {
var action_obj = params.data.extra_param;
OpenNebulaAction.simple_action(params, RESOURCE, "rename", action_obj);
},
"getName": function(id){
return OpenNebulaAction.getName(id, RESOURCE);
}
};
return VirtualRouter;
});

View File

@ -0,0 +1,61 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2015, 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) {
var Locale = require('utils/locale');
var Buttons = require('./vrouters-tab/buttons');
var Actions = require('./vrouters-tab/actions');
var Table = require('./vrouters-tab/datatable');
var TAB_ID = require('./vrouters-tab/tabId');
var DATATABLE_ID = "dataTableVirtualRouters";
var _dialogs = [
require('./vrouters-tab/dialogs/clone')
];
var _panels = [
require('./vrouters-tab/panels/info')
];
var _panelsHooks = [
require('../utils/hooks/header')
];
var _formPanels = [
require('./vrouters-tab/form-panels/create')
];
var Tab = {
tabId: TAB_ID,
title: Locale.tr("Virtual Routers"),
tabClass: "subTab",
parentTab: "infra-tab",
listHeader: '<i class="fa fa-fw fa-random"></i>&emsp;'+Locale.tr("Virtual Routers"),
infoHeader: '<i class="fa fa-fw fa-random"></i>&emsp;'+Locale.tr("Virtual Router"),
subheader: '<span/> <small></small>&emsp;',
resource: 'VirtualRouter',
buttons: Buttons,
actions: Actions,
dataTable: new Table(DATATABLE_ID, {actions: true, info: true}),
panels: _panels,
panelsHooks: _panelsHooks,
formPanels: _formPanels,
dialogs: _dialogs
};
return Tab;
});

View File

@ -0,0 +1,70 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2015, 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) {
var Sunstone = require('sunstone');
var Notifier = require('utils/notifier');
var Locale = require('utils/locale');
var DataTable = require('./datatable');
var OpenNebulaResource = require('opennebula/virtualrouter');
var CommonActions = require('utils/common-actions');
var RESOURCE = "VirtualRouter";
var XML_ROOT = "VROUTER";
var TAB_ID = require('./tabId');
var CREATE_DIALOG_ID = require('./form-panels/create/formPanelId');
var CLONE_DIALOG_ID = require('./dialogs/clone/dialogId');
var _commonActions = new CommonActions(OpenNebulaResource, RESOURCE, TAB_ID, XML_ROOT);
var _actions = {
"VirtualRouter.create" : _commonActions.create(CREATE_DIALOG_ID),
"VirtualRouter.create_dialog" : _commonActions.showCreate(CREATE_DIALOG_ID),
"VirtualRouter.list" : _commonActions.list(),
"VirtualRouter.show" : _commonActions.show(),
"VirtualRouter.refresh" : _commonActions.refresh(),
"VirtualRouter.delete" : _commonActions.del(),
"VirtualRouter.chown": _commonActions.multipleAction('chown'),
"VirtualRouter.chgrp": _commonActions.multipleAction('chgrp'),
"VirtualRouter.chmod": _commonActions.singleAction('chmod'),
"VirtualRouter.rename": _commonActions.singleAction('rename'),
"VirtualRouter.update" : _commonActions.update(),
"VirtualRouter.update_template" : _commonActions.updateTemplate(),
"VirtualRouter.update_dialog" : _commonActions.checkAndShowUpdate(),
"VirtualRouter.show_to_update" : _commonActions.showUpdate(CREATE_DIALOG_ID),
"VirtualRouter.clone_dialog" : {
type: "custom",
call: function(){
Sunstone.getDialog(CLONE_DIALOG_ID).show();
}
},
"VirtualRouter.clone" : {
type: "single",
call: OpenNebulaResource.clone,
callback: function(request, response) {
Sunstone.getDialog(CLONE_DIALOG_ID).hide();
Sunstone.getDialog(CLONE_DIALOG_ID).reset();
Sunstone.runAction('VirtualRouter.refresh');
},
error: Notifier.onError,
notify: true
}
};
return _actions;
});

View File

@ -0,0 +1,62 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2015, 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) {
var Locale = require('utils/locale');
var Buttons = {
"VirtualRouter.refresh" : {
type: "action",
layout: "refresh",
alwaysActive: true
},
"VirtualRouter.create_dialog" : {
type: "create_dialog",
layout: "create"
},
"VirtualRouter.update_dialog" : {
type: "action",
layout: "main",
text: Locale.tr("Update")
},
"VirtualRouter.chown" : {
type: "confirm_with_select",
text: Locale.tr("Change owner"),
layout: "user_select",
select: "User",
tip: Locale.tr("Select the new owner")+":"
},
"VirtualRouter.chgrp" : {
type: "confirm_with_select",
text: Locale.tr("Change group"),
layout: "user_select",
select: "Group",
tip: Locale.tr("Select the new group")+":"
},
"VirtualRouter.clone_dialog" : {
type: "action",
layout: "main",
text: Locale.tr("Clone")
},
"VirtualRouter.delete" : {
type: "confirm",
layout: "del",
text: Locale.tr("Delete")
}
};
return Buttons;
});

View File

@ -0,0 +1,99 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2015, 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 TabDataTable = require('utils/tab-datatable');
var SunstoneConfig = require('sunstone-config');
var Locale = require('utils/locale');
/*
CONSTANTS
*/
var RESOURCE = "VirtualRouter";
var XML_ROOT = "VROUTER";
var TAB_NAME = require('./tabId');
/*
CONSTRUCTOR
*/
function Table(dataTableId, conf) {
this.conf = conf || {};
this.tabId = TAB_NAME;
this.dataTableId = dataTableId;
this.resource = RESOURCE;
this.xmlRoot = XML_ROOT;
this.dataTableOptions = {
"bAutoWidth": false,
"bSortClasses" : false,
"bDeferRender": true,
"aoColumnDefs": [
{"bSortable": false, "aTargets": ["check"]},
{"sWidth": "35px", "aTargets": [0]},
{"bVisible": true, "aTargets": SunstoneConfig.tabTableColumns(TAB_NAME)},
{"bVisible": false, "aTargets": ['_all']}
]
};
this.columns = [
Locale.tr("ID"),
Locale.tr("Owner"),
Locale.tr("Group"),
Locale.tr("Name")
];
this.selectOptions = {
"id_index": 1,
"name_index": 4,
"select_resource": Locale.tr("Please select a virtual router from the list"),
"you_selected": Locale.tr("You selected the following virtual router:"),
"select_resource_multiple": Locale.tr("Please select one or more virtual routers from the list"),
"you_selected_multiple": Locale.tr("You selected the following virtual routers:")
};
TabDataTable.call(this);
}
Table.prototype = Object.create(TabDataTable.prototype);
Table.prototype.constructor = Table;
Table.prototype.elementArray = _elementArray;
return Table;
/*
FUNCTION DEFINITIONS
*/
function _elementArray(element_json) {
var element = element_json[XML_ROOT];
return [
'<input class="check_item" type="checkbox" id="'+RESOURCE.toLowerCase()+'_' +
element.ID + '" name="selected_items" value="' +
element.ID + '"/>',
element.ID,
element.UNAME,
element.GNAME,
element.NAME
];
}
});

View File

@ -0,0 +1,113 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2015, 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 BaseDialog = require('utils/dialogs/dialog');
var TemplateHTML = require('hbs!./clone/html');
var Sunstone = require('sunstone');
var Notifier = require('utils/notifier');
var Locale = require('utils/locale');
var OpenNebulaVirtualRouter = require('opennebula/virtualrouter');
/*
CONSTANTS
*/
var DIALOG_ID = require('./clone/dialogId');
var TAB_ID = require('../tabId');
/*
CONSTRUCTOR
*/
function Dialog() {
this.dialogId = DIALOG_ID;
BaseDialog.call(this);
}
Dialog.DIALOG_ID = DIALOG_ID;
Dialog.prototype = Object.create(BaseDialog.prototype);
Dialog.prototype.constructor = Dialog;
Dialog.prototype.html = _html;
Dialog.prototype.onShow = _onShow;
Dialog.prototype.setup = _setup;
return Dialog;
/*
FUNCTION DEFINITIONS
*/
function _html() {
return TemplateHTML({
'dialogId': this.dialogId
});
}
function _setup(context) {
var that = this;
context.foundation('abide', 'reflow');
context.off('invalid.fndtn.abide', '#' + DIALOG_ID + 'Form');
context.off('valid.fndtn.abide', '#' + DIALOG_ID + 'Form');
context.on('invalid.fndtn.abide', '#' + DIALOG_ID + 'Form', function(e) {
Notifier.notifyError(Locale.tr("One or more required fields are missing or malformed."));
}).on('valid.fndtn.abide', '#' + DIALOG_ID + 'Form', function(e) {
var name = $('input', this).val();
var sel_elems = Sunstone.getDataTable(TAB_ID).elements();
if (sel_elems.length > 1){
for (var i=0; i< sel_elems.length; i++)
//use name as prefix if several items selected
Sunstone.runAction('VirtualRouter.clone',
sel_elems[i],
name + OpenNebulaVirtualRouter.getName(sel_elems[i]));
} else {
Sunstone.runAction('VirtualRouter.clone',sel_elems[0],name);
}
return false;
});
return false;
}
function _onShow(context) {
var sel_elems = Sunstone.getDataTable(TAB_ID).elements();
//show different text depending on how many elements are selected
if (sel_elems.length > 1) {
$('.clone_one', context).hide();
$('.clone_several', context).show();
$('input',context).val('Copy of ');
} else {
$('.clone_one', context).show();
$('.clone_several', context).hide();
$('input',context).val('Copy of ' + OpenNebulaVirtualRouter.getName(sel_elems[0]));
}
$("input[name='name']",context).focus();
return false;
}
});

View File

@ -0,0 +1,19 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2015, 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 'cloneVirtualRouterDialog';
});

View File

@ -0,0 +1,45 @@
{{! -------------------------------------------------------------------------- }}
{{! Copyright 2002-2015, 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. }}
{{! -------------------------------------------------------------------------- }}
<div id="{{dialogId}}" class="reveal-modal" role="dialog" data-reveal >
<div class="row">
<h3 class="subheader">{{tr "Clone Virtual Router"}}</h3>
</div>
<form data-abide="ajax" id="{{dialogId}}Form">
<div class="row">
<div class="large-12 columns">
<div class="clone_one"></div>
<div class="clone_several">
{{tr "Several virtual routers are selected, please choose a prefix to name the new copies"}}
<br>
</div>
</div>
</div>
<div class="row">
<div class="large-12 columns">
<label class="clone_one">{{tr "Name"}}</label>
<label class="clone_several">{{tr "Prefix"}}</label>
<input required type="text" name="name"></input>
</div>
</div>
<div class="form_buttons row">
<button type="submit" class="button radius right">
{{tr "Clone"}}
</button>
</div>
<a class="close-reveal-modal">&#215;</a>
</form>
</div>

View File

@ -0,0 +1,162 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2015, 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
*/
require('foundation.tab');
var BaseFormPanel = require('utils/form-panels/form-panel');
var Sunstone = require('sunstone');
var Locale = require('utils/locale');
var Tips = require('utils/tips');
var TemplateUtils = require('utils/template-utils');
var WizardFields = require('utils/wizard-fields');
/*
TEMPLATES
*/
var TemplateWizardHTML = require('hbs!./create/wizard');
var TemplateAdvancedHTML = require('hbs!./create/advanced');
/*
CONSTANTS
*/
var FORM_PANEL_ID = require('./create/formPanelId');
var TAB_ID = require('../tabId');
/*
CONSTRUCTOR
*/
function FormPanel() {
this.formPanelId = FORM_PANEL_ID;
this.tabId = TAB_ID;
this.actions = {
'create': {
'title': Locale.tr("Create Virtual Router"),
'buttonText': Locale.tr("Create"),
'resetButton': true
},
'update': {
'title': Locale.tr("Update Virtual Router"),
'buttonText': Locale.tr("Update"),
'resetButton': false
}
};
BaseFormPanel.call(this);
}
FormPanel.FORM_PANEL_ID = FORM_PANEL_ID;
FormPanel.prototype = Object.create(BaseFormPanel.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.fill = _fill;
FormPanel.prototype.setup = _setup;
return FormPanel;
/*
FUNCTION DEFINITIONS
*/
function _htmlWizard() {
return TemplateWizardHTML({
'formPanelId': this.formPanelId
});
}
function _htmlAdvanced() {
return TemplateAdvancedHTML({formPanelId: this.formPanelId});
}
function _setup(context) {
var that = this;
Tips.setup();
return false;
}
function _submitWizard(context) {
var name = $('#virtual_router_name', context).val();
var description = $('#virtual_router_description', context).val();
var virtual_router_json = {
"NAME" : name,
"DESCRIPTION": description
};
if (this.action == "create") {
virtual_router_json = {
"virtual_router" : virtual_router_json
};
Sunstone.runAction("VirtualRouter.create",virtual_router_json);
return false;
} else if (this.action == "update") {
delete virtual_router_json["NAME"];
Sunstone.runAction(
"VirtualRouter.update",
this.resourceId,
TemplateUtils.templateToString(virtual_router_json));
return false;
}
}
function _submitAdvanced(context) {
if (this.action == "create") {
var template = $('textarea#template', context).val();
var virtual_router_json = {virtual_router: {virtual_router_raw: template}};
Sunstone.runAction("VirtualRouter.create",virtual_router_json);
return false;
} else if (this.action == "update") {
var template_raw = $('textarea#template', context).val();
Sunstone.runAction("VirtualRouter.update", this.resourceId, template_raw);
return false;
}
}
function _onShow(context) {
}
function _fill(context, element) {
var that = this;
this.resourceId = element.ID;
// Populates the Avanced mode Tab
$('#template', context).val(TemplateUtils.templateToString(element.TEMPLATE).replace(/^[\r\n]+$/g, ""));
$('#virtual_router_name',context).val(
TemplateUtils.escapeDoubleQuotes(TemplateUtils.htmlDecode( element.NAME ))).
prop("disabled", true);
$('#virtual_router_description', context).val(
TemplateUtils.escapeDoubleQuotes(TemplateUtils.htmlDecode( element.TEMPLATE.DESCRIPTION )) );
}
});

View File

@ -0,0 +1,28 @@
{{! -------------------------------------------------------------------------- }}
{{! Copyright 2002-2015, 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. }}
{{! -------------------------------------------------------------------------- }}
<form data-abide="ajax" id="{{formPanelId}}Advanced" class="custom creation">
<div class="row">
<div class="large-12 columns">
<p>{{tr "Write the Virtual Router template here"}}</p>
</div>
</div>
<div class="row">
<div class="large-12 columns">
<textarea id="template" rows="15" required></textarea>
</div>
</div>
</form>

View File

@ -0,0 +1,19 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2015, 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 'createVirtualRouterForm';
});

View File

@ -0,0 +1,33 @@
{{! -------------------------------------------------------------------------- }}
{{! Copyright 2002-2015, 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. }}
{{! -------------------------------------------------------------------------- }}
<div id="create_virtual_router_form_wrapper">
<form data-abide="ajax" id="{{formPanelId}}Wizard" class="custom creation">
<div class="row">
<div class="medium-4 columns">
<label for="virtual_router_name">{{tr "Virtual Router Name"}}:</label>
<input required type="text" name="virtual_router_name" id="virtual_router_name"/>
</div>
<div class="medium-8 columns">
<label for="virtual_router_description">{{tr "Description"}}
<span class="tip">{{tr "Description for the Virtual Router"}}</span>
</label>
<textarea type="text" id="virtual_router_description" name="virtual_router_description" style="height: 70px;"/>
</div>
</div>
<hr/>
</form>
</div>

View File

@ -0,0 +1,101 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2015, 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 TemplateInfo = require('hbs!./info/html');
var Locale = require('utils/locale');
var PermissionsTable = require('utils/panel/permissions-table');
var RenameTr = require('utils/panel/rename-tr');
var OpenNebulaVirtualRouter = require('opennebula/virtualrouter');
/*
TEMPLATES
*/
var TemplateTable = require('utils/panel/template-table');
/*
CONSTANTS
*/
var TAB_ID = require('../tabId');
var PANEL_ID = require('./info/panelId');
var RESOURCE = "VirtualRouter";
var XML_ROOT = "VROUTER";
/*
CONSTRUCTOR
*/
function Panel(info) {
this.title = Locale.tr("Info");
this.icon = "fa-info-circle";
this.element = info[XML_ROOT];
return this;
}
Panel.PANEL_ID = PANEL_ID;
Panel.prototype.html = _html;
Panel.prototype.setup = _setup;
return Panel;
/*
FUNCTION DEFINITIONS
*/
function _html() {
var renameTrHTML = RenameTr.html(TAB_ID, RESOURCE, this.element.NAME);
var permissionsTableHTML = PermissionsTable.html(TAB_ID, RESOURCE, this.element);
// TODO: simplify interface?
var strippedTemplate = $.extend({}, this.element.TEMPLATE);
//delete strippedTemplate[""];
var templateTableHTML = TemplateTable.html(strippedTemplate, RESOURCE,
Locale.tr("Attributes"));
//====
return TemplateInfo({
'element': this.element,
'renameTrHTML': renameTrHTML,
'permissionsTableHTML': permissionsTableHTML,
'templateTableHTML': templateTableHTML
});
}
function _setup(context) {
RenameTr.setup(TAB_ID, RESOURCE, this.element.ID, context);
PermissionsTable.setup(TAB_ID, RESOURCE, this.element, context);
// TODO: simplify interface?
var strippedTemplate = $.extend({}, this.element.TEMPLATE);
//delete strippedTemplate[""];
var hiddenValues = {RULE: this.element.TEMPLATE.RULE};
TemplateTable.setup(strippedTemplate, RESOURCE, this.element.ID, context, hiddenValues);
//===
return false;
}
});

View File

@ -0,0 +1,42 @@
{{! -------------------------------------------------------------------------- }}
{{! Copyright 2002-2015, 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. }}
{{! -------------------------------------------------------------------------- }}
<div class="row">
<div class="large-6 columns">
<table id="info_virtual_router_table" class="dataTable">
<thead>
<tr>
<th colspan="3">{{tr "Information"}}</th>
</tr>
</thead>
<tbody>
<tr>
<td class="key_td">{{tr "ID"}}</td>
<td class="value_td" colspan="2">{{element.ID}}</td>
</tr>
{{{renameTrHTML}}}
</tbody>
</table>
</div>
<div class="large-6 columns">
{{{permissionsTableHTML}}}
</div>
</div>
<div class="row">
<div class="large-9 columns">
{{{templateTableHTML}}}
</div>
</div>

View File

@ -0,0 +1,19 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2015, 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 'virtual_router_info_tab';
})

View File

@ -0,0 +1,19 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2015, 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 'vrouters-tab';
});