mirror of https://github.com/apache/cloudstack.git
bug 10804: added defaultDns parameter to DhcpEntry command
This commit is contained in:
parent
797836723d
commit
84394ac3d4
|
|
@ -29,6 +29,7 @@ public class DhcpEntryCommand extends NetworkElementCommand {
|
|||
String nextServer;
|
||||
String defaultRouter;
|
||||
String staticRoutes;
|
||||
String defaultDns;
|
||||
|
||||
|
||||
protected DhcpEntryCommand() {
|
||||
|
|
@ -96,5 +97,11 @@ public class DhcpEntryCommand extends NetworkElementCommand {
|
|||
this.staticRoutes = staticRoutes;
|
||||
}
|
||||
|
||||
|
||||
public String getDefaultDns() {
|
||||
return defaultDns;
|
||||
}
|
||||
|
||||
public void setDefaultDns(String defaultDns) {
|
||||
this.defaultDns = defaultDns;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1442,6 +1442,11 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
if (cmd.getStaticRoutes() != null) {
|
||||
args += " -s " + cmd.getStaticRoutes();
|
||||
}
|
||||
|
||||
if (cmd.getDefaultDns() != null) {
|
||||
args += " -N " + cmd.getDefaultDns();
|
||||
}
|
||||
|
||||
String result = callHostPlugin(conn, "vmops", "saveDhcpEntry", "args", args);
|
||||
if (result == null || result.isEmpty()) {
|
||||
return new Answer(cmd, false, "DhcpEntry failed");
|
||||
|
|
|
|||
|
|
@ -2024,8 +2024,8 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
if (sendDnsDhcpData) {
|
||||
DhcpEntryCommand dhcpCommand = new DhcpEntryCommand(nic.getMacAddress(), nic.getIp4Address(), profile.getVirtualMachine().getHostName());
|
||||
|
||||
String defaultDhcpIp = findDefaultDhcpIp(profile.getVirtualMachine().getId());
|
||||
dhcpCommand.setDefaultRouter(defaultDhcpIp);
|
||||
dhcpCommand.setDefaultRouter(findGatewayIp(profile.getVirtualMachine().getId()));
|
||||
dhcpCommand.setDefaultDns(findDefaultDnsIp(profile.getVirtualMachine().getId()));
|
||||
|
||||
dhcpCommand.setAccessDetail(NetworkElementCommand.ROUTER_IP, routerControlIpAddress);
|
||||
dhcpCommand.setAccessDetail(NetworkElementCommand.ROUTER_GUEST_IP, router.getGuestIpAddress());
|
||||
|
|
@ -2084,11 +2084,11 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
return rets;
|
||||
}
|
||||
|
||||
private String findDefaultDhcpIp(long userVmId) {
|
||||
private String findDefaultDnsIp(long userVmId) {
|
||||
NicVO defaultNic = _nicDao.findDefaultNicForVM(userVmId);
|
||||
|
||||
//check if the DhcpProvider is the domR
|
||||
if (!_networkMgr.isProviderSupportServiceInNetwork(defaultNic.getNetworkId(), Service.Dhcp, Provider.VirtualRouter)) {
|
||||
//check if DNS provider is the domR
|
||||
if (!_networkMgr.isProviderSupportServiceInNetwork(defaultNic.getNetworkId(), Service.Dns, Provider.VirtualRouter)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
@ -2096,6 +2096,11 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
NicVO domrDefaultNic = _nicDao.findByNetworkIdAndType(defaultNic.getNetworkId(), VirtualMachine.Type.DomainRouter);
|
||||
return domrDefaultNic.getIp4Address();
|
||||
}
|
||||
|
||||
private String findGatewayIp(long userVmId) {
|
||||
NicVO defaultNic = _nicDao.findDefaultNicForVM(userVmId);
|
||||
return defaultNic.getGateway();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<VirtualRouter> applyUserData(Network network, NicProfile nic, VirtualMachineProfile<UserVm> profile, DeployDestination dest, ReservationContext context, List<DomainRouterVO> routers)
|
||||
|
|
@ -2570,7 +2575,8 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
s_logger.debug("Creating dhcp entry for vm " + vm + " on domR " + router + ".");
|
||||
|
||||
DhcpEntryCommand dhcpCommand = new DhcpEntryCommand(nic.getMacAddress(), nic.getIp4Address(), vm.getHostName());
|
||||
dhcpCommand.setDefaultRouter(findDefaultDhcpIp(vm.getId()));
|
||||
dhcpCommand.setDefaultRouter(findGatewayIp(vm.getId()));
|
||||
dhcpCommand.setDefaultRouter(findDefaultDnsIp(vm.getId()));
|
||||
|
||||
dhcpCommand.setAccessDetail(NetworkElementCommand.ROUTER_IP, router.getPrivateIpAddress());
|
||||
dhcpCommand.setAccessDetail(NetworkElementCommand.ROUTER_NAME, router.getInstanceName());
|
||||
|
|
|
|||
Loading…
Reference in New Issue