You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cloudstack.apache.org by Prasanna Santhanam <Pr...@citrix.com> on 2012/06/11 11:54:18 UTC
[PATCH] Implementing the SetFirewallRulesCommand for the simulator
* Essential since we need firewall rules open before applying network
rules. Without the fix one recieves an UnsupportedCommandAnswer and
fails the application of the network rule
* Also RebootCommand responds with a RebootAnswer - minor fix
Signed-off-by: Prasanna Santhanam <Pr...@citrix.com>
---
.../src/com/cloud/agent/manager/MockVmManager.java | 4 +++-
.../com/cloud/agent/manager/MockVmManagerImpl.java | 12 ++++++++++--
.../cloud/agent/manager/SimulatorManagerImpl.java | 3 +++
3 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/agent-simulator/src/com/cloud/agent/manager/MockVmManager.java b/agent-simulator/src/com/cloud/agent/manager/MockVmManager.java
index 2aacf19..10ae300 100644
--- a/agent-simulator/src/com/cloud/agent/manager/MockVmManager.java
+++ b/agent-simulator/src/com/cloud/agent/manager/MockVmManager.java
@@ -13,7 +13,6 @@
package com.cloud.agent.manager;
import java.util.HashMap;
-import java.util.List;
import java.util.Map;
import com.cloud.agent.api.Answer;
@@ -39,6 +38,7 @@ import com.cloud.agent.api.routing.DhcpEntryCommand;
import com.cloud.agent.api.routing.IpAssocCommand;
import com.cloud.agent.api.routing.LoadBalancerConfigCommand;
import com.cloud.agent.api.routing.SavePasswordCommand;
+import com.cloud.agent.api.routing.SetFirewallRulesCommand;
import com.cloud.agent.api.routing.SetPortForwardingRulesCommand;
import com.cloud.agent.api.routing.SetStaticNatRulesCommand;
import com.cloud.agent.api.routing.VmDataCommand;
@@ -63,6 +63,8 @@ public interface MockVmManager extends Manager {
Answer SetStaticNatRules(SetStaticNatRulesCommand cmd);
Answer SetPortForwardingRules(SetPortForwardingRulesCommand cmd);
+
+ Answer SetFirewallRules(SetFirewallRulesCommand cmd);
Answer getNetworkUsage(NetworkUsageCommand cmd);
diff --git a/agent-simulator/src/com/cloud/agent/manager/MockVmManagerImpl.java b/agent-simulator/src/com/cloud/agent/manager/MockVmManagerImpl.java
index e791b65..b1b370a 100644
--- a/agent-simulator/src/com/cloud/agent/manager/MockVmManagerImpl.java
+++ b/agent-simulator/src/com/cloud/agent/manager/MockVmManagerImpl.java
@@ -37,6 +37,7 @@ import com.cloud.agent.api.MigrateAnswer;
import com.cloud.agent.api.MigrateCommand;
import com.cloud.agent.api.NetworkUsageAnswer;
import com.cloud.agent.api.NetworkUsageCommand;
+import com.cloud.agent.api.RebootAnswer;
import com.cloud.agent.api.RebootCommand;
import com.cloud.agent.api.SecurityGroupRuleAnswer;
import com.cloud.agent.api.SecurityGroupRulesCmd;
@@ -53,6 +54,7 @@ import com.cloud.agent.api.routing.DhcpEntryCommand;
import com.cloud.agent.api.routing.IpAssocCommand;
import com.cloud.agent.api.routing.LoadBalancerConfigCommand;
import com.cloud.agent.api.routing.SavePasswordCommand;
+import com.cloud.agent.api.routing.SetFirewallRulesCommand;
import com.cloud.agent.api.routing.SetPortForwardingRulesCommand;
import com.cloud.agent.api.routing.SetStaticNatRulesCommand;
import com.cloud.agent.api.routing.VmDataCommand;
@@ -273,6 +275,12 @@ public class MockVmManagerImpl implements MockVmManager {
}
@Override
+ public Answer SetFirewallRules(SetFirewallRulesCommand cmd) {
+ return new Answer(cmd);
+ }
+
+
+ @Override
public NetworkUsageAnswer getNetworkUsage(NetworkUsageCommand cmd) {
return new NetworkUsageAnswer(cmd, null, 100L, 100L);
}
@@ -345,7 +353,7 @@ public class MockVmManagerImpl implements MockVmManager {
@Override
public Answer rebootVM(RebootCommand cmd) {
- return new Answer(cmd);
+ return new RebootAnswer(cmd, "Rebooted "+cmd.getVmName());
}
@Override
@@ -457,5 +465,5 @@ public class MockVmManagerImpl implements MockVmManager {
}
return maps;
}
-
+
}
diff --git a/agent-simulator/src/com/cloud/agent/manager/SimulatorManagerImpl.java b/agent-simulator/src/com/cloud/agent/manager/SimulatorManagerImpl.java
index 87846b3..1517c94 100644
--- a/agent-simulator/src/com/cloud/agent/manager/SimulatorManagerImpl.java
+++ b/agent-simulator/src/com/cloud/agent/manager/SimulatorManagerImpl.java
@@ -64,6 +64,7 @@ import com.cloud.agent.api.routing.DhcpEntryCommand;
import com.cloud.agent.api.routing.IpAssocCommand;
import com.cloud.agent.api.routing.LoadBalancerConfigCommand;
import com.cloud.agent.api.routing.SavePasswordCommand;
+import com.cloud.agent.api.routing.SetFirewallRulesCommand;
import com.cloud.agent.api.routing.SetPortForwardingRulesCommand;
import com.cloud.agent.api.routing.SetStaticNatRulesCommand;
import com.cloud.agent.api.routing.VmDataCommand;
@@ -200,6 +201,8 @@ public class SimulatorManagerImpl implements SimulatorManager {
return _mockVmMgr.checkSshCommand((CheckSshCommand)cmd);
} else if (cmd instanceof SetStaticNatRulesCommand) {
return _mockVmMgr.SetStaticNatRules((SetStaticNatRulesCommand)cmd);
+ } else if (cmd instanceof SetFirewallRulesCommand) {
+ return _mockVmMgr.SetFirewallRules((SetFirewallRulesCommand)cmd);
} else if (cmd instanceof SetPortForwardingRulesCommand) {
return _mockVmMgr.SetPortForwardingRules((SetPortForwardingRulesCommand)cmd);
} else if (cmd instanceof NetworkUsageCommand) {
--
1.7.9.5
--
Prasanna.,
RE: [PATCH] Implementing the SetFirewallRulesCommand for the
simulator
Posted by Kishan Kavala <Ki...@citrix.com>.
Prasanna,
I've applied the patch.
commit 59f7cd4126c17fe73e5470de332f53a5ab9e47a8
Author: Prasanna Santhanam <Pr...@citrix.com>
Date: Mon Jun 11 15:24:18 2012 +0530
~kishan
> -----Original Message-----
> From: Prasanna Santhanam [mailto:Prasanna.Santhanam@citrix.com]
> Sent: Monday, 11 June 2012 3:24 PM
> To: CloudStack Dev
> Subject: [PATCH] Implementing the SetFirewallRulesCommand for the
> simulator
>
> * Essential since we need firewall rules open before applying network rules.
> Without the fix one recieves an UnsupportedCommandAnswer and fails the
> application of the network rule
>
> * Also RebootCommand responds with a RebootAnswer - minor fix
>
> Signed-off-by: Prasanna Santhanam <Pr...@citrix.com>
> ---
> .../src/com/cloud/agent/manager/MockVmManager.java | 4 +++-
> .../com/cloud/agent/manager/MockVmManagerImpl.java | 12
> ++++++++++--
> .../cloud/agent/manager/SimulatorManagerImpl.java | 3 +++
> 3 files changed, 16 insertions(+), 3 deletions(-)
>
> diff --git a/agent-
> simulator/src/com/cloud/agent/manager/MockVmManager.java b/agent-
> simulator/src/com/cloud/agent/manager/MockVmManager.java
> index 2aacf19..10ae300 100644
> --- a/agent-simulator/src/com/cloud/agent/manager/MockVmManager.java
> +++ b/agent-
> simulator/src/com/cloud/agent/manager/MockVmManager.java
> @@ -13,7 +13,6 @@
> package com.cloud.agent.manager;
>
> import java.util.HashMap;
> -import java.util.List;
> import java.util.Map;
>
> import com.cloud.agent.api.Answer;
> @@ -39,6 +38,7 @@ import
> com.cloud.agent.api.routing.DhcpEntryCommand;
> import com.cloud.agent.api.routing.IpAssocCommand;
> import com.cloud.agent.api.routing.LoadBalancerConfigCommand;
> import com.cloud.agent.api.routing.SavePasswordCommand;
> +import com.cloud.agent.api.routing.SetFirewallRulesCommand;
> import com.cloud.agent.api.routing.SetPortForwardingRulesCommand;
> import com.cloud.agent.api.routing.SetStaticNatRulesCommand;
> import com.cloud.agent.api.routing.VmDataCommand;
> @@ -63,6 +63,8 @@ public interface MockVmManager extends Manager {
> Answer SetStaticNatRules(SetStaticNatRulesCommand cmd);
>
> Answer SetPortForwardingRules(SetPortForwardingRulesCommand cmd);
> +
> + Answer SetFirewallRules(SetFirewallRulesCommand cmd);
>
> Answer getNetworkUsage(NetworkUsageCommand cmd);
>
> diff --git a/agent-
> simulator/src/com/cloud/agent/manager/MockVmManagerImpl.java
> b/agent-
> simulator/src/com/cloud/agent/manager/MockVmManagerImpl.java
> index e791b65..b1b370a 100644
> --- a/agent-
> simulator/src/com/cloud/agent/manager/MockVmManagerImpl.java
> +++ b/agent-
> simulator/src/com/cloud/agent/manager/MockVmManagerImpl.java
> @@ -37,6 +37,7 @@ import com.cloud.agent.api.MigrateAnswer;
> import com.cloud.agent.api.MigrateCommand;
> import com.cloud.agent.api.NetworkUsageAnswer;
> import com.cloud.agent.api.NetworkUsageCommand;
> +import com.cloud.agent.api.RebootAnswer;
> import com.cloud.agent.api.RebootCommand;
> import com.cloud.agent.api.SecurityGroupRuleAnswer;
> import com.cloud.agent.api.SecurityGroupRulesCmd;
> @@ -53,6 +54,7 @@ import
> com.cloud.agent.api.routing.DhcpEntryCommand;
> import com.cloud.agent.api.routing.IpAssocCommand;
> import com.cloud.agent.api.routing.LoadBalancerConfigCommand;
> import com.cloud.agent.api.routing.SavePasswordCommand;
> +import com.cloud.agent.api.routing.SetFirewallRulesCommand;
> import com.cloud.agent.api.routing.SetPortForwardingRulesCommand;
> import com.cloud.agent.api.routing.SetStaticNatRulesCommand;
> import com.cloud.agent.api.routing.VmDataCommand;
> @@ -273,6 +275,12 @@ public class MockVmManagerImpl implements
> MockVmManager {
> }
>
> @Override
> + public Answer SetFirewallRules(SetFirewallRulesCommand cmd) {
> + return new Answer(cmd);
> + }
> +
> +
> + @Override
> public NetworkUsageAnswer getNetworkUsage(NetworkUsageCommand
> cmd) {
> return new NetworkUsageAnswer(cmd, null, 100L, 100L);
> }
> @@ -345,7 +353,7 @@ public class MockVmManagerImpl implements
> MockVmManager {
>
> @Override
> public Answer rebootVM(RebootCommand cmd) {
> - return new Answer(cmd);
> + return new RebootAnswer(cmd, "Rebooted "+cmd.getVmName());
> }
>
> @Override
> @@ -457,5 +465,5 @@ public class MockVmManagerImpl implements
> MockVmManager {
> }
> return maps;
> }
> -
> +
> }
> diff --git a/agent-
> simulator/src/com/cloud/agent/manager/SimulatorManagerImpl.java
> b/agent-
> simulator/src/com/cloud/agent/manager/SimulatorManagerImpl.java
> index 87846b3..1517c94 100644
> --- a/agent-
> simulator/src/com/cloud/agent/manager/SimulatorManagerImpl.java
> +++ b/agent-
> simulator/src/com/cloud/agent/manager/SimulatorManagerImpl.j
> +++ ava
> @@ -64,6 +64,7 @@ import
> com.cloud.agent.api.routing.DhcpEntryCommand;
> import com.cloud.agent.api.routing.IpAssocCommand;
> import com.cloud.agent.api.routing.LoadBalancerConfigCommand;
> import com.cloud.agent.api.routing.SavePasswordCommand;
> +import com.cloud.agent.api.routing.SetFirewallRulesCommand;
> import com.cloud.agent.api.routing.SetPortForwardingRulesCommand;
> import com.cloud.agent.api.routing.SetStaticNatRulesCommand;
> import com.cloud.agent.api.routing.VmDataCommand;
> @@ -200,6 +201,8 @@ public class SimulatorManagerImpl implements
> SimulatorManager {
> return _mockVmMgr.checkSshCommand((CheckSshCommand)cmd);
> } else if (cmd instanceof SetStaticNatRulesCommand) {
> return
> _mockVmMgr.SetStaticNatRules((SetStaticNatRulesCommand)cmd);
> + } else if (cmd instanceof SetFirewallRulesCommand) {
> + return
> + _mockVmMgr.SetFirewallRules((SetFirewallRulesCommand)cmd);
> } else if (cmd instanceof SetPortForwardingRulesCommand) {
> return
> _mockVmMgr.SetPortForwardingRules((SetPortForwardingRulesCommand)
> cmd);
> } else if (cmd instanceof NetworkUsageCommand) {
> --
> 1.7.9.5
>
>
> --
> Prasanna.,