cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bfede...@apache.org
Subject [41/50] [abbrv] git commit: updated refs/heads/ui-restyle to c64bfa5
Date Thu, 20 Feb 2014 19:17:47 GMT
CLOUDSTACK-6047: Generalize execution in VirtualRoutingResource


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

Branch: refs/heads/ui-restyle
Commit: ebf7ee40b11cf50c99d7699100ea8d98862fb6e9
Parents: 8fccb8c
Author: Sheng Yang <sheng.yang@citrix.com>
Authored: Wed Feb 19 19:12:07 2014 -0800
Committer: Sheng Yang <sheng.yang@citrix.com>
Committed: Wed Feb 19 19:46:59 2014 -0800

----------------------------------------------------------------------
 .../virtualnetwork/VirtualRoutingResource.java  | 66 +++++++-------------
 1 file changed, 23 insertions(+), 43 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ebf7ee40/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
b/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
index d51e8bb..faa826a 100755
--- a/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
+++ b/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
@@ -236,6 +236,16 @@ public class VirtualRoutingResource {
         }
     }
 
+    private Answer applyConfigSingle(NetworkElementCommand cmd, List<ConfigItem> cfg)
{
+        for (ConfigItem c : cfg) {
+            ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), c.getScript(),
c.getArgs());
+            if (!result.isSuccess()) {
+                return new Answer(cmd, false, result.getDetails());
+            }
+        }
+        return new Answer(cmd);
+    }
+
     private List<ConfigItem> generateConfig(VpnUsersCfgCommand cmd) {
         LinkedList<ConfigItem> cfg = new LinkedList<>();
         for (VpnUsersCfgCommand.UsernamePassword userpwd : cmd.getUserpwds()) {
@@ -254,13 +264,7 @@ public class VirtualRoutingResource {
 
     private Answer execute(VpnUsersCfgCommand cmd) {
         List<ConfigItem> cfg = generateConfig(cmd);
-        for (ConfigItem c : cfg) {
-            ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), c.getScript(),
c.getArgs());
-            if (!result.isSuccess()) {
-                return new Answer(cmd, false, "Configure VPN user failed: " + result.getDetails());
-            }
-        }
-        return new Answer(cmd);
+        return applyConfigSingle(cmd, cfg);
     }
 
     private List<ConfigItem> generateConfig(RemoteAccessVpnCfgCommand cmd) {
@@ -289,9 +293,7 @@ public class VirtualRoutingResource {
 
     private Answer execute(RemoteAccessVpnCfgCommand cmd) {
         List<ConfigItem> cfg = generateConfig(cmd);
-        ConfigItem c = cfg.get(0);
-        ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), c.getScript(),
c.getArgs());
-        return new Answer(cmd, result.isSuccess(), result.getDetails());
+        return applyConfigSingle(cmd, cfg);
     }
 
     private List<ConfigItem> generateConfig(SetFirewallRulesCommand cmd) {
@@ -543,9 +545,7 @@ public class VirtualRoutingResource {
 
     protected Answer execute(VmDataCommand cmd) {
         List<ConfigItem> cfg = generateConfig(cmd);
-        ConfigItem c = cfg.get(0);
-        final ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), c.getScript(),
c.getArgs());
-        return new Answer(cmd, result.isSuccess(), result.getDetails());
+        return applyConfigSingle(cmd, cfg);
     }
 
     private List<ConfigItem> generateConfig(SavePasswordCommand cmd) {
@@ -563,9 +563,7 @@ public class VirtualRoutingResource {
 
     protected Answer execute(final SavePasswordCommand cmd) {
         List<ConfigItem> cfg = generateConfig(cmd);
-        ConfigItem c = cfg.get(0);
-        ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), c.getScript(),
c.getArgs());
-        return new Answer(cmd, result.isSuccess(), result.getDetails());
+        return applyConfigSingle(cmd, cfg);
     }
 
     private List<ConfigItem> generateConfig(DhcpEntryCommand cmd) {
@@ -604,9 +602,7 @@ public class VirtualRoutingResource {
 
     protected Answer execute(final DhcpEntryCommand cmd) {
         List<ConfigItem> cfg = generateConfig(cmd);
-        ConfigItem c = cfg.get(0);
-        final ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), c.getScript(),
c.getArgs());
-        return new Answer(cmd, result.isSuccess(), result.getDetails());
+        return applyConfigSingle(cmd, cfg);
     }
 
     private List<ConfigItem> generateConfig(CreateIpAliasCommand cmd) {
@@ -624,9 +620,7 @@ public class VirtualRoutingResource {
 
     protected Answer execute(final CreateIpAliasCommand cmd) {
         List<ConfigItem> cfg = generateConfig(cmd);
-        ConfigItem c = cfg.get(0);
-        final ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), c.getScript(),
c.getArgs());
-        return new Answer(cmd, result.isSuccess(), result.getDetails());
+        return applyConfigSingle(cmd, cfg);
     }
 
     private List<ConfigItem> generateConfig(DeleteIpAliasCommand cmd) {
@@ -650,9 +644,7 @@ public class VirtualRoutingResource {
 
     protected Answer execute(final DeleteIpAliasCommand cmd) {
         List<ConfigItem> cfg = generateConfig(cmd);
-        ConfigItem c = cfg.get(0);
-        final ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), c.getScript(),
c.getArgs());
-        return new Answer(cmd, result.isSuccess(), result.getDetails());
+        return applyConfigSingle(cmd, cfg);
     }
 
     private List<ConfigItem> generateConfig(DnsMasqConfigCommand cmd) {
@@ -670,9 +662,7 @@ public class VirtualRoutingResource {
 
     protected Answer execute(final DnsMasqConfigCommand cmd) {
         List<ConfigItem> cfg = generateConfig(cmd);
-        ConfigItem c = cfg.get(0);
-        final ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), c.getScript(),
c.getArgs());
-        return new Answer(cmd, result.isSuccess(), result.getDetails());
+        return applyConfigSingle(cmd, cfg);
     }
 
     private CheckS2SVpnConnectionsAnswer execute(CheckS2SVpnConnectionsCommand cmd) {
@@ -701,9 +691,7 @@ public class VirtualRoutingResource {
 
     protected Answer execute(BumpUpPriorityCommand cmd) {
         List<ConfigItem> cfg = generateConfig(cmd);
-        ConfigItem c = cfg.get(0);
-        final ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), c.getScript(),
c.getArgs());
-        return new Answer(cmd, result.isSuccess(), result.getDetails());
+        return applyConfigSingle(cmd, cfg);
     }
 
     protected Answer execute(GetDomRVersionCmd cmd) {
@@ -769,9 +757,7 @@ public class VirtualRoutingResource {
 
     protected Answer execute(Site2SiteVpnCfgCommand cmd) {
         List<ConfigItem> cfg = generateConfig(cmd);
-        ConfigItem c = cfg.get(0);
-        final ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), c.getScript(),
c.getArgs());
-        return new Answer(cmd, result.isSuccess(), result.getDetails());
+        return applyConfigSingle(cmd, cfg);
     }
 
     protected List<ConfigItem> generateConfig(SetMonitorServiceCommand cmd) {
@@ -791,9 +777,7 @@ public class VirtualRoutingResource {
 
     protected Answer execute(SetMonitorServiceCommand cmd) {
         List<ConfigItem> cfg = generateConfig(cmd);
-        ConfigItem c = cfg.get(0);
-        final ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), c.getScript(),
c.getArgs());
-        return new Answer(cmd, result.isSuccess(), result.getDetails());
+        return applyConfigSingle(cmd, cfg);
     }
 
     protected List<ConfigItem> generateConfig(SetupGuestNetworkCommand cmd) {
@@ -838,9 +822,7 @@ public class VirtualRoutingResource {
 
     protected Answer execute(SetupGuestNetworkCommand cmd) {
         List<ConfigItem> cfg = generateConfig(cmd);
-        ConfigItem c = cfg.get(0);
-        final ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), c.getScript(),
c.getArgs());
-        return new Answer(cmd, result.isSuccess(), result.getDetails());
+        return applyConfigSingle(cmd, cfg);
     }
 
     protected List<ConfigItem> generateConfig(SetNetworkACLCommand cmd) {
@@ -911,9 +893,7 @@ public class VirtualRoutingResource {
 
     protected Answer execute(SetSourceNatCommand cmd) {
         List<ConfigItem> cfg = generateConfig(cmd);
-        ConfigItem c = cfg.get(0);
-        final ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), c.getScript(),
c.getArgs());
-        return new Answer(cmd, result.isSuccess(), result.getDetails());
+        return applyConfigSingle(cmd, cfg);
     }
 
     protected List<ConfigItem> generateConfig(SetPortForwardingRulesVpcCommand cmd)
{


Mime
View raw message