mirror of https://github.com/apache/cloudstack.git
Added NicTO to SetSourceNat command, CreateLoadBalancerConfigCommand, SetNetworkACLCommand
This commit is contained in:
parent
ccec9192a2
commit
887970690b
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -2593,8 +2593,16 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
DomainRouterVO domr = (DomainRouterVO)router;
|
||||
RouterPublicIp = domr.getPublicIpAddress();
|
||||
}
|
||||
|
||||
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());
|
||||
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());
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue