bug 9504: don't send DHCP entry command for Destroyed vm

status 9504: resolved fixed
This commit is contained in:
alena 2011-04-21 14:26:42 -07:00
parent d7ec734b01
commit b83456f895
1 changed files with 10 additions and 8 deletions

View File

@ -1566,16 +1566,18 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
private void createDhcpEntriesCommands(DomainRouterVO router, Commands cmds) {
long networkId = router.getNetworkId();
List<UserVmVO> vms = _userVmDao.listByNetworkId(networkId);
if (vms != null && !vms.isEmpty()) {
if (!vms.isEmpty()) {
for (UserVmVO vm : vms) {
NicVO nic = _nicDao.findByInstanceIdAndNetworkId(networkId, vm.getId());
if (nic != null) {
s_logger.debug("Creating dhcp entry for vm " + vm + " on domR " + router + ".");
if (vm.getState() != State.Destroyed && vm.getState() != State.Expunging) {
NicVO nic = _nicDao.findByInstanceIdAndNetworkId(networkId, vm.getId());
if (nic != null) {
s_logger.debug("Creating dhcp entry for vm " + vm + " on domR " + router + ".");
DhcpEntryCommand dhcpCommand = new DhcpEntryCommand(nic.getMacAddress(), nic.getIp4Address(), vm.getName());
dhcpCommand.setAccessDetail(NetworkElementCommand.ROUTER_IP, router.getPrivateIpAddress());
dhcpCommand.setAccessDetail(NetworkElementCommand.ROUTER_NAME, router.getInstanceName());
cmds.addCommand("dhcp", dhcpCommand);
DhcpEntryCommand dhcpCommand = new DhcpEntryCommand(nic.getMacAddress(), nic.getIp4Address(), vm.getName());
dhcpCommand.setAccessDetail(NetworkElementCommand.ROUTER_IP, router.getPrivateIpAddress());
dhcpCommand.setAccessDetail(NetworkElementCommand.ROUTER_NAME, router.getInstanceName());
cmds.addCommand("dhcp", dhcpCommand);
}
}
}
}