incubator-cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ahu...@apache.org
Subject [2/50] [abbrv] git commit: CS-16269: Fix savePassword on one stopped RvR
Date Wed, 05 Sep 2012 21:31:49 GMT
CS-16269: Fix savePassword on one stopped RvR


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

Branch: refs/heads/javelin
Commit: 86427559cb389eebdc28c0a5d7fd14799bd35803
Parents: caebc0c
Author: Sheng Yang <sheng.yang@citrix.com>
Authored: Wed Sep 5 12:05:58 2012 -0700
Committer: Sheng Yang <sheng.yang@citrix.com>
Committed: Wed Sep 5 13:46:44 2012 -0700

----------------------------------------------------------------------
 .../router/VirtualNetworkApplianceManagerImpl.java |   40 ++++----------
 1 files changed, 12 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/86427559/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
index f98cbc4..bc92916 100755
--- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
+++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
@@ -444,37 +444,21 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
     }
 
     @Override
-    public boolean savePasswordToRouter(Network network, NicProfile nic, VirtualMachineProfile<UserVm>
profile, List<? extends VirtualRouter> routers) throws ResourceUnavailableException
{
-        if (routers == null || routers.isEmpty()) {
-            s_logger.warn("Unable save password, router doesn't exist in network " + network.getId());
-            throw new CloudRuntimeException("Unable to save password to router");
-        }
-
-        UserVm userVm = profile.getVirtualMachine();
-        String password = (String) profile.getParameter(Param.VmPassword);
-        String encodedPassword = PasswordGenerator.rot13(password);
-        DataCenter dc = _dcDao.findById(userVm.getDataCenterIdToDeployIn());
-
-        boolean result = true;
-        for (VirtualRouter router : routers) {
-            boolean sendPassword = true;
-            if (dc.getNetworkType() == NetworkType.Basic && userVm.getPodIdToDeployIn().longValue()
!= router.getPodIdToDeployIn().longValue()) {
-                sendPassword = false;
-            }
+    public boolean savePasswordToRouter(Network network, final NicProfile nic, VirtualMachineProfile<UserVm>
profile, List<? extends VirtualRouter> routers) throws ResourceUnavailableException
{
+        _userVmDao.loadDetails((UserVmVO) profile.getVirtualMachine());
 
-            if (sendPassword) {
-                Commands cmds = new Commands(OnError.Continue);
-                SavePasswordCommand cmd = new SavePasswordCommand(encodedPassword, nic.getIp4Address(),
userVm.getHostName());
-                cmd.setAccessDetail(NetworkElementCommand.ROUTER_IP, getRouterControlIp(router.getId()));
-                cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, router.getInstanceName());
-                DataCenterVO dcVo = _dcDao.findById(router.getDataCenterIdToDeployIn());
-                cmd.setAccessDetail(NetworkElementCommand.ZONE_NETWORK_TYPE, dcVo.getNetworkType().toString());
-                cmds.addCommand("password", cmd);
+        final VirtualMachineProfile<UserVm> updatedProfile = profile;
 
-                result = result && sendCommandsToRouter(router, cmds);
+        return applyRules(network, routers, "save password entry", false, null, false, new
RuleApplier() {
+            @Override
+            public boolean execute(Network network, VirtualRouter router) throws ResourceUnavailableException
{
+                // for basic zone, send vm data/password information only to the router in
the same pod
+                Commands cmds = new Commands(OnError.Stop);
+                NicVO nicVo = _nicDao.findById(nic.getId());
+                createPasswordCommand(router, updatedProfile, nicVo, cmds);
+                return sendCommandsToRouter(router, cmds);
             }
-        }
-        return result;
+        });
     }
 
     @Override @ActionEvent(eventType = EventTypes.EVENT_ROUTER_STOP, eventDescription = "stopping
router Vm", async = true)


Mime
View raw message