diff --git a/server/src/com/cloud/network/NetworkManagerImpl.java b/server/src/com/cloud/network/NetworkManagerImpl.java index 805be6fa0bd..46896c83f99 100755 --- a/server/src/com/cloud/network/NetworkManagerImpl.java +++ b/server/src/com/cloud/network/NetworkManagerImpl.java @@ -3625,7 +3625,10 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag s_logger.debug("Sending destroy to " + element); } - element.destroy(network); + if (!element.destroy(network)) { + success = false; + s_logger.warn("Unable to complete destroy of the network: failed to destroy network element " + element.getName()); + } } catch (ResourceUnavailableException e) { s_logger.warn("Unable to complete destroy of the network due to element: " + element.getName(), e); success = false; @@ -3635,7 +3638,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag } catch (Exception e) { s_logger.warn("Unable to complete destroy of the network due to element: " + element.getName(), e); success = false; - } + } } } diff --git a/server/src/com/cloud/network/vpn/Site2SiteVpnManagerImpl.java b/server/src/com/cloud/network/vpn/Site2SiteVpnManagerImpl.java index 9121f14d1f3..62485661b67 100644 --- a/server/src/com/cloud/network/vpn/Site2SiteVpnManagerImpl.java +++ b/server/src/com/cloud/network/vpn/Site2SiteVpnManagerImpl.java @@ -120,18 +120,13 @@ public class Site2SiteVpnManagerImpl implements Site2SiteVpnManager, Manager { idList.add(new IdentityProxy(vpc, vpcId, "vpcId")); throw new InvalidParameterValueException("The VPN gateway of VPC with specified vpcId already exists!", idList); } - Long accountId = cmd.getEntityOwnerId(); - Long domainId = cmd.getDomainId(); - if (domainId == null) { - domainId = Domain.ROOT_DOMAIN; - } //Use source NAT ip for VPC List ips = _ipAddressDao.listByAssociatedVpc(vpcId, true); if (ips.size() != 1) { throw new CloudRuntimeException("Cannot found source nat ip of vpc " + vpcId); } - Site2SiteVpnGatewayVO gw = new Site2SiteVpnGatewayVO(accountId, domainId, ips.get(0).getId(), vpcId); + Site2SiteVpnGatewayVO gw = new Site2SiteVpnGatewayVO(owner.getAccountId(), owner.getDomainId(), ips.get(0).getId(), vpcId); _vpnGatewayDao.persist(gw); return gw; } @@ -180,12 +175,7 @@ public class Site2SiteVpnManagerImpl implements Site2SiteVpnManager, Manager { if (_customerGatewayDao.findByName(name) != null) { throw new InvalidParameterValueException("The customer gateway with name " + name + " already existed!", null); } - Long accountId = cmd.getEntityOwnerId(); - Long domainId = cmd.getDomainId(); - if (domainId == null) { - domainId = Domain.ROOT_DOMAIN; - } - Site2SiteCustomerGatewayVO gw = new Site2SiteCustomerGatewayVO(name, accountId, domainId, gatewayIp, guestCidrList, ipsecPsk, + Site2SiteCustomerGatewayVO gw = new Site2SiteCustomerGatewayVO(name, owner.getAccountId(), owner.getDomainId(), gatewayIp, guestCidrList, ipsecPsk, ikePolicy, espPolicy, lifetime); _customerGatewayDao.persist(gw); return gw; @@ -221,12 +211,7 @@ public class Site2SiteVpnManagerImpl implements Site2SiteVpnManager, Manager { throw new InvalidParameterValueException("The vpn connection with specified customer gateway id or vpn gateway id " + " already exists!", idList); } - Long accountId = cmd.getEntityOwnerId(); - Long domainId = cmd.getDomainId(); - if (domainId == null) { - domainId = Domain.ROOT_DOMAIN; - } - Site2SiteVpnConnectionVO conn = new Site2SiteVpnConnectionVO(accountId, domainId, vpnGatewayId, customerGatewayId); + Site2SiteVpnConnectionVO conn = new Site2SiteVpnConnectionVO(owner.getAccountId(), owner.getDomainId(), vpnGatewayId, customerGatewayId); conn.setState(State.Pending); _vpnConnectionDao.persist(conn); return conn; diff --git a/server/src/com/cloud/user/AccountManagerImpl.java b/server/src/com/cloud/user/AccountManagerImpl.java index 8bf4ba34029..063e8e004d5 100755 --- a/server/src/com/cloud/user/AccountManagerImpl.java +++ b/server/src/com/cloud/user/AccountManagerImpl.java @@ -126,7 +126,9 @@ import com.cloud.vm.ReservationContextImpl; import com.cloud.vm.UserVmManager; import com.cloud.vm.UserVmVO; import com.cloud.vm.VMInstanceVO; +import com.cloud.vm.VirtualMachine.Type; import com.cloud.vm.VirtualMachineManager; +import com.cloud.vm.dao.DomainRouterDao; import com.cloud.vm.dao.InstanceGroupDao; import com.cloud.vm.dao.UserVmDao; import com.cloud.vm.dao.VMInstanceDao; @@ -204,6 +206,8 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag private IPAddressDao _ipAddressDao; @Inject private VpcManager _vpcMgr; + @Inject + private DomainRouterDao _routerDao; private Adapters _userAuthenticators; @@ -676,7 +680,13 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag for (VMInstanceVO vm : vms) { try { try { - success = (success && _itMgr.advanceStop(vm, false, getSystemUser(), getSystemAccount())); + if (vm.getType() == Type.User) { + success = (success && _itMgr.advanceStop(_userVmDao.findById(vm.getId()), false, getSystemUser(), getSystemAccount())); + } else if (vm.getType() == Type.DomainRouter) { + success = (success && _itMgr.advanceStop(_routerDao.findById(vm.getId()), false, getSystemUser(), getSystemAccount())); + } else { + success = (success && _itMgr.advanceStop(vm, false, getSystemUser(), getSystemAccount())); + } } catch (OperationTimedoutException ote) { s_logger.warn("Operation for stopping vm timed out, unable to stop vm " + vm.getHostName(), ote); success = false; diff --git a/server/src/com/cloud/vm/VirtualMachineManagerImpl.java b/server/src/com/cloud/vm/VirtualMachineManagerImpl.java index ae0b4937aa5..f63f182c7d0 100755 --- a/server/src/com/cloud/vm/VirtualMachineManagerImpl.java +++ b/server/src/com/cloud/vm/VirtualMachineManagerImpl.java @@ -1020,7 +1020,6 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Listene } VirtualMachineGuru vmGuru = getVmGuru(vm); - vm = vmGuru.findById(vm.getId()); VirtualMachineProfile profile = new VirtualMachineProfileImpl(vm); try {