mirror of https://github.com/apache/cloudstack.git
Internal LB: fixed some bugs in internal lb vm startup process
This commit is contained in:
parent
1db240c2b6
commit
af6201257b
|
|
@ -23,7 +23,6 @@ import org.apache.cloudstack.api.BaseAsyncCreateCmd;
|
|||
import org.apache.cloudstack.api.Parameter;
|
||||
import org.apache.cloudstack.api.ServerApiException;
|
||||
import org.apache.cloudstack.api.response.ApplicationLoadBalancerResponse;
|
||||
import org.apache.cloudstack.api.response.DomainResponse;
|
||||
import org.apache.cloudstack.api.response.NetworkResponse;
|
||||
import org.apache.cloudstack.network.lb.ApplicationLoadBalancerRule;
|
||||
import org.apache.log4j.Logger;
|
||||
|
|
@ -37,9 +36,7 @@ import com.cloud.exception.NetworkRuleConflictException;
|
|||
import com.cloud.exception.ResourceAllocationException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.network.rules.LoadBalancerContainer.Scheme;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.UserContext;
|
||||
import com.cloud.utils.net.NetUtils;
|
||||
|
||||
|
|
@ -77,14 +74,6 @@ public class CreateApplicationLoadBalancerCmd extends BaseAsyncCreateCmd {
|
|||
@Parameter(name=ApiConstants.SOURCE_IP_NETWORK_ID, type=CommandType.UUID, entityType = NetworkResponse.class, required=true,
|
||||
description="the network id of the source ip address")
|
||||
private Long sourceIpNetworkId;
|
||||
|
||||
@Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, description="the account associated with the load balancer." +
|
||||
" Must be used with the domainId parameter.")
|
||||
private String accountName;
|
||||
|
||||
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.UUID, entityType = DomainResponse.class,
|
||||
description="the domain ID associated with the load balancer")
|
||||
private Long domainId;
|
||||
|
||||
@Parameter(name=ApiConstants.SCHEME, type=CommandType.STRING, required=true, description="the load balancer scheme. Supported value in this release is Internal")
|
||||
private String scheme;
|
||||
|
|
@ -128,35 +117,20 @@ public class CreateApplicationLoadBalancerCmd extends BaseAsyncCreateCmd {
|
|||
}
|
||||
|
||||
public long getAccountId() {
|
||||
Account account = null;
|
||||
//get account info from the network object if it's a guest network
|
||||
//get account info from the network object
|
||||
Network ntwk = _networkService.getNetwork(networkId);
|
||||
if (ntwk.getTrafficType() == TrafficType.Guest){
|
||||
return ntwk.getAccountId();
|
||||
} else if (sourceIp != null) {
|
||||
//get account info from the ip address object if the traffic type is public
|
||||
|
||||
} if ((domainId != null) && (accountName != null)) {
|
||||
account = _responseGenerator.findAccountByNameDomain(accountName, domainId);
|
||||
if (account != null) {
|
||||
return account.getId();
|
||||
} else {
|
||||
throw new InvalidParameterValueException("Unable to find account " + account + " in domain id=" + domainId);
|
||||
}
|
||||
} else {
|
||||
throw new InvalidParameterValueException("Can't define the Load Balancer owner. Either specify guest" +
|
||||
" network in networkId, or Public Ip address in sourceIpAddress, or account/domainId parameters");
|
||||
}
|
||||
if (ntwk == null) {
|
||||
throw new InvalidParameterValueException("Invalid network id specified");
|
||||
}
|
||||
|
||||
return ntwk.getAccountId();
|
||||
|
||||
}
|
||||
|
||||
public int getInstancePort() {
|
||||
return instancePort.intValue();
|
||||
}
|
||||
|
||||
public String getAccountName() {
|
||||
return accountName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_LOAD_BALANCER_CREATE;
|
||||
|
|
@ -164,7 +138,7 @@ public class CreateApplicationLoadBalancerCmd extends BaseAsyncCreateCmd {
|
|||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
return "creating load balancer: " + getName() + " account: " + getAccountName();
|
||||
return "creating load balancer: " + getName() + " account: " + getAccountId();
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -483,7 +483,8 @@ InternalLoadBalancerManager, VirtualMachineGuru<DomainRouterVO> {
|
|||
_ntwkModel.isSecurityGroupSupportedInNetwork(guestNetwork),
|
||||
_ntwkModel.getNetworkTag(internalLbVm.getHypervisorType(), guestNetwork));
|
||||
|
||||
LoadBalancerConfigCommand cmd = new LoadBalancerConfigCommand(lbs, null,
|
||||
//FIXME - for ha proxy
|
||||
LoadBalancerConfigCommand cmd = new LoadBalancerConfigCommand(lbs, guestNic.getIp4Address(),
|
||||
guestNic.getIp4Address(), internalLbVm.getPrivateIpAddress(),
|
||||
_itMgr.toNicTO(guestNicProfile, internalLbVm.getHypervisorType()), internalLbVm.getVpcId());
|
||||
|
||||
|
|
@ -635,8 +636,13 @@ InternalLoadBalancerManager, VirtualMachineGuru<DomainRouterVO> {
|
|||
Pair<DeploymentPlan, List<DomainRouterVO>> planAndInternalLbVms = getDeploymentPlanAndInternalLbVms(dest, guestNetwork.getId(), requestedGuestIp);
|
||||
internalLbs = planAndInternalLbVms.second();
|
||||
DeploymentPlan plan = planAndInternalLbVms.first();
|
||||
|
||||
if (internalLbs.size() > 0) {
|
||||
s_logger.debug("Found " + internalLbs.size() + " internal lb vms for the requested IP " + requestedGuestIp.addr());
|
||||
return internalLbs;
|
||||
}
|
||||
|
||||
List<Pair<NetworkVO, NicProfile>> networks = createInternalLbVmNetworks(guestNetwork, plan, null);
|
||||
List<Pair<NetworkVO, NicProfile>> networks = createInternalLbVmNetworks(guestNetwork, plan, requestedGuestIp);
|
||||
//don't start the internal lb as we are holding the network lock that needs to be released at the end of router allocation
|
||||
DomainRouterVO internalLbVm = deployInternalLbVm(owner, dest, plan, params, internalLbProvider, offeringId, guestNetwork.getVpcId(),
|
||||
networks, false);
|
||||
|
|
@ -717,13 +723,13 @@ InternalLoadBalancerManager, VirtualMachineGuru<DomainRouterVO> {
|
|||
|
||||
long id = _routerDao.getNextInSequence(Long.class, "id");
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Creating the internal lb " + id + " in datacenter " + dest.getDataCenter());
|
||||
s_logger.debug("Creating the internal lb vm " + id + " in datacenter " + dest.getDataCenter());
|
||||
}
|
||||
|
||||
ServiceOfferingVO routerOffering = _serviceOfferingDao.findById(svcOffId);
|
||||
|
||||
// Internal lb is the network element, we don't know the hypervisor type yet.
|
||||
// Try to allocate the domR twice using diff hypervisors, and when failed both times, throw the exception up
|
||||
// Try to allocate the internal lb twice using diff hypervisors, and when failed both times, throw the exception up
|
||||
List<HypervisorType> hypervisors = getHypervisors(dest, plan, null);
|
||||
|
||||
int allocateRetry = 0;
|
||||
|
|
|
|||
|
|
@ -304,7 +304,7 @@ public class ApplicationLoadBalancerManagerImpl extends ManagerBase implements A
|
|||
return;
|
||||
} else {
|
||||
List<String> usedIps = _networkModel.getUsedIpsInNetwork(sourceIpNtwk);
|
||||
if (usedIps.size() > 0) {
|
||||
if (usedIps.contains(requestedSourceIp.toString())) {
|
||||
throw new InvalidParameterValueException("Ip address " + requestedSourceIp.addr() + " is already in use");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue