incubator-cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alena1...@apache.org
Subject git commit: CS-16222: send password reset command only to the element responsible for the userdata service in network Reviewed-by: Sheng Yang
Date Tue, 04 Sep 2012 20:40:20 GMT
Updated Branches:
  refs/heads/master 19a303732 -> 51cc301fe


CS-16222: send password reset command only to the element responsible for the userdata service
in network
Reviewed-by: Sheng Yang


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

Branch: refs/heads/master
Commit: 51cc301fefbf226bf997c8b326dbd927f378f12c
Parents: 19a3037
Author: Alena Prokharchyk <alena.prokharchyk@citrix.com>
Authored: Fri Aug 31 16:26:37 2012 -0700
Committer: Alena Prokharchyk <alena.prokharchyk@citrix.com>
Committed: Tue Sep 4 13:41:10 2012 -0700

----------------------------------------------------------------------
 server/src/com/cloud/network/NetworkManager.java   |    2 +-
 .../src/com/cloud/network/NetworkManagerImpl.java  |   16 +++++++-------
 server/src/com/cloud/vm/UserVmManagerImpl.java     |   15 +++++++------
 .../com/cloud/network/MockNetworkManagerImpl.java  |    2 +-
 .../test/com/cloud/vpc/MockNetworkManagerImpl.java |    2 +-
 5 files changed, 19 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/51cc301f/server/src/com/cloud/network/NetworkManager.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/NetworkManager.java b/server/src/com/cloud/network/NetworkManager.java
index 592ae85..4124b19 100755
--- a/server/src/com/cloud/network/NetworkManager.java
+++ b/server/src/com/cloud/network/NetworkManager.java
@@ -187,7 +187,7 @@ public interface NetworkManager extends NetworkService {
 
     Nic getDefaultNic(long vmId);
 
-    List<? extends UserDataServiceProvider> getPasswordResetElements();
+    UserDataServiceProvider getPasswordResetProvider(Network network);
 
     boolean networkIsConfiguredForExternalNetworking(long zoneId, long networkId);
 

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/51cc301f/server/src/com/cloud/network/NetworkManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/NetworkManagerImpl.java b/server/src/com/cloud/network/NetworkManagerImpl.java
index 817075e..292a259 100755
--- a/server/src/com/cloud/network/NetworkManagerImpl.java
+++ b/server/src/com/cloud/network/NetworkManagerImpl.java
@@ -4298,15 +4298,15 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService,
Manag
     }
 
     @Override
-    public List<? extends UserDataServiceProvider> getPasswordResetElements() {
-        List<UserDataServiceProvider> elements = new ArrayList<UserDataServiceProvider>();
-        for (NetworkElement element : _networkElements) {
-            if (element instanceof UserDataServiceProvider) {
-                UserDataServiceProvider e = (UserDataServiceProvider) element;
-                elements.add(e);
-            }
+    public UserDataServiceProvider getPasswordResetProvider(Network network) {
+        String passwordProvider = _ntwkSrvcDao.getProviderForServiceInNetwork(network.getId(),
Service.UserData);
+
+        if (passwordProvider == null) {
+            s_logger.debug("Network " + network + " doesn't support service " + Service.UserData.getName());
+            return null;
         }
-        return elements;
+        
+        return (UserDataServiceProvider)getElementImplementingProvider(passwordProvider);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/51cc301f/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 667b048..1836176 100755
--- a/server/src/com/cloud/vm/UserVmManagerImpl.java
+++ b/server/src/com/cloud/vm/UserVmManagerImpl.java
@@ -421,6 +421,8 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService,
Manager
                 userVm.setDetail("Encrypted.Password", encryptedPasswd);
                 _vmDao.saveDetails(userVm);
             }
+        } else {
+            throw new CloudRuntimeException("Failed to reset password for the virtual machine
");
         }
 
         return userVm;
@@ -448,15 +450,14 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService,
Manager
             VirtualMachineProfile<VMInstanceVO> vmProfile = new VirtualMachineProfileImpl<VMInstanceVO>(vmInstance);
             vmProfile.setParameter(VirtualMachineProfile.Param.VmPassword, password);
 
-            List<? extends UserDataServiceProvider> elements = _networkMgr.getPasswordResetElements();
-
-            boolean result = true;
-            for (UserDataServiceProvider element : elements) {
-                if (!element.savePassword(defaultNetwork, defaultNicProfile, vmProfile))
{
-                    result = false;
-                }
+            UserDataServiceProvider element = _networkMgr.getPasswordResetProvider(defaultNetwork);
+            if (element == null) {
+                throw new CloudRuntimeException("Can't find network element for " + Service.UserData.getName()
+ 
+                        " provider needed for password reset");
             }
 
+            boolean result = element.savePassword(defaultNetwork, defaultNicProfile, vmProfile);
+
             // Need to reboot the virtual machine so that the password gets redownloaded
from the DomR, and reset on the VM
             if (!result) {
                 s_logger.debug("Failed to reset password for the virutal machine; no need
to reboot the vm");

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/51cc301f/server/test/com/cloud/network/MockNetworkManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/network/MockNetworkManagerImpl.java b/server/test/com/cloud/network/MockNetworkManagerImpl.java
index 9c89785..c2ae1bf 100755
--- a/server/test/com/cloud/network/MockNetworkManagerImpl.java
+++ b/server/test/com/cloud/network/MockNetworkManagerImpl.java
@@ -610,7 +610,7 @@ public class MockNetworkManagerImpl implements NetworkManager, Manager,
NetworkS
     }
 
     @Override
-    public List<? extends UserDataServiceProvider> getPasswordResetElements() {
+    public UserDataServiceProvider getPasswordResetProvider(Network network) {
         // TODO Auto-generated method stub
         return null;
     }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/51cc301f/server/test/com/cloud/vpc/MockNetworkManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/vpc/MockNetworkManagerImpl.java b/server/test/com/cloud/vpc/MockNetworkManagerImpl.java
index eb0584e..dfd4f7e 100644
--- a/server/test/com/cloud/vpc/MockNetworkManagerImpl.java
+++ b/server/test/com/cloud/vpc/MockNetworkManagerImpl.java
@@ -805,7 +805,7 @@ public class MockNetworkManagerImpl implements NetworkManager, Manager{
      * @see com.cloud.network.NetworkManager#getPasswordResetElements()
      */
     @Override
-    public List<? extends UserDataServiceProvider> getPasswordResetElements() {
+    public UserDataServiceProvider getPasswordResetProvider(Network network) {
         // TODO Auto-generated method stub
         return null;
     }


Mime
View raw message