/** * Allocate the NicProfile object. * At this point the UUID of the nic is not yet known. We defer allocating the VMI and instance-ip objects * until the reserve API is called because of this reason. */ @Override public NicProfile allocate(Network network, NicProfile profile, VirtualMachineProfile vm) throws InsufficientVirtualNetworkCapacityException, InsufficientAddressCapacityException, ConcurrentOperationException { s_logger.debug("allocate NicProfile on " + network.getName()); if (profile != null && profile.getRequestedIPv4() != null) { throw new CloudRuntimeException("Does not support custom ip allocation at this time: " + profile); } if (profile == null) { profile = new NicProfile(ReservationStrategy.Create, null, null, null, null); } profile.setReservationStrategy(ReservationStrategy.Start); URI broadcastUri = null; try { broadcastUri = new URI("vlan://untagged"); } catch (Exception e) { s_logger.warn("unable to instantiate broadcast URI: " + e); } profile.setBroadcastUri(broadcastUri); return profile; }
@Override public NicProfile allocate(Network network, NicProfile nic, VirtualMachineProfile vm) throws InsufficientVirtualNetworkCapacityException, InsufficientAddressCapacityException, ConcurrentOperationException { DataCenter dc = _dcDao.findById(network.getDataCenterId()); 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(ReservationStrategy.Create, null, null, null, null); } getIp(nic, dc, vm, network); if (nic.getIPv4Address() == null) { nic.setReservationStrategy(ReservationStrategy.Start); } else if (vm.getVirtualMachine().getType() == VirtualMachine.Type.DomainRouter) { nic.setReservationStrategy(ReservationStrategy.Managed); } else { nic.setReservationStrategy(ReservationStrategy.Create); } return nic; }
@Override public void reserve(NicProfile nic, Network network, VirtualMachineProfile vm, DeployDestination dest, ReservationContext context) throws InsufficientVirtualNetworkCapacityException, InsufficientAddressCapacityException, ConcurrentOperationException { if (nic.getIPv4Address() == null && nic.getIPv6Address() == null) { allocateDirectIp(nic, network, vm, dest.getDataCenter(), null, null); nic.setReservationStrategy(ReservationStrategy.Create); } }
@Override public void reserve(NicProfile nic, Network network, VirtualMachineProfile vm, DeployDestination dest, ReservationContext context) throws InsufficientVirtualNetworkCapacityException, InsufficientAddressCapacityException { if (nic.getIPv4Address() == null) { getIp(nic, _entityMgr.findById(DataCenter.class, network.getDataCenterId()), network); nic.setReservationStrategy(ReservationStrategy.Create); } }
@Override public NicProfile allocate(Network network, NicProfile nic, VirtualMachineProfile vm) throws InsufficientVirtualNetworkCapacityException, InsufficientAddressCapacityException { DataCenter dc = _entityMgr.findById(DataCenter.class, network.getDataCenterId()); NetworkOffering offering = _entityMgr.findById(NetworkOffering.class, network.getNetworkOfferingId()); if (!canHandle(offering, dc)) { return null; } if (nic == null) { nic = new NicProfile(ReservationStrategy.Create, null, null, null, null); } getIp(nic, dc, network); if (nic.getIPv4Address() == null) { nic.setReservationStrategy(ReservationStrategy.Start); } else { nic.setReservationStrategy(ReservationStrategy.Create); } return nic; }
@Override public NicProfile allocate(Network config, NicProfile nic, VirtualMachineProfile vm) throws InsufficientVirtualNetworkCapacityException, InsufficientAddressCapacityException { TrafficType trafficType = config.getTrafficType(); assert trafficType == TrafficType.Management || trafficType == TrafficType.Storage : "Well, I can't take care of this config now can I? " + config; if (nic != null) { if (nic.getRequestedIPv4() != null) { throw new CloudRuntimeException("Does not support custom ip allocation at this time: " + nic); } nic.setReservationStrategy(nic.getIPv4Address() != null ? ReservationStrategy.Create : ReservationStrategy.Start); } else { nic = new NicProfile(ReservationStrategy.Start, null, null, null, null); } return nic; }
@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; }
@Override public NicProfile allocate(Network network, NicProfile nic, VirtualMachineProfile vm) throws InsufficientVirtualNetworkCapacityException, InsufficientAddressCapacityException, ConcurrentOperationException { DataCenter dc = _dcDao.findById(network.getDataCenterId()); if (nic == null) { nic = new NicProfile(ReservationStrategy.Create, null, null, null, null); } else if (nic.getIPv4Address() == null && nic.getIPv6Address() == null) { nic.setReservationStrategy(ReservationStrategy.Start); } else { nic.setReservationStrategy(ReservationStrategy.Create); } allocateDirectIp(nic, network, vm, dc, nic.getRequestedIPv4(), nic.getRequestedIPv6()); nic.setReservationStrategy(ReservationStrategy.Create); if (nic.getMacAddress() == null) { nic.setMacAddress(_networkModel.getNextAvailableMacAddressInNetwork(network.getId())); if (nic.getMacAddress() == null) { throw new InsufficientAddressCapacityException("Unable to allocate more mac addresses", Network.class, network.getId()); } } return nic; }
@Override public NicProfile allocate(Network config, NicProfile nic, VirtualMachineProfile vm) throws InsufficientVirtualNetworkCapacityException, InsufficientAddressCapacityException { if (_networkModel.networkIsConfiguredForExternalNetworking(config.getDataCenterId(), config.getId()) && nic != null && nic.getRequestedIPv4() != null) { throw new CloudRuntimeException("Does not support custom ip allocation at this time: " + nic); } NicProfile profile = super.allocate(config, nic, vm); if (_networkModel.networkIsConfiguredForExternalNetworking(config.getDataCenterId(), config.getId())) { profile.setReservationStrategy(ReservationStrategy.Start); /* We won't clear IP address, because router may set gateway as it IP, and it would be updated properly later */ //profile.setIp4Address(null); profile.setIPv4Gateway(null); profile.setIPv4Netmask(null); } return profile; }
nic.setReservationStrategy(ReservationStrategy.Start);