use of com.cloud.vm.Nic.ReservationStrategy in project cloudstack by apache.
the class DirectPodBasedNetworkGuru method allocate.
@Override
public NicProfile allocate(Network network, NicProfile nic, VirtualMachineProfile vm) throws InsufficientVirtualNetworkCapacityException, InsufficientAddressCapacityException, ConcurrentOperationException {
DataCenterVO dc = _dcDao.findById(network.getDataCenterId());
ReservationStrategy rsStrategy = ReservationStrategy.Start;
_dcDao.loadDetails(dc);
String dhcpStrategy = dc.getDetail(ZoneConfig.DhcpStrategy.key());
if ("external".equalsIgnoreCase(dhcpStrategy)) {
rsStrategy = ReservationStrategy.Create;
}
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) {
String mac = _networkModel.getNextAvailableMacAddressInNetwork(network.getId());
nic.setMacAddress(mac);
}
return nic;
}
use of com.cloud.vm.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