You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by al...@apache.org on 2012/06/26 06:01:15 UTC
[16/16] git commit: Added NicTO to SetSourceNat command,
CreateLoadBalancerConfigCommand, SetNetworkACLCommand
Added NicTO to SetSourceNat command, CreateLoadBalancerConfigCommand, SetNetworkACLCommand
Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/88797069
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/88797069
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/88797069
Branch: refs/heads/vpc
Commit: 887970690bbb52aed5331c59dd7b0fcf6fe52b00
Parents: ccec919
Author: Alena Prokharchyk <al...@citrix.com>
Authored: Thu Jun 21 10:02:33 2012 -0700
Committer: Alena Prokharchyk <al...@citrix.com>
Committed: Thu Jun 21 10:02:33 2012 -0700
----------------------------------------------------------------------
.../api/routing/LoadBalancerConfigCommand.java | 8 +++++-
.../agent/api/routing/SetNetworkACLCommand.java | 9 +++++-
.../agent/api/routing/SetSourceNatCommand.java | 10 +++++-
.../src/com/cloud/network/NetworkManagerImpl.java | 1 +
.../network/lb/ElasticLoadBalancerManagerImpl.java | 2 +-
.../router/VirtualNetworkApplianceManagerImpl.java | 12 +++++++-
.../VpcVirtualNetworkApplianceManagerImpl.java | 22 +++++++++++---
7 files changed, 52 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/88797069/api/src/com/cloud/agent/api/routing/LoadBalancerConfigCommand.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/agent/api/routing/LoadBalancerConfigCommand.java b/api/src/com/cloud/agent/api/routing/LoadBalancerConfigCommand.java
index f327248..8d3bf68 100644
--- a/api/src/com/cloud/agent/api/routing/LoadBalancerConfigCommand.java
+++ b/api/src/com/cloud/agent/api/routing/LoadBalancerConfigCommand.java
@@ -17,6 +17,7 @@
package com.cloud.agent.api.routing;
import com.cloud.agent.api.to.LoadBalancerTO;
+import com.cloud.agent.api.to.NicTO;
/**
* LoadBalancerConfigCommand sends the load balancer configuration
@@ -31,6 +32,7 @@ public class LoadBalancerConfigCommand extends NetworkElementCommand {
public String lbStatsSrcCidrs = "0/0" ; /* TODO : currently there is no filtering based on the source ip */
public String lbStatsAuth = "admin1:AdMiN123";
public String lbStatsUri = "/admin?stats";
+ NicTO nic;
protected LoadBalancerConfigCommand() {
}
@@ -39,13 +41,17 @@ public class LoadBalancerConfigCommand extends NetworkElementCommand {
this.loadBalancers = loadBalancers;
}
- public LoadBalancerConfigCommand(LoadBalancerTO[] loadBalancers,String PublicIp,String GuestIp,String PrivateIp) {
+ public LoadBalancerConfigCommand(LoadBalancerTO[] loadBalancers,String PublicIp,String GuestIp,String PrivateIp, NicTO nic) {
this.loadBalancers = loadBalancers;
this.lbStatsPublicIP = PublicIp;
this.lbStatsPrivateIP = PrivateIp;
this.lbStatsGuestIP = GuestIp;
+ this.nic = nic;
}
+ public NicTO getNic() {
+ return nic;
+ }
public LoadBalancerTO[] getLoadBalancers() {
return loadBalancers;
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/88797069/api/src/com/cloud/agent/api/routing/SetNetworkACLCommand.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/agent/api/routing/SetNetworkACLCommand.java b/api/src/com/cloud/agent/api/routing/SetNetworkACLCommand.java
index f26e337..42e6329 100644
--- a/api/src/com/cloud/agent/api/routing/SetNetworkACLCommand.java
+++ b/api/src/com/cloud/agent/api/routing/SetNetworkACLCommand.java
@@ -15,21 +15,28 @@ package com.cloud.agent.api.routing;
import java.util.List;
import com.cloud.agent.api.to.NetworkACLTO;
+import com.cloud.agent.api.to.NicTO;
/**
* @author Alena Prokharchyk
*/
public class SetNetworkACLCommand extends NetworkElementCommand{
NetworkACLTO[] rules;
+ NicTO nic;
protected SetNetworkACLCommand() {
}
- public SetNetworkACLCommand(List<NetworkACLTO> rules) {
+ public SetNetworkACLCommand(List<NetworkACLTO> rules, NicTO nic) {
this.rules = rules.toArray(new NetworkACLTO[rules.size()]);
+ this.nic = nic;
}
public NetworkACLTO[] getRules() {
return rules;
}
+
+ public NicTO getNic() {
+ return nic;
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/88797069/api/src/com/cloud/agent/api/routing/SetSourceNatCommand.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/agent/api/routing/SetSourceNatCommand.java b/api/src/com/cloud/agent/api/routing/SetSourceNatCommand.java
index 59d4856..9a88554 100644
--- a/api/src/com/cloud/agent/api/routing/SetSourceNatCommand.java
+++ b/api/src/com/cloud/agent/api/routing/SetSourceNatCommand.java
@@ -13,6 +13,7 @@
package com.cloud.agent.api.routing;
import com.cloud.agent.api.to.IpAddressTO;
+import com.cloud.agent.api.to.NicTO;
/**
* @author Alena Prokharchyk
@@ -20,13 +21,15 @@ import com.cloud.agent.api.to.IpAddressTO;
public class SetSourceNatCommand extends NetworkElementCommand{
IpAddressTO ipAddress;
boolean add;
+ NicTO nic;
protected SetSourceNatCommand() {
}
- public SetSourceNatCommand(IpAddressTO ip, boolean add) {
+ public SetSourceNatCommand(IpAddressTO ip, boolean add, NicTO nic) {
this.ipAddress = ip;
this.add = add;
+ this.nic = nic;
}
@Override
@@ -37,5 +40,8 @@ public class SetSourceNatCommand extends NetworkElementCommand{
public IpAddressTO getIpAddress() {
return ipAddress;
}
-
+
+ public NicTO getNic() {
+ return nic;
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/88797069/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 c891a3e..ed94884 100755
--- a/server/src/com/cloud/network/NetworkManagerImpl.java
+++ b/server/src/com/cloud/network/NetworkManagerImpl.java
@@ -173,6 +173,7 @@ import com.cloud.user.User;
import com.cloud.user.UserContext;
import com.cloud.user.dao.AccountDao;
import com.cloud.user.dao.UserStatisticsDao;
+import com.cloud.utils.AnnotationHelper;
import com.cloud.utils.NumbersUtil;
import com.cloud.utils.Pair;
import com.cloud.utils.component.Adapters;
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/88797069/server/src/com/cloud/network/lb/ElasticLoadBalancerManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/lb/ElasticLoadBalancerManagerImpl.java b/server/src/com/cloud/network/lb/ElasticLoadBalancerManagerImpl.java
index 1870518..5b0a194 100644
--- a/server/src/com/cloud/network/lb/ElasticLoadBalancerManagerImpl.java
+++ b/server/src/com/cloud/network/lb/ElasticLoadBalancerManagerImpl.java
@@ -299,7 +299,7 @@ public class ElasticLoadBalancerManagerImpl implements
}
LoadBalancerConfigCommand cmd = new LoadBalancerConfigCommand(lbs,elbVm.getPublicIpAddress(),
- _nicDao.getIpAddress(guestNetworkId, elbVm.getId()),elbVm.getPrivateIpAddress());
+ _nicDao.getIpAddress(guestNetworkId, elbVm.getId()),elbVm.getPrivateIpAddress(), null);
cmd.setAccessDetail(NetworkElementCommand.ROUTER_IP,
elbVm.getPrivateIpAddress());
cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME,
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/88797069/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 be5d4b6..c3d32ca 100755
--- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
+++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
@@ -2593,8 +2593,16 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
DomainRouterVO domr = (DomainRouterVO)router;
RouterPublicIp = domr.getPublicIpAddress();
}
-
- LoadBalancerConfigCommand cmd = new LoadBalancerConfigCommand(lbs,RouterPublicIp, getRouterIpInNetwork(guestNetworkId, router.getId()),router.getPrivateIpAddress());
+
+ Network guestNetwork = _networkMgr.getNetwork(guestNetworkId);
+ Nic nic = _nicDao.findByInstanceIdAndNetworkId(guestNetwork.getId(), router.getId());
+ NicProfile nicProfile = new NicProfile(nic, guestNetwork, nic.getBroadcastUri(), nic.getIsolationUri(),
+ _networkMgr.getNetworkRate(guestNetwork.getId(), router.getId()),
+ _networkMgr.isSecurityGroupSupportedInNetwork(guestNetwork),
+ _networkMgr.getNetworkTag(router.getHypervisorType(), guestNetwork));
+
+ LoadBalancerConfigCommand cmd = new LoadBalancerConfigCommand(lbs,RouterPublicIp,
+ getRouterIpInNetwork(guestNetworkId, router.getId()),router.getPrivateIpAddress(), _itMgr.toNicTO(nicProfile, router.getHypervisorType()));
cmd.lbStatsVisibility = _configDao.getValue(Config.NetworkLBHaproxyStatsVisbility.key());
cmd.lbStatsUri = _configDao.getValue(Config.NetworkLBHaproxyStatsUri.key());
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/88797069/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java b/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java
index 872d1a6..2dbe053 100644
--- a/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java
+++ b/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java
@@ -615,10 +615,17 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
//set source nat ip
if (sourceNatIpAdd != null) {
IpAddressTO sourceNatIp = sourceNatIpAdd.first();
- Long networkId = sourceNatIpAdd.second();
- SetSourceNatCommand cmd = new SetSourceNatCommand(sourceNatIp, addSourceNat);
+ Long publicNetworkId = sourceNatIpAdd.second();
+
+ Network guestNetwork = _networkMgr.getNetwork(publicNetworkId);
+ Nic nic = _nicDao.findByInstanceIdAndNetworkId(guestNetwork.getId(), router.getId());
+ NicProfile nicProfile = new NicProfile(nic, guestNetwork, nic.getBroadcastUri(), nic.getIsolationUri(),
+ _networkMgr.getNetworkRate(guestNetwork.getId(), router.getId()),
+ _networkMgr.isSecurityGroupSupportedInNetwork(guestNetwork),
+ _networkMgr.getNetworkTag(router.getHypervisorType(), guestNetwork));
+
+ SetSourceNatCommand cmd = new SetSourceNatCommand(sourceNatIp, addSourceNat, _itMgr.toNicTO(nicProfile, router.getHypervisorType()));
cmd.setAccessDetail(NetworkElementCommand.ROUTER_IP, getRouterControlIp(router.getId()));
- cmd.setAccessDetail(NetworkElementCommand.ROUTER_GUEST_IP, getRouterIpInNetwork(networkId, router.getId()));
cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, router.getInstanceName());
DataCenterVO dcVo = _dcDao.findById(router.getDataCenterIdToDeployIn());
cmd.setAccessDetail(NetworkElementCommand.ZONE_NETWORK_TYPE, dcVo.getNetworkType().toString());
@@ -728,7 +735,6 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
Commands cmds = new Commands(OnError.Continue);
createNetworkACLsCommands(rules, router, cmds, guestNetworkId);
return sendCommandsToRouter(router, cmds);
-
}
private void createNetworkACLsCommands(List<NetworkACL> rules, VirtualRouter router, Commands cmds, long guestNetworkId) {
@@ -748,8 +754,14 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
rulesTO.add(ruleTO);
}
}
+
+ Network network = _networkMgr.getNetwork(guestNetworkId);
+ Nic nic = _nicDao.findByInstanceIdAndNetworkId(network.getId(), router.getId());
+ NicProfile nicProfile = new NicProfile(nic, network, nic.getBroadcastUri(), nic.getIsolationUri(),
+ _networkMgr.getNetworkRate(network.getId(), router.getId()),
+ _networkMgr.isSecurityGroupSupportedInNetwork(network), _networkMgr.getNetworkTag(router.getHypervisorType(), network));
- SetNetworkACLCommand cmd = new SetNetworkACLCommand(rulesTO);
+ SetNetworkACLCommand cmd = new SetNetworkACLCommand(rulesTO, _itMgr.toNicTO(nicProfile, router.getHypervisorType()));
cmd.setAccessDetail(NetworkElementCommand.ROUTER_IP, getRouterControlIp(router.getId()));
cmd.setAccessDetail(NetworkElementCommand.ROUTER_GUEST_IP, getRouterIpInNetwork(guestNetworkId, router.getId()));
cmd.setAccessDetail(NetworkElementCommand.GUEST_VLAN_TAG, guestVlan);