Hello community, here is the log from the commit of package hawk2 for openSUSE:Factory checked in at 2016-04-06 11:52:28 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/hawk2 (Old) and /work/SRC/openSUSE:Factory/.hawk2.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "hawk2" Changes: -------- --- /work/SRC/openSUSE:Factory/hawk2/hawk2.changes 2016-04-01 13:03:06.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.hawk2.new/hawk2.changes 2016-04-06 11:52:30.000000000 +0200 @@ -1,0 +2,12 @@ +Sat Apr 02 20:43:22 UTC 2016 - kgronl...@suse.com + +- Update to version 2.0.0+git.1459616683.31efac7: + + Reports: Allow generating reports on offline nodes + + UI: Add clear state operation for nodes + + UI: Status: Always show migrate option + + Model: Fix missing fence operation for nodes (bsc#973722) + + UI: Status: Refresh CIB after user changes (bsc#973723) + + UI: Fix partial CIB refresh by removing monitor epoch (bsc#973723) + + UI: Only overwrite CIB if epoch is newer + +------------------------------------------------------------------- Old: ---- hawk2-2.0.0+git.1459374052.159281a.tar.bz2 New: ---- hawk2-2.0.0+git.1459616683.31efac7.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ hawk2.spec ++++++ --- /var/tmp/diff_new_pack.F5tlXH/_old 2016-04-06 11:52:31.000000000 +0200 +++ /var/tmp/diff_new_pack.F5tlXH/_new 2016-04-06 11:52:31.000000000 +0200 @@ -31,13 +31,13 @@ %define gname haclient %define uname hacluster -%define version_unconverted 2.0.0+git.1459374052.159281a +%define version_unconverted 2.0.0+git.1459616683.31efac7 Name: hawk2 Summary: HA Web Konsole License: GPL-2.0 Group: %{pkg_group} -Version: 2.0.0+git.1459374052.159281a +Version: 2.0.0+git.1459616683.31efac7 Release: 0 Url: http://www.clusterlabs.org/wiki/Hawk Source: %{name}-%{version}.tar.bz2 ++++++ _servicedata ++++++ --- /var/tmp/diff_new_pack.F5tlXH/_old 2016-04-06 11:52:31.000000000 +0200 +++ /var/tmp/diff_new_pack.F5tlXH/_new 2016-04-06 11:52:31.000000000 +0200 @@ -1,4 +1,4 @@ <servicedata> <service name="tar_scm"> <param name="url">git://github.com/ClusterLabs/hawk.git</param> - <param name="changesrevision">159281ac28491b758b46e3f492d3990423aa8953</param></service></servicedata> \ No newline at end of file + <param name="changesrevision">31efac70e90a9014985c8c6d59920d0e9a825a3c</param></service></servicedata> \ No newline at end of file ++++++ hawk2-2.0.0+git.1459374052.159281a.tar.bz2 -> hawk2-2.0.0+git.1459616683.31efac7.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hawk2-2.0.0+git.1459374052.159281a/hawk/app/assets/javascripts/dashboard.js new/hawk2-2.0.0+git.1459616683.31efac7/hawk/app/assets/javascripts/dashboard.js --- old/hawk2-2.0.0+git.1459374052.159281a/hawk/app/assets/javascripts/dashboard.js 2016-03-31 07:22:40.000000000 +0200 +++ new/hawk2-2.0.0+git.1459616683.31efac7/hawk/app/assets/javascripts/dashboard.js 2016-04-02 22:43:16.000000000 +0200 @@ -307,14 +307,12 @@ function clusterRefresh(clusterId, clusterInfo) { indicator(clusterId, "refresh"); - //console.log("request cib", $("#" + clusterId).data('epoch'), (new Date()).getTime()); ajaxQuery({ url: baseUrl(clusterInfo) + "/cib/live?mini=true&format=json", type: "GET", data: { _method: 'show' }, crossDomain: clusterInfo.host != null, success: function(data) { displayClusterStatus(clusterId, data); - //console.log("response cib", data.meta.epoch, (new Date()).getTime()); $("#" + clusterId).data('epoch', data.meta.epoch); clusterUpdate(clusterId, clusterInfo); }, @@ -328,14 +326,12 @@ function clusterUpdate(clusterId, clusterInfo) { var current_epoch = $("#" + clusterId).data('epoch'); - //console.log("request monitor", current_epoch, (new Date()).getTime()); ajaxQuery({ url: baseUrl(clusterInfo) + "/monitor.json", type: "GET", data: current_epoch, timeout: 90000, crossDomain: clusterInfo.host != null, success: function(data) { - //console.log("response monitor", data.epoch, current_epoch, (new Date()).getTime()); if (data.epoch != current_epoch) { clusterRefresh(clusterId, clusterInfo); } else { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hawk2-2.0.0+git.1459374052.159281a/hawk/app/assets/javascripts/module/basics.js new/hawk2-2.0.0+git.1459616683.31efac7/hawk/app/assets/javascripts/module/basics.js --- old/hawk2-2.0.0+git.1459374052.159281a/hawk/app/assets/javascripts/module/basics.js 2016-03-31 07:22:40.000000000 +0200 +++ new/hawk2-2.0.0+git.1459616683.31efac7/hawk/app/assets/javascripts/module/basics.js 2016-04-02 22:43:16.000000000 +0200 @@ -212,4 +212,63 @@ $.views.converters("hasKeys", function(val) { return !($.isEmptyObject(val)); }); + + $.hawkRunOperation = function(confirmMsg, route) { + $.hawkAsyncConfirm(confirmMsg, function() { + $.ajax({ + dataType: 'json', + method: 'GET', + url: route, + success: function(data) { + if (data.success) { + $.growl({ message: data.message }, { type: 'success' }); + } else { + if (data.error) { + $.growl({ message: data.error }, { type: 'danger' }); + } + } + $.runSimulator(); + }, + error: function(xhr, status, msg) { + $.growl({ message: xhr.responseJSON.error || msg }, { type: 'danger' }); + $.runSimulator(); + } + }); + }); + }; + + $.hawkDeleteOperation = function(id, url) { + $.hawkAsyncConfirm(i18n.translate('Are you sure you wish to delete %s?').fetch(id), function() { + $.ajax({ + dataType: 'json', + method: 'POST', + data: { + _method: 'delete' + }, + url: url, + success: function(data) { + if (data.success) { + $.growl({ message: data.message }, { type: 'success' }); + } else { + if (data.error) { + $.growl({ message: data.error }, { type: 'danger' }); + } + } + $.runSimulator(); + }, + error: function(xhr, status, msg) { + $.growl({ message: xhr.responseJSON.error || msg }, { type: 'danger' }); + $.runSimulator(); + } + }); + }); + }; + + window.hawkEpochValue = function(epochString) { + var parts = epochString.split(":"); + if (parts.length == 3) { + return parseInt(parts[0]) * 1000000 + parseInt(parts[1]) * 10000 + parseInt(parts[2]); + } + return 0; + }; }); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hawk2-2.0.0+git.1459374052.159281a/hawk/app/assets/javascripts/module/monitor.js new/hawk2-2.0.0+git.1459616683.31efac7/hawk/app/assets/javascripts/module/monitor.js --- old/hawk2-2.0.0+git.1459374052.159281a/hawk/app/assets/javascripts/module/monitor.js 2016-03-31 07:22:40.000000000 +0200 +++ new/hawk2-2.0.0+git.1459616683.31efac7/hawk/app/assets/javascripts/module/monitor.js 2016-04-02 22:43:16.000000000 +0200 @@ -2,8 +2,6 @@ // See COPYING for license. ;(function($, doc, win) { - 'use strict'; - window.userIsNavigatingAway = false; var _obunload = (window.onbeforeunload) ? window.onbeforeunload : function() {}; window.onbeforeunload = function() { @@ -12,31 +10,16 @@ }; function MonitorCheck(el, options) { - this.$el = $(el); - - this.currentEpoch = this.$el.data('epoch'); - this.defaults = { faster: 15, timeout: 90, cache: false }; - - this.options = $.extend( - this.defaults, - options - ); - - this.init(); - } - - MonitorCheck.prototype.init = function() { - var self = this; - - if (self.$el.data('cib') === 'live') { - self.processCheck(); + this.options = $.extend(this.defaults, options); + if ($('body').data('cib') === 'live') { + this.processCheck(); } - }; + } MonitorCheck.prototype.processCheck = function() { var self = this; @@ -45,9 +28,8 @@ $.ajax({ url: Routes.monitor_path(), - type: 'GET', - data: self.currentEpoch, + data: $('body').data('content').meta.epoch, dataType: "json", cache: self.options.cache, timeout: self.options.timeout * 1000, @@ -59,17 +41,16 @@ } else { $('body').trigger($.Event('checked.hawk.monitor')); } - self.processCheck(); } else { - if (window.userIsNavigatingAway) + if (window.userIsNavigatingAway) { return; + } var msg = __('Connection to server aborted - will retry every 15 seconds.'); $.growl(msg, { type: 'warning' }); $('.circle').statusCircle('disconnected', msg); $('body').trigger($.Event('aborted.hawk.monitor')); - setTimeout(function() { - self.processCheck(); }, self.options.faster * 1000); + setTimeout(function() { self.processCheck(); }, self.options.faster * 1000); } }, @@ -79,10 +60,12 @@ var msg = null; var code = 'danger'; var status = 'errors'; - if (request.readyState > 1) { + if (request.readyState == 4 && request.status == 200) { + msg = __('Failed to parse monitor response - Internal server error.'); + code = 'warning'; + } else if (request.readyState > 1) { if (request.status >= 10000) { msg = __('Connection to server failed - will retry every 15 seconds.'); - } else { } } else { msg = __('Connection to server timed out - will retry every 15 seconds.'); @@ -102,9 +85,8 @@ MonitorCheck.prototype.updateEpoch = function(epoch) { if (epoch !== undefined) { - var changed = this.currentEpoch !== epoch; - this.currentEpoch = epoch; - return changed; + var cib = $('body').data('content'); + return !cib || cib.meta.epoch !== epoch; } return false; }; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hawk2-2.0.0+git.1459374052.159281a/hawk/app/assets/javascripts/module/nodes.js new/hawk2-2.0.0+git.1459616683.31efac7/hawk/app/assets/javascripts/module/nodes.js --- old/hawk2-2.0.0+git.1459374052.159281a/hawk/app/assets/javascripts/module/nodes.js 2016-03-31 07:22:40.000000000 +0200 +++ new/hawk2-2.0.0+git.1459616683.31efac7/hawk/app/assets/javascripts/module/nodes.js 2016-04-02 22:43:16.000000000 +0200 @@ -92,90 +92,17 @@ events: { 'click .ready': function (e, value, row, index) { e.preventDefault(); - var $self = $(this); - - $.hawkAsyncConfirm(i18n.translate('This will bring node %s out of maintenance mode. Do you want to continue?').fetch(row.name), function() { - $.ajax({ - dataType: 'json', - method: 'GET', - url: Routes.ready_cib_node_path( - $('body').data('cib'), - row.id, - { format: 'json' } - ), - - success: function(data) { - if (data.success) { - $.growl({ - message: data.message - }, { - type: 'success' - }); - - $self.parents('table').bootstrapTable('refresh') - } else { - if (data.error) { - $.growl({ - message: data.error - }, { - type: 'danger' - }); - } - } - }, - error: function(xhr, status, msg) { - $.growl({ - message: xhr.responseJSON.error || msg - },{ - type: 'danger' - }); - } - }); - }); + $.hawkRunOperation( + i18n.translate('This will bring node %s out of maintenance mode. Do you want to continue?').fetch(row.name), + Routes.ready_cib_node_path($('body').data('cib'), row.id, { format: 'json' })); return false; }, 'click .maintenance': function (e, value, row, index) { e.preventDefault(); - var $self = $(this); - - $.hawkAsyncConfirm(i18n.translate('This will put node %s in maintenance mode. All resources on this node will become unmanaged. Do you want to continue?').fetch(row.name), function() { - $.ajax({ - dataType: 'json', - method: 'GET', - url: Routes.maintenance_cib_node_path( - $('body').data('cib'), - row.id, - { format: 'json' } - ), - - success: function(data) { - if (data.success) { - $.growl({ - message: data.message - }, { - type: 'success' - }); - $self.parents('table').bootstrapTable('refresh') - } else { - if (data.error) { - $.growl({ - message: data.error - }, { - type: 'danger' - }); - } - } - }, - error: function(xhr, status, msg) { - $.growl({ - message: xhr.responseJSON.error || msg - },{ - type: 'danger' - }); - } - }); - }); + $.hawkRunOperation( + i18n.translate('This will put node %s in maintenance mode. All resources on this node will become unmanaged. Do you want to continue?').fetch(row.name), + Routes.maintenance_cib_node_path($('body').data('cib'), row.id, { format: 'json' })); return false; } }, @@ -219,90 +146,16 @@ events: { 'click .online': function (e, value, row, index) { e.preventDefault(); - var $self = $(this); - - $.hawkAsyncConfirm(i18n.translate('This will bring node %s online if it is currently on standby. Do you want to continue?').fetch(row.name), function() { - $.ajax({ - dataType: 'json', - method: 'GET', - url: Routes.online_cib_node_path( - $('body').data('cib'), - row.id, - { format: 'json' } - ), - - success: function(data) { - if (data.success) { - $.growl({ - message: data.message - }, { - type: 'success' - }); - - $self.parents('table').bootstrapTable('refresh') - } else { - if (data.error) { - $.growl({ - message: data.error - }, { - type: 'danger' - }); - } - } - }, - error: function(xhr, status, msg) { - $.growl({ - message: xhr.responseJSON.error || msg - },{ - type: 'danger' - }); - } - }); - }); + $.hawkRunOperation( + i18n.translate('This will bring node %s online if it is currently on standby. Do you want to continue?').fetch(row.name), + Routes.online_cib_node_path($('body').data('cib'), row.id, { format: 'json' })); return false; }, 'click .standby': function (e, value, row, index) { e.preventDefault(); - var $self = $(this); - - $.hawkAsyncConfirm(i18n.translate('This will put node %s on standby. All resources will be stopped and/or moved to another node. Do you want to continue?').fetch(row.name), function() { - $.ajax({ - dataType: 'json', - method: 'GET', - url: Routes.standby_cib_node_path( - $('body').data('cib'), - row.id, - { format: 'json' } - ), - - success: function(data) { - if (data.success) { - $.growl({ - message: data.message - }, { - type: 'success' - }); - - $self.parents('table').bootstrapTable('refresh') - } else { - if (data.error) { - $.growl({ - message: data.error - }, { - type: 'danger' - }); - } - } - }, - error: function(xhr, status, msg) { - $.growl({ - message: xhr.responseJSON.error || msg - },{ - type: 'danger' - }); - } - }); - }); + $.hawkRunOperation( + i18n.translate('This will put node %s on standby. All resources will be stopped and/or moved to another node. Do you want to continue?').fetch(row.name), + Routes.standby_cib_node_path($('body').data('cib'), row.id, { format: 'json' })); return false; } }, @@ -346,47 +199,16 @@ events: { 'click .fence': function (e, value, row, index) { e.preventDefault(); - var $self = $(this); - - $.hawkAsyncConfirm(i18n.translate('This will attempt to immediately fence node %s. Do you want to continue?').fetch(row.name), function() { - $.ajax({ - dataType: 'json', - method: 'GET', - url: Routes.fence_cib_node_path( - $('body').data('cib'), - row.id, - { format: 'json' } - ), - - success: function(data) { - if (data.success) { - $.growl({ - message: data.message - }, { - type: 'success' - }); - - $self.parents('table').bootstrapTable('refresh') - } else { - if (data.error) { - $.growl({ - message: data.error - }, { - type: 'danger' - }); - } - } - }, - error: function(xhr, status, msg) { - $.growl({ - message: xhr.responseJSON.error || msg - },{ - type: 'danger' - }); - } - }); - }); - + $.hawkRunOperation( + i18n.translate('This will attempt to immediately fence node %s. Do you want to continue?').fetch(row.name), + Routes.fence_cib_node_path($('body').data('cib'), row.id, { format: 'json' })); + return false; + }, + 'click .clearstate': function (e, value, row, index) { + e.preventDefault(); + $.hawkRunOperation( + i18n.translate('Clear the state of node %s. The node is afterwards assumed clean and offline. This command can be used to manually confirm that a node has been fenced. Be careful! This can cause data corruption if the node is not cleanly down! Do you want to clear the state?').fetch(row.name), + Routes.clearstate_cib_node_path($('body').data('cib'), row.id, { format: 'json' })); return false; } }, @@ -415,7 +237,13 @@ if (row.fence) { add_operation("menu", Routes.fence_cib_node_path($('body').data('cib'), row.id), 'fence', 'plug', __('Fence')); + add_operation("menu", Routes.clearstate_cib_node_path($('body').data('cib'), row.id), 'clearstate', 'eraser', __('Clear state')); + dropdowns.push(['<li role="separator" class="divider"></li>'].join('')); + } + + add_operation("menu", Routes.edit_cib_node_path($('body').data('cib'), row.id), 'edit', 'pencil', __('Edit')); + if (dropdowns.length > 0) { operations.push([ '<div class="btn-group" role="group">', '<button class="btn btn-default btn-xs dropdown-toggle" type="button" data-toggle="dropdown" data-container="body" aria-haspopup="true" aria-expanded="true">', diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hawk2-2.0.0+git.1459374052.159281a/hawk/app/assets/javascripts/module/resources.js new/hawk2-2.0.0+git.1459616683.31efac7/hawk/app/assets/javascripts/module/resources.js --- old/hawk2-2.0.0+git.1459374052.159281a/hawk/app/assets/javascripts/module/resources.js 2016-03-31 07:22:40.000000000 +0200 +++ new/hawk2-2.0.0+git.1459616683.31efac7/hawk/app/assets/javascripts/module/resources.js 2016-04-02 22:43:16.000000000 +0200 @@ -3,43 +3,7 @@ $(function() { function executeAction(context, confirmMsg) { - $.hawkAsyncConfirm(confirmMsg, function() { - $.ajax({ - dataType: 'json', - method: 'GET', - url: [ - context.attr('href'), - ".json" - ].join(""), - - success: function(data) { - if (data.success) { - $.growl({ - message: data.message - },{ - type: 'success' - }); - } else { - if (data.error) { - $.growl({ - message: data.error - },{ - type: 'danger' - }); - } - } - $.runSimulator(); - }, - error: function(xhr, status, msg) { - $.growl({ - message: xhr.responseJSON.error || msg - },{ - type: 'danger' - }); - $.runSimulator(); - } - }); - }); + $.hawkRunOperation(confirmMsg, [context.attr('href'), ".json"].join("")); return false; } @@ -403,10 +367,9 @@ var rsc_routes = resourceRoutes(row); + add_operation("menu", Routes.migrate_cib_resource_path($('body').data('cib'), row.id), 'migrate', 'arrows', __('Migrate')); if (resourceMigrationConstraints(row.id).length > 0) { add_operation("menu", Routes.unmigrate_cib_resource_path($('body').data('cib'), row.id), 'unmigrate', 'chain-broken', __('Unmigrate')); - } else { - add_operation("menu", Routes.migrate_cib_resource_path($('body').data('cib'), row.id), 'migrate', 'arrows', __('Migrate')); } add_operation("menu", Routes.cleanup_cib_resource_path($('body').data('cib'), row.id), 'cleanup', 'eraser', __('Cleanup')); @@ -686,48 +649,7 @@ events: { 'click .delete': function (e, value, row, index) { e.preventDefault(); - var $self = $(this); - - $.hawkAsyncConfirm(i18n.translate('Are you sure you wish to delete %s?').fetch(row.id), function() { - $.ajax({ - dataType: 'json', - method: 'POST', - data: { - _method: 'delete' - }, - url: [ - $self.attr('href'), - ".json" - ].join(""), - - success: function(data) { - if (data.success) { - $.growl({ - message: data.message - },{ - type: 'success' - }); - - $self.parents('table').bootstrapTable('refresh') - } else { - if (data.error) { - $.growl({ - message: data.error - },{ - type: 'danger' - }); - } - } - }, - error: function(xhr, status, msg) { - $.growl({ - message: xhr.responseJSON.error || msg - },{ - type: 'danger' - }); - } - }); - }); + $.hawkDeleteOperation(row.id, [$(this).attr('href'), ".json"].join("")); return false; } }, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hawk2-2.0.0+git.1459374052.159281a/hawk/app/assets/javascripts/module/status.js new/hawk2-2.0.0+git.1459616683.31efac7/hawk/app/assets/javascripts/module/status.js --- old/hawk2-2.0.0+git.1459374052.159281a/hawk/app/assets/javascripts/module/status.js 2016-03-31 07:22:40.000000000 +0200 +++ new/hawk2-2.0.0+git.1459616683.31efac7/hawk/app/assets/javascripts/module/status.js 2016-04-02 22:43:16.000000000 +0200 @@ -62,6 +62,9 @@ } }); + this.currCib = $('body').data('cib'); + this.currEpoch = -1; + this.init(); } @@ -85,28 +88,13 @@ ); }; - var hashCodeForCib = function(cib) { - var s; - var hash = 0, i, chr, len; - s = $.map(cib, function(val, key) { - return key + "=" + val; - }).join("|"); - if (s.length === 0) return hash; - for (i = 0, len = s.length; i < len; i++) { - chr = s.charCodeAt(i); - hash = ((hash << 5) - hash) + chr; - hash |= 0; // Convert to 32bit integer - } - return hash; - }; - StatusCheck.prototype.update = function() { var self = this; - self.cib_hash = 0; + var cibName = $('body').data('cib'); $.ajax({ - url: Routes.cib_path($('body').data('cib'), { format: 'json' }), + url: Routes.cib_path(cibName, { format: 'json' }), type: 'GET', dataType: 'json', cache: self.options.cache, @@ -116,9 +104,10 @@ if (!cib) { return; } - var h = hashCodeForCib(cib); - if (self.cib_hash != h) { - self.cib_hash = h; + var newEpoch = hawkEpochValue(cib.meta.epoch); + if (self.currCib != cibName || self.currEpoch < newEpoch) { + self.currCib = cibName; + self.currEpoch = newEpoch; $('body').data('content', cib); $('.circle').statusCircleFromCIB(cib); self.options.content = cib; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hawk2-2.0.0+git.1459374052.159281a/hawk/app/assets/javascripts/module/tickets.js new/hawk2-2.0.0+git.1459616683.31efac7/hawk/app/assets/javascripts/module/tickets.js --- old/hawk2-2.0.0+git.1459374052.159281a/hawk/app/assets/javascripts/module/tickets.js 2016-03-31 07:22:40.000000000 +0200 +++ new/hawk2-2.0.0+git.1459616683.31efac7/hawk/app/assets/javascripts/module/tickets.js 2016-04-02 22:43:16.000000000 +0200 @@ -45,53 +45,10 @@ events: { 'click .delete': function (e, value, row, index) { e.preventDefault(); - var $self = $(this); - if (row.id == null) { return false; } - - $.hawkAsyncConfirm(i18n.translate('Are you sure you wish to delete %s?').fetch(row.id), function() { - $.ajax({ - dataType: 'json', - method: 'POST', - data: { - _method: 'delete' - }, - url: Routes.cib_ticket_path( - $('body').data('cib'), - row.id, - { format: 'json' } - ), - - success: function(data) { - if (data.success) { - $.growl({ - message: data.message - },{ - type: 'success' - }); - - $self.parents('table').bootstrapTable('refresh') - } else { - if (data.error) { - $.growl({ - message: data.error - },{ - type: 'danger' - }); - } - } - }, - error: function(xhr, status, msg) { - $.growl({ - message: xhr.responseJSON.error || msg - },{ - type: 'danger' - }); - } - }); - }); + $.hawkDeleteOperation(row.id, Routes.cib_ticket_path($('body').data('cib'), row.id, { format: 'json' })); return false; } }, @@ -215,89 +172,24 @@ events: { 'click .grant': function (e, value, row, index) { e.preventDefault(); - var $self = $(this); - if (row.id == null) { return false; } - $.hawkAsyncConfirm(i18n.translate('This will request the ticket %s be granted to the present site. Do you want to continue?').fetch(row.id), function() { - $.ajax({ - dataType: 'json', - method: 'GET', - url: [context.attr('href'), ".json"].join(""), - success: function(data) { - if (data.success) { - $.growl({ - message: data.message - },{ - type: 'success' - }); - - $self.parents('table').bootstrapTable('refresh') - } else { - if (data.error) { - $.growl({ - message: data.error - },{ - type: 'danger' - }); - } - } - }, - error: function(xhr, status, msg) { - $.growl({ - message: xhr.responseJSON.error || msg - },{ - type: 'danger' - }); - } - }); - }); + $.hawkRunOperation( + i18n.translate('This will request the ticket %s be granted to the present site. Do you want to continue?').fetch(row.id), + [context.attr('href'), ".json"].join("")); return false; }, 'click .revoke': function (e, value, row, index) { e.preventDefault(); - var $self = $(this); - if (row.id == null) { return false; } - $.hawkAsyncConfirm(i18n.translate('This will request the ticket %s be revoked. Do you want to continue?').fetch(row.id), function() { - $.ajax({ - dataType: 'json', - method: 'GET', - url: [context.attr('href'), ".json"].join(""), - - success: function(data) { - if (data.success) { - $.growl({ - message: data.message - },{ - type: 'success' - }); - - $self.parents('table').bootstrapTable('refresh') - } else { - if (data.error) { - $.growl({ - message: data.error - },{ - type: 'danger' - }); - } - } - }, - error: function(xhr, status, msg) { - $.growl({ - message: xhr.responseJSON.error || msg - },{ - type: 'danger' - }); - } - }); - }); + $.hawkRunOperation( + i18n.translate('This will request the ticket %s be revoked. Do you want to continue?').fetch(row.id), + [context.attr('href'), ".json"].join("")); return false; } }, @@ -343,53 +235,10 @@ events: { 'click .delete': function (e, value, row, index) { e.preventDefault(); - var $self = $(this); - if (row.id == null) { return false; } - - $.hawkAsyncConfirm(i18n.translate('Are you sure you wish to delete %s?').fetch(row.id), function() { - $.ajax({ - dataType: 'json', - method: 'POST', - data: { - _method: 'delete' - }, - url: Routes.cib_ticket_path( - $('body').data('cib'), - row.id, - { format: 'json' } - ), - - success: function(data) { - if (data.success) { - $.growl({ - message: data.message - },{ - type: 'success' - }); - - $self.parents('table').bootstrapTable('refresh') - } else { - if (data.error) { - $.growl({ - message: data.error - },{ - type: 'danger' - }); - } - } - }, - error: function(xhr, status, msg) { - $.growl({ - message: xhr.responseJSON.error || msg - },{ - type: 'danger' - }); - } - }); - }); + $.hawkDeleteOperation(row.id, Routes.cib_ticket_path($('body').data('cib'), row.id, { format: 'json' })); return false; } }, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hawk2-2.0.0+git.1459374052.159281a/hawk/app/controllers/monitor_controller.rb new/hawk2-2.0.0+git.1459616683.31efac7/hawk/app/controllers/monitor_controller.rb --- old/hawk2-2.0.0+git.1459374052.159281a/hawk/app/controllers/monitor_controller.rb 2016-03-31 07:22:40.000000000 +0200 +++ new/hawk2-2.0.0+git.1459616683.31efac7/hawk/app/controllers/monitor_controller.rb 2016-04-02 22:43:16.000000000 +0200 @@ -18,7 +18,8 @@ skip_after_filter :cors_set_access_control_headers def monitor - ENV['QUERY_STRING'] = request.query_string.to_s + epoch = request.query_string.to_s.split('&').first || "" + ENV['QUERY_STRING'] = epoch ENV['HTTP_ORIGIN'] = request.headers['Origin'] response.headers['Content-Type'] = 'text/event-stream' @@ -30,9 +31,11 @@ response.headers['Access-Control-Max-Age'] = "1728000" end Open3.popen2("/usr/sbin/hawk_monitor") do |_i, o, _t| + _i.close result = o.read _, body = result.split("\n\n", 2) - response.stream.write(body.to_s + "\n") + body = body.to_s.strip + "\n" + response.stream.write(body) end ensure response.stream.close diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hawk2-2.0.0+git.1459374052.159281a/hawk/app/controllers/nodes_controller.rb new/hawk2-2.0.0+git.1459616683.31efac7/hawk/app/controllers/nodes_controller.rb --- old/hawk2-2.0.0+git.1459374052.159281a/hawk/app/controllers/nodes_controller.rb 2016-03-31 07:22:40.000000000 +0200 +++ new/hawk2-2.0.0+git.1459616683.31efac7/hawk/app/controllers/nodes_controller.rb 2016-04-02 22:43:16.000000000 +0200 @@ -5,7 +5,7 @@ before_filter :login_required before_filter :set_title before_filter :set_cib - before_filter :set_record, only: [:online, :standby, :maintenance, :ready, :fence, :show, :events, :edit, :update] + before_filter :set_record, only: [:online, :standby, :maintenance, :ready, :fence, :clearstate, :show, :events, :edit, :update] rescue_from Node::CommandError do |e| Rails.logger.error e @@ -59,88 +59,27 @@ end def online - @node.online! - - respond_to do |format| - format.html do - flash[:success] = _("Set the node state to online") - redirect_to cib_nodes_url(cib_id: @cib.id) - end - format.json do - render json: { - success: true, - message: _("Set the node state to online") - } - end - end + run_node_action @node.online!, _("Set the node state to online"), _("Failed to set the node online: %{err}") end def standby - @node.standby! - - respond_to do |format| - format.html do - flash[:success] = _("Set the node state to standby") - redirect_to cib_nodes_url(cib_id: @cib.id) - end - format.json do - render json: { - success: true, - message: _("Set the node state to standby") - } - end - end + run_node_action @node.standby!, _("Set the node state to standby"), _("Failed to set the node standby: %{err}") end def maintenance - @node.maintenance! - - respond_to do |format| - format.html do - flash[:success] = _("Set the node state to maintenance") - redirect_to cib_nodes_url(cib_id: @cib.id) - end - format.json do - render json: { - success: true, - message: _("Set the node state to maintenance") - } - end - end + run_node_action @node.maintenance!, _("Set the node state to maintenance"), _("Failed to set the node state to maintenance: %{err}") end def ready - @node.ready! - - respond_to do |format| - format.html do - flash[:success] = _("Set the node state to ready") - redirect_to cib_nodes_url(cib_id: @cib.id) - end - format.json do - render json: { - success: true, - message: _("Set the node state to ready") - } - end - end + run_node_action @node.ready!, _("Set the node state to ready"), _("Failed to set the node state to ready: %{err}") end def fence - @node.fence! + run_node_action @node.fence!, _("Successfully fenced the node"), _("Failed to fence the node: %{err}") + end - respond_to do |format| - format.html do - flash[:success] = _("Set the node state to fence") - redirect_to cib_nodes_url(cib_id: @cib.id) - end - format.json do - render json: { - success: true, - message: _("Set the node state to fence") - } - end - end + def clearstate + run_node_action @node.clearstate!, _("Cleared the node state"), _("Failed to clear the node state: %{err}") end def show @@ -195,4 +134,26 @@ def default_base_layout "withrightbar" end + + def run_node_action(result, success, error) + _out, err, rc = result + + respond_to do |format| + if rc == 0 + format.json do + render json: { + success: true, + message: success + } + end + else + format.json do + render json: { + error: error % { err: err } + }, status: :unprocessable_entity + end + end + end + end + end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hawk2-2.0.0+git.1459374052.159281a/hawk/app/controllers/resources_controller.rb new/hawk2-2.0.0+git.1459616683.31efac7/hawk/app/controllers/resources_controller.rb --- old/hawk2-2.0.0+git.1459374052.159281a/hawk/app/controllers/resources_controller.rb 2016-03-31 07:22:40.000000000 +0200 +++ new/hawk2-2.0.0+git.1459616683.31efac7/hawk/app/controllers/resources_controller.rb 2016-04-02 22:43:16.000000000 +0200 @@ -226,7 +226,7 @@ end def run_resource_action(result, success, error) - out, err, rc = result + _out, err, rc = result respond_to do |format| if rc == 0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hawk2-2.0.0+git.1459374052.159281a/hawk/app/models/cib.rb new/hawk2-2.0.0+git.1459616683.31efac7/hawk/app/models/cib.rb --- old/hawk2-2.0.0+git.1459374052.159281a/hawk/app/models/cib.rb 2016-03-31 07:22:40.000000000 +0200 +++ new/hawk2-2.0.0+git.1459616683.31efac7/hawk/app/models/cib.rb 2016-04-02 22:43:16.000000000 +0200 @@ -122,6 +122,11 @@ meta[:status] == :offline end + def not_a_node? + return false unless offline? + !File.exist?('/var/lib/pacemaker') + end + def node_state_of_resource(rsc) nodestate = {} rsc[:instances].each do |_, attrs| @@ -218,15 +223,14 @@ state = @nodes.select { |n| n[:id] == node_id || n[:uname] == node_id } fail(RecordNotFound, node_id) if state.blank? - can_fence = @crm_config[:stonith_enabled] node = @xml.elements["cib/configuration/nodes/node[@uname=\"#{node_id}\"]"] if node - Node.instantiate(node, state.first, can_fence) + Node.instantiate(node, state.first) else node = @xml.elements["cib/configuration/nodes/node[@id=\"#{node_id}\"]"] if node - Node.instantiate(node, state.first, can_fence) + Node.instantiate(node, state.first) else fail RecordNotFound, node_id end @@ -236,11 +240,10 @@ def nodes_ordered ret = [] return ret if @xml.nil? - can_fence = @crm_config[:stonith_enabled] @xml.elements.each('cib/configuration/nodes/node') do |xml| node_id = xml.attributes['id'] state = @nodes.select { |n| n[:id] == node_id } - ret << Node.instantiate(xml, state[0], can_fence) + ret << Node.instantiate(xml, state[0]) end ret end @@ -602,8 +605,10 @@ state = :standby end + can_fence = @crm_config[:stonith_enabled] + # check stonith history - if crm_config[:stonith_enabled] + if can_fence fence_history = %x[/usr/sbin/stonith_admin -H #{uname} 2>/dev/null].strip else fence_history = "" @@ -617,6 +622,7 @@ standby: standby, maintenance: maintenance, remote: remote, + fence: can_fence, fence_history: fence_history } if state == :unclean diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hawk2-2.0.0+git.1459374052.159281a/hawk/app/models/node.rb new/hawk2-2.0.0+git.1459616683.31efac7/hawk/app/models/node.rb --- old/hawk2-2.0.0+git.1459374052.159281a/hawk/app/models/node.rb 2016-03-31 07:22:40.000000000 +0200 +++ new/hawk2-2.0.0+git.1459616683.31efac7/hawk/app/models/node.rb 2016-04-02 22:43:16.000000000 +0200 @@ -30,9 +30,7 @@ format: { with: /\A[a-zA-Z0-9_-]+\z/, message: _('Invalid name') } def online! - out, err, rc = Invoker.instance.run "crm_attribute", "-N", name, "-n", "standby", "-v", "off", "-l", "forever" - raise CommandError.new err unless rc == 0 - true + Invoker.instance.no_log { |i| i.crm("-F", "node", "online", name) } end def online @@ -40,31 +38,27 @@ end def standby! - out, err, rc = Invoker.instance.run "crm_attribute", "-N", name, "-n", "standby", "-v", "on", "-l", "forever" - raise CommandError.new err unless rc == 0 - true + Invoker.instance.no_log { |i| i.crm("-F", "node", "standby", name) } end def ready! - out, err, rc = Invoker.instance.run "crm_attribute", "-N", name, "-n", "maintenance", "-v", "off", "-l", "forever" - raise CommandError.new err unless rc == 0 - true - end - - def ready - !maintenance + Invoker.instance.no_log { |i| i.crm("-F", "node", "ready", name) } end def maintenance! - out, err, rc = Invoker.instance.run "crm_attribute", "-N", name, "-n", "maintenance", "-v", "on", "-l", "forever" - raise CommandError.new err unless rc == 0 - true + Invoker.instance.no_log { |i| i.crm("-F", "node", "maintenance", name) } end def fence! - out, err, rc = Invoker.instance.run "crm_attribute", "-t", "status", "-U", name, "-n", "terminate", "-v", "true" - raise CommandError.new err unless rc == 0 - true + Invoker.instance.no_log { |i| i.crm("-F", "node", "fence", name) } + end + + def clearstate! + Invoker.instance.no_log { |i| i.crm("-F", "node", "clearstate", name) } + end + + def ready + !maintenance end def to_param @@ -137,7 +131,7 @@ end class << self - def instantiate(xml, state, can_fence) + def instantiate(xml, state) record = allocate record.id = xml.attributes['id'] record.xml = xml @@ -147,7 +141,7 @@ record.maintenance = state[:maintenance] record.remote = state[:remote] record.fence_history = state[:fence_history] - record.fence = can_fence + record.fence = state[:fence] record.params = if xml.elements['instance_attributes'] vals = xml.elements['instance_attributes'].elements.collect do |e| @@ -255,4 +249,5 @@ return elem.attributes['uname'] if elem.attributes['uname'] elem.attributes['id'] end + end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hawk2-2.0.0+git.1459374052.159281a/hawk/app/views/reports/index.html.haml new/hawk2-2.0.0+git.1459616683.31efac7/hawk/app/views/reports/index.html.haml --- old/hawk2-2.0.0+git.1459374052.159281a/hawk/app/views/reports/index.html.haml 2016-03-31 07:22:40.000000000 +0200 +++ new/hawk2-2.0.0+git.1459616683.31efac7/hawk/app/views/reports/index.html.haml 2016-04-02 22:43:16.000000000 +0200 @@ -28,7 +28,7 @@ #report-tabs.panel.panel-default.with-nav-tabs.hidden .panel-heading %ul.nav.nav-tabs - - unless current_cib.offline? + - unless current_cib.not_a_node? %li.active %a{ href: "#generate", data: { toggle: "tab" } } = _("Generate") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hawk2-2.0.0+git.1459374052.159281a/hawk/config/routes.rb new/hawk2-2.0.0+git.1459616683.31efac7/hawk/config/routes.rb --- old/hawk2-2.0.0+git.1459374052.159281a/hawk/config/routes.rb 2016-03-31 07:22:40.000000000 +0200 +++ new/hawk2-2.0.0+git.1459616683.31efac7/hawk/config/routes.rb 2016-04-02 22:43:16.000000000 +0200 @@ -16,6 +16,7 @@ get :maintenance get :ready get :fence + get :clearstate get :events end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hawk2-2.0.0+git.1459374052.159281a/hawk/lib/cibtools.rb new/hawk2-2.0.0+git.1459616683.31efac7/hawk/lib/cibtools.rb --- old/hawk2-2.0.0+git.1459374052.159281a/hawk/lib/cibtools.rb 2016-03-31 07:22:40.000000000 +0200 +++ new/hawk2-2.0.0+git.1459616683.31efac7/hawk/lib/cibtools.rb 2016-04-02 22:43:16.000000000 +0200 @@ -17,7 +17,7 @@ # Format the epoch string "admin_epoch:epoch:num_updates" def epoch_string(elem) - "#{CibTools.get_xml_attr(elem, 'admin_epoch')}:#{CibTools.get_xml_attr(elem, 'epoch')}:#{CibTools.get_xml_attr(elem, 'num_updates')}"; + "#{CibTools.get_xml_attr(elem, 'admin_epoch', '0')}:#{CibTools.get_xml_attr(elem, 'epoch', '0')}:#{CibTools.get_xml_attr(elem, 'num_updates', '0')}"; end module_function :epoch_string