diff --git a/src/sunstone/public/app/tabs/vmgroup-tab/datatable.js b/src/sunstone/public/app/tabs/vmgroup-tab/datatable.js
index 020407c36e..9dcd8c4715 100644
--- a/src/sunstone/public/app/tabs/vmgroup-tab/datatable.js
+++ b/src/sunstone/public/app/tabs/vmgroup-tab/datatable.js
@@ -63,9 +63,9 @@ define(function(require) {
this.columns = [
Locale.tr("ID"),
+ Locale.tr("Name"),
Locale.tr("Owner"),
Locale.tr("Group"),
- Locale.tr("Name"),
Locale.tr("Labels"),
"search_data"
];
@@ -110,9 +110,9 @@ define(function(require) {
element.ID + '" name="selected_items" value="' +
element.ID + '"/>',
element.ID,
+ element.NAME,
element.UNAME,
element.GNAME,
- element.NAME,
(LabelsUtils.labelsStr(element[TEMPLATE_ATTR])||''),
btoa(unescape(encodeURIComponent(JSON.stringify(search))))
];
diff --git a/src/sunstone/public/app/tabs/vmgroup-tab/form-panels/create.js b/src/sunstone/public/app/tabs/vmgroup-tab/form-panels/create.js
index cc5538522f..2ba22b501a 100644
--- a/src/sunstone/public/app/tabs/vmgroup-tab/form-panels/create.js
+++ b/src/sunstone/public/app/tabs/vmgroup-tab/form-panels/create.js
@@ -238,6 +238,7 @@ define(function(require) {
}
function _fill(context, element) {
+ $("#new_role", context)[0].parentElement.remove();
var that = this;
this.setHeader(element);
this.resourceId = element.ID;
@@ -253,16 +254,20 @@ define(function(require) {
$.each(element.ROLES.ROLE, function(index, value){
var name = value.NAME;
if(name){
- var html = "\
- \
-
";
+ var html = "";
$("#list_roles_select").append(html);
+ $("select #" + name).mousedown(function(e) {
+ e.preventDefault();
+ $(this).prop('selected', !$(this).prop('selected'));
+ return false;
+ });
}
});
+ this.affinity_role_tab.fill(context, element);
$("#btn_refresh_roles", context).remove();
$("#affinity",context).show();
- $("#new_role", context).remove();
+
//Remove row of roles------------------------------------------------------------------
/*var role_context_first = $('.role_content', context).first();
diff --git a/src/sunstone/public/app/tabs/vmgroup-tab/utils/affinity-role-tab.js b/src/sunstone/public/app/tabs/vmgroup-tab/utils/affinity-role-tab.js
index bbfd02bde4..5a9832ac6e 100644
--- a/src/sunstone/public/app/tabs/vmgroup-tab/utils/affinity-role-tab.js
+++ b/src/sunstone/public/app/tabs/vmgroup-tab/utils/affinity-role-tab.js
@@ -108,6 +108,7 @@ define(function(require) {
}
function _fill(context, element) {
+ var that = this;
var group_roles_index = 0;
$.each(element.TEMPLATE, function(affinity, value){
if(affinity == "AFFINED" || affinity == "ANTI_AFFINED"){
@@ -184,6 +185,12 @@ define(function(require) {
}
function _add_group_affinity_box(rolesSt, context, group_roles_index, group_roles_affinity, affinity){
+ for(group in group_roles_affinity){
+ if(group_roles_affinity[group].retrieve(context) == rolesSt){
+ Notifier.notifyError(Locale.tr("Already exist a group role with this vaues."));
+ return false;
+ }
+ }
var that = this;
var index = group_roles_index;
var group_roles_id = 'group_role_' + group_roles_index;
diff --git a/src/sunstone/public/app/tabs/vmgroup-tab/utils/role-tab.js b/src/sunstone/public/app/tabs/vmgroup-tab/utils/role-tab.js
index 1cd028e606..c4dbba62d4 100644
--- a/src/sunstone/public/app/tabs/vmgroup-tab/utils/role-tab.js
+++ b/src/sunstone/public/app/tabs/vmgroup-tab/utils/role-tab.js
@@ -58,6 +58,7 @@ define(function(require) {
this.hostsTable.initialize();
return TemplateHTML({
+ 'idRole': this.html_role_id,
'hostsTableHTML': this.hostsTable.dataTableHTML,
'value_host_affinity': "value_host_affinity_"+this.html_role_id,
'tf_btn_host_affined': "btn_host_vm_roles_affined"+this.html_role_id,
@@ -150,7 +151,7 @@ define(function(require) {
var text = "";
role['NAME'] = $('input[name="name"]', context).val();
role['VIRTUAL_MACHINES'] = $('input[name="cardinality"]', context).val();
- role['POLICY'] = $('input[name="protocol"]:checked', context).val();
+ role['POLICY'] = $('input[name="protocol_'+this.html_role_id+'"]:checked', context).val();
if(this.host_affined.length > 0){
for(data in this.host_affined)
text += this.host_affined[data] + ", ";
@@ -174,10 +175,7 @@ define(function(require) {
$("#role_name", context).val(value.NAME);
$("#role_name", context).change();
$("#role_cardinality", context).val(value.VIRTUAL_MACHINES);
- if(value.POLICY)
- $("#role_protocol", context).val(value.POLICY);
- else
- $("#role_protocol", context).val("NONE");
+ $('input[name="protocol_'+this.html_role_id+', value='+value.POLICY+']', context).attr("checked", true);
if(value.HOST_AFFINED)
_generateBox("AFFINED",value.HOST_AFFINED, this);
if(value.HOST_ANTI_AFFINED)
diff --git a/src/sunstone/public/app/tabs/vmgroup-tab/utils/role-tab/html.hbs b/src/sunstone/public/app/tabs/vmgroup-tab/utils/role-tab/html.hbs
index 9fabbf8575..971dd5b22c 100644
--- a/src/sunstone/public/app/tabs/vmgroup-tab/utils/role-tab/html.hbs
+++ b/src/sunstone/public/app/tabs/vmgroup-tab/utils/role-tab/html.hbs
@@ -31,9 +31,9 @@
{{tr "VM-VM Affinity"}}
- {{tr "None"}}
- {{tr "Affined"}}
- {{tr "Anti Affined"}}
+ {{tr "None"}}
+ {{tr "Affined"}}
+ {{tr "Anti Affined"}}
diff --git a/src/sunstone/public/app/tabs/vms-tab/panels/placement.js b/src/sunstone/public/app/tabs/vms-tab/panels/placement.js
index 29a603bd39..6cb7ff7650 100644
--- a/src/sunstone/public/app/tabs/vms-tab/panels/placement.js
+++ b/src/sunstone/public/app/tabs/vms-tab/panels/placement.js
@@ -68,7 +68,9 @@ define(function(require) {
\
@@ -117,7 +123,9 @@ define(function(require) {
' + Navigation.link(history[i].HOSTNAME, "hosts-tab", history[i].HID) + ' | \
' + Navigation.link(OpenNebula.Datastore.getName(history[i].DS_ID), "datastores-tab", history[i].DS_ID) + ' | \
' + OpenNebula.VM.migrateActionStr(parseInt(history[i].ACTION, 10)) + ' | \
- ' + OpenNebula.VM.migrateReasonStr(parseInt(history[i].REASON, 10)) + ' | \
+ ' + uid + ' | \
+ ' + gid + ' | \
+ ' + req_id + ' | \
' + Humanize.prettyTime(history[i].STIME) + ' | \
' + Humanize.prettyDuration(dtime) + ' | \
' + Humanize.prettyDuration(dtime2) + ' | \
diff --git a/src/sunstone/public/app/utils/vmgroup-section.js b/src/sunstone/public/app/utils/vmgroup-section.js
new file mode 100644
index 0000000000..31336e0fd2
--- /dev/null
+++ b/src/sunstone/public/app/utils/vmgroup-section.js
@@ -0,0 +1,155 @@
+/* -------------------------------------------------------------------------- */
+/* 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) {
+ var Locale = require('utils/locale');
+ var Tips = require('utils/tips');
+ var Notifier = require('utils/notifier');
+ var OpenNebula = require('opennebula');
+ var OpenNebulaTemplate = require('opennebula/template');
+ var TemplateSection = require('hbs!./vmgroup-section/html');
+ var VMGroupsTable = require('tabs/vmgroup-tab/datatable');
+ var UniqueId = require('utils/unique-id');
+ //var RoleTable = require('./vmgroup-section/datatable');
+
+ //var roleTable = undefined;
+
+ return {
+ 'onShow': _onShow,
+ 'setup': _setup,
+ 'html': _html,
+ 'fill': _fill,
+ 'insert': _insert,
+ 'retrieve': _retrieve
+ }
+
+ function _setup(context, vmGroupTable){
+ var templateVmgroup = null;
+ vmGroupTable.idInput().on("change", function(){
+ _generate_provision_role_table(context, $(this).val());
+ });
+ $("#role_section",context).hide();
+ $(".role_table_section", context).prop('required', false);
+ $(".clear_vmgroup_select",context).bind("click", function(){
+ vmGroupTable.initSelectResourceTableSelect();
+ $("#role_section",context).hide();
+ $(".role_table_section", context).prop('required', false);
+ $(".role_table_section > option").removeAttr('selected');
+ });
+
+ }
+ function _html(vmGroupTable){
+ return TemplateSection({
+ vmGroupTableHTML: vmGroupTable.dataTableHTML
+ });
+ }
+
+ function _onShow(context,vmGroupTable=undefined){
+ if(vmGroupTable)
+ vmGroupTable.refreshResourceTableSelect();
+ $("#role_section",context).hide();
+ $(".role_table_section", context).prop('required', false);
+ }
+
+ function _insert(template_json, context) {
+ var templateVmgroup = null;
+ this.vmGroupTable = new VMGroupsTable('vmgroups_table'+UniqueId.id(), { 'select': true });
+ var that = this;
+ var templateVmgroup = $(TemplateSection({
+ vmGroupTableHTML: this.vmGroupTable.dataTableHTML,
+ })).appendTo($(".provision_vmgroup_selector",context));
+
+ this.vmGroupTable.initialize();
+ this.vmGroupTable.refreshResourceTableSelect();
+ $("#vmgroup_section_tables", context).hide();
+ $(".provision_add_vmgroup",context).bind("click", function(){
+ $("#vmgroup_section_tables", context).show();
+ $(".provision_add_vmgroup",context).hide();
+ });
+
+ $(".clear_vmgroup_select",context).bind("click", function(){
+ $("#vmgroup_section_tables",context).hide();
+ $(".provision_add_vmgroup",context).show();
+ that.vmGroupTable.initSelectResourceTableSelect();
+ $(".role_table_section", context).prop('required', false);
+ $(".role_table_section > option").removeAttr('selected');
+ });
+ this.vmGroupTable.idInput().on("change", function(){
+ _generate_provision_role_table(context, $(this).val());
+ });
+ $("#role_section",context).hide();
+ $(".role_table_section", context).prop('required', false);
+ }
+
+ function _fill(context, templateJSON, vmGroupTable=undefined){
+ var element = templateJSON.VMGROUP;
+ vmGroupTable.selectResourceTableSelect({ids:element.VMGROUP_ID});
+ _generate_provision_role_table(context,element.VMGROUP_ID, element.ROLE);
+ }
+ function _retrieve(context, vmGroupTable=undefined) {
+ var role_selected = $('.role_table_section').val();
+
+ var vmgroup_selected = undefined;
+ if(this.vmGroupTable)
+ this.vmGroupTable.retrieveResourceTableSelect();
+ if(vmGroupTable)
+ vmgroup_selected = vmGroupTable.retrieveResourceTableSelect();
+ if(vmgroup_selected){
+ if(role_selected){
+ var vmgroup_json = {
+ "VMGROUP_ID": vmgroup_selected,
+ "ROLE": role_selected
+ }
+ vmgroup_json = {
+ "VMGROUP" : vmgroup_json
+ }
+ return vmgroup_json;
+ }
+ }else return undefined;
+ return false;
+ }
+
+ function _generate_provision_role_table(context, idvmgroup, fill=undefined) {
+ OpenNebula.VMGroup.show({
+ data : {
+ id: idvmgroup,
+ },
+ success: function (request, template_json) {
+ $(".role_table_section",context).empty();
+ var roles = template_json["VM_GROUP"].ROLES.ROLE;
+ $(".title_roles",context).text(Locale.tr("Roles")+" "+ template_json["VM_GROUP"].NAME);
+ if(roles){
+ if(Array.isArray(roles)){
+ $.each(roles, function(){
+ $("
").appendTo(".role_table_section",context);
+ });
+ }
+ else{
+ $("").appendTo(".role_table_section",context);
+ }
+ $("#role_section",context).show();
+ $(".role_table_section", context).prop('required', true);
+ if(fill){
+ $('.role_table_section option[value='+fill+']').attr("selected",true);
+ }
+ }
+ },
+ error: function(request, error_json, container) {
+ Notifier.notifyError(Locale.tr("Internal server error."));
+ }
+ });
+ }
+})
diff --git a/src/sunstone/public/app/utils/vmgroup-section/html.hbs b/src/sunstone/public/app/utils/vmgroup-section/html.hbs
new file mode 100644
index 0000000000..262f0ea7df
--- /dev/null
+++ b/src/sunstone/public/app/utils/vmgroup-section/html.hbs
@@ -0,0 +1,18 @@
+
+
+
+
+ {{{vmGroupTableHTML}}}
+
+
+
+
{{tr "Roles"}}
+
+
+
+
\ No newline at end of file