use of com.cloud.legacymodel.network.Nic.ReservationStrategy in project cosmic by MissionCriticalCloud.
the class DirectPodBasedNetworkGuru method allocate.
@Override
public NicProfile allocate(final Network network, NicProfile nic, final VirtualMachineProfile vm) throws InsufficientVirtualNetworkCapacityException, InsufficientAddressCapacityException, ConcurrentOperationException {
final DataCenterVO dc = _dcDao.findById(network.getDataCenterId());
ReservationStrategy rsStrategy = ReservationStrategy.Start;
_dcDao.loadDetails(dc);
final String dhcpStrategy = dc.getDetail(ZoneConfig.DhcpStrategy.key());
if ("external".equalsIgnoreCase(dhcpStrategy)) {
rsStrategy = ReservationStrategy.Create;
}
if (nic != null && nic.getRequestedIPv4() != null) {
throw new CloudRuntimeException("Does not support custom ip allocation at this time: " + nic);
}
if (nic == null) {
nic = new NicProfile(rsStrategy, null, null, null, null);
} else if (nic.getIPv4Address() == null) {
nic.setReservationStrategy(ReservationStrategy.Start);
} else {
nic.setReservationStrategy(ReservationStrategy.Create);
}
if (rsStrategy == ReservationStrategy.Create) {
final String mac = _networkModel.getNextAvailableMacAddressInNetwork(network.getId());
nic.setMacAddress(mac);
}
return nic;
}
Aggregations