diff options
| author | beccabroek <rebecca.shaw@ibm.com> | 2018-08-14 13:47:18 -0500 |
|---|---|---|
| committer | Gunnar Mills <gmills@us.ibm.com> | 2018-09-19 21:42:12 +0000 |
| commit | c3abaa9b8bf1aa7af9dd04d7bbf62356af545704 (patch) | |
| tree | ab6d32c342ea217a78d6f5f6ea3af18ca01a1d93 /app/server-control/controllers | |
| parent | 90121f3fa15d73e8cd98eee7aaf853241cec0d2e (diff) | |
| download | phosphor-webui-c3abaa9b8bf1aa7af9dd04d7bbf62356af545704.tar.gz phosphor-webui-c3abaa9b8bf1aa7af9dd04d7bbf62356af545704.zip | |
Activate image and reboot host
When activating a host image, gives the option to:
a) Activate image without booting
b) Activate image and boot host. If server is
in 'off' status the option is to power on.
If the server is in 'unavailable', 'on', or
'error' status the option is to reboot
Also updated polling during boot and reboot to use
/subscribe API.
Resolves openbmc/openbmc#3323
Tested: The GUI displays the options and boots /
reboots appropriately based on server status.
Change-Id: I62c19e094ecc7112263c26844fcd30b2bf3c2b84
Signed-off-by: beccabroek <rebecca.shaw@ibm.com>
Diffstat (limited to 'app/server-control/controllers')
| -rw-r--r-- | app/server-control/controllers/power-operations-controller.js | 79 |
1 files changed, 4 insertions, 75 deletions
diff --git a/app/server-control/controllers/power-operations-controller.js b/app/server-control/controllers/power-operations-controller.js index e36b61d..6c6f68c 100644 --- a/app/server-control/controllers/power-operations-controller.js +++ b/app/server-control/controllers/power-operations-controller.js @@ -25,7 +25,6 @@ window.angular && (function(angular) { $scope.loading = true; var pollChassisStatusTimer = undefined; - var pollHostStatusTimer = undefined; var pollStartTime = null; //@TODO: call api and get proper state @@ -59,8 +58,7 @@ window.angular && (function(angular) { return response; }) .then(function(lastStatus) { - pollStartTime = new Date(); - return pollHostStatusTillOn(); + return APIUtils.pollHostStatusTillOn(); }) .then(function(hostState) { $scope.loading = false; @@ -113,68 +111,6 @@ window.angular && (function(angular) { return deferred.promise; } - - function pollHostStatusTillOn() { - var deferred = $q.defer(); - pollHostStatusTimer = $interval(function() { - var now = new Date(); - if ((now.getTime() - pollStartTime.getTime()) >= - Constants.TIMEOUT.HOST_ON) { - $interval.cancel(pollHostStatusTimer); - pollHostStatusTimer = undefined; - deferred.reject(new Error(Constants.MESSAGES.POLL.HOST_ON_TIMEOUT)); - } - APIUtils.getHostState() - .then(function(state) { - if (state === Constants.HOST_STATE_TEXT.on_code) { - $interval.cancel(pollHostStatusTimer); - pollHostStatusTimer = undefined; - deferred.resolve(state); - } else if (state === Constants.HOST_STATE_TEXT.error_code) { - $interval.cancel(pollHostStatusTimer); - pollHostStatusTimer = undefined; - deferred.reject( - new Error(Constants.MESSAGES.POLL.HOST_QUIESCED)); - } - }) - .catch(function(error) { - $interval.cancel(pollHostStatusTimer); - pollHostStatusTimer = undefined; - deferred.reject(error); - }); - }, Constants.POLL_INTERVALS.POWER_OP); - - return deferred.promise; - } - - function pollHostStatusTillOff() { - var deferred = $q.defer(); - pollHostStatusTimer = $interval(function() { - var now = new Date(); - if ((now.getTime() - pollStartTime.getTime()) >= - Constants.TIMEOUT.HOST_OFF) { - $interval.cancel(pollHostStatusTimer); - pollHostStatusTimer = undefined; - deferred.reject( - new Error(Constants.MESSAGES.POLL.HOST_OFF_TIMEOUT)); - } - APIUtils.getHostState() - .then(function(state) { - if (state === Constants.HOST_STATE_TEXT.off_code) { - $interval.cancel(pollHostStatusTimer); - pollHostStatusTimer = undefined; - deferred.resolve(state); - } - }) - .catch(function(error) { - $interval.cancel(pollHostStatusTimer); - pollHostStatusTimer = undefined; - deferred.reject(error); - }); - }, Constants.POLL_INTERVALS.POWER_OP); - - return deferred.promise; - } $scope.warmReboot = function() { $scope.loading = true; dataService.setUnreachableState(); @@ -183,12 +119,7 @@ window.angular && (function(angular) { return response; }) .then(function(lastStatus) { - pollStartTime = new Date(); - return pollHostStatusTillOff(); - }) - .then(function(hostState) { - pollStartTime = new Date(); - return pollHostStatusTillOn(); + return APIUtils.pollHostStatusTilReboot(); }) .then(function(hostState) { $scope.loading = false; @@ -238,8 +169,7 @@ window.angular && (function(angular) { }); }) .then(function(hostState) { - pollStartTime = new Date(); - return pollHostStatusTillOn(); + return APIUtils.pollHostStatusTillOn(); }) .then(function(state) { $scope.loading = false; @@ -272,8 +202,7 @@ window.angular && (function(angular) { return response; }) .then(function(lastStatus) { - pollStartTime = new Date(); - return pollHostStatusTillOff(); + return APIUtils.pollHostStatusTillOff(); }) .then(function(hostState) { pollStartTime = new Date(); |

