cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bhais...@apache.org
Subject [1/2] git commit: updated refs/heads/4.9 to 1060dc4
Date Mon, 22 Aug 2016 10:22:32 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/4.9 b7f1ba944 -> 1060dc47e


oobm: simply change password transactional logic

- Simplifies change password transactional logic without using pessmistic locks
- Adds a re-enter password field in the UI to valid ipmi/oobm password

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/8ac3c883
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/8ac3c883
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/8ac3c883

Branch: refs/heads/4.9
Commit: 8ac3c883cd61fa0e18498aaae4e4f519743295c4
Parents: 227ff38
Author: Rohit Yadav <rohit.yadav@shapeblue.com>
Authored: Mon Jul 11 17:06:09 2016 +0530
Committer: Rohit Yadav <rohit.yadav@shapeblue.com>
Committed: Tue Aug 2 12:47:15 2016 +0530

----------------------------------------------------------------------
 .../classes/resources/messages.properties       |  1 +
 .../OutOfBandManagementServiceImpl.java         | 83 ++++++++------------
 ui/dictionary.jsp                               |  1 +
 ui/scripts/system.js                            | 11 +++
 4 files changed, 47 insertions(+), 49 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8ac3c883/client/WEB-INF/classes/resources/messages.properties
----------------------------------------------------------------------
diff --git a/client/WEB-INF/classes/resources/messages.properties b/client/WEB-INF/classes/resources/messages.properties
index 8b8ad1a..289e04f 100644
--- a/client/WEB-INF/classes/resources/messages.properties
+++ b/client/WEB-INF/classes/resources/messages.properties
@@ -1016,6 +1016,7 @@ label.outofbandmanagement.driver=Driver
 label.outofbandmanagement.disable=Disable Out-of-band Management
 label.outofbandmanagement.enable=Enable Out-of-band Management
 label.outofbandmanagement.password=Password
+label.outofbandmanagement.reenterpassword=Re-enter Password
 label.outofbandmanagement.port=Port
 label.outofbandmanagement.username=Username
 message.outofbandmanagement.changepassword=Change Out-of-band Management password

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8ac3c883/server/src/org/apache/cloudstack/outofbandmanagement/OutOfBandManagementServiceImpl.java
----------------------------------------------------------------------
diff --git a/server/src/org/apache/cloudstack/outofbandmanagement/OutOfBandManagementServiceImpl.java
b/server/src/org/apache/cloudstack/outofbandmanagement/OutOfBandManagementServiceImpl.java
index bb099c8..ca65ef7 100644
--- a/server/src/org/apache/cloudstack/outofbandmanagement/OutOfBandManagementServiceImpl.java
+++ b/server/src/org/apache/cloudstack/outofbandmanagement/OutOfBandManagementServiceImpl.java
@@ -31,7 +31,6 @@ import com.cloud.host.dao.HostDao;
 import com.cloud.org.Cluster;
 import com.cloud.utils.component.Manager;
 import com.cloud.utils.component.ManagerBase;
-import com.cloud.utils.db.GlobalLock;
 import com.cloud.utils.db.Transaction;
 import com.cloud.utils.db.TransactionCallback;
 import com.cloud.utils.db.TransactionStatus;
@@ -87,7 +86,6 @@ public class OutOfBandManagementServiceImpl extends ManagerBase implements
OutOf
     private final Map<String, OutOfBandManagementDriver> outOfBandManagementDriversMap
= new HashMap<String, OutOfBandManagementDriver>();
 
     private static final String OOBM_ENABLED_DETAIL = "outOfBandManagementEnabled";
-    private static final int ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_HOST = 120;
 
     private static Cache<Long, Long> hostAlertCache;
     private static ExecutorService backgroundSyncBlockingExecutor;
@@ -435,59 +433,46 @@ public class OutOfBandManagementServiceImpl extends ManagerBase implements
OutOf
         if (Strings.isNullOrEmpty(newPassword)) {
             throw new CloudRuntimeException(String.format("Cannot change out-of-band management
password as provided new-password is null or empty for the host %s.", host.getUuid()));
         }
-        GlobalLock outOfBandManagementHostLock = GlobalLock.getInternLock(getOutOfBandManagementHostLock(host.getId()));
-        try {
-            if (outOfBandManagementHostLock.lock(ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_HOST)) {
-                try {
-                    final OutOfBandManagement outOfBandManagementConfig = outOfBandManagementDao.findByHost(host.getId());
 
-                    final ImmutableMap<OutOfBandManagement.Option, String> options
= getOptions(outOfBandManagementConfig);
-                    if (!(options.containsKey(OutOfBandManagement.Option.PASSWORD) &&
!Strings.isNullOrEmpty(options.get(OutOfBandManagement.Option.PASSWORD)))) {
-                        throw new CloudRuntimeException(String.format("Cannot change out-of-band
management password as we've no previously configured password for the host %s.", host.getUuid()));
-                    }
-                    final OutOfBandManagementDriver driver = getDriver(outOfBandManagementConfig);
-
-                    final OutOfBandManagementDriverChangePasswordCommand cmd = new OutOfBandManagementDriverChangePasswordCommand(options,
ActionTimeout.valueIn(host.getClusterId()), newPassword);
-                    final OutOfBandManagementDriverResponse driverResponse;
-                    try {
-                        driverResponse = driver.execute(cmd);
-                    } catch (Exception e) {
-                        LOG.error("Out-of-band management change password failed due to driver
error: " + e.getMessage());
-                        throw new CloudRuntimeException(String.format("Failed to change out-of-band
management password for host (%s) due to driver error: %s", host.getUuid(), e.getMessage()));
-                    }
+        final OutOfBandManagement outOfBandManagementConfig = outOfBandManagementDao.findByHost(host.getId());
+        final ImmutableMap<OutOfBandManagement.Option, String> options = getOptions(outOfBandManagementConfig);
+        if (!(options.containsKey(OutOfBandManagement.Option.PASSWORD) && !Strings.isNullOrEmpty(options.get(OutOfBandManagement.Option.PASSWORD))))
{
+            throw new CloudRuntimeException(String.format("Cannot change out-of-band management
password as we've no previously configured password for the host %s.", host.getUuid()));
+        }
+        final OutOfBandManagementDriver driver = getDriver(outOfBandManagementConfig);
+        final OutOfBandManagementDriverChangePasswordCommand changePasswordCmd = new OutOfBandManagementDriverChangePasswordCommand(options,
ActionTimeout.valueIn(host.getClusterId()), newPassword);
 
-                    if (!driverResponse.isSuccess()) {
-                        throw new CloudRuntimeException(String.format("Failed to change out-of-band
management password for host (%s) with error: %s", host.getUuid(), driverResponse.getError()));
-                    }
+        final boolean changePasswordResult = Transaction.execute(new TransactionCallback<Boolean>()
{
+            @Override
+            public Boolean doInTransaction(TransactionStatus status) {
+                final OutOfBandManagement updatedOutOfBandManagementConfig = outOfBandManagementDao.findByHost(host.getId());
+                updatedOutOfBandManagementConfig.setPassword(newPassword);
+                boolean result = outOfBandManagementDao.update(updatedOutOfBandManagementConfig.getId(),
(OutOfBandManagementVO) updatedOutOfBandManagementConfig);
 
-                    final boolean updatedConfigResult = Transaction.execute(new TransactionCallback<Boolean>()
{
-                        @Override
-                        public Boolean doInTransaction(TransactionStatus status) {
-                            OutOfBandManagement updatedOutOfBandManagementConfig = outOfBandManagementDao.findByHost(host.getId());
-                            updatedOutOfBandManagementConfig.setPassword(newPassword);
-                            return outOfBandManagementDao.update(updatedOutOfBandManagementConfig.getId(),
(OutOfBandManagementVO) updatedOutOfBandManagementConfig);
-                        }
-                    });
-
-                    if (!updatedConfigResult) {
-                        LOG.error(String.format("Succeeded to change out-of-band management
password but failed to updated in database the new password:%s for the host id:%d", newPassword,
host.getId()));
-                    }
+                if (!result) {
+                    throw new CloudRuntimeException(String.format("Failed to change out-of-band
management password for host (%s) in the database.", host.getUuid()));
+                }
 
-                    final OutOfBandManagementResponse response = new OutOfBandManagementResponse();
-                    response.setSuccess(updatedConfigResult && driverResponse.isSuccess());
-                    response.setResultDescription(driverResponse.getResult());
-                    response.setId(host.getUuid());
-                    return response;
-                } finally {
-                    outOfBandManagementHostLock.unlock();
+                final OutOfBandManagementDriverResponse driverResponse;
+                try {
+                    driverResponse = driver.execute(changePasswordCmd);
+                } catch (Exception e) {
+                    LOG.error("Out-of-band management change password failed due to driver
error: " + e.getMessage());
+                    throw new CloudRuntimeException(String.format("Failed to change out-of-band
management password for host (%s) due to driver error: %s", host.getUuid(), e.getMessage()));
                 }
-            } else {
-                LOG.error("Unable to acquire synchronization lock to change out-of-band management
password for host id: " + host.getId());
-                throw new CloudRuntimeException(String.format("Unable to acquire lock to
change out-of-band management password for host (%s), please try after some time.", host.getUuid()));
+
+                if (!driverResponse.isSuccess()) {
+                    throw new CloudRuntimeException(String.format("Failed to change out-of-band
management password for host (%s) with error: %s", host.getUuid(), driverResponse.getError()));
+                }
+
+                return result && driverResponse.isSuccess();
             }
-        } finally {
-            outOfBandManagementHostLock.releaseRef();
-        }
+        });
+
+        final OutOfBandManagementResponse response = new OutOfBandManagementResponse();
+        response.setSuccess(changePasswordResult );
+        response.setId(host.getUuid());
+        return response;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8ac3c883/ui/dictionary.jsp
----------------------------------------------------------------------
diff --git a/ui/dictionary.jsp b/ui/dictionary.jsp
index b064299..c15dae2 100644
--- a/ui/dictionary.jsp
+++ b/ui/dictionary.jsp
@@ -999,6 +999,7 @@ dictionary = {
 'label.outofbandmanagement.disable': '<fmt:message key="label.outofbandmanagement.disable"
/>',
 'label.outofbandmanagement.enable': '<fmt:message key="label.outofbandmanagement.enable"
/>',
 'label.outofbandmanagement.password': '<fmt:message key="label.outofbandmanagement.password"
/>',
+'label.outofbandmanagement.reenterpassword': '<fmt:message key="label.outofbandmanagement.reenterpassword"
/>',
 'label.outofbandmanagement.port': '<fmt:message key="label.outofbandmanagement.port" />',
 'label.outofbandmanagement.timeout': '<fmt:message key="label.outofbandmanagement.timeout"
/>',
 'label.outofbandmanagement.username': '<fmt:message key="label.outofbandmanagement.username"
/>',

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8ac3c883/ui/scripts/system.js
----------------------------------------------------------------------
diff --git a/ui/scripts/system.js b/ui/scripts/system.js
index 2eef6b1..7ffacd0 100644
--- a/ui/scripts/system.js
+++ b/ui/scripts/system.js
@@ -16814,10 +16814,21 @@
                                                 required: false
                                             },
                                         },
+                                        reenterpassword: {
+                                            label: 'label.outofbandmanagement.reenterpassword',
+                                            isPassword: true,
+                                            validation: {
+                                                required: false
+                                            }
+                                        },
                                     }
                                 },
                                 action: function (args) {
                                     var data = args.data;
+                                    if (data.password != data.reenterpassword) {
+                                        args.response.error("Passwords do not match");
+                                        return;
+                                    }
                                     data.hostid = args.context.hosts[0].id;
                                     $.ajax({
                                         url: createURL('changeOutOfBandManagementPassword'),


Mime
View raw message