summaryrefslogtreecommitdiff
path: root/meta-openbmc-mods/meta-common/recipes-phosphor/webui/phosphor-webui/0004-Implement-force-boot-to-bios-in-server-power-control.patch
blob: 3885318de1c2857607c51c8212679873670ec4b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
From 5a6e97bdca6db517eabb94a926623e2f662b1315 Mon Sep 17 00:00:00 2001
From: Kuiying Wang <kuiying.wang@intel.com>
Date: Thu, 1 Aug 2019 17:37:17 +0800
Subject: [PATCH] force to bios fix bump fail

Signed-off-by: Kuiying Wang <kuiying.wang@intel.com>
---
 app/common/services/api-utils.js                   | 30 ++++++++++++++++++
 app/common/services/constants.js                   |  4 +++
 app/common/services/dataService.js                 |  1 +
 .../controllers/power-operations-controller.html   | 11 +++++++
 .../controllers/power-operations-controller.js     | 36 ++++++++++++++++++++--
 5 files changed, 80 insertions(+), 2 deletions(-)

diff --git a/app/common/services/api-utils.js b/app/common/services/api-utils.js
index d485016..3d64406 100644
--- a/app/common/services/api-utils.js
+++ b/app/common/services/api-utils.js
@@ -29,12 +29,42 @@ window.angular && (function(angular) {
         HOST_STATE_TEXT: Constants.HOST_STATE,
         LED_STATE: Constants.LED_STATE,
         LED_STATE_TEXT: Constants.LED_STATE_TEXT,
+        FORCE_TO_BIOS_STATE_TEXT: Constants.FORCE_TO_BIOS_STATE_TEXT,
         HOST_SESSION_STORAGE_KEY: Constants.API_CREDENTIALS.host_storage_key,
         validIPV4IP: function(ip) {
           // Checks for [0-255].[0-255].[0-255].[0-255]
           return ip.match(
               /\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b/);
         },
+        setForceToBIOSState: function(state) {
+          console.log(state);
+          var data = JSON.stringify({'Boot':
+                                          {
+                                            'BootSourceOverrideTarget': state
+                                          }
+                                    });
+          return $http({
+            method: 'PATCH',
+            url: DataService.getHost() + '/redfish/v1/Systems/system',
+            withCredentials: true,
+            data: data
+          });
+        },
+        getForceToBIOSState: function() {
+
+          return $http({
+            method: 'GET',
+            url: DataService.getHost() + '/redfish/v1/Systems/system',
+            withCredentials: true
+          }).then(
+                  function(response) {
+                    console.log(JSON.stringify(response.data.Boot.BootSourceOverrideTarget));
+                    return response.data.Boot.BootSourceOverrideTarget;
+                  },
+                  function(error) {
+                    console.log(error);
+                  });
+        },
         getRedfishSysName: function() {
           return $http({
                    method: 'GET',
diff --git a/app/common/services/constants.js b/app/common/services/constants.js
index ae82e76..e594570 100644
--- a/app/common/services/constants.js
+++ b/app/common/services/constants.js
@@ -42,6 +42,10 @@ window.angular && (function(angular) {
       },
       LED_STATE: {on: true, off: false},
       LED_STATE_TEXT: {on: 'on', off: 'off'},
+      FORCE_TO_BIOS_STATE_TEXT: {
+        on: 'BiosSetup',
+        off: 'None'
+      },
       SEVERITY_TO_PRIORITY_MAP: {
         Emergency: 'High',
         Alert: 'High',
diff --git a/app/common/services/dataService.js b/app/common/services/dataService.js
index 87fddba..cc9c0b3 100644
--- a/app/common/services/dataService.js
+++ b/app/common/services/dataService.js
@@ -16,6 +16,7 @@ window.angular && (function(angular) {
       this.server_health = Constants.SERVER_HEALTH.unknown;
       this.server_state = 'Unreachable';
       this.LED_state = Constants.LED_STATE_TEXT.off;
+      this.ForceToBIOS_state = Constants.FORCE_TO_BIOS_STATE_TEXT.off;
       this.last_updated = new Date();
 
       this.loading = false;
diff --git a/app/server-control/controllers/power-operations-controller.html b/app/server-control/controllers/power-operations-controller.html
index ddf8bda..ea46e00 100644
--- a/app/server-control/controllers/power-operations-controller.html
+++ b/app/server-control/controllers/power-operations-controller.html
@@ -10,6 +10,17 @@
     <div class="row column">
         <div id="power-indicator-bar" class="power__indicator-bar" ng-class="{'power__state-on': dataService.server_state == 'Running', 'power__state-off': dataService.server_state == 'Off', 'power__state-indet': dataService.server_state == 'Standby', 'power__state-error': dataService.server_state == 'Quiesced'}">
             <p class="inline">{{dataService.hostname}} - {{dataService.server_id}}</p>
+              <div class="toggle float-right">
+                <input id="toggle__switch-round"
+                    class="toggle-switch toggle-switch__round-flat"
+                    type="checkbox"
+                    tabindex="0"
+                    ng-click="toggleForceToBIOS()"
+                    ng-checked="dataService.ForceToBIOS_state == 'BiosSetup'"
+                    ng-disabled="dataService.server_unreachable">
+                <label for="toggle__switch-round" tabindex="0"> </label>
+                <h3 class="inline">Boot to BIOS</h3>
+              </div>
             <h3 class="power__state inline no-margin h3"><span>{{dataService.server_state | quiescedToError}}</span></h3>
         </div>
     </div>
diff --git a/app/server-control/controllers/power-operations-controller.js b/app/server-control/controllers/power-operations-controller.js
index 986ac3b..2c29093 100644
--- a/app/server-control/controllers/power-operations-controller.js
+++ b/app/server-control/controllers/power-operations-controller.js
@@ -10,10 +10,10 @@ window.angular && (function(angular) {
   'use strict';
 
   angular.module('app.serverControl').controller('powerOperationsController', [
-    '$scope', 'APIUtils', 'dataService', 'Constants', '$interval', '$q',
+    '$route', '$scope', 'APIUtils', 'dataService', 'Constants', '$interval', '$q',
     'toastService',
     function(
-        $scope, APIUtils, dataService, Constants, $interval, $q, toastService) {
+        $route, $scope, APIUtils, dataService, Constants, $interval, $q, toastService) {
       $scope.dataService = dataService;
       // Is a || of the other 4 "confirm" variables to ensure only
       // one confirm is shown at a time.
@@ -57,6 +57,17 @@ window.angular && (function(angular) {
             }, Constants.POLL_INTERVALS.POWER_OP);
             return deferred.promise;
           };
+      APIUtils.getForceToBIOSState().then(
+          function(data) {
+            if (data == APIUtils.FORCE_TO_BIOS_STATE_TEXT.on) {
+              dataService.ForceToBIOS_state = APIUtils.FORCE_TO_BIOS_STATE_TEXT.on;
+            } else {
+              dataService.ForceToBIOS_state = APIUtils.FORCE_TO_BIOS_STATE_TEXT.off;
+            }
+          },
+          function(error) {
+            console.log(JSON.stringify(error));
+          });
 
       APIUtils.getLastPowerTime()
           .then(
@@ -74,6 +85,27 @@ window.angular && (function(angular) {
             $scope.loading = false;
           });
 
+      $scope.toggleForceToBIOS = function() {
+        var toggleState =
+            (dataService.ForceToBIOS_state == APIUtils.FORCE_TO_BIOS_STATE_TEXT.on) ?
+            APIUtils.FORCE_TO_BIOS_STATE_TEXT.off :
+            APIUtils.FORCE_TO_BIOS_STATE_TEXT.on;
+        dataService.ForceToBIOS_state =
+            (dataService.ForceToBIOS_state == APIUtils.FORCE_TO_BIOS_STATE_TEXT.on) ?
+            APIUtils.FORCE_TO_BIOS_STATE_TEXT.off :
+            APIUtils.FORCE_TO_BIOS_STATE_TEXT.on;
+        APIUtils.setForceToBIOSState(toggleState)
+            .then(
+                function(response) {},
+                function(errors) {
+                  toastService.error(
+                      'Failed to set Boot to BIOS ');
+                  console.log(JSON.stringify(errors));
+                  // Reload to get correct current state
+                  $route.reload();
+                })
+      };
+
       $scope.toggleState = function() {
         dataService.server_state =
             (dataService.server_state == 'Running') ? 'Off' : 'Running';
-- 
2.7.4