bug 8187: retreive DNS information from DataCenter instead of resetting it for the network. After the DNS is reset, all networks in the zone have to be restarted. Console proxy and secondary vm should be restarted too.

status 8187: resolved fixed
This commit is contained in:
alena 2011-01-26 16:54:47 -08:00
parent 518ea5dbb4
commit 77e89b72ca
16 changed files with 217 additions and 95 deletions

View File

@ -27,6 +27,7 @@ import com.cloud.api.Implementation;
import com.cloud.api.Parameter;
import com.cloud.api.ServerApiException;
import com.cloud.api.response.FirewallRuleResponse;
import com.cloud.api.response.IpForwardingRuleResponse;
import com.cloud.event.EventTypes;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.NetworkRuleConflictException;
@ -96,7 +97,7 @@ public class CreateIpForwardingRuleCmd extends BaseAsyncCreateCmd implements Por
}
if (result) {
PortForwardingRule rule = _entityMgr.findById(PortForwardingRule.class, getEntityId());
FirewallRuleResponse fwResponse = _responseGenerator.createFirewallRuleResponse(rule);
IpForwardingRuleResponse fwResponse = _responseGenerator.createIpForwardingRuleResponse(rule);
fwResponse.setResponseName(getCommandName());
this.setResponseObject(fwResponse);
} else {

View File

@ -192,10 +192,6 @@ public interface Network extends ControlledEntity {
URI getBroadcastUri();
String getDns1();
String getDns2();
GuestIpType getGuestType();
String getDisplayText();

View File

@ -0,0 +1,44 @@
package com.cloud.network;
public class NetworkProfile{
private Network network;
private String dns1;
private String dns2;
public NetworkProfile(Network network, String dns1, String dns2) {
this.network = network;
this.dns1 = dns1;
this.dns2 = dns2;
}
public NetworkProfile() {
}
public Network getNetwork() {
return network;
}
public void setNetwork(Network network){
this.network = network;
}
public String getDns1() {
return dns1;
}
public String getDns2() {
return dns2;
}
public void setDns1(String dns1) {
this.dns1 = dns1;
}
public void setDns2(String dns2) {
this.dns2 = dns2;
}
}

View File

@ -61,4 +61,6 @@ public interface NetworkService {
IpAddress getIp(Ip ip);
NetworkProfile getNetworkProfile(long networkId);
}

View File

@ -9,6 +9,7 @@ import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientAddressCapacityException;
import com.cloud.exception.InsufficientVirtualNetworkCapcityException;
import com.cloud.network.Network;
import com.cloud.network.NetworkProfile;
import com.cloud.offering.NetworkOffering;
import com.cloud.user.Account;
import com.cloud.utils.component.Adapter;
@ -72,6 +73,8 @@ public interface NetworkGuru extends Adapter {
void deallocate(Network network, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm);
void updateNicProfile(NicProfile profile, Network network);
void destroy(Network network, NetworkOffering offering);
/**
@ -82,4 +85,7 @@ public interface NetworkGuru extends Adapter {
* @return
*/
boolean trash(Network network, NetworkOffering offering, Account owner);
void updateNetworkProfile(NetworkProfile networkProfile);
}

View File

@ -205,8 +205,7 @@ public class NicProfile {
this.broadcastUri = broadcastUri;
this.isolationUri = isolationUri;
this.netmask = nic.getNetmask();
this.dns1 = network.getDns1();
this.dns2 = network.getDns2();
if (networkRate != null) {
this.networkRate = networkRate;
}

View File

@ -34,6 +34,7 @@ import com.cloud.network.Network;
import com.cloud.network.Network.Capability;
import com.cloud.network.Network.Service;
import com.cloud.network.NetworkManager;
import com.cloud.network.NetworkProfile;
import com.cloud.network.NetworkRuleConfigVO;
import com.cloud.network.NetworkVO;
import com.cloud.network.Networks.TrafficType;
@ -91,6 +92,7 @@ import com.cloud.utils.net.Ip;
import com.cloud.vm.DomainRouterVO;
import com.cloud.vm.InstanceGroupVO;
import com.cloud.vm.Nic;
import com.cloud.vm.NicProfile;
import com.cloud.vm.UserVmManager;
import com.cloud.vm.UserVmVO;
import com.cloud.vm.VMInstanceVO;
@ -492,12 +494,12 @@ public class ApiDBUtils {
return _storageMgr.volumeOnSharedStoragePool(volume);
}
public static List<? extends Nic> getNics(VirtualMachine vm) {
return _networkMgr.getNics(vm);
public static List<NicProfile> getNics(VirtualMachine vm) {
return _networkMgr.getNicProfiles(vm);
}
public static Network getNetwork(long id) {
return _networkMgr.getNetwork(id);
public static NetworkProfile getNetworkProfile(long networkId) {
return _networkMgr.getNetworkProfile(networkId);
}
public static void synchronizeCommand(Object job, String syncObjType, long syncObjId) {

View File

@ -102,6 +102,7 @@ import com.cloud.network.IpAddress;
import com.cloud.network.Network;
import com.cloud.network.Network.Capability;
import com.cloud.network.Network.Service;
import com.cloud.network.NetworkProfile;
import com.cloud.network.Networks.TrafficType;
import com.cloud.network.RemoteAccessVpn;
import com.cloud.network.VpnUser;
@ -150,7 +151,7 @@ import com.cloud.utils.net.NetUtils;
import com.cloud.vm.ConsoleProxyVO;
import com.cloud.vm.InstanceGroup;
import com.cloud.vm.InstanceGroupVO;
import com.cloud.vm.Nic;
import com.cloud.vm.NicProfile;
import com.cloud.vm.SecondaryStorageVmVO;
import com.cloud.vm.SystemVm;
import com.cloud.vm.UserVmVO;
@ -1104,27 +1105,27 @@ public class ApiResponseHelper implements ResponseGenerator {
// network groups
userVmResponse.setSecurityGroupList(ApiDBUtils.getNetworkGroupsNamesForVm(userVm.getId()));
List<? extends Nic> nics = ApiDBUtils.getNics(userVm);
List<NicProfile> nicProfiles = ApiDBUtils.getNics(userVm);
List<NicResponse> nicResponses = new ArrayList<NicResponse>();
for (Nic singleNic : nics) {
for (NicProfile singleNicProfile : nicProfiles) {
NicResponse nicResponse = new NicResponse();
nicResponse.setId(singleNic.getId());
nicResponse.setIpaddress(singleNic.getIp4Address());
nicResponse.setGateway(singleNic.getGateway());
nicResponse.setNetmask(singleNic.getNetmask());
nicResponse.setNetworkid(singleNic.getNetworkId());
nicResponse.setId(singleNicProfile.getId());
nicResponse.setIpaddress(singleNicProfile.getIp4Address());
nicResponse.setGateway(singleNicProfile.getGateway());
nicResponse.setNetmask(singleNicProfile.getNetmask());
nicResponse.setNetworkid(singleNicProfile.getNetworkId());
if (acct.getType() == Account.ACCOUNT_TYPE_ADMIN) {
if (singleNic.getBroadcastUri() != null) {
nicResponse.setBroadcastUri(singleNic.getBroadcastUri().toString());
if (singleNicProfile.getBroadCastUri() != null) {
nicResponse.setBroadcastUri(singleNicProfile.getBroadCastUri().toString());
}
if (singleNic.getIsolationUri() != null) {
nicResponse.setIsolationUri(singleNic.getIsolationUri().toString());
if (singleNicProfile.getIsolationUri() != null) {
nicResponse.setIsolationUri(singleNicProfile.getIsolationUri().toString());
}
}
Network network = ApiDBUtils.findNetworkById(singleNic.getNetworkId());
Network network = ApiDBUtils.findNetworkById(singleNicProfile.getNetworkId());
nicResponse.setTrafficType(network.getTrafficType().toString());
nicResponse.setType(network.getGuestType().toString());
nicResponse.setIsDefault(singleNic.isDefaultNic());
nicResponse.setIsDefault(singleNicProfile.isDefaultNic());
nicResponse.setObjectName("nic");
@ -1159,23 +1160,23 @@ public class ApiResponseHelper implements ResponseGenerator {
routerResponse.setDomainName(ApiDBUtils.findDomainById(accountTemp.getDomainId()).getName());
}
List<? extends Nic> nics = ApiDBUtils.getNics(router);
for (Nic singleNic : nics) {
Network network = ApiDBUtils.findNetworkById(singleNic.getNetworkId());
List<NicProfile> nicProfiles = ApiDBUtils.getNics(router);
for (NicProfile singleNicProfile : nicProfiles) {
Network network = ApiDBUtils.findNetworkById(singleNicProfile.getNetworkId());
if (network != null) {
if (network.getTrafficType() == TrafficType.Public) {
routerResponse.setPublicIp(singleNic.getIp4Address());
routerResponse.setPublicMacAddress(singleNic.getMacAddress());
routerResponse.setPublicNetmask(singleNic.getNetmask());
routerResponse.setGateway(singleNic.getGateway());
routerResponse.setPublicIp(singleNicProfile.getIp4Address());
routerResponse.setPublicMacAddress(singleNicProfile.getMacAddress());
routerResponse.setPublicNetmask(singleNicProfile.getNetmask());
routerResponse.setGateway(singleNicProfile.getGateway());
} else if (network.getTrafficType() == TrafficType.Control) {
routerResponse.setPrivateIp(singleNic.getIp4Address());
routerResponse.setPrivateMacAddress(singleNic.getMacAddress());
routerResponse.setPrivateNetmask(singleNic.getNetmask());
routerResponse.setPrivateIp(singleNicProfile.getIp4Address());
routerResponse.setPrivateMacAddress(singleNicProfile.getMacAddress());
routerResponse.setPrivateNetmask(singleNicProfile.getNetmask());
} else if (network.getTrafficType() == TrafficType.Guest) {
routerResponse.setGuestIpAddress(singleNic.getIp4Address());
routerResponse.setGuestMacAddress(singleNic.getMacAddress());
routerResponse.setGuestNetmask(singleNic.getNetmask());
routerResponse.setGuestIpAddress(singleNicProfile.getIp4Address());
routerResponse.setGuestMacAddress(singleNicProfile.getMacAddress());
routerResponse.setGuestNetmask(singleNicProfile.getNetmask());
}
}
}
@ -1238,22 +1239,22 @@ public class ApiResponseHelper implements ResponseGenerator {
vmResponse.setDns2(zone.getDns2());
}
List<? extends Nic> nics = ApiDBUtils.getNics(systemVM);
for (Nic singleNic : nics) {
Network network = ApiDBUtils.findNetworkById(singleNic.getNetworkId());
List<NicProfile> nicProfiles = ApiDBUtils.getNics(systemVM);
for (NicProfile singleNicProfile : nicProfiles) {
Network network = ApiDBUtils.findNetworkById(singleNicProfile.getNetworkId());
if (network != null) {
TrafficType trafficType = TrafficType.Public;
if(zone.getNetworkType() == NetworkType.Basic) {
trafficType = TrafficType.Guest;
}
if (network.getTrafficType() == trafficType) {
vmResponse.setPublicIp(singleNic.getIp4Address());
vmResponse.setPublicMacAddress(singleNic.getMacAddress());
vmResponse.setPublicNetmask(singleNic.getNetmask());
vmResponse.setPublicIp(singleNicProfile.getIp4Address());
vmResponse.setPublicMacAddress(singleNicProfile.getMacAddress());
vmResponse.setPublicNetmask(singleNicProfile.getNetmask());
} else if (network.getTrafficType() == TrafficType.Control) {
vmResponse.setPrivateIp(singleNic.getIp4Address());
vmResponse.setPrivateMacAddress(singleNic.getMacAddress());
vmResponse.setPrivateNetmask(singleNic.getNetmask());
vmResponse.setPrivateIp(singleNicProfile.getIp4Address());
vmResponse.setPrivateMacAddress(singleNicProfile.getMacAddress());
vmResponse.setPrivateNetmask(singleNicProfile.getNetmask());
}
}
}
@ -2237,6 +2238,8 @@ public class ApiResponseHelper implements ResponseGenerator {
@Override
public NetworkResponse createNetworkResponse(Network network) {
NetworkProfile profile = ApiDBUtils.getNetworkProfile(network.getId());
network = profile.getNetwork();
NetworkResponse response = new NetworkResponse();
response.setId(network.getId());
response.setName(network.getName());
@ -2285,10 +2288,11 @@ public class ApiResponseHelper implements ResponseGenerator {
response.setIsDefault(network.isDefault());
response.setState(network.getState().toString());
response.setRelated(network.getRelated());
response.setDns1(network.getDns1());
response.setDns2(network.getDns2());
response.setNetworkDomain(network.getNetworkDomain());
response.setDns1(profile.getDns1());
response.setDns2(profile.getDns2());
//populate capability
Map<Service, Map<Capability, String>> serviceCapabilitiesMap = ApiDBUtils.getZoneCapabilities(network.getDataCenterId());
List<ServiceResponse> serviceResponses = new ArrayList<ServiceResponse>();

View File

@ -1066,10 +1066,6 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
_zoneDao.addVnet(zone.getId(), begin, end);
}
if(dnsUpdate){
// FIXME: Need to update dns in network rather than in the vms.
}
return zone;
}

View File

@ -112,6 +112,8 @@ public interface NetworkManager extends NetworkService {
void expungeNics(VirtualMachineProfile<? extends VMInstanceVO> vm);
List<? extends Nic> getNics(VirtualMachine vm);
List<NicProfile> getNicProfiles(VirtualMachine vm);
List<AccountVO> getAccountsUsingNetwork(long configurationId);
AccountVO getNetworkOwner(long configurationId);

View File

@ -911,12 +911,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
to.setIp(nic.getIp4Address());
to.setNetmask(nic.getNetmask());
to.setMac(nic.getMacAddress());
if (config.getDns1() != null) {
to.setDns1(config.getDns1());
}
if (config.getDns2() != null) {
to.setDns2(config.getDns2());
}
to.setDns1(profile.getDns1());
to.setDns2(profile.getDns2());
if (nic.getGateway() != null) {
to.setGateway(nic.getGateway());
} else {
@ -969,8 +965,6 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
network.setCidr(result.getCidr());
network.setBroadcastUri(result.getBroadcastUri());
network.setGateway(result.getGateway());
network.setDns1(result.getDns1());
network.setDns2(result.getDns2());
network.setMode(result.getMode());
_networksDao.update(networkId, network);
@ -1051,7 +1045,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
}
element.prepare(network, profile, vmProfile, dest, context);
}
concierge.updateNicProfile(profile, network);
vmProfile.addNic(profile);
}
}
@ -1060,12 +1054,13 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
public <T extends VMInstanceVO> void prepareNicForMigration(VirtualMachineProfile<T> vm, DeployDestination dest) {
List<NicVO> nics = _nicDao.listBy(vm.getId());
for (NicVO nic : nics) {
Network network = _networksDao.findById(nic.getNetworkId());
NetworkVO network = _networksDao.findById(nic.getNetworkId());
NetworkOffering no = _configMgr.getNetworkOffering(network.getNetworkOfferingId());
Integer networkRate = _configMgr.getNetworkRate(no.getId());
NetworkGuru concierge = _networkGurus.get(network.getGuruName());
NicProfile profile = new NicProfile(nic, network, nic.getBroadcastUri(), nic.getIsolationUri(), networkRate);
concierge.updateNicProfile(profile, network);
vm.addNic(profile);
}
}
@ -1110,6 +1105,27 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
}
return null;
}
@Override
public List<NicProfile> getNicProfiles(VirtualMachine vm) {
List<NicVO> nics = _nicDao.listBy(vm.getId());
List<NicProfile> profiles = new ArrayList<NicProfile>();
if (nics != null) {
for (Nic nic : nics) {
NetworkVO network = _networksDao.findById(nic.getNetworkId());
NetworkOffering no = _configMgr.getNetworkOffering(network.getNetworkOfferingId());
Integer networkRate = _configMgr.getNetworkRate(no.getId());
NetworkGuru concierge = _networkGurus.get(network.getGuruName());
NicProfile profile = new NicProfile(nic, network, nic.getBroadcastUri(), nic.getIsolationUri(), networkRate);
concierge.updateNicProfile(profile, network);
profiles.add(profile);
}
}
return profiles;
}
@Override
@DB
@ -1984,4 +2000,14 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
public IpAddress getIp(Ip ip) {
return _ipAddressDao.findById(ip);
}
@Override
public NetworkProfile getNetworkProfile(long networkId) {
NetworkVO network = _networksDao.findById(networkId);
NetworkGuru concierge = _networkGurus.get(network.getGuruName());
NetworkProfile profile = new NetworkProfile(network, null, null);
concierge.updateNetworkProfile(profile);
return profile;
}
}

View File

@ -164,8 +164,6 @@ public class NetworkVO implements Network {
public NetworkVO(long id, Network that, long offeringId, long dataCenterId, String guruName, long domainId, long accountId, long related, String name, String displayText, Boolean isShared, boolean isDefault) {
this(id, that.getTrafficType(), that.getGuestType(), that.getMode(), that.getBroadcastDomainType(), offeringId, dataCenterId, domainId, accountId, related, name, displayText, isShared, isDefault);
this.gateway = that.getGateway();
this.dns1 = that.getDns1();
this.dns2 = that.getDns2();
this.cidr = that.getCidr();
this.broadcastUri = that.getBroadcastUri();
this.broadcastDomainType = that.getBroadcastDomainType();
@ -340,7 +338,6 @@ public class NetworkVO implements Network {
return dataCenterId;
}
@Override
public String getDns1() {
return dns1;
}
@ -349,7 +346,6 @@ public class NetworkVO implements Network {
this.dns1 = dns;
}
@Override
public String getDns2() {
return dns2;
}

View File

@ -36,6 +36,7 @@ import com.cloud.network.Network;
import com.cloud.network.Network.GuestIpType;
import com.cloud.network.Network.State;
import com.cloud.network.NetworkManager;
import com.cloud.network.NetworkProfile;
import com.cloud.network.NetworkVO;
import com.cloud.network.Networks.AddressFormat;
import com.cloud.network.Networks.BroadcastDomainType;
@ -49,6 +50,7 @@ import com.cloud.offerings.dao.NetworkOfferingDao;
import com.cloud.user.Account;
import com.cloud.utils.component.AdapterBase;
import com.cloud.utils.component.Inject;
import com.cloud.vm.Nic;
import com.cloud.vm.Nic.ReservationStrategy;
import com.cloud.vm.NicProfile;
import com.cloud.vm.ReservationContext;
@ -110,9 +112,6 @@ public class DirectNetworkGuru extends AdapterBase implements NetworkGuru {
config.setBroadcastDomainType(userSpecified.getBroadcastDomainType());
}
}
config.setDns1(dc.getDns1());
config.setDns2(dc.getDns2());
return config;
}
@ -137,6 +136,15 @@ public class DirectNetworkGuru extends AdapterBase implements NetworkGuru {
nic.setDns1(dc.getDns1());
nic.setDns2(dc.getDns2());
}
@Override
public void updateNicProfile(NicProfile profile, Network network) {
DataCenter dc = _dcDao.findById(network.getDataCenterId());
if (profile != null) {
profile.setDns1(dc.getDns1());
profile.setDns2(dc.getDns2());
}
}
@Override
public NicProfile allocate(Network network, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm) throws InsufficientVirtualNetworkCapcityException,
@ -190,4 +198,11 @@ public class DirectNetworkGuru extends AdapterBase implements NetworkGuru {
public boolean trash(Network network, NetworkOffering offering, Account owner) {
return true;
}
@Override
public void updateNetworkProfile(NetworkProfile networkProfile) {
DataCenter dc = _dcDao.findById(networkProfile.getNetwork().getDataCenterId());
networkProfile.setDns1(dc.getDns1());
networkProfile.setDns2(dc.getDns2());
}
}

View File

@ -39,11 +39,13 @@ import com.cloud.network.Network;
import com.cloud.network.Network.GuestIpType;
import com.cloud.network.Network.State;
import com.cloud.network.NetworkManager;
import com.cloud.network.NetworkProfile;
import com.cloud.network.NetworkVO;
import com.cloud.network.Networks.AddressFormat;
import com.cloud.network.Networks.BroadcastDomainType;
import com.cloud.network.Networks.Mode;
import com.cloud.network.Networks.TrafficType;
import com.cloud.network.dao.NetworkDao;
import com.cloud.offering.NetworkOffering;
import com.cloud.user.Account;
import com.cloud.utils.component.AdapterBase;
@ -64,6 +66,7 @@ public class GuestNetworkGuru extends AdapterBase implements NetworkGuru {
@Inject protected DataCenterDao _dcDao;
@Inject protected VlanDao _vlanDao;
@Inject protected NicDao _nicDao;
@Inject protected NetworkDao _networkDao;
String _defaultGateway;
String _defaultCidr;
@ -110,9 +113,6 @@ public class GuestNetworkGuru extends AdapterBase implements NetworkGuru {
}
}
network.setDns1(dc.getDns1());
network.setDns2(dc.getDns2());
if (userSpecified.getBroadcastUri() != null) {
network.setBroadcastUri(userSpecified.getBroadcastUri());
network.setState(State.Setup);
@ -125,9 +125,7 @@ public class GuestNetworkGuru extends AdapterBase implements NetworkGuru {
String guestNetworkCidr = dc.getGuestNetworkCidr();
String[] cidrTuple = guestNetworkCidr.split("\\/");
network.setGateway(NetUtils.getIpRangeStartIpFromCidr(cidrTuple[0], Long.parseLong(cidrTuple[1])));
network.setCidr(guestNetworkCidr);
network.setDns1(dc.getDns1());
network.setDns2(dc.getDns2());
network.setCidr(guestNetworkCidr);;
}
return network;
@ -161,35 +159,31 @@ public class GuestNetworkGuru extends AdapterBase implements NetworkGuru {
implemented.setCidr(network.getCidr());
}
if (network.getDns1() != null) {
implemented.setDns1(network.getDns1());
}
if (network.getDns2() != null) {
implemented.setDns2(network.getDns2());
}
return implemented;
}
@Override
public NicProfile allocate(Network network, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm)
throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException {
assert (network.getTrafficType() == TrafficType.Guest) : "Look at my name! Why are you calling me when the traffic type is : " + network.getTrafficType();
if (nic == null) {
nic = new NicProfile(ReservationStrategy.Start, null, null, null, null);
}
DataCenter dc = _dcDao.findById(network.getDataCenterId());
if (nic.getIp4Address() == null){
nic.setBroadcastUri(network.getBroadcastUri());
nic.setIsolationUri(network.getBroadcastUri());
nic.setGateway(network.getGateway());
nic.setIp4Address(acquireGuestIpAddress(network));
nic.setNetmask(NetUtils.cidr2Netmask(network.getCidr()));
nic.setDns1(network.getDns1());
nic.setDns2(network.getDns2());
nic.setFormat(AddressFormat.Ip4);
nic.setDns1(dc.getDns1());
nic.setDns2(dc.getDns2());
}
nic.setStrategy(ReservationStrategy.Start);
@ -204,6 +198,15 @@ public class GuestNetworkGuru extends AdapterBase implements NetworkGuru {
return nic;
}
@Override
public void updateNicProfile(NicProfile profile, Network network) {
DataCenter dc = _dcDao.findById(network.getDataCenterId());
if (profile != null) {
profile.setDns1(dc.getDns1());
profile.setDns2(dc.getDns2());
}
}
@DB
protected String acquireGuestIpAddress(Network network) {
List<String> ips = _nicDao.listIpAddressInNetwork(network.getId());
@ -249,4 +252,11 @@ public class GuestNetworkGuru extends AdapterBase implements NetworkGuru {
public boolean trash(Network network, NetworkOffering offering, Account owner) {
return true;
}
@Override
public void updateNetworkProfile(NetworkProfile networkProfile) {
DataCenter dc = _dcDao.findById(networkProfile.getNetwork().getDataCenterId());
networkProfile.setDns1(dc.getDns1());
networkProfile.setDns2(dc.getDns2());
}
}

View File

@ -9,7 +9,6 @@ import javax.ejb.Local;
import org.apache.log4j.Logger;
import com.cloud.dc.DataCenterVO;
import com.cloud.dc.Pod;
import com.cloud.dc.dao.DataCenterDao;
import com.cloud.deploy.DeployDestination;
@ -18,6 +17,7 @@ import com.cloud.exception.InsufficientAddressCapacityException;
import com.cloud.exception.InsufficientVirtualNetworkCapcityException;
import com.cloud.network.Network;
import com.cloud.network.NetworkManager;
import com.cloud.network.NetworkProfile;
import com.cloud.network.NetworkVO;
import com.cloud.network.Networks.AddressFormat;
import com.cloud.network.Networks.BroadcastDomainType;
@ -51,9 +51,6 @@ public class PodBasedNetworkGuru extends AdapterBase implements NetworkGuru {
}
NetworkVO config = new NetworkVO(type, null, Mode.Static, BroadcastDomainType.Native, offering.getId(), plan.getDataCenterId(), Network.State.Setup);
DataCenterVO dc = _dcDao.findById(plan.getDataCenterId());
config.setDns1(dc.getDns1());
config.setDns2(dc.getDns2());
return config;
}
@ -103,7 +100,16 @@ public class PodBasedNetworkGuru extends AdapterBase implements NetworkGuru {
s_logger.debug("Allocated a nic " + nic + " for " + vm);
}
@Override
public void updateNicProfile(NicProfile profile, Network network) {
}
@Override
public void updateNetworkProfile(NetworkProfile networkProfile) {
}
@Override
public boolean release(NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm, String reservationId) {
_dcDao.releasePrivateIpAddress(nic.getId(), nic.getReservationId());

View File

@ -20,6 +20,7 @@ import com.cloud.exception.InsufficientVirtualNetworkCapcityException;
import com.cloud.network.Network;
import com.cloud.network.Network.State;
import com.cloud.network.NetworkManager;
import com.cloud.network.NetworkProfile;
import com.cloud.network.NetworkVO;
import com.cloud.network.Networks.AddressFormat;
import com.cloud.network.Networks.BroadcastDomainType;
@ -70,8 +71,6 @@ public class PublicNetworkGuru extends AdapterBase implements NetworkGuru {
if (offering.getTrafficType() == TrafficType.Public) {
NetworkVO ntwk = new NetworkVO(offering.getTrafficType(), null, Mode.Static, BroadcastDomainType.Vlan, offering.getId(), plan.getDataCenterId(), State.Setup);
ntwk.setDns1(dc.getDns1());
ntwk.setDns2(dc.getDns2());
return ntwk;
} else {
return null;
@ -95,9 +94,20 @@ public class PublicNetworkGuru extends AdapterBase implements NetworkGuru {
nic.setReservationId(String.valueOf(ip.getVlanTag()));
nic.setMacAddress(ip.getMacAddress());
}
nic.setDns1(dc.getDns1());
nic.setDns2(dc.getDns2());
}
@Override
public void updateNicProfile(NicProfile profile, Network network) {
DataCenter dc = _dcDao.findById(network.getDataCenterId());
if (profile != null) {
profile.setDns1(dc.getDns1());
profile.setDns2(dc.getDns2());
}
}
@Override
public NicProfile allocate(Network network, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm) throws InsufficientVirtualNetworkCapcityException,
@ -155,4 +165,11 @@ public class PublicNetworkGuru extends AdapterBase implements NetworkGuru {
public boolean trash(Network network, NetworkOffering offering, Account owner) {
return true;
}
@Override
public void updateNetworkProfile(NetworkProfile networkProfile) {
DataCenter dc = _dcDao.findById(networkProfile.getNetwork().getDataCenterId());
networkProfile.setDns1(dc.getDns1());
networkProfile.setDns2(dc.getDns2());
}
}