|
30 | 30 | import com.cloud.network.IpAddressManager; |
31 | 31 | import com.cloud.network.Network; |
32 | 32 | import com.cloud.network.Network.GuestType; |
| 33 | +import com.cloud.network.Network.Provider; |
| 34 | +import com.cloud.network.Network.Service; |
33 | 35 | import com.cloud.network.Network.State; |
34 | 36 | import com.cloud.network.Networks.BroadcastDomainType; |
35 | 37 | import com.cloud.network.PhysicalNetwork; |
|
51 | 53 | import com.cloud.utils.exception.CloudRuntimeException; |
52 | 54 | import com.cloud.utils.net.Ip; |
53 | 55 | import com.cloud.utils.net.NetUtils; |
| 56 | +import com.cloud.vm.Nic; |
54 | 57 | import com.cloud.vm.Nic.ReservationStrategy; |
55 | 58 | import com.cloud.vm.NicProfile; |
56 | 59 | import com.cloud.vm.NicVO; |
57 | 60 | import com.cloud.vm.ReservationContext; |
| 61 | +import com.cloud.vm.VirtualMachine; |
58 | 62 | import com.cloud.vm.VirtualMachineProfile; |
59 | 63 | import org.apache.cloudstack.context.CallContext; |
60 | 64 | import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService; |
@@ -261,6 +265,17 @@ public NicProfile allocate(Network config, NicProfile nic, VirtualMachineProfile |
261 | 265 | profile.setIPv4Netmask(null); |
262 | 266 | } |
263 | 267 |
|
| 268 | + if (config.getVpcId() == null && vm.getType() == VirtualMachine.Type.DomainRouter) { |
| 269 | + boolean isPublicNetwork = _networkModel.isProviderSupportServiceInNetwork(config.getId(), Service.SourceNat, Provider.VirtualRouter); |
| 270 | + if (!isPublicNetwork) { |
| 271 | + Nic placeholderNic = _networkModel.getPlaceholderNicForRouter(config, null); |
| 272 | + if (placeholderNic == null) { |
| 273 | + s_logger.debug("Saving placeholder nic with ip4 address " + profile.getIPv4Address() + |
| 274 | + " and ipv6 address " + profile.getIPv6Address() + " for the network " + config); |
| 275 | + _networkMgr.savePlaceholderNic(config, profile.getIPv4Address(), profile.getIPv6Address(), VirtualMachine.Type.DomainRouter); |
| 276 | + } |
| 277 | + } |
| 278 | + } |
264 | 279 | return profile; |
265 | 280 | } |
266 | 281 |
|
|
0 commit comments