Added BMC reboot functionality
Change-Id: I1fe5a9f2f1079760396044eff2bf8f3eaef25bff
Signed-off-by: Iftekharul Islam <iislam@us.ibm.com>
diff --git a/app/common/services/api-utils.js b/app/common/services/api-utils.js
index af66f81..65ae86b 100644
--- a/app/common/services/api-utils.js
+++ b/app/common/services/api-utils.js
@@ -143,13 +143,31 @@
}
});
},
+ bmcReboot: function(callback){
+ $http({
+ method: 'PUT',
+ url: SERVICE.API_CREDENTIALS.host + "/xyz/openbmc_project/state/bmc0/attr/RequestedBmcTransition",
+ headers: {
+ 'Accept': 'application/json',
+ 'Content-Type': 'application/json'
+ },
+ withCredentials: true,
+ data: JSON.stringify({"data": "xyz.openbmc_project.State.BMC.Transition.Reboot"})
+ }).success(function(response){
+ var json = JSON.stringify(response);
+ var content = JSON.parse(json);
+ if(callback){
+ return callback(content.status);
+ }
+ }).error(function(error){
+ if(callback){
+ callback(error);
+ }else{
+ console.log(error);
+ }
+ });
+ },
hostPowerOn: function(callback){
- /**
- curl -c cjar -b cjar -k -H "Content-Type: application/json" -d
- "{\"data\": \"xyz.openbmc_project.State.Host.Transition.Off\"}"
- -X PUT
- https://9.3.164.147/xyz/openbmc_project/state/host0/attr/RequestedHostTransition
- **/
$http({
method: 'PUT',
url: SERVICE.API_CREDENTIALS.host + "/xyz/openbmc_project/state/host0/attr/RequestedHostTransition",
diff --git a/app/overview/controllers/bmc-reboot-controller.html b/app/overview/controllers/bmc-reboot-controller.html
index 22df0c2..b847624 100644
--- a/app/overview/controllers/bmc-reboot-controller.html
+++ b/app/overview/controllers/bmc-reboot-controller.html
@@ -8,7 +8,7 @@
</div>
<div class="row column btm-border-grey bmc-reboot-option"
- ng-class="{transitionAll: confirm && immediately_confirm}">
+ ng-class="{disabled: confirm || dataService.loading, transitionAll: confirm}">
<ul>
<li>Rebooting the BMC causes your browser to lose contact with the BMC for several minutes.</li>
<li>When the BMC software has started, you can then log in again.</li>
@@ -16,10 +16,12 @@
BMC’s address and log in again.
</li>
</ul>
- <button id="bmc__reboot" class="btn-secondary" ng-click="bmcRebootConfirm()"><i>↻</i> Reboot BMC
+ <button id="bmc__reboot" class="btn-secondary" ng-click="rebootConfirm()"><i>↻</i> Reboot BMC
</button>
<confirm title="Reboot the BMC"
message="Rebooting the BMC causes your browser to lose contact with the BMC for several minutes."
- confirm="bmcReboot_confirm" cancel="bmcRebootCancel"></confirm>
+ confirm="confirm"
+ ng-show="confirm"
+ callback="reboot"></confirm>
</div>
</div>
diff --git a/app/overview/controllers/bmc-reboot-controller.js b/app/overview/controllers/bmc-reboot-controller.js
index 040b444..5ed1b58 100644
--- a/app/overview/controllers/bmc-reboot-controller.js
+++ b/app/overview/controllers/bmc-reboot-controller.js
@@ -17,8 +17,25 @@
'$window',
'APIUtils',
'dataService',
- function($scope, $window, APIUtils, dataService, userModel){
+ function($scope, $window, APIUtils, dataService){
$scope.dataService = dataService;
+ $scope.confirm = false;
+ $scope.rebootConfirm = function(){
+ if($scope.confirm) {
+ return;
+ }
+ $scope.confirm = true;
+ };
+ $scope.reboot = function(){
+ dataService.setBootingState();
+ APIUtils.bmcReboot(function(response){
+ if(response){
+ dataService.setPowerOnState();
+ }else{
+ dataService.setUnreachableState();
+ }
+ });
+ };
}
]
);