mirror of https://github.com/apache/cloudstack.git
Removed unused methods doing ipAllocation from GuestNetworkGuru and NetworkServiceImpl. The correct method is located in NetworkModelImpl
This commit is contained in:
parent
3f2a62c7f6
commit
915e39fbaa
|
|
@ -30,7 +30,6 @@ import java.util.HashSet;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.ejb.Local;
|
||||
|
|
@ -2069,35 +2068,6 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService {
|
|||
return getNetwork(network.getId());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
protected Set<Long> getAvailableIps(Network network, String requestedIp) {
|
||||
String[] cidr = network.getCidr().split("/");
|
||||
List<String> ips = _nicDao.listIpAddressInNetwork(network.getId());
|
||||
Set<Long> allPossibleIps = NetUtils.getAllIpsFromCidr(cidr[0], Integer.parseInt(cidr[1]));
|
||||
Set<Long> usedIps = new TreeSet<Long>();
|
||||
|
||||
for (String ip : ips) {
|
||||
if (requestedIp != null && requestedIp.equals(ip)) {
|
||||
s_logger.warn("Requested ip address " + requestedIp + " is already in use in network" + network);
|
||||
return null;
|
||||
}
|
||||
|
||||
usedIps.add(NetUtils.ip2Long(ip));
|
||||
}
|
||||
if (usedIps.size() != 0) {
|
||||
allPossibleIps.removeAll(usedIps);
|
||||
}
|
||||
|
||||
String gateway = network.getGateway();
|
||||
if ((gateway != null) && (allPossibleIps.contains(NetUtils.ip2Long(gateway))))
|
||||
allPossibleIps.remove(NetUtils.ip2Long(gateway));
|
||||
|
||||
return allPossibleIps;
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected boolean canUpgrade(Network network, long oldNetworkOfferingId, long newNetworkOfferingId) {
|
||||
NetworkOffering oldNetworkOffering = _networkOfferingDao.findByIdIncludingRemoved(oldNetworkOfferingId);
|
||||
|
|
|
|||
|
|
@ -222,48 +222,7 @@ public abstract class GuestNetworkGuru extends AdapterBase implements NetworkGur
|
|||
nic.deallocate();
|
||||
}
|
||||
}
|
||||
|
||||
public Ip4Address acquireIp4Address(Network network, Ip4Address requestedIp, String reservationId) {
|
||||
List<String> ips = _nicDao.listIpAddressInNetwork(network.getId());
|
||||
String[] cidr = network.getCidr().split("/");
|
||||
SortedSet<Long> usedIps = new TreeSet<Long>();
|
||||
|
||||
if (requestedIp != null && requestedIp.equals(network.getGateway())) {
|
||||
s_logger.warn("Requested ip address " + requestedIp + " is used as a gateway address in network " + network);
|
||||
return null;
|
||||
}
|
||||
|
||||
for (String ip : ips) {
|
||||
usedIps.add(NetUtils.ip2Long(ip));
|
||||
}
|
||||
|
||||
if (network.getGateway() != null) {
|
||||
usedIps.add(NetUtils.ip2Long(network.getGateway()));
|
||||
}
|
||||
|
||||
if (requestedIp != null) {
|
||||
if (usedIps.contains(requestedIp.toLong())) {
|
||||
s_logger.warn("Requested ip address " + requestedIp + " is already in used in " + network);
|
||||
return null;
|
||||
}
|
||||
//check that requested ip has the same cidr
|
||||
boolean isSameCidr = NetUtils.sameSubnetCIDR(requestedIp.ip4(), cidr[0], Integer.parseInt(cidr[1]));
|
||||
if (!isSameCidr) {
|
||||
s_logger.warn("Requested ip address " + requestedIp + " doesn't belong to the network " + network + " cidr");
|
||||
return null;
|
||||
}
|
||||
|
||||
return requestedIp;
|
||||
}
|
||||
|
||||
long ip = NetUtils.getRandomIpFromCidr(cidr[0], Integer.parseInt(cidr[1]), usedIps);
|
||||
if (ip == -1) {
|
||||
s_logger.warn("Unable to allocate any more ip address in " + network);
|
||||
return null;
|
||||
}
|
||||
|
||||
return new Ip4Address(ip);
|
||||
}
|
||||
|
||||
|
||||
public int getVlanOffset(long physicalNetworkId, int vlanTag) {
|
||||
PhysicalNetworkVO pNetwork = _physicalNetworkDao.findById(physicalNetworkId);
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ import org.apache.cloudstack.network.lb.dao.ApplicationLoadBalancerRuleDao;
|
|||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.event.ActionEvent;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.event.UsageEventUtils;
|
||||
import com.cloud.exception.InsufficientAddressCapacityException;
|
||||
|
|
@ -76,8 +77,8 @@ public class ApplicationLoadBalancerManagerImpl extends ManagerBase implements A
|
|||
@Inject ResourceTagDao _resourceTagDao;
|
||||
|
||||
|
||||
//TODO - add action even annotation here; test it as well
|
||||
@Override
|
||||
@ActionEvent(eventType = EventTypes.EVENT_LOAD_BALANCER_CREATE, eventDescription = "creating load balancer")
|
||||
public ApplicationLoadBalancerRule createApplicationLoadBalancer(String name, String description, Scheme scheme, long sourceIpNetworkId, String sourceIp,
|
||||
int sourcePort, int instancePort, String algorithm, long networkId, long lbOwnerId) throws InsufficientAddressCapacityException,
|
||||
NetworkRuleConflictException {
|
||||
|
|
|
|||
Loading…
Reference in New Issue