}
}
private void createDhcpEntryCommand(VirtualRouter router, UserVm vm, NicVO nic, Commands cmds) {
DhcpEntryCommand dhcpCommand = new DhcpEntryCommand(nic.getMacAddress(), nic.getIp4Address(), vm.getHostName());
DataCenterVO dcVo = _dcDao.findById(router.getDataCenterIdToDeployIn());
String gatewayIp = findGatewayIp(vm.getId());
if (!gatewayIp.equals(nic.getGateway())) {
GuestOSVO guestOS = _guestOSDao.findById(vm.getGuestOSId());
// Don't set dhcp:router option for non-default nic on CentOS/RHEL, because they would set routing on wrong interface
// This is tricky, we may need to update this when we have more information on various OS's behavior
if (guestOS.getDisplayName().startsWith("CentOS") || guestOS.getDisplayName().startsWith("Red Hat Enterprise")) {
gatewayIp = "0.0.0.0";
}
}
dhcpCommand.setDefaultRouter(gatewayIp);
dhcpCommand.setDefaultDns(findDefaultDnsIp(vm.getId()));
dhcpCommand.setAccessDetail(NetworkElementCommand.ROUTER_IP, getRouterControlIp(router.getId()));
dhcpCommand.setAccessDetail(NetworkElementCommand.ROUTER_NAME, router.getInstanceName());
dhcpCommand.setAccessDetail(NetworkElementCommand.ROUTER_GUEST_IP, getRouterIpInNetwork(nic.getNetworkId(), router.getId()));
dhcpCommand.setAccessDetail(NetworkElementCommand.ZONE_NETWORK_TYPE, dcVo.getNetworkType().toString());
cmds.addCommand("dhcp", dhcpCommand);
}