VPC: added vpcId to SetStaticNatRule and CreateLoadBalancerConfig commands

This commit is contained in:
Alena Prokharchyk 2012-06-26 13:35:52 -07:00
parent a764c9a09d
commit ccb075de6f
7 changed files with 27 additions and 13 deletions

View File

@ -29,20 +29,23 @@ public class LoadBalancerConfigCommand extends NetworkElementCommand {
public String lbStatsAuth = "admin1:AdMiN123";
public String lbStatsUri = "/admin?stats";
NicTO nic;
Long vpcId;
protected LoadBalancerConfigCommand() {
}
public LoadBalancerConfigCommand(LoadBalancerTO[] loadBalancers) {
public LoadBalancerConfigCommand(LoadBalancerTO[] loadBalancers, Long vpcId) {
this.loadBalancers = loadBalancers;
this.vpcId = vpcId;
}
public LoadBalancerConfigCommand(LoadBalancerTO[] loadBalancers,String PublicIp,String GuestIp,String PrivateIp, NicTO nic) {
public LoadBalancerConfigCommand(LoadBalancerTO[] loadBalancers,String PublicIp,String GuestIp,String PrivateIp, NicTO nic, Long vpcId) {
this.loadBalancers = loadBalancers;
this.lbStatsPublicIP = PublicIp;
this.lbStatsPrivateIP = PrivateIp;
this.lbStatsGuestIP = GuestIp;
this.nic = nic;
this.vpcId = vpcId;
}
public NicTO getNic() {
@ -52,4 +55,8 @@ public class LoadBalancerConfigCommand extends NetworkElementCommand {
public LoadBalancerTO[] getLoadBalancers() {
return loadBalancers;
}
public Long getVpcId() {
return vpcId;
}
}

View File

@ -19,20 +19,25 @@ import com.cloud.agent.api.to.StaticNatRuleTO;
public class SetStaticNatRulesCommand extends NetworkElementCommand{
StaticNatRuleTO[] rules;
Long vpcId;
protected SetStaticNatRulesCommand() {
}
public SetStaticNatRulesCommand(List<? extends StaticNatRuleTO> staticNatRules) {
public SetStaticNatRulesCommand(List<? extends StaticNatRuleTO> staticNatRules, Long vpcId) {
rules = new StaticNatRuleTO[staticNatRules.size()];
int i = 0;
for (StaticNatRuleTO rule : staticNatRules) {
rules[i++] = rule;
}
this.vpcId = vpcId;
}
public StaticNatRuleTO[] getRules() {
return rules;
}
public Long getVpcId() {
return vpcId;
}
}

View File

@ -492,7 +492,7 @@ public abstract class ExternalFirewallDeviceManagerImpl extends AdapterBase impl
protected void applyStaticNatRules(List<StaticNatRuleTO> staticNatRules, DataCenter zone, long externalFirewallId) throws ResourceUnavailableException {
if (!staticNatRules.isEmpty()) {
SetStaticNatRulesCommand cmd = new SetStaticNatRulesCommand(staticNatRules);
SetStaticNatRulesCommand cmd = new SetStaticNatRulesCommand(staticNatRules, null);
Answer answer = _agentMgr.easySend(externalFirewallId, cmd);
if (answer == null || !answer.getResult()) {
String details = (answer != null) ? answer.getDetails() : "details unavailable";

View File

@ -744,7 +744,7 @@ public abstract class ExternalLoadBalancerDeviceManagerImpl extends AdapterBase
protected void applyStaticNatRules(List<StaticNatRuleTO> staticNatRules, Network network, long firewallHostId) throws ResourceUnavailableException {
if (!staticNatRules.isEmpty()) {
SetStaticNatRulesCommand cmd = new SetStaticNatRulesCommand(staticNatRules);
SetStaticNatRulesCommand cmd = new SetStaticNatRulesCommand(staticNatRules, null);
Answer answer = _agentMgr.easySend(firewallHostId, cmd);
if (answer == null || !answer.getResult()) {
String details = (answer != null) ? answer.getDetails() : "details unavailable";
@ -869,7 +869,7 @@ public abstract class ExternalLoadBalancerDeviceManagerImpl extends AdapterBase
if (loadBalancersToApply.size() > 0) {
int numLoadBalancersForCommand = loadBalancersToApply.size();
LoadBalancerTO[] loadBalancersForCommand = loadBalancersToApply.toArray(new LoadBalancerTO[numLoadBalancersForCommand]);
LoadBalancerConfigCommand cmd = new LoadBalancerConfigCommand(loadBalancersForCommand);
LoadBalancerConfigCommand cmd = new LoadBalancerConfigCommand(loadBalancersForCommand, null);
long guestVlanTag = Integer.parseInt(network.getBroadcastUri().getHost());
cmd.setAccessDetail(NetworkElementCommand.GUEST_VLAN_TAG, String.valueOf(guestVlanTag));
Answer answer = _agentMgr.easySend(externalLoadBalancer.getId(), cmd);

View File

@ -608,7 +608,7 @@ public class NetscalerElement extends ExternalLoadBalancerDeviceManagerImpl impl
if (loadBalancersToApply.size() > 0) {
int numLoadBalancersForCommand = loadBalancersToApply.size();
LoadBalancerTO[] loadBalancersForCommand = loadBalancersToApply.toArray(new LoadBalancerTO[numLoadBalancersForCommand]);
LoadBalancerConfigCommand cmd = new LoadBalancerConfigCommand(loadBalancersForCommand);
LoadBalancerConfigCommand cmd = new LoadBalancerConfigCommand(loadBalancersForCommand, null);
HostVO externalLoadBalancer = _hostDao.findById(lbDeviceVO.getHostId());
Answer answer = _agentMgr.easySend(externalLoadBalancer.getId(), cmd);
@ -660,7 +660,7 @@ public class NetscalerElement extends ExternalLoadBalancerDeviceManagerImpl impl
}
}
SetStaticNatRulesCommand cmd = new SetStaticNatRulesCommand(rulesTO);
SetStaticNatRulesCommand cmd = new SetStaticNatRulesCommand(rulesTO, null);
answer = (SetStaticNatRulesAnswer) _agentMgr.send(lbDevice.getHostId(), cmd);
if (answer == null) {
return false;

View File

@ -299,7 +299,7 @@ public class ElasticLoadBalancerManagerImpl implements
}
LoadBalancerConfigCommand cmd = new LoadBalancerConfigCommand(lbs,elbVm.getPublicIpAddress(),
_nicDao.getIpAddress(guestNetworkId, elbVm.getId()),elbVm.getPrivateIpAddress(), null);
_nicDao.getIpAddress(guestNetworkId, elbVm.getId()),elbVm.getPrivateIpAddress(), null, null);
cmd.setAccessDetail(NetworkElementCommand.ROUTER_IP,
elbVm.getPrivateIpAddress());
cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME,

View File

@ -2594,7 +2594,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
}
}
SetStaticNatRulesCommand cmd = new SetStaticNatRulesCommand(rulesTO);
SetStaticNatRulesCommand cmd = new SetStaticNatRulesCommand(rulesTO, router.getVpcId());
cmd.setAccessDetail(NetworkElementCommand.ROUTER_IP, getRouterControlIp(router.getId()));
cmd.setAccessDetail(NetworkElementCommand.ROUTER_GUEST_IP, getRouterIpInNetwork(guestNetworkId, router.getId()));
cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, router.getInstanceName());
@ -2634,7 +2634,8 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
_networkMgr.getNetworkTag(router.getHypervisorType(), guestNetwork));
LoadBalancerConfigCommand cmd = new LoadBalancerConfigCommand(lbs,RouterPublicIp,
getRouterIpInNetwork(guestNetworkId, router.getId()),router.getPrivateIpAddress(), _itMgr.toNicTO(nicProfile, router.getHypervisorType()));
getRouterIpInNetwork(guestNetworkId, router.getId()),router.getPrivateIpAddress(),
_itMgr.toNicTO(nicProfile, router.getHypervisorType()), router.getVpcId());
cmd.lbStatsVisibility = _configDao.getValue(Config.NetworkLBHaproxyStatsVisbility.key());
cmd.lbStatsUri = _configDao.getValue(Config.NetworkLBHaproxyStatsUri.key());
@ -3073,7 +3074,8 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
return sendCommandsToRouter(router, cmds);
}
private void createApplyStaticNatCommands(List<? extends StaticNat> rules, VirtualRouter router, Commands cmds, long guestNetworkId) {
private void createApplyStaticNatCommands(List<? extends StaticNat> rules, VirtualRouter router, Commands cmds,
long guestNetworkId) {
List<StaticNatRuleTO> rulesTO = null;
if (rules != null) {
rulesTO = new ArrayList<StaticNatRuleTO>();
@ -3085,7 +3087,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
}
}
SetStaticNatRulesCommand cmd = new SetStaticNatRulesCommand(rulesTO);
SetStaticNatRulesCommand cmd = new SetStaticNatRulesCommand(rulesTO, router.getVpcId());
cmd.setAccessDetail(NetworkElementCommand.ROUTER_IP, getRouterControlIp(router.getId()));
cmd.setAccessDetail(NetworkElementCommand.ROUTER_GUEST_IP, getRouterIpInNetwork(guestNetworkId, router.getId()));
cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, router.getInstanceName());