Skip to content

Commit

Permalink
Merge pull request #921 from MissionCriticalCloud/fix/private-dns
Browse files Browse the repository at this point in the history
Fix/private dns
  • Loading branch information
Alexander authored Jan 29, 2021
2 parents b4c6c28 + 80f3abe commit 45501ea
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- Nullify DNS servers for Private networks
UPDATE `networks` SET dns1=NULL, dns2=NULL WHERE guest_type = 'Private' AND removed is NULL;
Original file line number Diff line number Diff line change
Expand Up @@ -2216,7 +2216,6 @@ public NetworkProfile convertNetworkToNetworkProfile(final long networkId) {
profile.setDns2(network.getDns2());
profile.setDhcpTftpServer(network.getDhcpTftpServer());
profile.setDhcpBootfileName(network.getDhcpBootfileName());
guru.updateNetworkProfile(profile);

return profile;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -901,6 +901,10 @@ && areServicesSupportedByNetworkOffering(ntwkOff.getId(), Service.SourceNat))) {
ip6Gateway = NetUtils.getCidrHostAddress6(ip6Cidr);
}

if (ntwkOff.getGuestType() == GuestType.Private && (dns1 != null || dns2 != null)) {
throw new InvalidParameterValueException("Network of type Private does not support setting DNS servers");
}

Network network = commitNetwork(networkOfferingId, gateway, startIP, endIP, netmask, networkDomain, vlanId, name, displayText, caller, physicalNetworkId, zoneId, domainId,
isDomainSpecific, subdomainAccess, vpcId, startIPv6, endIPv6, ip6Gateway, ip6Cidr, displayNetwork, aclId, isolatedPvlan, ntwkOff, pNtwk, aclType, owner, cidr,
createVlan, dns1, dns2, ipExclusionList, getDhcpTftpServer, getDhcpBootfileName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,6 @@ public boolean trash(final Network network, final NetworkOffering offering) {

@Override
public void updateNetworkProfile(final NetworkProfile networkProfile) {
final DataCenter dc = _dcDao.findById(networkProfile.getDataCenterId());
if (networkProfile.getDns1() != null && networkProfile.getDns1().equals("")) {
networkProfile.setDns1(null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,8 @@ protected void getIp(final NicProfile nic, final DataCenter dc, final Network ne
nic.setMacAddress(ip.getMacAddress());
}

nic.setIPv4Dns1(dc.getDns1());
nic.setIPv4Dns2(dc.getDns2());
nic.setIPv4Dns1(null);
nic.setIPv4Dns2(null);
}

@Override
Expand Down Expand Up @@ -284,10 +284,9 @@ public void deallocate(final Network network, final NicProfile nic, final Virtua

@Override
public void updateNicProfile(final NicProfile profile, final Network network) {
final DataCenter dc = _entityMgr.findById(DataCenter.class, network.getDataCenterId());
if (profile != null) {
profile.setIPv4Dns1(dc.getDns1());
profile.setIPv4Dns2(dc.getDns2());
profile.setIPv4Dns1(null);
profile.setIPv4Dns2(null);
}
}

Expand All @@ -303,9 +302,6 @@ public boolean trash(final Network network, final NetworkOffering offering) {

@Override
public void updateNetworkProfile(final NetworkProfile networkProfile) {
final DataCenter dc = _entityMgr.findById(DataCenter.class, networkProfile.getDataCenterId());
networkProfile.setDns1(dc.getDns1());
networkProfile.setDns2(dc.getDns2());
}

@Override
Expand Down

0 comments on commit 45501ea

Please sign in to comment.