Fix activate image and reboot BMC
- Change bmcReboot callback in apiutils.js to HTTP request that returns a promise that is resolved with response object
- Remove emitted 'user-logged-in' as it is not needed to reboot BMC on firmware controller and bmc reboot controller
- Add toast message for visual confirmation of successful BMC reboot
Tested: On Server Configuration > Firmware page uploaded new image to activate and automatically reboot. After 2-3 minutes confirmed image activated and then BMC rebooted after image activation. Tested Server Control > Reboot BMC page by selecting Reboot BMC, confirmed BMC rebooted.
Resolves openbmc/phosphor-webui#79
Signed-off-by: Dixsie Wolmers <dixsiew@gmail.com>
Change-Id: Ied6809ad1ed6cc3c73ac5c818c7a06607810c396
diff --git a/app/common/services/api-utils.js b/app/common/services/api-utils.js
index 211f6d7..e523993 100644
--- a/app/common/services/api-utils.js
+++ b/app/common/services/api-utils.js
@@ -710,30 +710,15 @@
data: JSON.stringify({'data': state})
})
},
- bmcReboot: function(callback) {
- $http({
+ bmcReboot: function() {
+ return $http({
method: 'PUT',
url: DataService.getHost() +
'/xyz/openbmc_project/state/bmc0/attr/RequestedBMCTransition',
withCredentials: true,
data: JSON.stringify(
{'data': 'xyz.openbmc_project.State.BMC.Transition.Reboot'})
- })
- .then(
- function(response) {
- var json = JSON.stringify(response.data);
- var content = JSON.parse(json);
- if (callback) {
- return callback(content.status);
- }
- },
- function(error) {
- if (callback) {
- callback(error);
- } else {
- console.log(error);
- }
- });
+ });
},
getLastRebootTime: function() {
return $http({
diff --git a/app/configuration/controllers/firmware-controller.js b/app/configuration/controllers/firmware-controller.js
index da4dc1c..c8ce099 100644
--- a/app/configuration/controllers/firmware-controller.js
+++ b/app/configuration/controllers/firmware-controller.js
@@ -122,11 +122,13 @@
// TODO: remove this timeout after sufficient time has
// passed.
$timeout(function() {
- APIUtils.bmcReboot(
- function(response) {},
+ APIUtils.bmcReboot().then(
+ function(response) {
+ toastService.success('BMC is rebooting.')
+ },
function(error) {
console.log(JSON.stringify(error));
- toastService.error('Unable to reboot BMC');
+ toastService.error('Unable to reboot BMC.');
});
}, 10000);
}
diff --git a/app/server-control/controllers/bmc-reboot-controller.js b/app/server-control/controllers/bmc-reboot-controller.js
index ea50bf3..2282627 100644
--- a/app/server-control/controllers/bmc-reboot-controller.js
+++ b/app/server-control/controllers/bmc-reboot-controller.js
@@ -10,8 +10,8 @@
'use strict';
angular.module('app.serverControl').controller('bmcRebootController', [
- '$scope', '$window', 'APIUtils', 'dataService',
- function($scope, $window, APIUtils, dataService) {
+ '$scope', '$window', 'APIUtils', 'dataService', 'toastService',
+ function($scope, $window, APIUtils, dataService, toastService) {
$scope.dataService = dataService;
$scope.confirm = false;
APIUtils.getLastRebootTime().then(
@@ -28,12 +28,14 @@
$scope.confirm = true;
};
$scope.reboot = function() {
- dataService.setUnreachableState();
- APIUtils.bmcReboot(function(response) {
- //@NOTE: using common event to reload server status, may be a better
- // event listener name?
- $scope.$emit('user-logged-in', {});
- });
+ APIUtils.bmcReboot().then(
+ function(response) {
+ toastService.success('BMC is rebooting.')
+ },
+ function(error) {
+ console.log(JSON.stringify(error));
+ toastService.error('Unable to reboot BMC.');
+ });
};
}
]);