cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From du...@apache.org
Subject [1/3] git commit: updated refs/heads/master to b6a1d11
Date Sun, 20 Jul 2014 17:36:50 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/master 08d7b46be -> b6a1d11c9


    Allow for length of password on VMs to be set via global settings

    Conflicts:
        server/src/com/cloud/vm/UserVmManagerImpl.java
        setup/db/db/schema-430to440.sql


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

Branch: refs/heads/master
Commit: d4428a93a8df233d5564ae4870649de1d9912f28
Parents: 08d7b46
Author: Ian Duffy <ian@ianduffy.ie>
Authored: Sun Jul 20 18:14:55 2014 +0100
Committer: Ian Duffy <ian@ianduffy.ie>
Committed: Sun Jul 20 18:14:55 2014 +0100

----------------------------------------------------------------------
 server/src/com/cloud/server/ManagementServerImpl.java |  3 ++-
 server/src/com/cloud/vm/UserVmManagerImpl.java        | 14 +++++++-------
 setup/db/db/schema-430to440.sql                       |  2 ++
 3 files changed, 11 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d4428a93/server/src/com/cloud/server/ManagementServerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java
index d822b59..99b12732 100755
--- a/server/src/com/cloud/server/ManagementServerImpl.java
+++ b/server/src/com/cloud/server/ManagementServerImpl.java
@@ -895,7 +895,8 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
 
     @Override
     public String generateRandomPassword() {
-        return PasswordGenerator.generateRandomPassword(6);
+        Integer passwordLength = Integer.parseInt(_configDao.getValue("vm.password.length"));
+        return PasswordGenerator.generateRandomPassword(passwordLength);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d4428a93/server/src/com/cloud/vm/UserVmManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java
index 2de6f86..174f85b 100755
--- a/server/src/com/cloud/vm/UserVmManagerImpl.java
+++ b/server/src/com/cloud/vm/UserVmManagerImpl.java
@@ -35,6 +35,7 @@ import javax.ejb.Local;
 import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 
+import com.cloud.server.ManagementService;
 import org.apache.commons.codec.binary.Base64;
 import org.apache.log4j.Logger;
 
@@ -482,6 +483,9 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager,
Vir
     @Inject
     VolumeOrchestrationService volumeMgr;
 
+    @Inject
+    ManagementService _mgr;
+
     @Override
     public UserVmVO getVirtualMachine(long vmId) {
         return _vmDao.findById(vmId);
@@ -643,7 +647,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager,
Vir
         String password = null;
         String sshPublicKey = s.getPublicKey();
         if (template != null && template.getEnablePassword()) {
-            password = generateRandomPassword();
+            password = _mgr.generateRandomPassword();
         }
 
         boolean result = resetVMSSHKeyInternal(vmId, sshPublicKey, password);
@@ -3362,10 +3366,6 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager,
Vir
         }
     }
 
-    public String generateRandomPassword() {
-        return PasswordGenerator.generateRandomPassword(6);
-    }
-
     @Override
     public Pair<UserVmVO, Map<VirtualMachineProfile.Param, Object>> startVirtualMachine(long
vmId, Long hostId, Map<VirtualMachineProfile.Param, Object> additionalParams, String
deploymentPlannerToUse)
             throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException
{
@@ -3443,7 +3443,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager,
Vir
                 if (vm.getDetail("password") != null) {
                     password = DBEncryptionUtil.decrypt(vm.getDetail("password"));
                  } else {
-                    password = generateRandomPassword();
+                    password = _mgr.generateRandomPassword();
                  }
             }
 
@@ -4733,7 +4733,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager,
Vir
         String password = null;
 
         if (template.getEnablePassword()) {
-            password = generateRandomPassword();
+            password = _mgr.generateRandomPassword();
             boolean result = resetVMPasswordInternal(vmId, password);
             if (result) {
                 vm.setPassword(password);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d4428a93/setup/db/db/schema-430to440.sql
----------------------------------------------------------------------
diff --git a/setup/db/db/schema-430to440.sql b/setup/db/db/schema-430to440.sql
index cff38d0..fdf7300 100644
--- a/setup/db/db/schema-430to440.sql
+++ b/setup/db/db/schema-430to440.sql
@@ -2494,3 +2494,5 @@ CREATE TABLE `cloud`.`snapshot_policy_details` (
   PRIMARY KEY (`id`),
   CONSTRAINT `fk_snapshot_policy_details__snapshot_policy_id` FOREIGN KEY `fk_snapshot_policy_details__snapshot_policy_id`(`policy_id`)
REFERENCES `snapshot_policy`(`id`) ON DELETE CASCADE
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+INSERT INTO `cloud`.`configuration`(category, instance, component, name, value, description,
default_value) VALUES ('Secure', 'DEFAULT', 'management-server', 'vm.password.length', '6',
'Specifies the length of a randomly generated password', '6') ON DUPLICATE KEY UPDATE category='Secure';


Mime
View raw message