Skip to content

Commit 77e89b7

Browse files
committed
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
1 parent 518ea5d commit 77e89b7

16 files changed

Lines changed: 217 additions & 95 deletions

api/src/com/cloud/api/commands/CreateIpForwardingRuleCmd.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import com.cloud.api.Parameter;
2828
import com.cloud.api.ServerApiException;
2929
import com.cloud.api.response.FirewallRuleResponse;
30+
import com.cloud.api.response.IpForwardingRuleResponse;
3031
import com.cloud.event.EventTypes;
3132
import com.cloud.exception.InvalidParameterValueException;
3233
import com.cloud.exception.NetworkRuleConflictException;
@@ -96,7 +97,7 @@ public void execute(){
9697
}
9798
if (result) {
9899
PortForwardingRule rule = _entityMgr.findById(PortForwardingRule.class, getEntityId());
99-
FirewallRuleResponse fwResponse = _responseGenerator.createFirewallRuleResponse(rule);
100+
IpForwardingRuleResponse fwResponse = _responseGenerator.createIpForwardingRuleResponse(rule);
100101
fwResponse.setResponseName(getCommandName());
101102
this.setResponseObject(fwResponse);
102103
} else {

api/src/com/cloud/network/Network.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,6 @@ private State(String description) {
192192

193193
URI getBroadcastUri();
194194

195-
String getDns1();
196-
197-
String getDns2();
198-
199195
GuestIpType getGuestType();
200196

201197
String getDisplayText();
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package com.cloud.network;
2+
3+
4+
public class NetworkProfile{
5+
private Network network;
6+
private String dns1;
7+
private String dns2;
8+
9+
public NetworkProfile(Network network, String dns1, String dns2) {
10+
this.network = network;
11+
this.dns1 = dns1;
12+
this.dns2 = dns2;
13+
}
14+
15+
public NetworkProfile() {
16+
17+
}
18+
19+
public Network getNetwork() {
20+
return network;
21+
}
22+
23+
public void setNetwork(Network network){
24+
this.network = network;
25+
}
26+
27+
public String getDns1() {
28+
return dns1;
29+
}
30+
31+
public String getDns2() {
32+
return dns2;
33+
}
34+
35+
public void setDns1(String dns1) {
36+
this.dns1 = dns1;
37+
}
38+
39+
public void setDns2(String dns2) {
40+
this.dns2 = dns2;
41+
}
42+
43+
44+
}

api/src/com/cloud/network/NetworkService.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,6 @@ public interface NetworkService {
6161

6262
IpAddress getIp(Ip ip);
6363

64+
NetworkProfile getNetworkProfile(long networkId);
65+
6466
}

api/src/com/cloud/network/guru/NetworkGuru.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import com.cloud.exception.InsufficientAddressCapacityException;
1010
import com.cloud.exception.InsufficientVirtualNetworkCapcityException;
1111
import com.cloud.network.Network;
12+
import com.cloud.network.NetworkProfile;
1213
import com.cloud.offering.NetworkOffering;
1314
import com.cloud.user.Account;
1415
import com.cloud.utils.component.Adapter;
@@ -72,6 +73,8 @@ public interface NetworkGuru extends Adapter {
7273

7374
void deallocate(Network network, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm);
7475

76+
void updateNicProfile(NicProfile profile, Network network);
77+
7578
void destroy(Network network, NetworkOffering offering);
7679

7780
/**
@@ -82,4 +85,7 @@ public interface NetworkGuru extends Adapter {
8285
* @return
8386
*/
8487
boolean trash(Network network, NetworkOffering offering, Account owner);
88+
89+
void updateNetworkProfile(NetworkProfile networkProfile);
90+
8591
}

api/src/com/cloud/vm/NicProfile.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,7 @@ public NicProfile(Nic nic, Network network, URI broadcastUri, URI isolationUri,
205205
this.broadcastUri = broadcastUri;
206206
this.isolationUri = isolationUri;
207207
this.netmask = nic.getNetmask();
208-
this.dns1 = network.getDns1();
209-
this.dns2 = network.getDns2();
208+
210209
if (networkRate != null) {
211210
this.networkRate = networkRate;
212211
}

server/src/com/cloud/api/ApiDBUtils.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import com.cloud.network.Network.Capability;
3535
import com.cloud.network.Network.Service;
3636
import com.cloud.network.NetworkManager;
37+
import com.cloud.network.NetworkProfile;
3738
import com.cloud.network.NetworkRuleConfigVO;
3839
import com.cloud.network.NetworkVO;
3940
import com.cloud.network.Networks.TrafficType;
@@ -91,6 +92,7 @@
9192
import com.cloud.vm.DomainRouterVO;
9293
import com.cloud.vm.InstanceGroupVO;
9394
import com.cloud.vm.Nic;
95+
import com.cloud.vm.NicProfile;
9496
import com.cloud.vm.UserVmManager;
9597
import com.cloud.vm.UserVmVO;
9698
import com.cloud.vm.VMInstanceVO;
@@ -492,12 +494,12 @@ public static boolean volumeIsOnSharedStorage(long volumeId) throws InvalidParam
492494
return _storageMgr.volumeOnSharedStoragePool(volume);
493495
}
494496

495-
public static List<? extends Nic> getNics(VirtualMachine vm) {
496-
return _networkMgr.getNics(vm);
497+
public static List<NicProfile> getNics(VirtualMachine vm) {
498+
return _networkMgr.getNicProfiles(vm);
497499
}
498500

499-
public static Network getNetwork(long id) {
500-
return _networkMgr.getNetwork(id);
501+
public static NetworkProfile getNetworkProfile(long networkId) {
502+
return _networkMgr.getNetworkProfile(networkId);
501503
}
502504

503505
public static void synchronizeCommand(Object job, String syncObjType, long syncObjId) {

server/src/com/cloud/api/ApiResponseHelper.java

Lines changed: 42 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@
102102
import com.cloud.network.Network;
103103
import com.cloud.network.Network.Capability;
104104
import com.cloud.network.Network.Service;
105+
import com.cloud.network.NetworkProfile;
105106
import com.cloud.network.Networks.TrafficType;
106107
import com.cloud.network.RemoteAccessVpn;
107108
import com.cloud.network.VpnUser;
@@ -150,7 +151,7 @@
150151
import com.cloud.vm.ConsoleProxyVO;
151152
import com.cloud.vm.InstanceGroup;
152153
import com.cloud.vm.InstanceGroupVO;
153-
import com.cloud.vm.Nic;
154+
import com.cloud.vm.NicProfile;
154155
import com.cloud.vm.SecondaryStorageVmVO;
155156
import com.cloud.vm.SystemVm;
156157
import com.cloud.vm.UserVmVO;
@@ -1104,27 +1105,27 @@ public UserVmResponse createUserVmResponse(UserVm userVm) {
11041105
// network groups
11051106
userVmResponse.setSecurityGroupList(ApiDBUtils.getNetworkGroupsNamesForVm(userVm.getId()));
11061107

1107-
List<? extends Nic> nics = ApiDBUtils.getNics(userVm);
1108+
List<NicProfile> nicProfiles = ApiDBUtils.getNics(userVm);
11081109
List<NicResponse> nicResponses = new ArrayList<NicResponse>();
1109-
for (Nic singleNic : nics) {
1110+
for (NicProfile singleNicProfile : nicProfiles) {
11101111
NicResponse nicResponse = new NicResponse();
1111-
nicResponse.setId(singleNic.getId());
1112-
nicResponse.setIpaddress(singleNic.getIp4Address());
1113-
nicResponse.setGateway(singleNic.getGateway());
1114-
nicResponse.setNetmask(singleNic.getNetmask());
1115-
nicResponse.setNetworkid(singleNic.getNetworkId());
1112+
nicResponse.setId(singleNicProfile.getId());
1113+
nicResponse.setIpaddress(singleNicProfile.getIp4Address());
1114+
nicResponse.setGateway(singleNicProfile.getGateway());
1115+
nicResponse.setNetmask(singleNicProfile.getNetmask());
1116+
nicResponse.setNetworkid(singleNicProfile.getNetworkId());
11161117
if (acct.getType() == Account.ACCOUNT_TYPE_ADMIN) {
1117-
if (singleNic.getBroadcastUri() != null) {
1118-
nicResponse.setBroadcastUri(singleNic.getBroadcastUri().toString());
1118+
if (singleNicProfile.getBroadCastUri() != null) {
1119+
nicResponse.setBroadcastUri(singleNicProfile.getBroadCastUri().toString());
11191120
}
1120-
if (singleNic.getIsolationUri() != null) {
1121-
nicResponse.setIsolationUri(singleNic.getIsolationUri().toString());
1121+
if (singleNicProfile.getIsolationUri() != null) {
1122+
nicResponse.setIsolationUri(singleNicProfile.getIsolationUri().toString());
11221123
}
11231124
}
1124-
Network network = ApiDBUtils.findNetworkById(singleNic.getNetworkId());
1125+
Network network = ApiDBUtils.findNetworkById(singleNicProfile.getNetworkId());
11251126
nicResponse.setTrafficType(network.getTrafficType().toString());
11261127
nicResponse.setType(network.getGuestType().toString());
1127-
nicResponse.setIsDefault(singleNic.isDefaultNic());
1128+
nicResponse.setIsDefault(singleNicProfile.isDefaultNic());
11281129

11291130
nicResponse.setObjectName("nic");
11301131

@@ -1159,23 +1160,23 @@ public DomainRouterResponse createDomainRouterResponse(VirtualRouter router) {
11591160
routerResponse.setDomainName(ApiDBUtils.findDomainById(accountTemp.getDomainId()).getName());
11601161
}
11611162

1162-
List<? extends Nic> nics = ApiDBUtils.getNics(router);
1163-
for (Nic singleNic : nics) {
1164-
Network network = ApiDBUtils.findNetworkById(singleNic.getNetworkId());
1163+
List<NicProfile> nicProfiles = ApiDBUtils.getNics(router);
1164+
for (NicProfile singleNicProfile : nicProfiles) {
1165+
Network network = ApiDBUtils.findNetworkById(singleNicProfile.getNetworkId());
11651166
if (network != null) {
11661167
if (network.getTrafficType() == TrafficType.Public) {
1167-
routerResponse.setPublicIp(singleNic.getIp4Address());
1168-
routerResponse.setPublicMacAddress(singleNic.getMacAddress());
1169-
routerResponse.setPublicNetmask(singleNic.getNetmask());
1170-
routerResponse.setGateway(singleNic.getGateway());
1168+
routerResponse.setPublicIp(singleNicProfile.getIp4Address());
1169+
routerResponse.setPublicMacAddress(singleNicProfile.getMacAddress());
1170+
routerResponse.setPublicNetmask(singleNicProfile.getNetmask());
1171+
routerResponse.setGateway(singleNicProfile.getGateway());
11711172
} else if (network.getTrafficType() == TrafficType.Control) {
1172-
routerResponse.setPrivateIp(singleNic.getIp4Address());
1173-
routerResponse.setPrivateMacAddress(singleNic.getMacAddress());
1174-
routerResponse.setPrivateNetmask(singleNic.getNetmask());
1173+
routerResponse.setPrivateIp(singleNicProfile.getIp4Address());
1174+
routerResponse.setPrivateMacAddress(singleNicProfile.getMacAddress());
1175+
routerResponse.setPrivateNetmask(singleNicProfile.getNetmask());
11751176
} else if (network.getTrafficType() == TrafficType.Guest) {
1176-
routerResponse.setGuestIpAddress(singleNic.getIp4Address());
1177-
routerResponse.setGuestMacAddress(singleNic.getMacAddress());
1178-
routerResponse.setGuestNetmask(singleNic.getNetmask());
1177+
routerResponse.setGuestIpAddress(singleNicProfile.getIp4Address());
1178+
routerResponse.setGuestMacAddress(singleNicProfile.getMacAddress());
1179+
routerResponse.setGuestNetmask(singleNicProfile.getNetmask());
11791180
}
11801181
}
11811182
}
@@ -1238,22 +1239,22 @@ public SystemVmResponse createSystemVmResponse(VirtualMachine systemVM) {
12381239
vmResponse.setDns2(zone.getDns2());
12391240
}
12401241

1241-
List<? extends Nic> nics = ApiDBUtils.getNics(systemVM);
1242-
for (Nic singleNic : nics) {
1243-
Network network = ApiDBUtils.findNetworkById(singleNic.getNetworkId());
1242+
List<NicProfile> nicProfiles = ApiDBUtils.getNics(systemVM);
1243+
for (NicProfile singleNicProfile : nicProfiles) {
1244+
Network network = ApiDBUtils.findNetworkById(singleNicProfile.getNetworkId());
12441245
if (network != null) {
12451246
TrafficType trafficType = TrafficType.Public;
12461247
if(zone.getNetworkType() == NetworkType.Basic) {
12471248
trafficType = TrafficType.Guest;
12481249
}
12491250
if (network.getTrafficType() == trafficType) {
1250-
vmResponse.setPublicIp(singleNic.getIp4Address());
1251-
vmResponse.setPublicMacAddress(singleNic.getMacAddress());
1252-
vmResponse.setPublicNetmask(singleNic.getNetmask());
1251+
vmResponse.setPublicIp(singleNicProfile.getIp4Address());
1252+
vmResponse.setPublicMacAddress(singleNicProfile.getMacAddress());
1253+
vmResponse.setPublicNetmask(singleNicProfile.getNetmask());
12531254
} else if (network.getTrafficType() == TrafficType.Control) {
1254-
vmResponse.setPrivateIp(singleNic.getIp4Address());
1255-
vmResponse.setPrivateMacAddress(singleNic.getMacAddress());
1256-
vmResponse.setPrivateNetmask(singleNic.getNetmask());
1255+
vmResponse.setPrivateIp(singleNicProfile.getIp4Address());
1256+
vmResponse.setPrivateMacAddress(singleNicProfile.getMacAddress());
1257+
vmResponse.setPrivateNetmask(singleNicProfile.getNetmask());
12571258
}
12581259
}
12591260
}
@@ -2237,6 +2238,8 @@ public NetworkOfferingResponse createNetworkOfferingResponse(NetworkOffering off
22372238

22382239
@Override
22392240
public NetworkResponse createNetworkResponse(Network network) {
2241+
NetworkProfile profile = ApiDBUtils.getNetworkProfile(network.getId());
2242+
network = profile.getNetwork();
22402243
NetworkResponse response = new NetworkResponse();
22412244
response.setId(network.getId());
22422245
response.setName(network.getName());
@@ -2285,10 +2288,11 @@ public NetworkResponse createNetworkResponse(Network network) {
22852288
response.setIsDefault(network.isDefault());
22862289
response.setState(network.getState().toString());
22872290
response.setRelated(network.getRelated());
2288-
response.setDns1(network.getDns1());
2289-
response.setDns2(network.getDns2());
22902291
response.setNetworkDomain(network.getNetworkDomain());
22912292

2293+
response.setDns1(profile.getDns1());
2294+
response.setDns2(profile.getDns2());
2295+
22922296
//populate capability
22932297
Map<Service, Map<Capability, String>> serviceCapabilitiesMap = ApiDBUtils.getZoneCapabilities(network.getDataCenterId());
22942298
List<ServiceResponse> serviceResponses = new ArrayList<ServiceResponse>();

server/src/com/cloud/configuration/ConfigurationManagerImpl.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,10 +1066,6 @@ public DataCenter editZone(UpdateZoneCmd cmd) {
10661066
_zoneDao.addVnet(zone.getId(), begin, end);
10671067
}
10681068

1069-
if(dnsUpdate){
1070-
// FIXME: Need to update dns in network rather than in the vms.
1071-
}
1072-
10731069
return zone;
10741070
}
10751071

server/src/com/cloud/network/NetworkManager.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ public interface NetworkManager extends NetworkService {
112112
void expungeNics(VirtualMachineProfile<? extends VMInstanceVO> vm);
113113

114114
List<? extends Nic> getNics(VirtualMachine vm);
115+
116+
List<NicProfile> getNicProfiles(VirtualMachine vm);
115117

116118
List<AccountVO> getAccountsUsingNetwork(long configurationId);
117119
AccountVO getNetworkOwner(long configurationId);

0 commit comments

Comments
 (0)