From 2622a80d2f7362071207e3c70e0696add2ca417b Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Mon, 26 Sep 2011 15:13:45 +0200 Subject: [PATCH 1/4] bug #831: Adapt novnc installer to the new yaml configuration format --- share/install_novnc.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/install_novnc.sh b/share/install_novnc.sh index 6e2a0b4a1f..5dc90d6763 100755 --- a/share/install_novnc.sh +++ b/share/install_novnc.sh @@ -34,7 +34,7 @@ mv $ONE_SHARE/$dir $ONE_SHARE/noVNC mkdir -p $ONE_PUBLIC_SUNSTONE/vendor/noVNC mv $ONE_SHARE/noVNC/include/ $ONE_PUBLIC_SUNSTONE/vendor/noVNC/ -sed -i "s%^\(NOVNC_PATH=\).*$%\1$ONE_SHARE/noVNC%" $SUNSTONE_CONF +sed -i.bck "s%^\(:novnc_path: \).*$%\1$ONE_SHARE/noVNC%" $SUNSTONE_CONF #Update file permissions chmod +x $ONE_SHARE/noVNC/utils/launch.sh From 244ef191538540517fbf372da442040d077d36e9 Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Fri, 23 Sep 2011 21:07:27 +0200 Subject: [PATCH 2/4] Feature #790: Update oZones create VDC dialog By default the new dialog only shows the hosts of the selected zone which are not part of a different VDC. An option exists to force addition of hosts which do not complain with the uniqueness requirement. (cherry picked from commit 776c18825733c7f9fe9c18bd4aa78fb377cefb39) Conflicts: src/ozones/Server/models/OzonesServer.rb (cherry picked from commit cbec09ab8c53d4b4ab8b795e04bb33d71f38ea7a) --- src/ozones/Server/models/OzonesServer.rb | 34 ++++---- .../Server/public/js/plugins/vdcs-tab.js | 80 +++++++++++++++++-- 2 files changed, 93 insertions(+), 21 deletions(-) diff --git a/src/ozones/Server/models/OzonesServer.rb b/src/ozones/Server/models/OzonesServer.rb index 25eeed4204..d7623781ba 100644 --- a/src/ozones/Server/models/OzonesServer.rb +++ b/src/ozones/Server/models/OzonesServer.rb @@ -165,12 +165,13 @@ class OzonesServer return [404, error.to_json] end - if (!vdc_data[:force] or vdc_data[:force].upcase!="YES") and + if (!defined? vdc_data[:force] or + (defined? vdc_data[:force] and vdc_data[:force]!="yes")) and !host_uniqueness?(zone, vdc_data[:hosts]) return [403, OZones::Error.new( "Error: Couldn't create resource #{kind}. " + - "Hosts are not unique, and no force option" + - " was given.").to_json] + "One or several hosts belong to a different VDC "+ + "and no force option was provided.").to_json] end vdcadminname = vdc_data[:vdcadminname] @@ -265,7 +266,7 @@ class OzonesServer return [404, error.to_json] end end - + ############################################################################ # Update resources ############################################################################ @@ -289,7 +290,7 @@ class OzonesServer } # Check parameters - if !vdc_data[:hosts] || !vdc_id + if !vdc_data[:hosts] || !vdc_id return [400, OZones::Error.new( "Error: Couldn't update resource #{kind}. " + "Need ID and HOSTS to update.").to_json] @@ -302,7 +303,7 @@ class OzonesServer "#{vdc_id} not found, cannot update Vdc.") return [404, error.to_json] end - + # Get the zone where the Vdc belongs zone=OZones::Zones.get(vdc.zones.id) if !zone @@ -310,24 +311,25 @@ class OzonesServer "#{vdc.zones.id} not found, cannot update Vdc.") return [404, error.to_json] end - - if (!vdc_data[:force] or vdc_data[:force].upcase!="YES") and - !host_uniqueness?(zone, vdc_data[:hosts], vdc_id.to_i) + + if (!defined? vdc_data[:force] or + (defined? vdc_data[:force] and vdc_data[:force]!="yes")) and + !host_uniqueness?(zone, vdc_data[:hosts], vdc_id.to_i) return [403, OZones::Error.new( "Error: Couldn't update resource #{kind}. " + - "Hosts are not unique, and no force option" + - " was given.").to_json] + "One or several hosts belong to a different VDC "+ + "and no force option was provided.").to_json] end - + rc = @ocaInt.update_vdc_hosts(zone, vdc, vdc_data[:hosts]) - + if !OpenNebula.is_error?(rc) vdc.hosts = vdc_data[:hosts] vdc.get_host_acls!(rc) vdc.save - - if vdc.saved? + + if vdc.saved? return [200, vdc.to_json] else return [500, OZones::Error.new( @@ -378,7 +380,7 @@ class OzonesServer ############################################################################ # Helper functions ############################################################################ - + # Check if hosts are already include in any Vdc of the zone def host_uniqueness?(zone, host_list, vdc_id = -1) all_hosts = "" diff --git a/src/ozones/Server/public/js/plugins/vdcs-tab.js b/src/ozones/Server/public/js/plugins/vdcs-tab.js index dcd5555296..572d7db5e0 100644 --- a/src/ozones/Server/public/js/plugins/vdcs-tab.js +++ b/src/ozones/Server/public/js/plugins/vdcs-tab.js @@ -25,6 +25,7 @@ var vdcs_tab_content = ID\ Name\ Zone ID\ + Hosts\ \ \ \ @@ -44,7 +45,12 @@ var create_vdc_tmpl = \ \ \ +
\ +
\ + \ + \ +
Allows hosts belonging to other VDCs to be re-added to this one. They will appear marked with * in the list.
\ +
\ \ \ \ @@ -81,6 +87,19 @@ var vdc_actions = { call: openCreateVDCDialog }, + "VDC.update" : { + type: "create", + call: oZones.VDC.update, + callback: updateVDCElement, + error: onError, + notify: true + }, + + "VDC.update_dialog" : { + type: "custom", + call: openUpdateVDCDialog + }, + "VDC.list" : { type: "list", call: oZones.VDC.list, @@ -169,7 +188,8 @@ function vdcElementArray(vdc_json){ '', vdc.id, vdc.name, - vdc.zones_id + vdc.zones_id, + vdc.hosts ? vdc.hosts : "none" ]; } @@ -230,6 +250,18 @@ function updateVDCInfo(req,vdc_json){ Hosts\ '+(vdc.hosts? vdc.hosts : "none")+'\ \ + \ + Admin name\ + '+vdc.vdcadminname+'\ + \ + \ + Group ID\ + '+vdc.group_id+'\ + \ + \ + ACLs\ + '+vdc.acls+'\ + \ \ ' }; @@ -239,13 +271,41 @@ function updateVDCInfo(req,vdc_json){ } function fillHostList(req, host_list_json){ - list = ""; + var list = ""; + var force = $('div#create_vdc_dialog #vdc_force_hosts:checked').length ? + true : false; + var zone_id = req.request.data[0]; + var free; + $.each(host_list_json,function(){ - list+='
  • '+this.HOST.NAME+'
  • '; + free = isHostFree(this.HOST.ID,zone_id); + + if (force || free){ + list+='
  • '+(free? this.HOST.NAME : this.HOST.NAME+'*')+'
  • '; + } }); $('div#create_vdc_dialog #vdc_available_hosts_list').html(list); } +function isHostFree(id,zone_id){//strings + var data = dataTable_vdcs.fnGetData(); + var result = true; + var hosts; + for (var i=0; i= 0){ + result = false; + break; + } + } + return result; +} + function setupCreateVDCDialog(){ $('div#dialogs').append('
    '); var dialog = $('div#create_vdc_dialog'); @@ -266,6 +326,12 @@ function setupCreateVDCDialog(){ containment: dialog }); + $('input#vdc_force_hosts').change(function(){ + select = $('select#zoneid'); + if (select.val().length){ + select.trigger("change"); + } + }); //load zone hosts $('select#zoneid').change(function(){ @@ -289,6 +355,7 @@ function setupCreateVDCDialog(){ var vdcadminname = $('#vdcadminname',$(this)).val(); var vdcadminpass = $('#vdcadminpass',$(this)).val(); var zoneid = $('select#zoneid',$(this)).val(); + var force = $('#vdc_force_hosts',$(this)).length ? "yes" : "please no"; if (!name.length || !vdcadminname.length || !vdcadminpass.length || !zoneid.length){ notifyError("Name, administrator credentials or zones are missing"); @@ -308,6 +375,7 @@ function setupCreateVDCDialog(){ "zoneid" : zoneid, "vdcadminname" : vdcadminname, "vdcadminpass" : vdcadminpass, + "force" : force } }; if (hosts.length){ @@ -347,15 +415,17 @@ $(document).ready(function(){ "aoColumnDefs": [ { "bSortable": false, "aTargets": ["check"] }, { "sWidth": "60px", "aTargets": [0] }, + { "sWidth": "150px", "aTargets": [4] }, { "sWidth": "35px", "aTargets": [1,3] } ] }); dataTable_vdcs.fnClearTable(); - addElement([spinner,'','',''],dataTable_vdcs); + addElement([spinner,'','','',''],dataTable_vdcs); Sunstone.runAction("VDC.list"); setupCreateVDCDialog(); + setupTips($('#create_vdc_dialog')); setVDCAutorefresh(); initCheckAllBoxes(dataTable_vdcs); tableCheckboxesListener(dataTable_vdcs); From 5bfa14ce2f1133b2ba9372874c55415cdbe15df4 Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Sat, 24 Sep 2011 00:42:54 +0200 Subject: [PATCH 3/4] Feature #817: Added GUI support for add/remove hosts from VDC in oZones (cherry picked from commit 0820dd38a01929b9bf0f847ceb46d5e317617deb) (cherry picked from commit 532175b4e23334315e419d83d0752d328a7aa987) --- src/ozones/Server/public/js/ozones.js | 27 ++- .../Server/public/js/plugins/vdcs-tab.js | 216 +++++++++++++++++- 2 files changed, 237 insertions(+), 6 deletions(-) diff --git a/src/ozones/Server/public/js/ozones.js b/src/ozones/Server/public/js/ozones.js index 051df3fb0b..734cc4d6c6 100644 --- a/src/ozones/Server/public/js/ozones.js +++ b/src/ozones/Server/public/js/ozones.js @@ -201,6 +201,28 @@ var oZones = { }); }, + "update": function(params,resource){ + var callback = params.success; + var callback_error = params.error; + var id = params.data.id; + var data = params.data.extra_param; + var request = oZones.Helper.request(resource,"update", data); + + $.ajax({ + url: resource.toLowerCase()+'/'+id, + type: "PUT", + dataType: "json", + data: JSON.stringify(data), + success: function(response){ + return callback ? callback(request, response) : null; + }, + error: function(response){ + return callback_error ? + callback_error(request, oZones.Error(response)) : null; + } + }); + }, + "delete": function(params,resource){ var callback = params.success; var callback_error = params.error; @@ -385,7 +407,7 @@ var oZones = { callback(request, oZones.Helper.pool(subresource.toUpperCase(),response)) : null; }, error: function(response){ - return callback_error ? calback_error(request,oZones.Error(response)) : null; + return callback_error ? callback_error(request,oZones.Error(response)) : null; } }); @@ -421,6 +443,9 @@ var oZones = { "create": function(params){ oZones.Action.create(params,oZones.VDC.resource); }, + "update": function(params){ + oZones.Action.update(params,oZones.VDC.resource); + }, "delete": function(params){ oZones.Action.delete(params,oZones.VDC.resource); }, diff --git a/src/ozones/Server/public/js/plugins/vdcs-tab.js b/src/ozones/Server/public/js/plugins/vdcs-tab.js index 572d7db5e0..db7e6fc211 100644 --- a/src/ozones/Server/public/js/plugins/vdcs-tab.js +++ b/src/ozones/Server/public/js/plugins/vdcs-tab.js @@ -67,7 +67,36 @@ var create_vdc_tmpl = \ '; +var update_vdc_tmpl = +'
    \ +
    \ +
    \ + \ + \ +
    \ + \ + \ +
    Allows hosts belonging to other VDCs to be re-added to this one. They will appear marked with * in the list.
    \ +
    \ + \ + \ + \ +
    \ +
      \ +
        \ +
        \ +
        \ +
        \ +
        \ + \ + \ +
        \ +
        \ +
        '; + var dataTable_vdcs; +var $update_vdc_dialog; function vdcSelectedNodes() { return getSelectedNodes(dataTable_vdcs); @@ -88,7 +117,7 @@ var vdc_actions = { }, "VDC.update" : { - type: "create", + type: "single", call: oZones.VDC.update, callback: updateVDCElement, error: onError, @@ -142,6 +171,12 @@ var vdc_actions = { call: oZones.Zone.host, callback: fillHostList, error: onError + }, + "VDC.update_zone_hosts" : { + type: "single", + call: oZones.Zone.host, + callback: fillUpdateHostList, + error: onError } }; @@ -156,6 +191,10 @@ var vdc_buttons = { text: "+ New", alwaysActive:true }, + "VDC.update_dialog" : { + type: "action", + text: "Add/Remove hosts", + }, "VDC.delete" : { type: "action", text: "Delete", @@ -213,6 +252,12 @@ function addVDCElement(req,vdc_json){ addElement(element,dataTable_vdcs); } +function updateVDCElement(request, vdc_json){ + var id = vdc_json.VDC.id; + var element = vdcElementArray(vdc_json); + updateSingleElement(element,dataTable_vdcs,'#vdc_'+id); +} + function updateVDCsView(req,vdc_list){ var vdc_list_array = []; @@ -287,6 +332,52 @@ function fillHostList(req, host_list_json){ $('div#create_vdc_dialog #vdc_available_hosts_list').html(list); } +//return the array of hosts +function isHostMine(host_id,vdc_id){ + //locate myself + var vdcs = dataTable_vdcs.fnGetData(); + var my_hosts=null; + for (var i=0; i < vdcs.length; i++){ + if (vdcs[i][1]==vdc_id){ + my_hosts = vdcs[i][4].split(','); + break; + } + }; + if (!my_hosts) return false; + return $.inArray(host_id,my_hosts) >= 0; +} + +function fillUpdateHostList(req, host_list_json){ + var list = ""; + var list_mine = ""; + var vdc_id = $('#vdc_update_id',$update_vdc_dialog).val(); + var force = $('#vdc_update_force_hosts:checked',$update_vdc_dialog).length ? + true : false; + + var zone_id = req.request.data[0]; + var free,li; + + $.each(host_list_json,function(){ + //if mine, put in mine_list + if (isHostMine(this.HOST.ID,vdc_id)){ + list_mine+='
      • '+this.HOST.NAME+'
      • '; + return true; //continue + } + //otherwise, check if its free etc... + free = isHostFree(this.HOST.ID,zone_id); + + if (force || free){ + list+='
      • '+(free? this.HOST.NAME : this.HOST.NAME+'*')+'
      • '; + } + }); + + + + $('#vdc_update_available_hosts_list',$update_vdc_dialog).html(list); + $('#vdc_update_selected_hosts_list',$update_vdc_dialog).html(list_mine); + +} + function isHostFree(id,zone_id){//strings var data = dataTable_vdcs.fnGetData(); var result = true; @@ -326,8 +417,8 @@ function setupCreateVDCDialog(){ containment: dialog }); - $('input#vdc_force_hosts').change(function(){ - select = $('select#zoneid'); + $('input#vdc_force_hosts',dialog).change(function(){ + select = $('select#zoneid',$('#create_vdc_dialog')); if (select.val().length){ select.trigger("change"); } @@ -355,10 +446,10 @@ function setupCreateVDCDialog(){ var vdcadminname = $('#vdcadminname',$(this)).val(); var vdcadminpass = $('#vdcadminpass',$(this)).val(); var zoneid = $('select#zoneid',$(this)).val(); - var force = $('#vdc_force_hosts',$(this)).length ? "yes" : "please no"; + var force = $('#vdc_force_hosts:checked',$(this)).length ? "yes" : "please no"; if (!name.length || !vdcadminname.length || !vdcadminpass.length || !zoneid.length){ - notifyError("Name, administrator credentials or zones are missing"); + notifyError("Name, administrator credentials or zone are missing"); return false; } var hosts=""; @@ -396,6 +487,119 @@ function openCreateVDCDialog(){ dialog.dialog('open'); } +function setupUpdateVDCDialog(){ + $('div#dialogs').append('
        '); + $update_vdc_dialog=$('div#update_vdc_dialog',dialogs_context); + var dialog = $update_vdc_dialog; + dialog.html(update_vdc_tmpl); + dialog.dialog({ + autoOpen: false, + modal: true, + width: 500 + }); + + $('button',dialog).button(); + $('#vdc_update_available_hosts_list',dialog).sortable({ + connectWith : '#vdc_update_selected_hosts_list', + containment: dialog + }); + $('#vdc_update_selected_hosts_list',dialog).sortable({ + connectWith : '#vdc_update_available_hosts_list', + containment: dialog + }); + + $('#vdc_update_force_hosts',dialog).change(function(){ + select = $('select#vdc_update_id',$update_vdc_dialog); + if (select.val().length){ + select.trigger("change"); + } + }); + + $('select#vdc_update_id').change(function(){ + var id = $(this).val(); + var zone_id = $('option:selected',this).attr("zone_id"); + var av_hosts= + $('#vdc_update_available_hosts_list',$update_vdc_dialog); + var sel_hosts= + $('#vdc_update_selected_hosts_list',$update_vdc_dialog); + + if (!id || !id.length) { + av_hosts.empty(); + sel_hosts.empty(); + return true; + }; + //A VDC has been selected + //Fill in available hosts column + //move current hosts to current + av_hosts.html('
      • '+spinner+'
      • '); + sel_hosts.empty(); + Sunstone.runAction("VDC.update_zone_hosts",zone_id); + }); + + $('#update_vdc_form').submit(function(){ + var force = $('#vdc_update_force_hosts',this).length ? "yes" : "nein"; + var id = $('#vdc_update_id',this).val(); + + var hosts=""; + $('#vdc_update_selected_hosts_list li',this).each(function(){ + hosts+=$(this).attr("host_id")+','; + }); + if (hosts.length){ + hosts= hosts.slice(0,-1); + }; + + var vdc_json = { + "vdc" : { + "id": id, + "force": force, + "hosts": hosts + } + }; + + if (hosts.length){ + vdc_json["vdc"]["hosts"]=hosts; + }; + Sunstone.runAction("VDC.update",id,vdc_json); + dialog.dialog('close'); + return false; + }); + +} + +function openUpdateVDCDialog(){ + var selected_elems = getSelectedNodes(dataTable_vdcs); + //populate select + var dialog = $update_vdc_dialog; + var options = ""; + var vdcs = dataTable_vdcs.fnGetData(); + for (var i = 0; i < vdcs.length; i++){ + //if this VDC is among the selected + if ($.inArray(vdcs[i][1].toString(),selected_elems) >= 0){ + options += ''; + }; + }; + + $('#vdc_update_available_hosts_list',dialog).empty(); + $('#vdc_update_selected_hosts_list',dialog).empty(); + + $('select#vdc_update_id',dialog).html(options); + if (selected_elems.length == 1){ + $('select#vdc_update_id',dialog).html(options); + $('select#vdc_update_id option',dialog).attr("checked","checked"); + $('select#vdc_update_id').trigger("change"); + } else { + $('select#vdc_update_id',dialog).html(''+ + options); + }; + + dialog.dialog('open'); +} + function setVDCAutorefresh() { setInterval(function(){ var checked = $('input:checked',dataTable_zones.fnGetNodes()); @@ -426,6 +630,8 @@ $(document).ready(function(){ setupCreateVDCDialog(); setupTips($('#create_vdc_dialog')); + setupUpdateVDCDialog(); + setupTips($('#update_vdc_dialog')); setVDCAutorefresh(); initCheckAllBoxes(dataTable_vdcs); tableCheckboxesListener(dataTable_vdcs); From d40d29a46fdfda326752504a08a69e21d8416837 Mon Sep 17 00:00:00 2001 From: Tino Vazquez Date: Mon, 26 Sep 2011 18:21:45 +0200 Subject: [PATCH 4/4] Bring back lost change in VDC host uniqueness --- src/ozones/Server/models/OzonesServer.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/ozones/Server/models/OzonesServer.rb b/src/ozones/Server/models/OzonesServer.rb index d7623781ba..a11e8cc132 100644 --- a/src/ozones/Server/models/OzonesServer.rb +++ b/src/ozones/Server/models/OzonesServer.rb @@ -311,9 +311,8 @@ class OzonesServer "#{vdc.zones.id} not found, cannot update Vdc.") return [404, error.to_json] end - - if (!defined? vdc_data[:force] or - (defined? vdc_data[:force] and vdc_data[:force]!="yes")) and + + if (!vdc_data[:force] or vdc_data[:force].upcase!="YES") and !host_uniqueness?(zone, vdc_data[:hosts], vdc_id.to_i) return [403, OZones::Error.new( "Error: Couldn't update resource #{kind}. " +