Enabling redfish support under configuration.
This commit contains:
1) Enabling redfish support under configuration.
While loading header, get the redfish root node
and sets the redfishSupport configuration param.
2) Depending on redfish support flag, it decide to
use redfish URI or REST uri for user password
change.
Tested:
- Tested both redfish enable and dsiable scenarios.
Change-Id: I98ecc7f419ddcfdbfac9c212ad2834479e9986b5
Signed-off-by: AppaRao Puli <apparao.puli@linux.intel.com>
diff --git a/app/common/services/api-utils.js b/app/common/services/api-utils.js
index 759d12c..31a2958 100644
--- a/app/common/services/api-utils.js
+++ b/app/common/services/api-utils.js
@@ -509,25 +509,35 @@
});
},
changePassword: function(user, newPassword) {
- var deferred = $q.defer();
- $http({
- method: 'POST',
- url: DataService.getHost() + '/xyz/openbmc_project/user/' + user +
- '/action/SetPassword',
- withCredentials: true,
- data: JSON.stringify({'data': [newPassword]}),
- responseType: 'arraybuffer'
- })
- .then(
- function(response, status, headers) {
- deferred.resolve(
- {data: response, status: status, headers: headers});
- },
- function(error) {
- console.log(error);
- deferred.reject(error);
- });
- return deferred.promise;
+ if (DataService.configJson.redfishSupportEnabled) {
+ return $http({
+ method: 'PATCH',
+ url: DataService.getHost() +
+ '/redfish/v1/AccountService/Accounts/' + user,
+ withCredentials: true,
+ data: JSON.stringify({'Password': newPassword})
+ });
+ } else {
+ var deferred = $q.defer();
+ $http({
+ method: 'POST',
+ url: DataService.getHost() + '/xyz/openbmc_project/user/' + user +
+ '/action/SetPassword',
+ withCredentials: true,
+ data: JSON.stringify({'data': [newPassword]}),
+ responseType: 'arraybuffer'
+ })
+ .then(
+ function(response, status, headers) {
+ deferred.resolve(
+ {data: response, status: status, headers: headers});
+ },
+ function(error) {
+ console.log(error);
+ deferred.reject(error);
+ });
+ return deferred.promise;
+ }
},
chassisPowerOff: function() {
var deferred = $q.defer();
diff --git a/app/common/services/dataService.js b/app/common/services/dataService.js
index 7ca13a6..76ab381 100644
--- a/app/common/services/dataService.js
+++ b/app/common/services/dataService.js
@@ -34,6 +34,9 @@
this.errorModalDetails = {};
this.ignoreHttpError = false;
+
+ this.configJson = require('../../../config.json');
+
this.getServerId = function() {
return this.host.replace(/^https?\:\/\//ig, '');
};
diff --git a/app/users/controllers/user-accounts-controller.html b/app/users/controllers/user-accounts-controller.html
index 1e8b0ac..9d388bc 100644
--- a/app/users/controllers/user-accounts-controller.html
+++ b/app/users/controllers/user-accounts-controller.html
@@ -6,7 +6,7 @@
</div>
</div>
<section class="row column" aria-label="change password form">
- <form class="user-manage__form" role="form" action="">
+ <form class="user-manage__form" role="form">
<fieldset>
<legend aria-label="user manager" class="accessible-text">Change password form</legend>
<div class="row column">
diff --git a/config.json b/config.json
index 0db3279..c57a626 100644
--- a/config.json
+++ b/config.json
@@ -1,3 +1,3 @@
{
-
+ "redfishSupportEnabled" : false
}