s_logger.info(e.getMessage());
s_logger.info("unable to configure dhcp for this VM.");
return false;
}
//this means we did not create a ip alis on the router.
final NicIpAliasVO alias =
new NicIpAliasVO(domr_guest_nic.getId(), routerAliasIp, router.getId(), CallContext.current().getCallingAccountId(), network.getDomainId(),
nic.getNetworkId(), nic.getGateway(), nic.getNetmask());
alias.setAliasCount((routerPublicIP.getIpMacAddress()));
_nicIpAliasDao.persist(alias);
final List<IpAliasTO> ipaliasTo = new ArrayList<IpAliasTO>();
ipaliasTo.add(new IpAliasTO(routerAliasIp, alias.getNetmask(), alias.getAliasCount().toString()));
final Commands cmds = new Commands(Command.OnError.Stop);
createIpAlias(router, ipaliasTo, alias.getNetworkId(), cmds);
//also add the required configuration to the dnsmasq for supporting dhcp and dns on the new ip.
configDnsMasq(router, network, cmds);
final boolean result = sendCommandsToRouter(router, cmds);
if (result == false) {
final NicIpAliasVO ipAliasVO = _nicIpAliasDao.findByInstanceIdAndNetworkId(network.getId(), router.getId());
final PublicIp routerPublicIPFinal = routerPublicIP;
Transaction.execute(new TransactionCallbackNoReturn() {
@Override
public void doInTransactionWithoutResult(final TransactionStatus status) {
_nicIpAliasDao.expunge(ipAliasVO.getId());
_ipAddressDao.unassignIpAddress(routerPublicIPFinal.getId());
}
});
throw new CloudRuntimeException("failed to configure ip alias on the router as a part of dhcp config");
}