mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-02 20:02:29 +01:00
bug 7348: reapply PortForwardingRules (including 1-1 Nat), LB rules, Vpn as a part of domr Stop/Start
status 7348: resolved fixed More fixes: * Update user_statistics on each domR stop/reboot * Reset dhcpData/userData as a part of domR stop/reboot * More logging for domR commands
This commit is contained in:
parent
d18eaa840e
commit
0b7a15ab99
@ -23,7 +23,6 @@ public class DhcpEntryCommand extends NetworkElementCommand {
|
||||
|
||||
String vmMac;
|
||||
String vmIpAddress;
|
||||
String routerPrivateIpAddress;
|
||||
String vmName;
|
||||
|
||||
protected DhcpEntryCommand() {
|
||||
@ -35,10 +34,9 @@ public class DhcpEntryCommand extends NetworkElementCommand {
|
||||
return true;
|
||||
}
|
||||
|
||||
public DhcpEntryCommand(String vmMac, String vmIpAddress, String routerPrivateIpAddress, String vmName) {
|
||||
public DhcpEntryCommand(String vmMac, String vmIpAddress, String vmName) {
|
||||
this.vmMac = vmMac;
|
||||
this.vmIpAddress = vmIpAddress;
|
||||
this.routerPrivateIpAddress = routerPrivateIpAddress;
|
||||
this.vmName = vmName;
|
||||
}
|
||||
|
||||
@ -46,10 +44,6 @@ public class DhcpEntryCommand extends NetworkElementCommand {
|
||||
return vmMac;
|
||||
}
|
||||
|
||||
public String getRouterPrivateIpAddress() {
|
||||
return routerPrivateIpAddress;
|
||||
}
|
||||
|
||||
public String getVmIpAddress() {
|
||||
return vmIpAddress;
|
||||
}
|
||||
@ -22,8 +22,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class VmDataCommand extends NetworkElementCommand {
|
||||
|
||||
String routerPrivateIpAddress;
|
||||
|
||||
String vmIpAddress;
|
||||
List<String[]> vmData;
|
||||
|
||||
@ -35,16 +34,11 @@ public class VmDataCommand extends NetworkElementCommand {
|
||||
return true;
|
||||
}
|
||||
|
||||
public VmDataCommand(String routerPrivateIpAddress, String vmIpAddress) {
|
||||
this.routerPrivateIpAddress = routerPrivateIpAddress;
|
||||
public VmDataCommand(String vmIpAddress) {
|
||||
this.vmIpAddress = vmIpAddress;
|
||||
this.vmData = new ArrayList<String[]>();
|
||||
}
|
||||
|
||||
public String getRouterPrivateIpAddress() {
|
||||
return routerPrivateIpAddress;
|
||||
}
|
||||
|
||||
public String getVmIpAddress() {
|
||||
return vmIpAddress;
|
||||
}
|
||||
@ -27,6 +27,8 @@ import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.AccountResponse;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.UserContext;
|
||||
|
||||
@ -90,7 +92,7 @@ public class DisableAccountCmd extends BaseAsyncCmd {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
public void execute() throws ConcurrentOperationException, ResourceUnavailableException{
|
||||
Account result = null;
|
||||
if(lockRequested)
|
||||
result = _accountService.lockAccount(this);
|
||||
|
||||
@ -29,6 +29,9 @@ import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.DomainRouterResponse;
|
||||
import com.cloud.async.AsyncJob;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.router.VirtualRouter;
|
||||
import com.cloud.user.Account;
|
||||
|
||||
@ -91,8 +94,8 @@ public class RebootRouterCmd extends BaseAsyncCmd {
|
||||
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
VirtualRouter result = _routerService.rebootRouter(this);
|
||||
public void execute() throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException{
|
||||
VirtualRouter result = _routerService.rebootRouter(this.getId());
|
||||
if (result != null){
|
||||
DomainRouterResponse response = _responseGenerator.createDomainRouterResponse(result);
|
||||
response.setResponseName("router");
|
||||
|
||||
@ -101,7 +101,7 @@ public class StartRouterCmd extends BaseAsyncCmd {
|
||||
|
||||
@Override
|
||||
public void execute() throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException{
|
||||
VirtualRouter result = _routerService.startRouter(this);
|
||||
VirtualRouter result = _routerService.startRouter(this.getId());
|
||||
if (result != null){
|
||||
DomainRouterResponse routerResponse = _responseGenerator.createDomainRouterResponse(result);
|
||||
routerResponse.setResponseName(getCommandName());
|
||||
|
||||
@ -95,7 +95,7 @@ public class StopRouterCmd extends BaseAsyncCmd {
|
||||
|
||||
@Override
|
||||
public void execute() throws ConcurrentOperationException, ResourceUnavailableException{
|
||||
VirtualRouter result = _routerService.stopRouter(this);
|
||||
VirtualRouter result = _routerService.stopRouter(this.getId());
|
||||
if (result != null){
|
||||
DomainRouterResponse response =_responseGenerator.createDomainRouterResponse(result);
|
||||
response.setResponseName(getCommandName());
|
||||
|
||||
@ -17,13 +17,11 @@
|
||||
*/
|
||||
package com.cloud.network;
|
||||
|
||||
import com.cloud.api.commands.RebootRouterCmd;
|
||||
import com.cloud.api.commands.StartRouterCmd;
|
||||
import com.cloud.api.commands.StopRouterCmd;
|
||||
import com.cloud.api.commands.UpgradeRouterCmd;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.PermissionDeniedException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.router.VirtualRouter;
|
||||
|
||||
@ -34,26 +32,7 @@ public interface VirtualNetworkApplianceService {
|
||||
* @return DomainRouter object
|
||||
* @throws InvalidParameterValueException, PermissionDeniedException
|
||||
*/
|
||||
VirtualRouter startRouter(StartRouterCmd cmd) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException;
|
||||
|
||||
/**
|
||||
* Stops domain router
|
||||
* @param cmd the command specifying router's id
|
||||
* @return router if successful, null otherwise
|
||||
*/
|
||||
VirtualRouter stopRouter(StopRouterCmd cmd) throws ConcurrentOperationException, ResourceUnavailableException;
|
||||
|
||||
VirtualRouter startRouter(long routerId) throws ResourceUnavailableException, InsufficientCapacityException, ConcurrentOperationException;
|
||||
|
||||
/**
|
||||
* Stops domain router
|
||||
* @param cmd the command specifying router's id
|
||||
* @return router if successful, null otherwise
|
||||
* @throws ConcurrentOperationException
|
||||
* @throws ResourceUnavailableException
|
||||
* @throws InvalidParameterValueException, PermissionDeniedException
|
||||
*/
|
||||
VirtualRouter stopDomainRouter(long routerId) throws ResourceUnavailableException, ConcurrentOperationException;
|
||||
VirtualRouter startRouter(long routerId) throws InvalidParameterValueException, PermissionDeniedException, ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException;
|
||||
|
||||
/**
|
||||
* Reboots domain router
|
||||
@ -61,10 +40,18 @@ public interface VirtualNetworkApplianceService {
|
||||
* @return router if successful
|
||||
* @throws InvalidParameterValueException, PermissionDeniedException
|
||||
*/
|
||||
VirtualRouter rebootRouter(RebootRouterCmd cmd);
|
||||
VirtualRouter rebootRouter(long routerId) throws InvalidParameterValueException, PermissionDeniedException, ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException;
|
||||
|
||||
VirtualRouter upgradeRouter(UpgradeRouterCmd cmd);
|
||||
|
||||
|
||||
/**
|
||||
* Stops domain router
|
||||
* @param id of the router
|
||||
* @return router if successful, null otherwise
|
||||
* @throws ConcurrentOperationException
|
||||
* @throws ResourceUnavailableException
|
||||
* @throws InvalidParameterValueException, PermissionDeniedException
|
||||
*/
|
||||
VirtualRouter stopRouter(long routerId) throws InvalidParameterValueException, PermissionDeniedException, ResourceUnavailableException, ConcurrentOperationException;
|
||||
|
||||
}
|
||||
|
||||
@ -28,14 +28,15 @@ import com.cloud.api.commands.DisableUserCmd;
|
||||
import com.cloud.api.commands.EnableAccountCmd;
|
||||
import com.cloud.api.commands.EnableUserCmd;
|
||||
import com.cloud.api.commands.ListResourceLimitsCmd;
|
||||
import com.cloud.api.commands.LockAccountCmd;
|
||||
import com.cloud.api.commands.LockUserCmd;
|
||||
import com.cloud.api.commands.UpdateAccountCmd;
|
||||
import com.cloud.api.commands.UpdateResourceLimitCmd;
|
||||
import com.cloud.api.commands.UpdateUserCmd;
|
||||
import com.cloud.configuration.ResourceLimit;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.PermissionDeniedException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
|
||||
public interface AccountService {
|
||||
|
||||
@ -88,7 +89,7 @@ public interface AccountService {
|
||||
* @return true if disable was successful, false otherwise
|
||||
* @throws InvalidParameterValueException, PermissionDeniedException
|
||||
*/
|
||||
Account disableAccount(DisableAccountCmd cmd);
|
||||
Account disableAccount(DisableAccountCmd cmd) throws InvalidParameterValueException, PermissionDeniedException, ConcurrentOperationException, ResourceUnavailableException;
|
||||
|
||||
/**
|
||||
* Enables an account by accountId
|
||||
|
||||
@ -211,7 +211,7 @@ public class VirtualRoutingResource implements Manager {
|
||||
}
|
||||
|
||||
final Script command = new Script(_vmDataPath, _timeout, s_logger);
|
||||
command.add("-r", cmd.getRouterPrivateIpAddress());
|
||||
command.add("-r", cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP));
|
||||
command.add("-v", cmd.getVmIpAddress());
|
||||
command.add("-F", folder);
|
||||
command.add("-f", file);
|
||||
@ -339,7 +339,7 @@ public class VirtualRoutingResource implements Manager {
|
||||
|
||||
protected synchronized Answer execute (final DhcpEntryCommand cmd) {
|
||||
final Script command = new Script(_dhcpEntryPath, _timeout, s_logger);
|
||||
command.add("-r", cmd.getRouterPrivateIpAddress());
|
||||
command.add("-r", cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP));
|
||||
command.add("-v", cmd.getVmIpAddress());
|
||||
command.add("-m", cmd.getVmMac());
|
||||
command.add("-n", cmd.getVmName());
|
||||
|
||||
@ -126,8 +126,8 @@ import com.cloud.agent.api.routing.IPAssocCommand;
|
||||
import com.cloud.agent.api.routing.IpAssocAnswer;
|
||||
import com.cloud.agent.api.routing.LoadBalancerCfgCommand;
|
||||
import com.cloud.agent.api.routing.LoadBalancerConfigCommand;
|
||||
import com.cloud.agent.api.routing.RemoteAccessVpnCfgCommand;
|
||||
import com.cloud.agent.api.routing.NetworkElementCommand;
|
||||
import com.cloud.agent.api.routing.RemoteAccessVpnCfgCommand;
|
||||
import com.cloud.agent.api.routing.SavePasswordCommand;
|
||||
import com.cloud.agent.api.routing.SetPortForwardingRulesAnswer;
|
||||
import com.cloud.agent.api.routing.SetPortForwardingRulesCommand;
|
||||
@ -1106,7 +1106,7 @@ public abstract class CitrixResourceBase implements ServerResource {
|
||||
|
||||
protected synchronized Answer execute(final DhcpEntryCommand cmd) {
|
||||
Connection conn = getConnection();
|
||||
String args = "-r " + cmd.getRouterPrivateIpAddress();
|
||||
String args = "-r " + cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
|
||||
args += " -v " + cmd.getVmIpAddress();
|
||||
args += " -m " + cmd.getVmMac();
|
||||
args += " -n " + cmd.getVmName();
|
||||
@ -1158,7 +1158,7 @@ public abstract class CitrixResourceBase implements ServerResource {
|
||||
|
||||
protected Answer execute(final VmDataCommand cmd) {
|
||||
Connection conn = getConnection();
|
||||
String routerPrivateIpAddress = cmd.getRouterPrivateIpAddress();
|
||||
String routerPrivateIpAddress = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
|
||||
String vmIpAddress = cmd.getVmIpAddress();
|
||||
List<String[]> vmData = cmd.getVmData();
|
||||
String[] vmDataArgs = new String[vmData.size() * 2 + 4];
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
/**
|
||||
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
|
||||
@ -27,6 +27,7 @@ import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.agent.AgentManager;
|
||||
import com.cloud.agent.api.AgentControlAnswer;
|
||||
import com.cloud.agent.api.Answer;
|
||||
import com.cloud.agent.api.Command;
|
||||
import com.cloud.agent.api.ConsoleAccessAuthenticationAnswer;
|
||||
import com.cloud.agent.api.ConsoleAccessAuthenticationCommand;
|
||||
@ -372,7 +373,7 @@ public class AgentBasedConsoleProxyManager implements ConsoleProxyManager, Virtu
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finalizeStop(VirtualMachineProfile<ConsoleProxyVO> profile, long hostId, String reservationId) {
|
||||
public void finalizeStop(VirtualMachineProfile<ConsoleProxyVO> profile, long hostId, String reservationId, Answer... answer) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@ -2105,6 +2105,6 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finalizeStop(VirtualMachineProfile<ConsoleProxyVO> profile, long hostId, String reservationId) {
|
||||
public void finalizeStop(VirtualMachineProfile<ConsoleProxyVO> profile, long hostId, String reservationId, Answer... answer) {
|
||||
}
|
||||
}
|
||||
|
||||
@ -584,6 +584,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
event.setParameters("address=" + ipAddress + "\nsourceNat=" + false + "\ndcId=" + zoneId);
|
||||
event.setDescription("Assigned a public IP address: " + ipAddress);
|
||||
_eventDao.persist(event);
|
||||
|
||||
s_logger.debug("Got " + ipAddress + " to assign for account " + owner.getId() + " in zone " + network.getDataCenterId());
|
||||
|
||||
txn.commit();
|
||||
|
||||
@ -599,7 +601,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
s_logger.error("Unable to associate ip address due to resource unavailable exception", e);
|
||||
return null;
|
||||
} finally {
|
||||
if (caller != null) {
|
||||
if (accountToLock != null) {
|
||||
_accountDao.releaseFromLockTable(ownerId);
|
||||
s_logger.debug("Associate IP address lock released");
|
||||
}
|
||||
@ -607,6 +609,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
if (!success) {
|
||||
if (ip != null) {
|
||||
try {
|
||||
s_logger.warn("Failed to associate ip address " + ip);
|
||||
_ipAddressDao.markAsUnavailable(ip.getAddress(), ip.getAccountId());
|
||||
applyIpAssociations(network, true);
|
||||
} catch (Exception e) {
|
||||
|
||||
@ -106,12 +106,12 @@ public class DhcpElement extends AdapterBase implements NetworkElement{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shutdown(Network network, ReservationContext context) throws ConcurrentOperationException {
|
||||
public boolean shutdown(Network network, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException {
|
||||
DomainRouterVO router = _routerDao.findByNetworkConfiguration(network.getId());
|
||||
if (router == null) {
|
||||
return true;
|
||||
}
|
||||
return _routerMgr.stopRouter(router.getId());
|
||||
return _routerMgr.stopRouterInternal(router.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -49,6 +49,7 @@ import com.cloud.network.lb.LoadBalancingRulesManager;
|
||||
import com.cloud.network.router.VirtualNetworkApplianceManager;
|
||||
import com.cloud.network.rules.FirewallRule;
|
||||
import com.cloud.network.rules.FirewallRule.Purpose;
|
||||
import com.cloud.network.rules.PortForwardingRule;
|
||||
import com.cloud.network.vpn.RemoteAccessVpnElement;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offering.NetworkOffering.GuestIpType;
|
||||
@ -122,12 +123,12 @@ public class VirtualRouterElement extends AdapterBase implements NetworkElement,
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shutdown(Network config, ReservationContext context) throws ConcurrentOperationException {
|
||||
public boolean shutdown(Network config, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException {
|
||||
DomainRouterVO router = _routerDao.findByNetworkConfiguration(config.getId());
|
||||
if (router == null) {
|
||||
return true;
|
||||
}
|
||||
return _routerMgr.stopRouter(router.getId());
|
||||
return _routerMgr.stopRouterInternal(router.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -157,7 +158,7 @@ public class VirtualRouterElement extends AdapterBase implements NetworkElement,
|
||||
|
||||
return _routerMgr.applyLBRules(config, lbRules);
|
||||
} else if (rules.get(0).getPurpose() == Purpose.PortForwarding) {
|
||||
return _routerMgr.applyPortForwardingRules(config, rules);
|
||||
return _routerMgr.applyPortForwardingRules(config, (List<PortForwardingRule>)rules);
|
||||
}
|
||||
} else {
|
||||
return true;
|
||||
|
||||
@ -31,10 +31,9 @@ import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.PublicIpAddress;
|
||||
import com.cloud.network.RemoteAccessVpn;
|
||||
import com.cloud.network.RemoteAccessVpnVO;
|
||||
import com.cloud.network.VpnUser;
|
||||
import com.cloud.network.VpnUserVO;
|
||||
import com.cloud.network.rules.FirewallRule;
|
||||
import com.cloud.network.lb.LoadBalancingRule;
|
||||
import com.cloud.network.rules.PortForwardingRule;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.uservm.UserVm;
|
||||
import com.cloud.utils.component.Manager;
|
||||
@ -68,27 +67,11 @@ public interface VirtualNetworkApplianceManager extends Manager {
|
||||
*/
|
||||
boolean savePasswordToRouter(long routerId, String vmIpAddress, String password);
|
||||
|
||||
boolean destroyRouter(long routerId);
|
||||
boolean destroyRouterInternal(long routerId) throws ResourceUnavailableException, ConcurrentOperationException;
|
||||
|
||||
boolean stopRouter(long routerId);
|
||||
boolean stopRouterInternal(long routerId) throws ResourceUnavailableException, ConcurrentOperationException;
|
||||
|
||||
boolean getRouterStatistics(long vmId, Map<String, long[]> netStats, Map<String, long[]> diskStats);
|
||||
|
||||
boolean rebootRouter(long routerId);
|
||||
|
||||
VirtualRouter startRouter(long routerId) throws ResourceUnavailableException, InsufficientCapacityException, ConcurrentOperationException;
|
||||
|
||||
/**
|
||||
* @param hostId get all of the virtual machine routers on a host.
|
||||
* @return collection of VirtualMachineRouter
|
||||
*/
|
||||
List<? extends VirtualRouter> getRouters(long hostId);
|
||||
|
||||
/**
|
||||
* @param routerId id of the router
|
||||
* @return VirtualMachineRouter
|
||||
*/
|
||||
DomainRouterVO getRouter(long routerId);
|
||||
|
||||
VirtualRouter upgradeRouter(UpgradeRouterCmd cmd) throws InvalidParameterValueException, PermissionDeniedException;
|
||||
|
||||
@ -101,16 +84,14 @@ public interface VirtualNetworkApplianceManager extends Manager {
|
||||
|
||||
boolean startRemoteAccessVpn(Network network, RemoteAccessVpn vpn) throws ResourceUnavailableException;
|
||||
|
||||
boolean addRemoveVpnUsers(RemoteAccessVpnVO vpnVO, List<VpnUserVO> addUsers, List<VpnUserVO> removeUsers);
|
||||
|
||||
boolean deleteRemoteAccessVpn(Network network, RemoteAccessVpn vpn) throws ResourceUnavailableException;
|
||||
|
||||
VirtualRouter addVirtualMachineIntoNetwork(Network config, NicProfile nic, VirtualMachineProfile<UserVm> vm, DeployDestination dest, ReservationContext context, Boolean startDhcp) throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException;
|
||||
|
||||
boolean associateIP (Network network, List<? extends PublicIpAddress> ipAddress) throws ResourceUnavailableException;
|
||||
|
||||
boolean applyLBRules(Network network, List<? extends FirewallRule> rules) throws ResourceUnavailableException;
|
||||
boolean applyPortForwardingRules(Network network, List<? extends FirewallRule> rules) throws AgentUnavailableException;
|
||||
boolean applyLBRules(Network network, List<LoadBalancingRule> rules) throws ResourceUnavailableException;
|
||||
boolean applyPortForwardingRules(Network network, List<PortForwardingRule> rules) throws AgentUnavailableException;
|
||||
|
||||
String[] applyVpnUsers(Network network, List<? extends VpnUser> users) throws ResourceUnavailableException;
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -34,7 +34,6 @@ import com.cloud.domain.DomainVO;
|
||||
import com.cloud.domain.dao.DomainDao;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.event.EventUtils;
|
||||
import com.cloud.event.EventVO;
|
||||
import com.cloud.exception.AccountLimitException;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.NetworkRuleConflictException;
|
||||
|
||||
@ -171,6 +171,7 @@ import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.ManagementServerException;
|
||||
import com.cloud.exception.OperationTimedoutException;
|
||||
import com.cloud.exception.PermissionDeniedException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.Status;
|
||||
@ -3198,7 +3199,7 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean cleanupDomain(Long domainId, Long ownerId) {
|
||||
private boolean cleanupDomain(Long domainId, Long ownerId) throws ConcurrentOperationException, ResourceUnavailableException{
|
||||
boolean success = true;
|
||||
{
|
||||
SearchCriteria<DomainVO> sc = _domainDao.createSearchCriteria();
|
||||
|
||||
@ -114,6 +114,7 @@ import com.cloud.host.dao.DetailsDao;
|
||||
import com.cloud.host.dao.HostDao;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.VirtualNetworkApplianceService;
|
||||
import com.cloud.network.router.VirtualNetworkApplianceManager;
|
||||
import com.cloud.offering.ServiceOffering;
|
||||
import com.cloud.service.ServiceOfferingVO;
|
||||
@ -2265,7 +2266,7 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
||||
//if the instance is of type domain router vm, call the network manager
|
||||
if(vmInstance.getType().equals(VirtualMachine.Type.DomainRouter))
|
||||
{
|
||||
if(!_routerMgr.stopRouter(vmInstance.getId()))
|
||||
if(_routerMgr.stopRouterInternal(vmInstance.getId()))
|
||||
{
|
||||
String errorMsg = "There was an error stopping the domain router id: "+vmInstance.getId()+" ,cannot enable primary storage maintenance";
|
||||
s_logger.warn(errorMsg);
|
||||
@ -2275,7 +2276,7 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
||||
}
|
||||
else if(restart)
|
||||
{
|
||||
if(_routerMgr.startRouter(vmInstance.getId()) == null)
|
||||
if(_routerMgr.stopRouterInternal(vmInstance.getId()))
|
||||
{
|
||||
String errorMsg = "There was an error starting the domain router id: "+vmInstance.getId()+" on another storage pool, cannot enable primary storage maintenance";
|
||||
s_logger.warn(errorMsg);
|
||||
|
||||
@ -1541,6 +1541,6 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
|
||||
@Override
|
||||
public void finalizeStop(
|
||||
VirtualMachineProfile<SecondaryStorageVmVO> profile, long hostId,
|
||||
String reservationId) {
|
||||
String reservationId, Answer... answer) {
|
||||
}
|
||||
}
|
||||
|
||||
@ -27,7 +27,9 @@ import com.cloud.configuration.ResourceCount.ResourceType;
|
||||
import com.cloud.configuration.ResourceLimitVO;
|
||||
import com.cloud.domain.Domain;
|
||||
import com.cloud.domain.DomainVO;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.PermissionDeniedException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.server.Criteria;
|
||||
|
||||
/**
|
||||
@ -103,7 +105,7 @@ public interface AccountManager extends AccountService {
|
||||
* @param accountId
|
||||
* @return true if disable was successful, false otherwise
|
||||
*/
|
||||
boolean disableAccount(long accountId);
|
||||
boolean disableAccount(long accountId) throws ConcurrentOperationException, ResourceUnavailableException;
|
||||
|
||||
boolean deleteAccount(AccountVO account, long callerUserId, Account caller);
|
||||
|
||||
@ -111,7 +113,7 @@ public interface AccountManager extends AccountService {
|
||||
|
||||
void checkAccess(Account account, ControlledEntity... entities) throws PermissionDeniedException;
|
||||
|
||||
boolean cleanupAccount(AccountVO account, long callerUserId, Account caller);
|
||||
boolean cleanupAccount(AccountVO account, long callerUserId, Account caller) throws ConcurrentOperationException, ResourceUnavailableException;
|
||||
|
||||
@Override
|
||||
UserVO createUser(CreateUserCmd cmd);
|
||||
|
||||
@ -67,11 +67,14 @@ import com.cloud.event.EventTypes;
|
||||
import com.cloud.event.EventUtils;
|
||||
import com.cloud.event.EventVO;
|
||||
import com.cloud.exception.AgentUnavailableException;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.PermissionDeniedException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.IPAddressVO;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkVO;
|
||||
import com.cloud.network.VirtualNetworkApplianceService;
|
||||
import com.cloud.network.dao.IPAddressDao;
|
||||
import com.cloud.network.dao.NetworkDao;
|
||||
import com.cloud.network.router.VirtualNetworkApplianceManager;
|
||||
@ -802,7 +805,7 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean cleanupAccount(AccountVO account, long callerUserId, Account caller) {
|
||||
public boolean cleanupAccount(AccountVO account, long callerUserId, Account caller) throws ConcurrentOperationException, ResourceUnavailableException{
|
||||
long accountId = account.getId();
|
||||
boolean accountCleanupNeeded = false;
|
||||
|
||||
@ -858,7 +861,7 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
|
||||
boolean routersCleanedUp = true;
|
||||
for (DomainRouterVO router : routers) {
|
||||
long startEventId = EventUtils.saveStartedEvent(callerUserId, router.getAccountId(), EventTypes.EVENT_ROUTER_DESTROY, "Starting to destroy router : " + router.getName());
|
||||
if (!_routerMgr.destroyRouter(router.getId())) {
|
||||
if (!_routerMgr.destroyRouterInternal(router.getId())) {
|
||||
s_logger.error("Unable to destroy router: " + router.getId());
|
||||
routersCleanedUp = false;
|
||||
EventUtils.saveEvent(callerUserId, router.getAccountId(), EventVO.LEVEL_ERROR, EventTypes.EVENT_ROUTER_DESTROY, "Unable to destroy router: " + router.getName(), startEventId);
|
||||
@ -946,7 +949,7 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean disableAccount(long accountId) {
|
||||
public boolean disableAccount(long accountId) throws ConcurrentOperationException, ResourceUnavailableException{
|
||||
boolean success = false;
|
||||
if (accountId <= 2) {
|
||||
if (s_logger.isInfoEnabled()) {
|
||||
@ -968,7 +971,7 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
|
||||
return success;
|
||||
}
|
||||
|
||||
private boolean doDisableAccount(long accountId) {
|
||||
private boolean doDisableAccount(long accountId) throws ConcurrentOperationException, ResourceUnavailableException{
|
||||
List<UserVmVO> vms = _userVmDao.listByAccountId(accountId);
|
||||
boolean success = true;
|
||||
for (UserVmVO vm : vms) {
|
||||
@ -982,7 +985,7 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
|
||||
|
||||
List<DomainRouterVO> routers = _routerDao.listBy(accountId);
|
||||
for (DomainRouterVO router : routers) {
|
||||
success = (success && _routerMgr.stopRouter(router.getId()));
|
||||
success = (success && _routerMgr.stopRouterInternal(router.getId()));
|
||||
}
|
||||
|
||||
return success;
|
||||
@ -1439,7 +1442,7 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
|
||||
}
|
||||
|
||||
@Override
|
||||
public AccountVO disableAccount(DisableAccountCmd cmd) throws InvalidParameterValueException, PermissionDeniedException {
|
||||
public AccountVO disableAccount(DisableAccountCmd cmd) throws InvalidParameterValueException, PermissionDeniedException, ConcurrentOperationException, ResourceUnavailableException {
|
||||
String accountName = cmd.getAccountName();
|
||||
Long domainId = cmd.getDomainId();
|
||||
|
||||
|
||||
@ -2451,7 +2451,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finalizeStop(VirtualMachineProfile<UserVmVO> profile, long hostId, String reservationId) {
|
||||
public void finalizeStop(VirtualMachineProfile<UserVmVO> profile, long hostId, String reservationId, Answer...answer) {
|
||||
}
|
||||
|
||||
public String generateRandomPassword() {
|
||||
|
||||
@ -17,6 +17,7 @@
|
||||
*/
|
||||
package com.cloud.vm;
|
||||
|
||||
import com.cloud.agent.api.Answer;
|
||||
import com.cloud.agent.api.Command;
|
||||
import com.cloud.agent.manager.Commands;
|
||||
import com.cloud.deploy.DeployDestination;
|
||||
@ -54,7 +55,7 @@ public interface VirtualMachineGuru<T extends VirtualMachine> {
|
||||
* @param dest destination to send the command.
|
||||
* @return true if everything checks out. false if not and we should try again.
|
||||
*/
|
||||
boolean finalizeDeployment(Commands cmds, VirtualMachineProfile<T> profile, DeployDestination dest, ReservationContext context);
|
||||
boolean finalizeDeployment(Commands cmds, VirtualMachineProfile<T> profile, DeployDestination dest, ReservationContext context) throws ResourceUnavailableException;
|
||||
|
||||
/**
|
||||
* Check the deployment results.
|
||||
@ -65,7 +66,7 @@ public interface VirtualMachineGuru<T extends VirtualMachine> {
|
||||
*/
|
||||
boolean finalizeStart(Commands cmds, VirtualMachineProfile<T> profile, DeployDestination dest, ReservationContext context);
|
||||
|
||||
void finalizeStop(VirtualMachineProfile<T> profile, long hostId, String reservationId);
|
||||
void finalizeStop(VirtualMachineProfile<T> profile, long hostId, String reservationId, Answer... answer);
|
||||
/**
|
||||
* Returns the id parsed from the name. If it cannot parse the name,
|
||||
* then return null. This method is used to determine if this is
|
||||
|
||||
@ -421,6 +421,7 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Cluster
|
||||
avoids.add(e);
|
||||
continue;
|
||||
} catch (RuntimeException e) {
|
||||
s_logger.warn("Failed to start instance " + vm, e);
|
||||
stateTransitTo(vm, Event.OperationFailed, null);
|
||||
return null;
|
||||
}
|
||||
@ -504,8 +505,9 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Cluster
|
||||
StopCommand stop = new StopCommand(vm, vm.getInstanceName(), null);
|
||||
|
||||
boolean stopped = false;
|
||||
StopAnswer answer = null;
|
||||
try {
|
||||
StopAnswer answer = (StopAnswer)_agentMgr.send(vm.getHostId(), stop);
|
||||
answer = (StopAnswer)_agentMgr.send(vm.getHostId(), stop);
|
||||
stopped = answer.getResult();
|
||||
if (!stopped) {
|
||||
throw new CloudRuntimeException("Unable to stop the virtual machine due to " + answer.getDetails());
|
||||
@ -526,8 +528,9 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Cluster
|
||||
boolean cleanup = false;
|
||||
|
||||
VirtualMachineProfile<T> profile = new VirtualMachineProfileImpl<T>(vm);
|
||||
try {
|
||||
try {
|
||||
_networkMgr.release(profile);
|
||||
s_logger.debug("Successfully released network resources for the vm " + vm);
|
||||
} catch (Exception e) {
|
||||
s_logger.warn("Unable to release some network resources.", e);
|
||||
cleanup = true;
|
||||
@ -535,6 +538,7 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Cluster
|
||||
|
||||
try {
|
||||
_storageMgr.release(profile);
|
||||
s_logger.debug("Successfully released storage resources for the vm " + vm);
|
||||
} catch (Exception e) {
|
||||
s_logger.warn("Unable to release storage resources.", e);
|
||||
cleanup = true;
|
||||
@ -543,7 +547,7 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Cluster
|
||||
@SuppressWarnings("unchecked")
|
||||
VirtualMachineGuru<T> guru = (VirtualMachineGuru<T>)_vmGurus.get(vm.getType());
|
||||
try {
|
||||
guru.finalizeStop(profile, vm.getHostId(), vm.getReservationId());
|
||||
guru.finalizeStop(profile, vm.getHostId(), vm.getReservationId(), answer);
|
||||
} catch (Exception e) {
|
||||
s_logger.warn("Guru " + guru.getClass() + " has trouble processing stop ");
|
||||
cleanup = true;
|
||||
|
||||
@ -93,6 +93,8 @@ public interface UserVmDao extends GenericDao<UserVmVO, Long>, StateDao<State, V
|
||||
*/
|
||||
List<UserVmVO> listVirtualNetworkInstancesByAcctAndZone(long accountId, long dcId, long networkId);
|
||||
|
||||
List<UserVmVO> listByNetworkId(long networkId);
|
||||
|
||||
List<UserVmVO> listVmsUsingGuestIpAddress(long dcId, String ipAddress);
|
||||
|
||||
UserVm findByZoneAndAcctAndGuestIpAddress(long zoneId, long accountId, String ipAddress);
|
||||
|
||||
@ -304,6 +304,25 @@ public class UserVmDaoImpl extends GenericDaoBase<UserVmVO, Long> implements Use
|
||||
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserVmVO> listByNetworkId(long networkId) {
|
||||
if (AccountDataCenterVirtualSearch == null) {
|
||||
NicDao _nicDao = ComponentLocator.getLocator("management-server").getDao(NicDao.class);
|
||||
SearchBuilder<NicVO> nicSearch = _nicDao.createSearchBuilder();
|
||||
nicSearch.and("networkId", nicSearch.entity().getNetworkId(), SearchCriteria.Op.EQ);
|
||||
nicSearch.and("ip4Address", nicSearch.entity().getIp4Address(), SearchCriteria.Op.NNULL);
|
||||
|
||||
AccountDataCenterVirtualSearch = createSearchBuilder();
|
||||
AccountDataCenterVirtualSearch.join("nicSearch", nicSearch, AccountDataCenterVirtualSearch.entity().getId(), nicSearch.entity().getInstanceId(), JoinBuilder.JoinType.INNER);
|
||||
AccountDataCenterVirtualSearch.done();
|
||||
}
|
||||
|
||||
SearchCriteria<UserVmVO> sc = AccountDataCenterVirtualSearch.create();
|
||||
sc.setJoinParameters("nicSearch", "networkId", networkId);
|
||||
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserVmVO> listVmsUsingGuestIpAddress(long dcId, String ipAddress) {
|
||||
|
||||
@ -24,7 +24,6 @@ import java.util.List;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
import com.cloud.utils.fsm.StateDao;
|
||||
import com.cloud.vm.State;
|
||||
import com.cloud.vm.UserVmVO;
|
||||
import com.cloud.vm.VMInstanceVO;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user