fixing the issue wherein public network guru failed to get ip address for direct network in case of security groups

This commit is contained in:
abhishek 2010-12-17 16:15:57 -08:00
parent d35fbad6f5
commit a54c5e8949
2 changed files with 3 additions and 1 deletions

View File

@ -138,6 +138,7 @@ public class Networks {
public <T> URI toUri(T value) {
try {
assert(this!=Vlan || value.getClass().isAssignableFrom(Integer.class)) : "Why are you putting non integer into vlan url";
return new URI(scheme + "://" + value.toString());
} catch (URISyntaxException e) {
throw new CloudRuntimeException("Unable to convert to isolation type URI: " + value);

View File

@ -9,6 +9,7 @@ import org.apache.log4j.Logger;
import com.cloud.dc.DataCenter;
import com.cloud.dc.DataCenterVO;
import com.cloud.dc.DataCenter.NetworkType;
import com.cloud.dc.Vlan.VlanType;
import com.cloud.dc.dao.DataCenterDao;
import com.cloud.dc.dao.VlanDao;
@ -71,7 +72,7 @@ public class PublicNetworkGuru extends AdapterBase implements NetworkGuru {
protected void getIp(NicProfile nic, DataCenter dc, VirtualMachineProfile<? extends VirtualMachine> vm, Network network) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException, ConcurrentOperationException {
if (nic.getIp4Address() == null) {
PublicIp ip = _networkMgr.assignPublicIpAddress(dc.getId(), vm.getOwner(), VlanType.VirtualNetwork, null);
PublicIp ip = _networkMgr.assignPublicIpAddress(dc.getId(), vm.getOwner(), dc.getNetworkType().equals(NetworkType.Basic) ? VlanType.DirectAttached : VlanType.VirtualNetwork, null);
nic.setIp4Address(ip.getAddress());
nic.setGateway(ip.getGateway());
nic.setNetmask(ip.getNetmask());