mirror of https://github.com/apache/cloudstack.git
parent
e5710e953a
commit
1376a9e762
|
|
@ -38,6 +38,8 @@ import com.cloud.exception.InvalidParameterValueException;
|
|||
import com.cloud.network.IPAddressVO;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.Network.GuestType;
|
||||
import com.cloud.network.Network.Provider;
|
||||
import com.cloud.network.Network.Service;
|
||||
import com.cloud.network.Network.State;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkProfile;
|
||||
|
|
@ -318,16 +320,29 @@ public class GuestNetworkGuru extends AdapterBase implements NetworkGuru {
|
|||
if (nic.getIp4Address() == null) {
|
||||
nic.setBroadcastUri(network.getBroadcastUri());
|
||||
nic.setIsolationUri(network.getBroadcastUri());
|
||||
nic.setGateway(network.getGateway());
|
||||
|
||||
String guestIp = null;
|
||||
if (network.getSpecifyIpRanges()) {
|
||||
_networkMgr.allocateDirectIp(nic, dc, vm, network, nic.getRequestedIp());
|
||||
} else {
|
||||
//if Vm is router vm, set ip4 to the network gateway
|
||||
//if Vm is router vm and source nat is enabled in the network, set ip4 to the network gateway
|
||||
boolean isGateway = false;
|
||||
if (vm.getVirtualMachine().getType() == VirtualMachine.Type.DomainRouter) {
|
||||
if (network.getVpcId() != null) {
|
||||
if (_networkMgr.isProviderSupportServiceInNetwork(nic.getNetworkId(), Service.SourceNat, Provider.VPCVirtualRouter)) {
|
||||
isGateway = true;
|
||||
}
|
||||
} else {
|
||||
if (_networkMgr.isProviderSupportServiceInNetwork(nic.getNetworkId(), Service.SourceNat, Provider.VirtualRouter)) {
|
||||
isGateway = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isGateway) {
|
||||
guestIp = network.getGateway();
|
||||
} else {
|
||||
nic.setGateway(network.getGateway());
|
||||
guestIp = _networkMgr.acquireGuestIpAddress(network, nic.getRequestedIp());
|
||||
if (guestIp == null) {
|
||||
throw new InsufficientVirtualNetworkCapcityException("Unable to acquire Guest IP" +
|
||||
|
|
|
|||
Loading…
Reference in New Issue