mirror of https://github.com/apache/cloudstack.git
new networking can be set by use.new.networking
This commit is contained in:
parent
e6f0ab4dba
commit
a73e3dc9ac
|
|
@ -55,7 +55,7 @@ public interface ServerResource extends Manager {
|
|||
*/
|
||||
public Answer executeRequest(Command cmd);
|
||||
|
||||
// public void revertRequest(Command cmd);
|
||||
// public void revertRequest(Command cmd, Answer answer);
|
||||
|
||||
/**
|
||||
* disconnected() is called when the connection is down between the
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import com.cloud.exception.AgentUnavailableException;
|
|||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.OperationTimedoutException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.exception.StorageUnavailableException;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.utils.exception.ExecutionException;
|
||||
|
|
@ -78,6 +79,7 @@ public interface VirtualMachineManager<T extends VMInstanceVO> {
|
|||
* @throws StorageUnavailableException if the storage is unavailable.
|
||||
* @throws ConcurrentOperationException there's multiple threads working on this vm.
|
||||
* @throws ExecutionException
|
||||
* @throws ResourceUnavailableException
|
||||
*/
|
||||
T start(long vmId, long startEventId) throws InsufficientCapacityException, StorageUnavailableException, ConcurrentOperationException, ExecutionException;
|
||||
|
||||
|
|
|
|||
|
|
@ -100,6 +100,7 @@ import com.cloud.vm.State;
|
|||
import com.cloud.vm.SystemVm;
|
||||
import com.cloud.vm.UserVmVO;
|
||||
import com.cloud.vm.VMInstanceVO;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
import com.cloud.vm.VmStats;
|
||||
|
||||
public class ApiResponseHelper {
|
||||
|
|
@ -479,7 +480,7 @@ public class ApiResponseHelper {
|
|||
return userVmResponse;
|
||||
}
|
||||
|
||||
public static SystemVmResponse createSystemVmResponse (VMInstanceVO systemVM) {
|
||||
public static SystemVmResponse createSystemVmResponse (VirtualMachine systemVM) {
|
||||
if (systemVM.getPrivateIpAddress() == null) {
|
||||
return createSystemVm2Response(systemVM);
|
||||
}
|
||||
|
|
@ -1211,7 +1212,7 @@ public class ApiResponseHelper {
|
|||
}
|
||||
|
||||
|
||||
public static SystemVmResponse createSystemVm2Response (VMInstanceVO systemVM) {
|
||||
public static SystemVmResponse createSystemVm2Response (VirtualMachine systemVM) {
|
||||
SystemVmResponse vmResponse = new SystemVmResponse();
|
||||
if (systemVM instanceof SystemVm) {
|
||||
SystemVm vm = (SystemVm)systemVM;
|
||||
|
|
|
|||
|
|
@ -116,7 +116,6 @@ public class ApiServer implements HttpRequestHandler {
|
|||
private AccountManager _accountMgr = null;
|
||||
private Account _systemAccount = null;
|
||||
private User _systemUser = null;
|
||||
|
||||
|
||||
private static int _workerCount = 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -31,6 +31,9 @@ import com.cloud.agent.AgentManager;
|
|||
import com.cloud.async.AsyncJobManager;
|
||||
import com.cloud.configuration.ConfigurationService;
|
||||
import com.cloud.consoleproxy.ConsoleProxyManager;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.DomainRouterService;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.security.NetworkGroupManager;
|
||||
|
|
@ -115,7 +118,7 @@ public abstract class BaseCmd {
|
|||
_routerMgr = locator.getManager(DomainRouterService.class);
|
||||
}
|
||||
|
||||
public abstract void execute();
|
||||
public abstract void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException;
|
||||
|
||||
public String getResponseType() {
|
||||
if (responseType == null) {
|
||||
|
|
|
|||
|
|
@ -177,20 +177,20 @@ public class DeployVm2Cmd extends BaseAsyncCreateCmd {
|
|||
|
||||
@Override
|
||||
public void callCreate() {
|
||||
try {
|
||||
UserVm vm = _userVmService.createVirtualMachine(this);
|
||||
if (vm != null) {
|
||||
this.setId(vm.getId());
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to deploy vm");
|
||||
}
|
||||
} catch (ResourceUnavailableException ex) {
|
||||
throw new ServerApiException(BaseCmd.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
|
||||
} catch (ConcurrentOperationException ex) {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
|
||||
} catch (InsufficientCapacityException ex) {
|
||||
throw new ServerApiException(BaseCmd.INSUFFICIENT_CAPACITY_ERROR, ex.getMessage());
|
||||
}
|
||||
// try {
|
||||
// UserVm vm = _userVmService.createVirtualMachine(this);
|
||||
// if (vm != null) {
|
||||
// this.setId(vm.getId());
|
||||
// } else {
|
||||
// throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to deploy vm");
|
||||
// }
|
||||
// } catch (ResourceUnavailableException ex) {
|
||||
// throw new ServerApiException(BaseCmd.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
|
||||
// } catch (ConcurrentOperationException ex) {
|
||||
// throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
|
||||
// } catch (InsufficientCapacityException ex) {
|
||||
// throw new ServerApiException(BaseCmd.INSUFFICIENT_CAPACITY_ERROR, ex.getMessage());
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,8 @@ import com.cloud.api.Parameter;
|
|||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.UserVmResponse;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.StorageUnavailableException;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.uservm.UserVm;
|
||||
|
||||
|
|
@ -84,7 +85,7 @@ public class DestroyVMCmd extends BaseAsyncCmd {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
public void execute() throws ResourceUnavailableException, ConcurrentOperationException{
|
||||
UserVm result = _userVmService.destroyVm(this);
|
||||
if (result != null) {
|
||||
UserVmResponse response = ApiResponseHelper.createUserVmResponse(result);
|
||||
|
|
|
|||
|
|
@ -1,108 +0,0 @@
|
|||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.ApiDBUtils;
|
||||
import com.cloud.api.ApiResponseHelper;
|
||||
import com.cloud.api.BaseAsyncCmd;
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.UserVmResponse;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientAddressCapacityException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.PermissionDeniedException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.uservm.UserVm;
|
||||
|
||||
@Implementation(description="Destroys a virtual machine. Once destroyed, only the administrator can recover it.", responseObject=UserVmResponse.class)
|
||||
public class DestroyVm2Cmd extends BaseAsyncCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(DestroyVm2Cmd.class.getName());
|
||||
|
||||
private static final String s_name = "destroyvirtualmachineresponse";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="The ID of the virtual machine")
|
||||
private Long id;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getAccountId() {
|
||||
UserVm vm = ApiDBUtils.findUserVmById(getId());
|
||||
if (vm != null) {
|
||||
return vm.getAccountId();
|
||||
}
|
||||
|
||||
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_VM_DESTROY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
return "destroying vm: " + getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
try {
|
||||
UserVm result = _userVmService.destroyVm(this);
|
||||
if (result != null) {
|
||||
UserVmResponse response = ApiResponseHelper.createUserVmResponse(result);
|
||||
response.setResponseName("virtualmachine");
|
||||
this.setResponseObject(response);
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to destroy vm");
|
||||
}
|
||||
}catch (ConcurrentOperationException ex) {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
|
||||
}catch (ResourceUnavailableException ex) {
|
||||
throw new ServerApiException(BaseCmd.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -86,7 +86,7 @@ public class RebootRouterCmd extends BaseAsyncCmd {
|
|||
|
||||
@Override
|
||||
public void execute(){
|
||||
DomainRouter result = _networkMgr.rebootRouter(this);
|
||||
DomainRouter result = _routerMgr.rebootRouter(this);
|
||||
if (result != null){
|
||||
DomainRouterResponse response = ApiResponseHelper.createDomainRouterResponse(result);
|
||||
response.setResponseName("router");
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ import com.cloud.api.response.SystemVmResponse;
|
|||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.UserContext;
|
||||
import com.cloud.vm.VMInstanceVO;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
|
||||
@Implementation(description="Reboots a system VM.", responseObject=SystemVmResponse.class)
|
||||
public class RebootSystemVmCmd extends BaseAsyncCmd {
|
||||
|
|
@ -85,7 +85,7 @@ public class RebootSystemVmCmd extends BaseAsyncCmd {
|
|||
|
||||
@Override
|
||||
public void execute(){
|
||||
VMInstanceVO result = _mgr.rebootSystemVM(this);
|
||||
VirtualMachine result = _mgr.rebootSystemVM(this);
|
||||
if (result != null) {
|
||||
SystemVmResponse response = ApiResponseHelper.createSystemVmResponse(result);
|
||||
response.setResponseName(getName());
|
||||
|
|
|
|||
|
|
@ -1,115 +0,0 @@
|
|||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.ApiDBUtils;
|
||||
import com.cloud.api.ApiResponseHelper;
|
||||
import com.cloud.api.BaseAsyncCmd;
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.DomainRouterResponse;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.uservm.UserVm;
|
||||
import com.cloud.vm.DomainRouter;
|
||||
|
||||
|
||||
@Implementation(responseObject=DomainRouterResponse.class, description="Starts a router.")
|
||||
public class StartRouter2Cmd extends BaseAsyncCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(StartRouter2Cmd.class.getName());
|
||||
private static final String s_name = "startrouterresponse";
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the ID of the router")
|
||||
private Long id;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
public static String getResultObjectName() {
|
||||
return "router";
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getAccountId() {
|
||||
UserVm vm = ApiDBUtils.findUserVmById(getId());
|
||||
if (vm != null) {
|
||||
return vm.getAccountId();
|
||||
}
|
||||
|
||||
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_ROUTER_START;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
return "starting router: " + getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
try {
|
||||
DomainRouter router = _routerMgr.startRouter(this);
|
||||
if (router != null){
|
||||
DomainRouterResponse routerResponse = ApiResponseHelper.createDomainRouterResponse(router);
|
||||
routerResponse.setResponseName(getName());
|
||||
this.setResponseObject(routerResponse);
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to start router");
|
||||
}
|
||||
}catch (InsufficientCapacityException ex) {
|
||||
throw new ServerApiException(BaseCmd.INSUFFICIENT_CAPACITY_ERROR, ex.getMessage());
|
||||
}catch (ConcurrentOperationException ex) {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
|
||||
}catch (ResourceUnavailableException ex) {
|
||||
throw new ServerApiException(BaseCmd.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -30,6 +30,9 @@ import com.cloud.api.Parameter;
|
|||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.DomainRouterResponse;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.uservm.UserVm;
|
||||
import com.cloud.vm.DomainRouter;
|
||||
|
|
@ -90,7 +93,7 @@ public class StartRouterCmd extends BaseAsyncCmd {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
public void execute() throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException{
|
||||
DomainRouter result = _routerMgr.startRouter(this);
|
||||
if (result != null){
|
||||
DomainRouterResponse routerResponse = ApiResponseHelper.createDomainRouterResponse(result);
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ import com.cloud.api.response.SystemVmResponse;
|
|||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.UserContext;
|
||||
import com.cloud.vm.VMInstanceVO;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
|
||||
@Implementation(responseObject=SystemVmResponse.class, description="Starts a system virtual machine.")
|
||||
public class StartSystemVMCmd extends BaseAsyncCmd {
|
||||
|
|
@ -89,7 +89,7 @@ public class StartSystemVMCmd extends BaseAsyncCmd {
|
|||
|
||||
@Override
|
||||
public void execute(){
|
||||
VMInstanceVO instance = _mgr.startSystemVM(this);
|
||||
VirtualMachine instance = _mgr.startSystemVM(this);
|
||||
if (instance != null) {
|
||||
SystemVmResponse response = ApiResponseHelper.createSystemVmResponse(instance);
|
||||
response.setResponseName(getName());
|
||||
|
|
|
|||
|
|
@ -1,102 +0,0 @@
|
|||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.ApiResponseHelper;
|
||||
import com.cloud.api.BaseAsyncCmd;
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.SystemVmResponse;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.UserContext;
|
||||
import com.cloud.vm.VMInstanceVO;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
|
||||
@Implementation(description="Starts a system virtual machine.", responseObject=SystemVmResponse.class)
|
||||
public class StartSystemVm2Cmd extends BaseAsyncCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(StartSystemVm2Cmd.class.getName());
|
||||
|
||||
private static final String s_name = "startsystemvmresponse";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="The ID of the system virtual machine")
|
||||
private Long id;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
public static String getResultObjectName() {
|
||||
return "systemvm";
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getAccountId() {
|
||||
Account account = UserContext.current().getAccount();
|
||||
if (account != null) {
|
||||
return account.getId();
|
||||
}
|
||||
|
||||
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_SSVM_START;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
return "starting system vm: " + getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
VirtualMachine instance = _mgr.startSystemVm(this);
|
||||
if (instance != null){
|
||||
SystemVmResponse response = ApiResponseHelper.createSystemVmResponse((VMInstanceVO)instance);
|
||||
response.setResponseName(getName());
|
||||
this.setResponseObject(response);
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to start system vm");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -30,6 +30,8 @@ import com.cloud.api.ServerApiException;
|
|||
import com.cloud.api.response.UserVmResponse;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.exception.StorageUnavailableException;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.uservm.UserVm;
|
||||
|
|
@ -90,7 +92,7 @@ public class StartVMCmd extends BaseAsyncCmd {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
public void execute() throws ResourceUnavailableException, InsufficientCapacityException{
|
||||
try {
|
||||
UserVm result = _userVmService.startVirtualMachine(this);
|
||||
if (result != null){
|
||||
|
|
|
|||
|
|
@ -1,201 +0,0 @@
|
|||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.ApiDBUtils;
|
||||
import com.cloud.api.BaseAsyncCmd;
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.UserVmResponse;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.offering.ServiceOffering;
|
||||
import com.cloud.storage.StoragePoolVO;
|
||||
import com.cloud.storage.VMTemplateVO;
|
||||
import com.cloud.storage.VolumeVO;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.uservm.UserVm;
|
||||
import com.cloud.vm.InstanceGroupVO;
|
||||
|
||||
@Implementation(responseObject=UserVmResponse.class, description="Starts a virtual machine.")
|
||||
public class StartVm2Cmd extends BaseAsyncCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(StartVMCmd.class.getName());
|
||||
|
||||
private static final String s_name = "startvirtualmachineresponse";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="The ID of the virtual machine")
|
||||
private Long id;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
@Override
|
||||
public void execute(){
|
||||
try {
|
||||
UserVm vm = _userVmService.startVirtualMachine(this);
|
||||
|
||||
if (vm != null){
|
||||
UserVmResponse response = new UserVmResponse();
|
||||
response.setId(vm.getId());
|
||||
response.setName(vm.getHostName());
|
||||
response.setCreated(vm.getCreated());
|
||||
response.setZoneId(vm.getDataCenterId());
|
||||
response.setZoneName(ApiDBUtils.findZoneById(vm.getDataCenterId()).getName());
|
||||
response.setIpAddress(vm.getPrivateIpAddress());
|
||||
response.setServiceOfferingId(vm.getServiceOfferingId());
|
||||
response.setHaEnable(vm.isHaEnabled());
|
||||
if (vm.getDisplayName() == null || vm.getDisplayName().length() == 0) {
|
||||
response.setDisplayName(vm.getHostName());
|
||||
} else {
|
||||
response.setDisplayName(vm.getDisplayName());
|
||||
}
|
||||
|
||||
InstanceGroupVO group = ApiDBUtils.findInstanceGroupForVM(vm.getId());
|
||||
if (group != null) {
|
||||
response.setGroup(group.getName());
|
||||
response.setGroupId(group.getId());
|
||||
}
|
||||
|
||||
if (vm.getState() != null) {
|
||||
response.setState(vm.getState().toString());
|
||||
}
|
||||
|
||||
Account acct = ApiDBUtils.findAccountById(vm.getAccountId());
|
||||
if (acct != null) {
|
||||
response.setAccountName(acct.getAccountName());
|
||||
response.setDomainId(acct.getDomainId());
|
||||
response.setDomainName(ApiDBUtils.findDomainById(acct.getDomainId()).getName());
|
||||
}
|
||||
|
||||
if (BaseCmd.isAdmin(acct.getType()) && (vm.getHostId() != null)) {
|
||||
response.setHostName(ApiDBUtils.findHostById(vm.getHostId()).getName());
|
||||
response.setHostId(vm.getHostId());
|
||||
}
|
||||
|
||||
String templateName = "ISO Boot";
|
||||
boolean templatePasswordEnabled = false;
|
||||
String templateDisplayText = "ISO Boot";
|
||||
|
||||
VMTemplateVO template = ApiDBUtils.findTemplateById(vm.getTemplateId());
|
||||
if (template != null) {
|
||||
templateName = template.getName();
|
||||
templatePasswordEnabled = template.getEnablePassword();
|
||||
templateDisplayText = template.getDisplayText();
|
||||
if (templateDisplayText == null) {
|
||||
templateDisplayText = templateName;
|
||||
}
|
||||
}
|
||||
|
||||
response.setTemplateId(vm.getTemplateId());
|
||||
response.setTemplateName(templateName);
|
||||
response.setTemplateDisplayText(templateDisplayText);
|
||||
response.setPasswordEnabled(templatePasswordEnabled);
|
||||
if (templatePasswordEnabled) {
|
||||
response.setPassword(null); // FIXME: Where should password come from? In the old framework, password was always passed
|
||||
// in to composeResultObject() as null, so that behavior is preserved...
|
||||
} else {
|
||||
response.setPassword("");
|
||||
}
|
||||
|
||||
String isoName = null;
|
||||
if (vm.getIsoId() != null) {
|
||||
VMTemplateVO iso = ApiDBUtils.findTemplateById(vm.getIsoId().longValue());
|
||||
if (iso != null) {
|
||||
isoName = iso.getName();
|
||||
}
|
||||
}
|
||||
|
||||
response.setIsoId(vm.getIsoId());
|
||||
response.setIsoName(isoName);
|
||||
|
||||
ServiceOffering offering = ApiDBUtils.findServiceOfferingById(vm.getServiceOfferingId());
|
||||
response.setServiceOfferingId(vm.getServiceOfferingId());
|
||||
response.setServiceOfferingName(offering.getName());
|
||||
|
||||
response.setCpuNumber(offering.getCpu());
|
||||
response.setCpuSpeed(offering.getSpeed());
|
||||
response.setMemory(offering.getRamSize());
|
||||
|
||||
VolumeVO rootVolume = ApiDBUtils.findRootVolume(vm.getId());
|
||||
if (rootVolume != null) {
|
||||
response.setRootDeviceId(rootVolume.getDeviceId());
|
||||
StoragePoolVO storagePool = ApiDBUtils.findStoragePoolById(rootVolume.getPoolId());
|
||||
response.setRootDeviceType(storagePool.getPoolType().toString());
|
||||
}
|
||||
|
||||
response.setGuestOsId(vm.getGuestOSId());
|
||||
|
||||
//Network groups
|
||||
response.setNetworkGroupList(ApiDBUtils.getNetworkGroupsNamesForVm(vm.getId()));
|
||||
response.setObjectName("virtualmachine");
|
||||
response.setResponseName(getName());
|
||||
//response.setResponseName(getResultObjectName());
|
||||
this.setResponseObject(response);
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to start a vm");
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to start a vm");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
public static String getResultObjectName() {
|
||||
return "virtualmachine";
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getAccountId() {
|
||||
UserVm vm = ApiDBUtils.findUserVmById(getId());
|
||||
if (vm != null) {
|
||||
return vm.getAccountId();
|
||||
}
|
||||
|
||||
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_VM_START;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
return "starting user vm: " + getId();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,106 +0,0 @@
|
|||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.ApiDBUtils;
|
||||
import com.cloud.api.ApiResponseHelper;
|
||||
import com.cloud.api.BaseAsyncCmd;
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.DomainRouterResponse;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.uservm.UserVm;
|
||||
import com.cloud.vm.DomainRouter;
|
||||
|
||||
|
||||
@Implementation(description="Stops a router.", responseObject=DomainRouterResponse.class)
|
||||
public class StopRouter2Cmd extends BaseAsyncCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(StopRouter2Cmd.class.getName());
|
||||
private static final String s_name = "stoprouterresponse";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the ID of the router")
|
||||
private Long id;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getAccountId() {
|
||||
UserVm vm = ApiDBUtils.findUserVmById(getId());
|
||||
if (vm != null) {
|
||||
return vm.getAccountId();
|
||||
}
|
||||
|
||||
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_ROUTER_STOP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
return "stopping router: " + getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
try {
|
||||
DomainRouter router = _routerMgr.stopRouter(this);
|
||||
if (router != null){
|
||||
DomainRouterResponse response =ApiResponseHelper.createDomainRouterResponse(router);
|
||||
response.setResponseName(getName());
|
||||
this.setResponseObject(response);
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to stop router");
|
||||
}
|
||||
}catch (ConcurrentOperationException ex) {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
|
||||
}catch (ResourceUnavailableException ex) {
|
||||
throw new ServerApiException(BaseCmd.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -30,6 +30,8 @@ import com.cloud.api.Parameter;
|
|||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.DomainRouterResponse;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.uservm.UserVm;
|
||||
import com.cloud.vm.DomainRouter;
|
||||
|
|
@ -85,7 +87,7 @@ public class StopRouterCmd extends BaseAsyncCmd {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
public void execute() throws ConcurrentOperationException, ResourceUnavailableException{
|
||||
DomainRouter result = _routerMgr.stopRouter(this);
|
||||
if (result != null){
|
||||
DomainRouterResponse response =ApiResponseHelper.createDomainRouterResponse(result);
|
||||
|
|
|
|||
|
|
@ -1,98 +0,0 @@
|
|||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.ApiResponseHelper;
|
||||
import com.cloud.api.BaseAsyncCmd;
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.SystemVmResponse;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.UserContext;
|
||||
import com.cloud.vm.VMInstanceVO;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
|
||||
@Implementation(description="Stops a system VM.", responseObject=SystemVmResponse.class)
|
||||
public class StopSystemVm2Cmd extends BaseAsyncCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(StopSystemVm2Cmd.class.getName());
|
||||
|
||||
private static final String s_name = "stopsystemvmresponse";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="The ID of the system virtual machine")
|
||||
private Long id;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getAccountId() {
|
||||
Account account = UserContext.current().getAccount();
|
||||
if (account != null) {
|
||||
return account.getId();
|
||||
}
|
||||
|
||||
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_SSVM_STOP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
return "stopping system vm: " + getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
VirtualMachine instance = _mgr.stopSystemVm(this);
|
||||
if (instance != null){
|
||||
SystemVmResponse response = ApiResponseHelper.createSystemVmResponse((VMInstanceVO)instance);
|
||||
response.setResponseName(getName());
|
||||
this.setResponseObject(response);
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to stop system vm");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -29,6 +29,7 @@ import com.cloud.api.Parameter;
|
|||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.UserVmResponse;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.uservm.UserVm;
|
||||
|
||||
|
|
@ -87,7 +88,7 @@ public class StopVMCmd extends BaseAsyncCmd {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
public void execute() throws ServerApiException, ConcurrentOperationException{
|
||||
UserVm result = _userVmService.stopVirtualMachine(this);
|
||||
if (result != null) {
|
||||
UserVmResponse response = ApiResponseHelper.createUserVmResponse(result);
|
||||
|
|
|
|||
|
|
@ -1,100 +0,0 @@
|
|||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.ApiDBUtils;
|
||||
import com.cloud.api.ApiResponseHelper;
|
||||
import com.cloud.api.BaseAsyncCmd;
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.UserVmResponse;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.uservm.UserVm;
|
||||
|
||||
@Implementation(description="Stops a virtual machine.", responseObject=UserVmResponse.class)
|
||||
public class StopVm2Cmd extends BaseAsyncCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(StopVMCmd.class.getName());
|
||||
|
||||
private static final String s_name = "stopvirtualmachineresponse";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="The ID of the virtual machine")
|
||||
private Long id;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
@Override
|
||||
public void execute(){
|
||||
try {
|
||||
UserVm userVm = _userVmService.stopVirtualMachine(this);
|
||||
UserVmResponse response = ApiResponseHelper.createUserVmResponse(userVm);
|
||||
response.setResponseName(getName());
|
||||
this.setResponseObject(response);
|
||||
} catch (ConcurrentOperationException ex) {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
public static String getResultObjectName() {
|
||||
return "virtualmachine";
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getAccountId() {
|
||||
UserVm vm = ApiDBUtils.findUserVmById(getId());
|
||||
if (vm != null) {
|
||||
return vm.getAccountId();
|
||||
}
|
||||
|
||||
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_VM_STOP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
return "stopping user vm: " + getId();
|
||||
}
|
||||
}
|
||||
|
|
@ -66,7 +66,7 @@ public class UpgradeRouterCmd extends BaseCmd {
|
|||
|
||||
@Override
|
||||
public void execute(){
|
||||
DomainRouter router = _networkMgr.upgradeRouter(this);
|
||||
DomainRouter router = _routerMgr.upgradeRouter(this);
|
||||
if (router != null){
|
||||
DomainRouterResponse routerResponse = ApiResponseHelper.createDomainRouterResponse(router);
|
||||
routerResponse.setResponseName(getName());
|
||||
|
|
|
|||
|
|
@ -24,13 +24,7 @@ import java.util.LinkedHashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.cloud.acl.DomainChecker;
|
||||
import com.cloud.acl.SecurityChecker;
|
||||
import com.cloud.agent.manager.AgentManagerImpl;
|
||||
import com.cloud.agent.manager.allocator.HostAllocator;
|
||||
import com.cloud.agent.manager.allocator.PodAllocator;
|
||||
import com.cloud.agent.manager.allocator.impl.RecreateHostAllocator;
|
||||
import com.cloud.agent.manager.allocator.impl.UserConcentratedAllocator;
|
||||
import com.cloud.alert.AlertManagerImpl;
|
||||
import com.cloud.alert.dao.AlertDaoImpl;
|
||||
import com.cloud.async.AsyncJobExecutorContextImpl;
|
||||
|
|
@ -47,8 +41,6 @@ import com.cloud.configuration.dao.ConfigurationDaoImpl;
|
|||
import com.cloud.configuration.dao.ResourceCountDaoImpl;
|
||||
import com.cloud.configuration.dao.ResourceLimitDaoImpl;
|
||||
import com.cloud.consoleproxy.AgentBasedStandaloneConsoleProxyManager;
|
||||
import com.cloud.consoleproxy.ConsoleProxyAllocator;
|
||||
import com.cloud.consoleproxy.ConsoleProxyBalanceAllocator;
|
||||
import com.cloud.dc.dao.AccountVlanMapDaoImpl;
|
||||
import com.cloud.dc.dao.ClusterDaoImpl;
|
||||
import com.cloud.dc.dao.DataCenterDaoImpl;
|
||||
|
|
@ -56,34 +48,17 @@ import com.cloud.dc.dao.DataCenterIpAddressDaoImpl;
|
|||
import com.cloud.dc.dao.HostPodDaoImpl;
|
||||
import com.cloud.dc.dao.PodVlanMapDaoImpl;
|
||||
import com.cloud.dc.dao.VlanDaoImpl;
|
||||
import com.cloud.deploy.DeploymentPlanner;
|
||||
import com.cloud.deploy.SimplePlanner;
|
||||
import com.cloud.domain.dao.DomainDaoImpl;
|
||||
import com.cloud.event.dao.EventDaoImpl;
|
||||
import com.cloud.ha.CheckOnAgentInvestigator;
|
||||
import com.cloud.ha.FenceBuilder;
|
||||
import com.cloud.ha.HighAvailabilityManagerImpl;
|
||||
import com.cloud.ha.Investigator;
|
||||
import com.cloud.ha.InvestigatorImpl;
|
||||
import com.cloud.ha.StorageFence;
|
||||
import com.cloud.ha.XenServerInvestigator;
|
||||
import com.cloud.ha.dao.HighAvailabilityDaoImpl;
|
||||
import com.cloud.host.dao.DetailsDaoImpl;
|
||||
import com.cloud.host.dao.HostDaoImpl;
|
||||
import com.cloud.hypervisor.kvm.discoverer.KvmServerDiscoverer;
|
||||
import com.cloud.hypervisor.xen.discoverer.XcpServerDiscoverer;
|
||||
import com.cloud.maid.StackMaidManagerImpl;
|
||||
import com.cloud.maid.dao.StackMaidDaoImpl;
|
||||
import com.cloud.maint.UpgradeManagerImpl;
|
||||
import com.cloud.maint.dao.AgentUpgradeDaoImpl;
|
||||
import com.cloud.network.ExteralIpAddressAllocator;
|
||||
import com.cloud.network.IpAddrAllocator;
|
||||
import com.cloud.network.NetworkManagerImpl;
|
||||
import com.cloud.network.configuration.ControlNetworkGuru;
|
||||
import com.cloud.network.configuration.GuestNetworkGuru;
|
||||
import com.cloud.network.configuration.NetworkGuru;
|
||||
import com.cloud.network.configuration.PodBasedNetworkGuru;
|
||||
import com.cloud.network.configuration.PublicNetworkGuru;
|
||||
import com.cloud.network.dao.FirewallRulesDaoImpl;
|
||||
import com.cloud.network.dao.IPAddressDaoImpl;
|
||||
import com.cloud.network.dao.LoadBalancerDaoImpl;
|
||||
|
|
@ -101,15 +76,8 @@ import com.cloud.network.security.dao.NetworkGroupVMMapDaoImpl;
|
|||
import com.cloud.network.security.dao.NetworkGroupWorkDaoImpl;
|
||||
import com.cloud.network.security.dao.VmRulesetLogDaoImpl;
|
||||
import com.cloud.offerings.dao.NetworkOfferingDaoImpl;
|
||||
import com.cloud.resource.Discoverer;
|
||||
import com.cloud.server.auth.MD5UserAuthenticator;
|
||||
import com.cloud.server.auth.UserAuthenticator;
|
||||
import com.cloud.service.dao.ServiceOfferingDaoImpl;
|
||||
import com.cloud.storage.StorageManagerImpl;
|
||||
import com.cloud.storage.allocator.FirstFitStoragePoolAllocator;
|
||||
import com.cloud.storage.allocator.GarbageCollectingStoragePoolAllocator;
|
||||
import com.cloud.storage.allocator.LocalStoragePoolAllocator;
|
||||
import com.cloud.storage.allocator.StoragePoolAllocator;
|
||||
import com.cloud.storage.dao.DiskOfferingDaoImpl;
|
||||
import com.cloud.storage.dao.GuestOSCategoryDaoImpl;
|
||||
import com.cloud.storage.dao.GuestOSDaoImpl;
|
||||
|
|
@ -127,10 +95,7 @@ import com.cloud.storage.dao.VMTemplateZoneDaoImpl;
|
|||
import com.cloud.storage.dao.VolumeDaoImpl;
|
||||
import com.cloud.storage.download.DownloadMonitorImpl;
|
||||
import com.cloud.storage.preallocatedlun.dao.PreallocatedLunDaoImpl;
|
||||
import com.cloud.storage.secondary.SecondaryStorageDiscoverer;
|
||||
import com.cloud.storage.secondary.SecondaryStorageManagerImpl;
|
||||
import com.cloud.storage.secondary.SecondaryStorageVmAllocator;
|
||||
import com.cloud.storage.secondary.SecondaryStorageVmDefaultAllocator;
|
||||
import com.cloud.storage.snapshot.SnapshotManagerImpl;
|
||||
import com.cloud.storage.snapshot.SnapshotSchedulerImpl;
|
||||
import com.cloud.storage.upload.UploadMonitorImpl;
|
||||
|
|
@ -333,51 +298,8 @@ public class DefaultComponentLibrary implements ComponentLibrary {
|
|||
}
|
||||
return _managers;
|
||||
}
|
||||
|
||||
|
||||
protected void populateAdapters() {
|
||||
|
||||
List<Pair<String, Class<? extends HostAllocator>>> hostAllocators = new ArrayList<Pair<String, Class<? extends HostAllocator>>>();
|
||||
hostAllocators.add(new Pair<String, Class<? extends HostAllocator>>("FirstFitRouting", RecreateHostAllocator.class));
|
||||
//addAdapter("FirstFit", FirstFitAllocator.class);
|
||||
addAdapterChain(HostAllocator.class, hostAllocators);
|
||||
|
||||
|
||||
List<Pair<String, Class<? extends StoragePoolAllocator>>> poolAllocators = new ArrayList<Pair<String, Class<? extends StoragePoolAllocator>>>();
|
||||
poolAllocators.add(new Pair<String, Class<? extends StoragePoolAllocator>>("LocalStorage", LocalStoragePoolAllocator.class));
|
||||
poolAllocators.add(new Pair<String, Class<? extends StoragePoolAllocator>>("Storage", FirstFitStoragePoolAllocator.class));
|
||||
poolAllocators.add(new Pair<String, Class<? extends StoragePoolAllocator>>("GarbageCollecting", GarbageCollectingStoragePoolAllocator.class));
|
||||
addAdapterChain(StoragePoolAllocator.class, poolAllocators);
|
||||
|
||||
List<Pair<String, Class<? extends NetworkGuru>>> networkGurus = new ArrayList<Pair<String, Class<? extends NetworkGuru>>>();
|
||||
networkGurus.add(new Pair<String, Class<? extends NetworkGuru>>("GuestNetworkGuru", GuestNetworkGuru.class));
|
||||
networkGurus.add(new Pair<String, Class<? extends NetworkGuru>>("PublicNetworkGuru", PublicNetworkGuru.class));
|
||||
networkGurus.add(new Pair<String, Class<? extends NetworkGuru>>("PodBasedNetworkGuru", PodBasedNetworkGuru.class));
|
||||
networkGurus.add(new Pair<String, Class<? extends NetworkGuru>>("ControlNetworkGuru", ControlNetworkGuru.class));
|
||||
addAdapterChain(NetworkGuru.class, networkGurus);
|
||||
|
||||
addOneAdapter(PodAllocator.class, "UserConcentratedPodAllocator", UserConcentratedAllocator.class);
|
||||
addOneAdapter(ConsoleProxyAllocator.class, "ConsoleProxyBalanceAllocator", ConsoleProxyBalanceAllocator.class);
|
||||
addOneAdapter(SecondaryStorageVmAllocator.class, "SecondaryStorageVmDefaultBalance", SecondaryStorageVmDefaultAllocator.class);
|
||||
addOneAdapter(IpAddrAllocator.class, "BasicExternalIpAddressAllocator", ExteralIpAddressAllocator.class);
|
||||
addOneAdapter(UserAuthenticator.class, "MD5UserAuthenticator", MD5UserAuthenticator.class);
|
||||
|
||||
|
||||
List<Pair<String, Class<? extends Investigator>>> investigators = new ArrayList<Pair<String, Class<? extends Investigator>>>();
|
||||
investigators.add(new Pair<String, Class<? extends Investigator>>("SimpleInvestigator", CheckOnAgentInvestigator.class));
|
||||
investigators.add(new Pair<String, Class<? extends Investigator>>("XenServerInvestigator", XenServerInvestigator.class));
|
||||
investigators.add(new Pair<String, Class<? extends Investigator>>("PingInvestigator", InvestigatorImpl.class));
|
||||
addAdapterChain(Investigator.class, investigators);
|
||||
|
||||
addOneAdapter(FenceBuilder.class, "StorageFenceBuilder", StorageFence.class);
|
||||
|
||||
List<Pair<String, Class<? extends Discoverer>>> discovers = new ArrayList<Pair<String, Class<? extends Discoverer>>>();
|
||||
discovers.add(new Pair<String, Class<? extends Discoverer>>("XCP Agent", XcpServerDiscoverer.class));
|
||||
discovers.add(new Pair<String, Class<? extends Discoverer>>("SecondaryStorage", SecondaryStorageDiscoverer.class));
|
||||
discovers.add(new Pair<String, Class<? extends Discoverer>>("KVM Agent", KvmServerDiscoverer.class));
|
||||
addAdapterChain(Discoverer.class, discovers);
|
||||
|
||||
addOneAdapter(SecurityChecker.class, "DomainChecker", DomainChecker.class);
|
||||
addOneAdapter(DeploymentPlanner.class, "SimpleDeploymentPlanner", SimplePlanner.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -286,6 +286,8 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, VirtualMach
|
|||
|
||||
private String _domain;
|
||||
private String _instance;
|
||||
|
||||
private boolean _useNewNetworking = false;
|
||||
|
||||
// private String _privateNetmask;
|
||||
private int _proxyCmdPort = DEFAULT_PROXY_CMD_PORT;
|
||||
|
|
@ -531,7 +533,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, VirtualMach
|
|||
@Override
|
||||
public ConsoleProxyVO startProxy(long proxyVmId, long startEventId) {
|
||||
try {
|
||||
return start(proxyVmId, startEventId);
|
||||
return start2(proxyVmId, startEventId);
|
||||
} catch (StorageUnavailableException e) {
|
||||
s_logger.warn("Exception while trying to start console proxy", e);
|
||||
return null;
|
||||
|
|
@ -548,6 +550,9 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, VirtualMach
|
|||
}
|
||||
|
||||
public ConsoleProxyVO start2(long proxyVmId, long startEventId) throws ResourceUnavailableException, InsufficientCapacityException, ConcurrentOperationException {
|
||||
if (!_useNewNetworking) {
|
||||
return start(proxyVmId, startEventId);
|
||||
}
|
||||
ConsoleProxyVO proxy = _consoleProxyDao.findById(proxyVmId);
|
||||
AccountVO systemAcct = _accountMgr.getSystemAccount();
|
||||
UserVO systemUser = _accountMgr.getSystemUser();
|
||||
|
|
@ -556,8 +561,8 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, VirtualMach
|
|||
|
||||
@Override
|
||||
@DB
|
||||
public ConsoleProxyVO start(long proxyId, long startEventId) throws StorageUnavailableException, InsufficientCapacityException,
|
||||
ConcurrentOperationException {
|
||||
public ConsoleProxyVO start(long proxyId, long startEventId) throws InsufficientCapacityException,
|
||||
ConcurrentOperationException, StorageUnavailableException {
|
||||
|
||||
AsyncJobExecutor asyncExecutor = BaseAsyncJobExecutor.getCurrentExecutor();
|
||||
if (asyncExecutor != null) {
|
||||
|
|
@ -881,7 +886,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, VirtualMach
|
|||
if (s_logger.isDebugEnabled())
|
||||
s_logger.debug("Assign console proxy from a newly started instance for request from data center : " + dataCenterId);
|
||||
|
||||
Map<String, Object> context = createProxyInstance(dataCenterId);
|
||||
Map<String, Object> context = _useNewNetworking ? createProxyInstance2(dataCenterId) : createProxyInstance(dataCenterId);
|
||||
|
||||
long proxyVmId = (Long) context.get("proxyVmId");
|
||||
if (proxyVmId == 0) {
|
||||
|
|
@ -921,7 +926,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, VirtualMach
|
|||
if (s_logger.isDebugEnabled())
|
||||
s_logger.debug("Assign console proxy from a newly started instance for request from data center : " + dataCenterId);
|
||||
|
||||
Map<String, Object> context = createProxyInstance(dataCenterId);
|
||||
Map<String, Object> context = _useNewNetworking ? createProxyInstance2(dataCenterId) : createProxyInstance(dataCenterId);
|
||||
|
||||
long proxyVmId = (Long) context.get("proxyVmId");
|
||||
if (proxyVmId == 0) {
|
||||
|
|
@ -1468,7 +1473,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, VirtualMach
|
|||
try {
|
||||
if (proxyLock.lock(ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_SYNC)) {
|
||||
try {
|
||||
readyProxy = start(readyProxy.getId(), 0);
|
||||
readyProxy = start2(readyProxy.getId(), 0);
|
||||
} finally {
|
||||
proxyLock.unlock();
|
||||
}
|
||||
|
|
@ -2294,6 +2299,8 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, VirtualMach
|
|||
value = configs.get("secondary.storage.vm");
|
||||
if (value != null && value.equalsIgnoreCase("true"))
|
||||
_use_storage_vm = true;
|
||||
|
||||
_useNewNetworking = Boolean.parseBoolean(configs.get("use.new.networking"));
|
||||
|
||||
if (s_logger.isInfoEnabled()) {
|
||||
s_logger.info("Console proxy max session soft limit : " + _capacityPerProxy);
|
||||
|
|
|
|||
|
|
@ -17,14 +17,13 @@
|
|||
*/
|
||||
package com.cloud.network;
|
||||
|
||||
import com.cloud.api.commands.StartRouter2Cmd;
|
||||
import com.cloud.api.commands.RebootRouterCmd;
|
||||
import com.cloud.api.commands.StartRouterCmd;
|
||||
import com.cloud.api.commands.StopRouter2Cmd;
|
||||
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.vm.DomainRouter;
|
||||
|
||||
|
|
@ -35,17 +34,16 @@ public interface DomainRouterService {
|
|||
* @return DomainRouter object
|
||||
* @throws InvalidParameterValueException, PermissionDeniedException
|
||||
*/
|
||||
DomainRouter startRouter(StartRouterCmd cmd) throws InvalidParameterValueException, PermissionDeniedException;
|
||||
DomainRouter startRouter(StartRouterCmd cmd) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException;
|
||||
|
||||
/**
|
||||
* Stops domain router
|
||||
* @param cmd the command specifying router's id
|
||||
* @return router if successful, null otherwise
|
||||
* @throws InvalidParameterValueException, PermissionDeniedException
|
||||
*/
|
||||
DomainRouter stopRouter(StopRouterCmd cmd);
|
||||
DomainRouter stopRouter(StopRouterCmd cmd) throws ConcurrentOperationException, ResourceUnavailableException;
|
||||
|
||||
DomainRouter startRouter(StartRouter2Cmd cmd) throws ResourceUnavailableException, InsufficientCapacityException, ConcurrentOperationException;
|
||||
DomainRouter startRouter(long routerId) throws ResourceUnavailableException, InsufficientCapacityException, ConcurrentOperationException;
|
||||
|
||||
/**
|
||||
* Stops domain router
|
||||
|
|
@ -55,5 +53,16 @@ public interface DomainRouterService {
|
|||
* @throws ResourceUnavailableException
|
||||
* @throws InvalidParameterValueException, PermissionDeniedException
|
||||
*/
|
||||
DomainRouter stopRouter(StopRouter2Cmd cmd) throws ResourceUnavailableException, ConcurrentOperationException;
|
||||
DomainRouter stopRouter(long routerId) throws ResourceUnavailableException, ConcurrentOperationException;
|
||||
|
||||
/**
|
||||
* Reboots domain router
|
||||
* @param cmd the command specifying router's id
|
||||
* @return router if successful
|
||||
* @throws InvalidParameterValueException, PermissionDeniedException
|
||||
*/
|
||||
DomainRouter rebootRouter(RebootRouterCmd cmd);
|
||||
|
||||
DomainRouter upgradeRouter(UpgradeRouterCmd cmd);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,23 +24,16 @@ import com.cloud.api.ServerApiException;
|
|||
import com.cloud.api.commands.AddVpnUserCmd;
|
||||
import com.cloud.api.commands.AssignToLoadBalancerRuleCmd;
|
||||
import com.cloud.api.commands.AssociateIPAddrCmd;
|
||||
import com.cloud.api.commands.CreateIpForwardingRuleCmd;
|
||||
import com.cloud.api.commands.CreatePortForwardingRuleCmd;
|
||||
import com.cloud.api.commands.CreateLoadBalancerRuleCmd;
|
||||
import com.cloud.api.commands.CreatePortForwardingRuleCmd;
|
||||
import com.cloud.api.commands.CreateRemoteAccessVpnCmd;
|
||||
import com.cloud.api.commands.DeleteIpForwardingRuleCmd;
|
||||
import com.cloud.api.commands.DeletePortForwardingRuleCmd;
|
||||
import com.cloud.api.commands.DeleteLoadBalancerRuleCmd;
|
||||
import com.cloud.api.commands.DeleteRemoteAccessVpnCmd;
|
||||
import com.cloud.api.commands.DisassociateIPAddrCmd;
|
||||
import com.cloud.api.commands.ListPortForwardingRulesCmd;
|
||||
import com.cloud.api.commands.RebootRouterCmd;
|
||||
import com.cloud.api.commands.RemoveFromLoadBalancerRuleCmd;
|
||||
import com.cloud.api.commands.RemoveVpnUserCmd;
|
||||
import com.cloud.api.commands.StartRouterCmd;
|
||||
import com.cloud.api.commands.StopRouterCmd;
|
||||
import com.cloud.api.commands.UpdateLoadBalancerRuleCmd;
|
||||
import com.cloud.api.commands.UpgradeRouterCmd;
|
||||
import com.cloud.dc.DataCenter;
|
||||
import com.cloud.dc.DataCenterVO;
|
||||
import com.cloud.dc.HostPodVO;
|
||||
|
|
@ -121,39 +114,16 @@ public interface NetworkManager {
|
|||
|
||||
DomainRouterVO startRouter(long routerId, long eventId);
|
||||
|
||||
/**
|
||||
* Starts domain router
|
||||
* @param cmd the command specifying router's id
|
||||
* @return DomainRouter object
|
||||
* @throws InvalidParameterValueException, PermissionDeniedException
|
||||
*/
|
||||
DomainRouter startRouter(StartRouterCmd cmd);
|
||||
|
||||
boolean releaseRouter(long routerId);
|
||||
|
||||
boolean destroyRouter(long routerId);
|
||||
|
||||
boolean stopRouter(long routerId, long eventId);
|
||||
|
||||
/**
|
||||
* Stops domain router
|
||||
* @param cmd the command specifying router's id
|
||||
* @return router if successful, null otherwise
|
||||
* @throws InvalidParameterValueException, PermissionDeniedException
|
||||
*/
|
||||
DomainRouter stopRouter(StopRouterCmd cmd);
|
||||
|
||||
boolean getRouterStatistics(long vmId, Map<String, long[]> netStats, Map<String, long[]> diskStats);
|
||||
|
||||
boolean rebootRouter(long routerId, long eventId);
|
||||
|
||||
/**
|
||||
* Reboots domain router
|
||||
* @param cmd the command specifying router's id
|
||||
* @return the rebooted router
|
||||
* @throws InvalidParameterValueException, PermissionDeniedException
|
||||
*/
|
||||
DomainRouter rebootRouter(RebootRouterCmd cmd);
|
||||
/**
|
||||
* @param hostId get all of the virtual machine routers on a host.
|
||||
* @return collection of VirtualMachineRouter
|
||||
|
|
@ -317,7 +287,6 @@ public interface NetworkManager {
|
|||
void prepare(VirtualMachineProfile<? extends VMInstanceVO> profile, DeployDestination dest, ReservationContext context) throws InsufficientNetworkCapacityException, ConcurrentOperationException, ResourceUnavailableException;
|
||||
void release(VirtualMachineProfile<? extends VMInstanceVO> vmProfile);
|
||||
|
||||
DomainRouter upgradeRouter(UpgradeRouterCmd cmd);
|
||||
List<? extends Nic> getNics (VirtualMachine vm);
|
||||
|
||||
List<AccountVO> getAccountsUsingNetworkConfiguration(long configurationId);
|
||||
|
|
|
|||
|
|
@ -53,17 +53,12 @@ import com.cloud.api.commands.CreateLoadBalancerRuleCmd;
|
|||
import com.cloud.api.commands.CreatePortForwardingRuleCmd;
|
||||
import com.cloud.api.commands.CreateRemoteAccessVpnCmd;
|
||||
import com.cloud.api.commands.DeleteLoadBalancerRuleCmd;
|
||||
import com.cloud.api.commands.DeletePortForwardingRuleCmd;
|
||||
import com.cloud.api.commands.DeleteRemoteAccessVpnCmd;
|
||||
import com.cloud.api.commands.DisassociateIPAddrCmd;
|
||||
import com.cloud.api.commands.ListPortForwardingRulesCmd;
|
||||
import com.cloud.api.commands.RebootRouterCmd;
|
||||
import com.cloud.api.commands.RemoveFromLoadBalancerRuleCmd;
|
||||
import com.cloud.api.commands.RemoveVpnUserCmd;
|
||||
import com.cloud.api.commands.StartRouterCmd;
|
||||
import com.cloud.api.commands.StopRouterCmd;
|
||||
import com.cloud.api.commands.UpdateLoadBalancerRuleCmd;
|
||||
import com.cloud.api.commands.UpgradeRouterCmd;
|
||||
import com.cloud.async.AsyncJobManager;
|
||||
import com.cloud.capacity.dao.CapacityDao;
|
||||
import com.cloud.configuration.Config;
|
||||
|
|
@ -496,11 +491,6 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
return _routerMgr.destroyRouter(routerId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DomainRouter upgradeRouter(UpgradeRouterCmd cmd) throws InvalidParameterValueException, PermissionDeniedException {
|
||||
return _routerMgr.upgradeRouter(cmd);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean savePasswordToRouter(final long routerId, final String vmIpAddress, final String password) {
|
||||
return _routerMgr.savePasswordToRouter(routerId, vmIpAddress, password);
|
||||
|
|
@ -511,22 +501,12 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
return _routerMgr.startRouter(routerId, eventId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DomainRouter startRouter(StartRouterCmd cmd) throws InvalidParameterValueException, PermissionDeniedException {
|
||||
return _routerMgr.startRouter(cmd);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean stopRouter(final long routerId, long eventId) {
|
||||
return _routerMgr.stopRouter(routerId, eventId);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public DomainRouter stopRouter(StopRouterCmd cmd) throws InvalidParameterValueException, PermissionDeniedException{
|
||||
return _routerMgr.stopRouter(cmd);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getRouterStatistics(final long vmId, final Map<String, long[]> netStats, final Map<String, long[]> diskStats) {
|
||||
return _routerMgr.getRouterStatistics(vmId, netStats, diskStats);
|
||||
|
|
@ -538,12 +518,6 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
return _routerMgr.rebootRouter(routerId, startEventId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DomainRouterVO rebootRouter(RebootRouterCmd cmd) throws InvalidParameterValueException, PermissionDeniedException{
|
||||
_routerMgr.rebootRouter(cmd);
|
||||
return _routerMgr.getRouter(cmd.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean associateIP(final DomainRouterVO router, final List<String> ipAddrList, final boolean add, long vmId) {
|
||||
Commands cmds = new Commands(OnError.Continue);
|
||||
|
|
|
|||
|
|
@ -20,9 +20,6 @@ package com.cloud.network.router;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
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.dc.DataCenterVO;
|
||||
import com.cloud.dc.HostPodVO;
|
||||
|
|
@ -97,39 +94,16 @@ public interface DomainRouterManager extends Manager {
|
|||
|
||||
DomainRouterVO startRouter(long routerId, long eventId);
|
||||
|
||||
/**
|
||||
* Starts domain router
|
||||
* @param cmd the command specifying router's id
|
||||
* @return DomainRouter object
|
||||
* @throws InvalidParameterValueException, PermissionDeniedException
|
||||
*/
|
||||
DomainRouter startRouter(StartRouterCmd cmd) throws InvalidParameterValueException, PermissionDeniedException;
|
||||
|
||||
boolean releaseRouter(long routerId);
|
||||
|
||||
boolean destroyRouter(long routerId);
|
||||
|
||||
boolean stopRouter(long routerId, long eventId);
|
||||
|
||||
/**
|
||||
* Stops domain router
|
||||
* @param cmd the command specifying router's id
|
||||
* @return router if successful, null otherwise
|
||||
* @throws InvalidParameterValueException, PermissionDeniedException
|
||||
*/
|
||||
DomainRouter stopRouter(StopRouterCmd cmd) throws InvalidParameterValueException, PermissionDeniedException;
|
||||
|
||||
boolean getRouterStatistics(long vmId, Map<String, long[]> netStats, Map<String, long[]> diskStats);
|
||||
|
||||
boolean rebootRouter(long routerId, long eventId);
|
||||
|
||||
/**
|
||||
* Reboots domain router
|
||||
* @param cmd the command specifying router's id
|
||||
* @return router if successful
|
||||
* @throws InvalidParameterValueException, PermissionDeniedException
|
||||
*/
|
||||
DomainRouter rebootRouter(RebootRouterCmd cmd) throws InvalidParameterValueException, PermissionDeniedException;
|
||||
/**
|
||||
* @param hostId get all of the virtual machine routers on a host.
|
||||
* @return collection of VirtualMachineRouter
|
||||
|
|
|
|||
|
|
@ -59,9 +59,7 @@ import com.cloud.agent.api.routing.VpnUsersCfgCommand;
|
|||
import com.cloud.agent.manager.Commands;
|
||||
import com.cloud.alert.AlertManager;
|
||||
import com.cloud.api.commands.RebootRouterCmd;
|
||||
import com.cloud.api.commands.StartRouter2Cmd;
|
||||
import com.cloud.api.commands.StartRouterCmd;
|
||||
import com.cloud.api.commands.StopRouter2Cmd;
|
||||
import com.cloud.api.commands.StopRouterCmd;
|
||||
import com.cloud.api.commands.UpgradeRouterCmd;
|
||||
import com.cloud.async.AsyncJobExecutor;
|
||||
|
|
@ -252,6 +250,7 @@ public class DomainRouterManagerImpl implements DomainRouterManager, DomainRoute
|
|||
ScheduledExecutorService _executor;
|
||||
|
||||
AccountVO _systemAcct;
|
||||
boolean _useNewNetworking;
|
||||
|
||||
@Override
|
||||
public DomainRouterVO getRouter(long accountId, long dataCenterId) {
|
||||
|
|
@ -757,7 +756,10 @@ public class DomainRouterManagerImpl implements DomainRouterManager, DomainRoute
|
|||
}
|
||||
|
||||
@Override
|
||||
public DomainRouter startRouter(StartRouterCmd cmd) throws InvalidParameterValueException, PermissionDeniedException{
|
||||
public DomainRouter startRouter(StartRouterCmd cmd) throws InvalidParameterValueException, PermissionDeniedException, ResourceUnavailableException, InsufficientCapacityException, ConcurrentOperationException{
|
||||
if (_useNewNetworking) {
|
||||
return startRouter(cmd.getId());
|
||||
}
|
||||
Long routerId = cmd.getId();
|
||||
Account account = UserContext.current().getAccount();
|
||||
|
||||
|
|
@ -1258,7 +1260,10 @@ public class DomainRouterManagerImpl implements DomainRouterManager, DomainRoute
|
|||
|
||||
|
||||
@Override
|
||||
public DomainRouter stopRouter(StopRouterCmd cmd) throws InvalidParameterValueException, PermissionDeniedException{
|
||||
public DomainRouter stopRouter(StopRouterCmd cmd) throws InvalidParameterValueException, PermissionDeniedException, ResourceUnavailableException, ConcurrentOperationException{
|
||||
if (_useNewNetworking) {
|
||||
return stopRouter(cmd.getId());
|
||||
}
|
||||
Long routerId = cmd.getId();
|
||||
Account account = UserContext.current().getAccount();
|
||||
|
||||
|
|
@ -1505,6 +1510,8 @@ public class DomainRouterManagerImpl implements DomainRouterManager, DomainRoute
|
|||
_routerTemplateId = _template.getId();
|
||||
}
|
||||
|
||||
_useNewNetworking = Boolean.parseBoolean(configs.get("use.new.networking"));
|
||||
|
||||
_systemAcct = _accountMgr.getSystemAccount();
|
||||
|
||||
s_logger.info("DomainRouterManager is configured.");
|
||||
|
|
@ -2341,8 +2348,7 @@ public class DomainRouterManagerImpl implements DomainRouterManager, DomainRoute
|
|||
}
|
||||
|
||||
@Override
|
||||
public DomainRouter startRouter(StartRouter2Cmd cmd) throws ResourceUnavailableException, InsufficientCapacityException, ConcurrentOperationException {
|
||||
Long routerId = cmd.getId();
|
||||
public DomainRouter startRouter(long routerId) throws ResourceUnavailableException, InsufficientCapacityException, ConcurrentOperationException {
|
||||
Account account = UserContext.current().getAccount();
|
||||
|
||||
//verify parameters
|
||||
|
|
@ -2367,8 +2373,7 @@ public class DomainRouterManagerImpl implements DomainRouterManager, DomainRoute
|
|||
* @throws InvalidParameterValueException, PermissionDeniedException
|
||||
*/
|
||||
@Override
|
||||
public DomainRouter stopRouter(StopRouter2Cmd cmd) throws ResourceUnavailableException, ConcurrentOperationException {
|
||||
Long routerId = cmd.getId();
|
||||
public DomainRouter stopRouter(long routerId) throws ResourceUnavailableException, ConcurrentOperationException {
|
||||
UserContext context = UserContext.current();
|
||||
Account account = context.getAccount();
|
||||
long accountId = context.getAccountId();
|
||||
|
|
|
|||
|
|
@ -71,8 +71,6 @@ import com.cloud.api.commands.RebootSystemVmCmd;
|
|||
import com.cloud.api.commands.RegisterCmd;
|
||||
import com.cloud.api.commands.RegisterPreallocatedLunCmd;
|
||||
import com.cloud.api.commands.StartSystemVMCmd;
|
||||
import com.cloud.api.commands.StartSystemVm2Cmd;
|
||||
import com.cloud.api.commands.StopSystemVm2Cmd;
|
||||
import com.cloud.api.commands.StopSystemVmCmd;
|
||||
import com.cloud.api.commands.UpdateDomainCmd;
|
||||
import com.cloud.api.commands.UpdateIsoCmd;
|
||||
|
|
@ -95,11 +93,13 @@ import com.cloud.dc.VlanVO;
|
|||
import com.cloud.domain.DomainVO;
|
||||
import com.cloud.event.EventVO;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.InsufficientStorageCapacityException;
|
||||
import com.cloud.exception.InternalErrorException;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.PermissionDeniedException;
|
||||
import com.cloud.exception.ResourceAllocationException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.exception.StorageUnavailableException;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.info.ConsoleProxyInfo;
|
||||
|
|
@ -302,8 +302,10 @@ public interface ManagementServer {
|
|||
* @throws ExecutionException
|
||||
* @throws StorageUnavailableException
|
||||
* @throws ConcurrentOperationException
|
||||
* @throws ResourceUnavailableException
|
||||
* @throws InsufficientCapacityException
|
||||
*/
|
||||
UserVm deployVirtualMachine(DeployVMCmd cmd, String password) throws ResourceAllocationException, InsufficientStorageCapacityException, ExecutionException, StorageUnavailableException, ConcurrentOperationException;
|
||||
UserVm deployVirtualMachine(DeployVMCmd cmd, String password) throws ResourceAllocationException, InsufficientStorageCapacityException, ExecutionException, StorageUnavailableException, ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException;
|
||||
|
||||
/**
|
||||
* Finds a domain router by user and data center
|
||||
|
|
@ -673,11 +675,11 @@ public interface ManagementServer {
|
|||
ConsoleProxyVO findConsoleProxyById(long instanceId);
|
||||
VMInstanceVO findSystemVMById(long instanceId);
|
||||
VMInstanceVO stopSystemVM(StopSystemVmCmd cmd);
|
||||
VMInstanceVO startSystemVM(StartSystemVMCmd cmd);
|
||||
VMInstanceVO rebootSystemVM(RebootSystemVmCmd cmd);
|
||||
VirtualMachine startSystemVM(StartSystemVMCmd cmd);
|
||||
VirtualMachine rebootSystemVM(RebootSystemVmCmd cmd);
|
||||
|
||||
VirtualMachine startSystemVm(StartSystemVm2Cmd cmd);
|
||||
VirtualMachine stopSystemVm(StopSystemVm2Cmd cmd);
|
||||
VirtualMachine startSystemVm(long vmId);
|
||||
VirtualMachine stopSystemVm(long vmId);
|
||||
|
||||
/**
|
||||
* Returns a configuration value with the specified name
|
||||
|
|
|
|||
|
|
@ -78,6 +78,7 @@ import com.cloud.api.commands.CreateDomainCmd;
|
|||
import com.cloud.api.commands.DeleteDomainCmd;
|
||||
import com.cloud.api.commands.DeletePreallocatedLunCmd;
|
||||
import com.cloud.api.commands.DeployVMCmd;
|
||||
import com.cloud.api.commands.DeployVm2Cmd;
|
||||
import com.cloud.api.commands.ExtractVolumeCmd;
|
||||
import com.cloud.api.commands.GetCloudIdentifierCmd;
|
||||
import com.cloud.api.commands.ListAccountsCmd;
|
||||
|
|
@ -120,8 +121,6 @@ import com.cloud.api.commands.RebootSystemVmCmd;
|
|||
import com.cloud.api.commands.RegisterCmd;
|
||||
import com.cloud.api.commands.RegisterPreallocatedLunCmd;
|
||||
import com.cloud.api.commands.StartSystemVMCmd;
|
||||
import com.cloud.api.commands.StartSystemVm2Cmd;
|
||||
import com.cloud.api.commands.StopSystemVm2Cmd;
|
||||
import com.cloud.api.commands.StopSystemVmCmd;
|
||||
import com.cloud.api.commands.UpdateDomainCmd;
|
||||
import com.cloud.api.commands.UpdateIsoCmd;
|
||||
|
|
@ -177,6 +176,7 @@ import com.cloud.exception.AgentUnavailableException;
|
|||
import com.cloud.exception.CloudAuthenticationException;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientAddressCapacityException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.InsufficientStorageCapacityException;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.ManagementServerException;
|
||||
|
|
@ -251,7 +251,6 @@ import com.cloud.storage.dao.VolumeDao;
|
|||
import com.cloud.storage.preallocatedlun.PreallocatedLunVO;
|
||||
import com.cloud.storage.preallocatedlun.dao.PreallocatedLunDao;
|
||||
import com.cloud.storage.secondary.SecondaryStorageVmManager;
|
||||
import com.cloud.storage.snapshot.SnapshotManager;
|
||||
import com.cloud.storage.upload.UploadMonitor;
|
||||
import com.cloud.template.TemplateManager;
|
||||
import com.cloud.user.Account;
|
||||
|
|
@ -274,6 +273,7 @@ import com.cloud.utils.Pair;
|
|||
import com.cloud.utils.PasswordGenerator;
|
||||
import com.cloud.utils.component.Adapters;
|
||||
import com.cloud.utils.component.ComponentLocator;
|
||||
import com.cloud.utils.component.Inject;
|
||||
import com.cloud.utils.concurrency.NamedThreadFactory;
|
||||
import com.cloud.utils.db.DB;
|
||||
import com.cloud.utils.db.Filter;
|
||||
|
|
@ -294,6 +294,7 @@ import com.cloud.vm.InstanceGroupVO;
|
|||
import com.cloud.vm.SecondaryStorageVmVO;
|
||||
import com.cloud.vm.State;
|
||||
import com.cloud.vm.UserVmManager;
|
||||
import com.cloud.vm.UserVmService;
|
||||
import com.cloud.vm.UserVmVO;
|
||||
import com.cloud.vm.VMInstanceVO;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
|
|
@ -362,7 +363,6 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
private final AsyncJobDao _jobDao;
|
||||
private final AsyncJobManager _asyncMgr;
|
||||
private final TemplateManager _tmpltMgr;
|
||||
private final SnapshotManager _snapMgr;
|
||||
private final NetworkGroupManager _networkGroupMgr;
|
||||
private final int _purgeDelay;
|
||||
private final boolean _directAttachNetworkExternalIpAllocator;
|
||||
|
|
@ -374,6 +374,7 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
private final CertificateDao _certDao;
|
||||
private final RemoteAccessVpnDao _remoteAccessVpnDao;
|
||||
private final VpnUserDao _vpnUsersDao;
|
||||
@Inject private UserVmService _userVmService;
|
||||
|
||||
private final ScheduledExecutorService _executor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("AccountChecker"));
|
||||
private final ScheduledExecutorService _eventExecutor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("EventChecker"));
|
||||
|
|
@ -388,6 +389,8 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
private final int _proxyRamSize;
|
||||
private final int _ssRamSize;
|
||||
private int _maxVolumeSizeInMb;
|
||||
|
||||
private boolean _useNewNetworking = false;
|
||||
|
||||
private final Map<String, Boolean> _availableIdsMap;
|
||||
|
||||
|
|
@ -459,7 +462,6 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
_alertMgr = locator.getManager(AlertManager.class);
|
||||
_asyncMgr = locator.getManager(AsyncJobManager.class);
|
||||
_tmpltMgr = locator.getManager(TemplateManager.class);
|
||||
_snapMgr = locator.getManager(SnapshotManager.class);
|
||||
_networkGroupMgr = locator.getManager(NetworkGroupManager.class);
|
||||
_uploadMonitor = locator.getManager(UploadMonitor.class);
|
||||
|
||||
|
|
@ -509,6 +511,8 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
String maxVolumeSizeInMbString = _configDao.getValue("max.volume.size.gb");
|
||||
int maxVolumeSizeMb = NumbersUtil.parseInt(maxVolumeSizeInMbString, (2000*1024));//2000 gb
|
||||
_maxVolumeSizeInMb = maxVolumeSizeMb;
|
||||
|
||||
_useNewNetworking = Boolean.parseBoolean(_configs.get("use.new.networking"));
|
||||
}
|
||||
|
||||
protected Map<String, String> getConfigs() {
|
||||
|
|
@ -1099,8 +1103,19 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
|
||||
@Override
|
||||
public UserVm deployVirtualMachine(DeployVMCmd cmd, String password) throws ResourceAllocationException,
|
||||
InsufficientStorageCapacityException, ExecutionException,
|
||||
StorageUnavailableException, ConcurrentOperationException {
|
||||
ExecutionException,
|
||||
ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException {
|
||||
if (_useNewNetworking) {
|
||||
UserVm vm = _userVmService.createVirtualMachine(cmd);
|
||||
if (vm == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
DeployVm2Cmd cmd2 = new DeployVm2Cmd();
|
||||
cmd2.setId(vm.getId());
|
||||
vm = _userVmService.startVirtualMachine(cmd2);
|
||||
return vm;
|
||||
}
|
||||
Account ctxAccount = UserContext.current().getAccount();
|
||||
Long userId = UserContext.current().getUserId();
|
||||
String accountName = cmd.getAccountName();
|
||||
|
|
@ -4810,7 +4825,10 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
}
|
||||
|
||||
@Override
|
||||
public VMInstanceVO startSystemVM(StartSystemVMCmd cmd) {
|
||||
public VirtualMachine startSystemVM(StartSystemVMCmd cmd) {
|
||||
if (_useNewNetworking) {
|
||||
return startSystemVm(cmd.getId());
|
||||
}
|
||||
|
||||
//verify input
|
||||
Long id = cmd.getId();
|
||||
|
|
@ -4830,52 +4848,47 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
}
|
||||
|
||||
@Override
|
||||
public VirtualMachine startSystemVm(StartSystemVm2Cmd cmd) {
|
||||
public VirtualMachine startSystemVm(long vmId) {
|
||||
UserContext context = UserContext.current();
|
||||
long callerId = context.getUserId();
|
||||
long callerAccountId = context.getAccountId();
|
||||
|
||||
//verify input
|
||||
Long id = cmd.getId();
|
||||
|
||||
VMInstanceVO systemVm = _vmInstanceDao.findByIdTypes(id, VirtualMachine.Type.ConsoleProxy, VirtualMachine.Type.SecondaryStorageVm);
|
||||
VMInstanceVO systemVm = _vmInstanceDao.findByIdTypes(vmId, VirtualMachine.Type.ConsoleProxy, VirtualMachine.Type.SecondaryStorageVm);
|
||||
if (systemVm == null) {
|
||||
throw new InvalidParameterValueException("unable to find a system vm with id " + id);
|
||||
throw new InvalidParameterValueException("unable to find a system vm with id " + vmId);
|
||||
}
|
||||
|
||||
if (systemVm.getType() == VirtualMachine.Type.ConsoleProxy) {
|
||||
long eventId = EventUtils.saveScheduledEvent(callerId, callerAccountId, EventTypes.EVENT_PROXY_START, "Starting console proxy with Id: "+id);
|
||||
return startConsoleProxy(id, eventId);
|
||||
long eventId = EventUtils.saveScheduledEvent(callerId, callerAccountId, EventTypes.EVENT_PROXY_START, "Starting console proxy with Id: "+vmId);
|
||||
return startConsoleProxy(vmId, eventId);
|
||||
} else if (systemVm.getType() == VirtualMachine.Type.SecondaryStorageVm) {
|
||||
long eventId = EventUtils.saveScheduledEvent(callerId, callerAccountId, EventTypes.EVENT_SSVM_START, "Starting secondary storage Vm Id: "+id);
|
||||
return startSecondaryStorageVm(id, eventId);
|
||||
long eventId = EventUtils.saveScheduledEvent(callerId, callerAccountId, EventTypes.EVENT_SSVM_START, "Starting secondary storage Vm Id: "+vmId);
|
||||
return startSecondaryStorageVm(vmId, eventId);
|
||||
} else {
|
||||
throw new InvalidParameterValueException("Unable to find a system vm: " + id);
|
||||
throw new InvalidParameterValueException("Unable to find a system vm: " + vmId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public VirtualMachine stopSystemVm(StopSystemVm2Cmd cmd) {
|
||||
public VirtualMachine stopSystemVm(long vmId) {
|
||||
UserContext context = UserContext.current();
|
||||
|
||||
long callerId = context.getUserId();
|
||||
long callerAccountId = context.getAccountId();
|
||||
|
||||
Long id = cmd.getId();
|
||||
|
||||
// verify parameters
|
||||
VMInstanceVO systemVm = _vmInstanceDao.findByIdTypes(id, VirtualMachine.Type.ConsoleProxy, VirtualMachine.Type.SecondaryStorageVm);
|
||||
VMInstanceVO systemVm = _vmInstanceDao.findByIdTypes(vmId, VirtualMachine.Type.ConsoleProxy, VirtualMachine.Type.SecondaryStorageVm);
|
||||
if (systemVm == null) {
|
||||
throw new ServerApiException (BaseCmd.PARAM_ERROR, "unable to find a system vm with id " + id);
|
||||
throw new ServerApiException (BaseCmd.PARAM_ERROR, "unable to find a system vm with id " + vmId);
|
||||
}
|
||||
|
||||
// FIXME: We need to return the system VM from this method, so what do we do with the boolean response from stopConsoleProxy and stopSecondaryStorageVm?
|
||||
if (systemVm.getType().equals(VirtualMachine.Type.ConsoleProxy)){
|
||||
long eventId = EventUtils.saveScheduledEvent(callerId, callerAccountId, EventTypes.EVENT_PROXY_STOP, "stopping console proxy with Id: "+id);
|
||||
return stopConsoleProxy(id, eventId);
|
||||
long eventId = EventUtils.saveScheduledEvent(callerId, callerAccountId, EventTypes.EVENT_PROXY_STOP, "stopping console proxy with Id: "+vmId);
|
||||
return stopConsoleProxy(vmId, eventId);
|
||||
} else {
|
||||
long eventId = EventUtils.saveScheduledEvent(callerId, callerAccountId, EventTypes.EVENT_SSVM_STOP, "stopping secondary storage Vm Id: "+id);
|
||||
return stopSecondaryStorageVm(id, eventId);
|
||||
long eventId = EventUtils.saveScheduledEvent(callerId, callerAccountId, EventTypes.EVENT_SSVM_STOP, "stopping secondary storage Vm Id: "+vmId);
|
||||
return stopSecondaryStorageVm(vmId, eventId);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -69,17 +69,15 @@ import com.cloud.api.commands.AttachVolumeCmd;
|
|||
import com.cloud.api.commands.CreateTemplateCmd;
|
||||
import com.cloud.api.commands.CreateVMGroupCmd;
|
||||
import com.cloud.api.commands.DeleteVMGroupCmd;
|
||||
import com.cloud.api.commands.DeployVMCmd;
|
||||
import com.cloud.api.commands.DeployVm2Cmd;
|
||||
import com.cloud.api.commands.DestroyVMCmd;
|
||||
import com.cloud.api.commands.DestroyVm2Cmd;
|
||||
import com.cloud.api.commands.DetachVolumeCmd;
|
||||
import com.cloud.api.commands.RebootVMCmd;
|
||||
import com.cloud.api.commands.RecoverVMCmd;
|
||||
import com.cloud.api.commands.ResetVMPasswordCmd;
|
||||
import com.cloud.api.commands.StartVMCmd;
|
||||
import com.cloud.api.commands.StartVm2Cmd;
|
||||
import com.cloud.api.commands.StopVMCmd;
|
||||
import com.cloud.api.commands.StopVm2Cmd;
|
||||
import com.cloud.api.commands.UpdateVMCmd;
|
||||
import com.cloud.api.commands.UpgradeVMCmd;
|
||||
import com.cloud.async.AsyncJobExecutor;
|
||||
|
|
@ -88,7 +86,6 @@ import com.cloud.async.AsyncJobResult;
|
|||
import com.cloud.async.AsyncJobVO;
|
||||
import com.cloud.async.BaseAsyncJobExecutor;
|
||||
import com.cloud.async.executor.OperationResponse;
|
||||
import com.cloud.async.executor.RebootVMExecutor;
|
||||
import com.cloud.async.executor.StartVMExecutor;
|
||||
import com.cloud.async.executor.StopVMExecutor;
|
||||
import com.cloud.async.executor.VMExecutorHelper;
|
||||
|
|
@ -165,7 +162,6 @@ import com.cloud.storage.dao.GuestOSCategoryDao;
|
|||
import com.cloud.storage.dao.GuestOSDao;
|
||||
import com.cloud.storage.dao.SnapshotDao;
|
||||
import com.cloud.storage.dao.StoragePoolDao;
|
||||
import com.cloud.storage.dao.StoragePoolHostDao;
|
||||
import com.cloud.storage.dao.VMTemplateDao;
|
||||
import com.cloud.storage.dao.VMTemplateHostDao;
|
||||
import com.cloud.storage.dao.VolumeDao;
|
||||
|
|
@ -242,7 +238,6 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
|
|||
@Inject AlertManager _alertMgr = null;
|
||||
@Inject AccountManager _accountMgr;
|
||||
@Inject AsyncJobManager _asyncMgr;
|
||||
@Inject protected StoragePoolHostDao _storagePoolHostDao;
|
||||
@Inject VlanDao _vlanDao;
|
||||
@Inject AccountVlanMapDao _accountVlanMapDao;
|
||||
@Inject StoragePoolDao _storagePoolDao;
|
||||
|
|
@ -264,6 +259,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
|
|||
String _instance;
|
||||
String _zone;
|
||||
String _defaultNetworkDomain;
|
||||
boolean _useNewNetworking = false;
|
||||
|
||||
Random _rand = new Random(System.currentTimeMillis());
|
||||
|
||||
|
|
@ -1314,43 +1310,6 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public OperationResponse executeRebootVM(RebootVMExecutor executor, VMOperationParam param) {
|
||||
|
||||
final UserVmVO vm = _vmDao.findById(param.getVmId());
|
||||
String resultDescription;
|
||||
|
||||
if (vm == null || vm.getState() == State.Destroyed || vm.getState() == State.Expunging || vm.getRemoved() != null) {
|
||||
resultDescription = "VM does not exist or in destroying state";
|
||||
executor.getAsyncJobMgr().completeAsyncJob(executor.getJob().getId(),
|
||||
AsyncJobResult.STATUS_FAILED, 0, resultDescription);
|
||||
if(s_logger.isDebugEnabled())
|
||||
s_logger.debug("Execute asynchronize Reboot VM command: " +resultDescription);
|
||||
return new OperationResponse(OperationResponse.STATUS_FAILED, resultDescription);
|
||||
}
|
||||
|
||||
if (vm.getState() == State.Running && vm.getHostId() != null) {
|
||||
RebootCommand cmd = new RebootCommand(vm.getInstanceName());
|
||||
try {
|
||||
long seq = _agentMgr.send(vm.getHostId(), new Commands(cmd), new VMOperationListener(executor, param, vm, 0));
|
||||
resultDescription = "Execute asynchronize Reboot VM command: sending command to agent, seq - " + seq;
|
||||
if(s_logger.isDebugEnabled())
|
||||
s_logger.debug(resultDescription);
|
||||
return new OperationResponse(OperationResponse.STATUS_IN_PROGRESS, resultDescription);
|
||||
} catch (AgentUnavailableException e) {
|
||||
resultDescription = "Agent is not available";
|
||||
executor.getAsyncJobMgr().completeAsyncJob(executor.getJob().getId(),
|
||||
AsyncJobResult.STATUS_FAILED, 0, resultDescription);
|
||||
return new OperationResponse(OperationResponse.STATUS_FAILED, resultDescription);
|
||||
}
|
||||
}
|
||||
resultDescription = "VM is not running or agent host is disconnected";
|
||||
executor.getAsyncJobMgr().completeAsyncJob(executor.getJob().getId(),
|
||||
AsyncJobResult.STATUS_FAILED, 0, resultDescription);
|
||||
return new OperationResponse(OperationResponse.STATUS_FAILED, resultDescription);
|
||||
}
|
||||
|
||||
@Override
|
||||
/*
|
||||
* TODO: cleanup eventually - Refactored API call
|
||||
|
|
@ -1785,113 +1744,6 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
|
|||
return true;
|
||||
}
|
||||
|
||||
// @Override @DB
|
||||
// public OperationResponse executeDestroyVM(DestroyVMExecutor executor, VMOperationParam param) {
|
||||
// UserVmVO vm = _vmDao.findById(param.getVmId());
|
||||
// State state = vm.getState();
|
||||
// OperationResponse response;
|
||||
// String resultDescription = "Success";
|
||||
//
|
||||
// if (vm == null || state == State.Destroyed || state == State.Expunging || vm.getRemoved() != null) {
|
||||
// if (s_logger.isDebugEnabled()) {
|
||||
// s_logger.debug("Unable to find vm or vm is destroyed: " + param.getVmId());
|
||||
// }
|
||||
// resultDescription = "VM does not exist or already in destroyed state";
|
||||
// response = new OperationResponse(OperationResponse.STATUS_FAILED, resultDescription);
|
||||
// executor.getAsyncJobMgr().completeAsyncJob(executor.getJob().getId(),
|
||||
// AsyncJobResult.STATUS_FAILED, 0, resultDescription);
|
||||
// return response;
|
||||
// }
|
||||
//
|
||||
// if(state == State.Stopping) {
|
||||
// if (s_logger.isDebugEnabled()) {
|
||||
// s_logger.debug("VM is being stopped: " + param.getVmId());
|
||||
// }
|
||||
// resultDescription = "VM is being stopped, please re-try later";
|
||||
// response = new OperationResponse(OperationResponse.STATUS_FAILED, resultDescription);
|
||||
// executor.getAsyncJobMgr().completeAsyncJob(executor.getJob().getId(),
|
||||
// AsyncJobResult.STATUS_FAILED, 0, resultDescription);
|
||||
// return response;
|
||||
// }
|
||||
//
|
||||
// if (state == State.Running) {
|
||||
// if (vm.getHostId() == null) {
|
||||
// resultDescription = "VM host is null (invalid VM)";
|
||||
// response = new OperationResponse(OperationResponse.STATUS_FAILED, resultDescription);
|
||||
// executor.getAsyncJobMgr().completeAsyncJob(executor.getJob().getId(),
|
||||
// AsyncJobResult.STATUS_FAILED, 0, resultDescription);
|
||||
// if(s_logger.isDebugEnabled())
|
||||
// s_logger.debug("Execute asynchronize destroy VM command: " + resultDescription);
|
||||
// return response;
|
||||
// }
|
||||
//
|
||||
// if (!_vmDao.updateIf(vm, Event.StopRequested, vm.getHostId())) {
|
||||
// resultDescription = "Failed to issue stop command, please re-try later";
|
||||
// response = new OperationResponse(OperationResponse.STATUS_FAILED, resultDescription);
|
||||
// executor.getAsyncJobMgr().completeAsyncJob(executor.getJob().getId(),
|
||||
// AsyncJobResult.STATUS_FAILED, 0, resultDescription);
|
||||
// if(s_logger.isDebugEnabled())
|
||||
// s_logger.debug("Execute asynchronize destroy VM command:" + resultDescription);
|
||||
// return response;
|
||||
// }
|
||||
// long childEventId = EventUtils.saveStartedEvent(param.getUserId(), param.getAccountId(),
|
||||
// EventTypes.EVENT_VM_STOP, "stopping vm " + vm.getName(), 0);
|
||||
// param.setChildEventId(childEventId);
|
||||
// StopCommand cmd = new StopCommand(vm, vm.getInstanceName(), vm.getVnet());
|
||||
// try {
|
||||
// long seq = _agentMgr.send(vm.getHostId(), new Command[] {cmd}, true,
|
||||
// new VMOperationListener(executor, param, vm, 0));
|
||||
// resultDescription = "Execute asynchronize destroy VM command: sending stop command to agent, seq - " + seq;
|
||||
// if(s_logger.isDebugEnabled())
|
||||
// s_logger.debug(resultDescription);
|
||||
// response = new OperationResponse(OperationResponse.STATUS_IN_PROGRESS, resultDescription);
|
||||
// return response;
|
||||
// } catch (AgentUnavailableException e) {
|
||||
// resultDescription = "Agent is not available";
|
||||
// response = new OperationResponse(OperationResponse.STATUS_FAILED, resultDescription);
|
||||
// executor.getAsyncJobMgr().completeAsyncJob(executor.getJob().getId(),
|
||||
// AsyncJobResult.STATUS_FAILED, 0, resultDescription);
|
||||
// return response;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// Transaction txn = Transaction.currentTxn();
|
||||
// txn.start();
|
||||
//
|
||||
// _accountMgr.decrementResourceCount(vm.getAccountId(), ResourceType.user_vm);
|
||||
// if (!_vmDao.updateIf(vm, VirtualMachine.Event.DestroyRequested, vm.getHostId()) ) {
|
||||
// resultDescription = "Unable to destroy the vm because it is not in the correct state";
|
||||
// s_logger.debug(resultDescription + vm.toString());
|
||||
//
|
||||
// txn.rollback();
|
||||
// response = new OperationResponse(OperationResponse.STATUS_FAILED, resultDescription);
|
||||
// executor.getAsyncJobMgr().completeAsyncJob(executor.getJob().getId(),
|
||||
// AsyncJobResult.STATUS_FAILED, 0, resultDescription);
|
||||
// return response;
|
||||
// }
|
||||
//
|
||||
// // Now that the VM is destroyed, clean the network rules associated with it.
|
||||
// cleanNetworkRules(param.getUserId(), vm.getId());
|
||||
//
|
||||
// // Mark the VM's root disk as destroyed
|
||||
// List<VolumeVO> volumes = _volsDao.findByInstanceAndType(vm.getId(), VolumeType.ROOT);
|
||||
// for (VolumeVO volume : volumes) {
|
||||
// _storageMgr.destroyVolume(volume);
|
||||
// }
|
||||
//
|
||||
// // Mark the VM's data disks as detached
|
||||
// volumes = _volsDao.findByInstanceAndType(vm.getId(), VolumeType.DATADISK);
|
||||
// for (VolumeVO volume : volumes) {
|
||||
// _volsDao.detachVolume(volume.getId());
|
||||
// }
|
||||
//
|
||||
// txn.commit();
|
||||
// response = new OperationResponse(OperationResponse.STATUS_SUCCEEDED, resultDescription);
|
||||
// executor.getAsyncJobMgr().completeAsyncJob(executor.getJob().getId(),
|
||||
// AsyncJobResult.STATUS_SUCCEEDED, 0, "success");
|
||||
// return response;
|
||||
// }
|
||||
|
||||
@Override @DB
|
||||
public UserVm recoverVirtualMachine(RecoverVMCmd cmd) throws ResourceAllocationException, CloudRuntimeException {
|
||||
|
||||
|
|
@ -2048,6 +1900,8 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
|
|||
String maxCap = configs.get("cpu.uservm.cap");
|
||||
_userVMCap = NumbersUtil.parseInt(maxCap, 0);
|
||||
|
||||
_useNewNetworking = Boolean.parseBoolean(configs.get("use.new.networking"));
|
||||
|
||||
_executor = Executors.newScheduledThreadPool(wrks, new NamedThreadFactory("UserVm-Scavenger"));
|
||||
|
||||
_haMgr.registerHandler(Type.User, this);
|
||||
|
|
@ -3307,8 +3161,10 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
|
|||
}
|
||||
|
||||
@Override
|
||||
public UserVm stopVirtualMachine(StopVMCmd cmd) throws ServerApiException{
|
||||
|
||||
public UserVm stopVirtualMachine(StopVMCmd cmd) throws ServerApiException, ConcurrentOperationException{
|
||||
if (_useNewNetworking) {
|
||||
return stopVirtualMachine(cmd.getId());
|
||||
}
|
||||
//Input validation
|
||||
Account account = UserContext.current().getAccount();
|
||||
Long userId = UserContext.current().getUserId();
|
||||
|
|
@ -3335,7 +3191,10 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
|
|||
}
|
||||
|
||||
@Override
|
||||
public UserVm startVirtualMachine(StartVMCmd cmd) throws StorageUnavailableException, ExecutionException, ConcurrentOperationException {
|
||||
public UserVm startVirtualMachine(StartVMCmd cmd) throws ExecutionException, ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException {
|
||||
if (_useNewNetworking) {
|
||||
return startVirtualMachine(cmd.getId());
|
||||
}
|
||||
//Input validation
|
||||
Account account = UserContext.current().getAccount();
|
||||
Long userId = UserContext.current().getUserId();
|
||||
|
|
@ -3393,8 +3252,10 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
|
|||
}
|
||||
|
||||
@Override
|
||||
public UserVm destroyVm(DestroyVMCmd cmd) {
|
||||
|
||||
public UserVm destroyVm(DestroyVMCmd cmd) throws ResourceUnavailableException, ConcurrentOperationException {
|
||||
if (_useNewNetworking) {
|
||||
return destroyVm(cmd.getId());
|
||||
}
|
||||
Account account = UserContext.current().getAccount();
|
||||
Long userId = UserContext.current().getUserId();
|
||||
Long vmId = cmd.getId();
|
||||
|
|
@ -3629,7 +3490,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
|
|||
}
|
||||
|
||||
@Override @DB
|
||||
public UserVm createVirtualMachine(DeployVm2Cmd cmd) throws InsufficientCapacityException, ResourceUnavailableException, ConcurrentOperationException {
|
||||
public UserVm createVirtualMachine(DeployVMCmd cmd) throws InsufficientCapacityException, ResourceUnavailableException, ConcurrentOperationException {
|
||||
Account caller = UserContext.current().getAccount();
|
||||
|
||||
AccountVO owner = _accountDao.findById(cmd.getAccountId());
|
||||
|
|
@ -3822,34 +3683,34 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
|
|||
}
|
||||
|
||||
@Override
|
||||
public UserVm stopVirtualMachine(StopVm2Cmd cmd) throws ConcurrentOperationException {
|
||||
public UserVm stopVirtualMachine(long vmId) throws ConcurrentOperationException {
|
||||
|
||||
//Input validation
|
||||
Account caller = UserContext.current().getAccount();
|
||||
Long userId = UserContext.current().getUserId();
|
||||
long id = cmd.getId();
|
||||
|
||||
//if account is removed, return error
|
||||
if (caller != null && caller.getRemoved() != null)
|
||||
throw new PermissionDeniedException("The account " + caller.getId()+" is removed");
|
||||
|
||||
UserVmVO vmInstance = _vmDao.findById(id);
|
||||
if (vmInstance == null) {
|
||||
throw new InvalidParameterValueException("unable to find a virtual machine with id " + id);
|
||||
UserVmVO vm = _vmDao.findById(vmId);
|
||||
if (vm == null) {
|
||||
throw new InvalidParameterValueException("unable to find a virtual machine with id " + vmId);
|
||||
}
|
||||
|
||||
long eventId = EventUtils.saveScheduledEvent(userId, vmInstance.getAccountId(), EventTypes.EVENT_VM_STOP, "stopping Vm with Id: "+id);
|
||||
userId = accountAndUserValidation(id, caller, userId, vmInstance);
|
||||
long eventId = EventUtils.saveScheduledEvent(userId, vm.getAccountId(), EventTypes.EVENT_VM_STOP, "stopping Vm with Id: "+ vmId);
|
||||
userId = accountAndUserValidation(vmId, caller, userId, vm);
|
||||
UserVO user = _userDao.findById(userId);
|
||||
|
||||
try {
|
||||
_itMgr.stop(vmInstance, user, caller);
|
||||
_itMgr.stop(vm, user, caller);
|
||||
} catch (AgentUnavailableException e) {
|
||||
throw new CloudRuntimeException("Unable to contact the agent to stop the virtual machine " + vmInstance, e);
|
||||
throw new CloudRuntimeException("Unable to contact the agent to stop the virtual machine " + vm, e);
|
||||
} catch (OperationTimedoutException e) {
|
||||
throw new CloudRuntimeException("Waiting too long for agent to stop the virtual machine " + vmInstance, e);
|
||||
throw new CloudRuntimeException("Waiting too long for agent to stop the virtual machine " + vm, e);
|
||||
}
|
||||
|
||||
return _vmDao.findById(id);
|
||||
return _vmDao.findById(vmId);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -3862,37 +3723,35 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
|
|||
|
||||
|
||||
@Override
|
||||
public UserVm startVirtualMachine(StartVm2Cmd cmd) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException {
|
||||
public UserVm startVirtualMachine(long vmId) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException {
|
||||
//Input validation
|
||||
Account account = UserContext.current().getAccount();
|
||||
Long userId = UserContext.current().getUserId();
|
||||
Long id = cmd.getId();
|
||||
|
||||
//if account is removed, return error
|
||||
if(account!=null && account.getRemoved() != null)
|
||||
throw new PermissionDeniedException("The account " + account.getId()+" is removed");
|
||||
|
||||
UserVmVO vm = _vmDao.findById(id.longValue());
|
||||
UserVmVO vm = _vmDao.findById(vmId);
|
||||
if (vm == null) {
|
||||
throw new ServerApiException(BaseCmd.PARAM_ERROR, "unable to find a virtual machine with id " + id);
|
||||
throw new ServerApiException(BaseCmd.PARAM_ERROR, "unable to find a virtual machine with id " + vmId);
|
||||
}
|
||||
|
||||
long eventId = EventUtils.saveScheduledEvent(userId, vm.getAccountId(), EventTypes.EVENT_VM_START, "Starting Vm with Id: "+id);
|
||||
long eventId = EventUtils.saveScheduledEvent(userId, vm.getAccountId(), EventTypes.EVENT_VM_START, "Starting Vm with Id: "+vmId);
|
||||
|
||||
userId = accountAndUserValidation(id, account, userId, vm);
|
||||
userId = accountAndUserValidation(vmId, account, userId, vm);
|
||||
UserVO user = _userDao.findById(userId);
|
||||
|
||||
return _itMgr.start(vm, null, user, account);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserVm destroyVm(DestroyVm2Cmd cmd) throws ResourceUnavailableException, ConcurrentOperationException {
|
||||
public UserVm destroyVm(long vmId) throws ResourceUnavailableException, ConcurrentOperationException {
|
||||
Account account = UserContext.current().getAccount();
|
||||
Long userId = UserContext.current().getUserId();
|
||||
Long vmId = cmd.getId();
|
||||
|
||||
//Verify input parameters
|
||||
UserVmVO vm = _vmDao.findById(vmId.longValue());
|
||||
UserVmVO vm = _vmDao.findById(vmId);
|
||||
if (vm == null) {
|
||||
throw new ServerApiException(BaseCmd.PARAM_ERROR, "unable to find a virtual machine with id " + vmId);
|
||||
}
|
||||
|
|
@ -3917,4 +3776,147 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
|
|||
throw new CloudRuntimeException("Failed to destroy vm with id " + vmId);
|
||||
}
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public OperationResponse executeRebootVM(RebootVMExecutor executor, VMOperationParam param) {
|
||||
//
|
||||
// final UserVmVO vm = _vmDao.findById(param.getVmId());
|
||||
// String resultDescription;
|
||||
//
|
||||
// if (vm == null || vm.getState() == State.Destroyed || vm.getState() == State.Expunging || vm.getRemoved() != null) {
|
||||
// resultDescription = "VM does not exist or in destroying state";
|
||||
// executor.getAsyncJobMgr().completeAsyncJob(executor.getJob().getId(),
|
||||
// AsyncJobResult.STATUS_FAILED, 0, resultDescription);
|
||||
// if(s_logger.isDebugEnabled())
|
||||
// s_logger.debug("Execute asynchronize Reboot VM command: " +resultDescription);
|
||||
// return new OperationResponse(OperationResponse.STATUS_FAILED, resultDescription);
|
||||
// }
|
||||
//
|
||||
// if (vm.getState() == State.Running && vm.getHostId() != null) {
|
||||
// RebootCommand cmd = new RebootCommand(vm.getInstanceName());
|
||||
// try {
|
||||
// long seq = _agentMgr.send(vm.getHostId(), new Commands(cmd), new VMOperationListener(executor, param, vm, 0));
|
||||
// resultDescription = "Execute asynchronize Reboot VM command: sending command to agent, seq - " + seq;
|
||||
// if(s_logger.isDebugEnabled())
|
||||
// s_logger.debug(resultDescription);
|
||||
// return new OperationResponse(OperationResponse.STATUS_IN_PROGRESS, resultDescription);
|
||||
// } catch (AgentUnavailableException e) {
|
||||
// resultDescription = "Agent is not available";
|
||||
// executor.getAsyncJobMgr().completeAsyncJob(executor.getJob().getId(),
|
||||
// AsyncJobResult.STATUS_FAILED, 0, resultDescription);
|
||||
// return new OperationResponse(OperationResponse.STATUS_FAILED, resultDescription);
|
||||
// }
|
||||
// }
|
||||
// resultDescription = "VM is not running or agent host is disconnected";
|
||||
// executor.getAsyncJobMgr().completeAsyncJob(executor.getJob().getId(),
|
||||
// AsyncJobResult.STATUS_FAILED, 0, resultDescription);
|
||||
// return new OperationResponse(OperationResponse.STATUS_FAILED, resultDescription);
|
||||
// }
|
||||
|
||||
// @Override @DB
|
||||
// public OperationResponse executeDestroyVM(DestroyVMExecutor executor, VMOperationParam param) {
|
||||
// UserVmVO vm = _vmDao.findById(param.getVmId());
|
||||
// State state = vm.getState();
|
||||
// OperationResponse response;
|
||||
// String resultDescription = "Success";
|
||||
//
|
||||
// if (vm == null || state == State.Destroyed || state == State.Expunging || vm.getRemoved() != null) {
|
||||
// if (s_logger.isDebugEnabled()) {
|
||||
// s_logger.debug("Unable to find vm or vm is destroyed: " + param.getVmId());
|
||||
// }
|
||||
// resultDescription = "VM does not exist or already in destroyed state";
|
||||
// response = new OperationResponse(OperationResponse.STATUS_FAILED, resultDescription);
|
||||
// executor.getAsyncJobMgr().completeAsyncJob(executor.getJob().getId(),
|
||||
// AsyncJobResult.STATUS_FAILED, 0, resultDescription);
|
||||
// return response;
|
||||
// }
|
||||
//
|
||||
// if(state == State.Stopping) {
|
||||
// if (s_logger.isDebugEnabled()) {
|
||||
// s_logger.debug("VM is being stopped: " + param.getVmId());
|
||||
// }
|
||||
// resultDescription = "VM is being stopped, please re-try later";
|
||||
// response = new OperationResponse(OperationResponse.STATUS_FAILED, resultDescription);
|
||||
// executor.getAsyncJobMgr().completeAsyncJob(executor.getJob().getId(),
|
||||
// AsyncJobResult.STATUS_FAILED, 0, resultDescription);
|
||||
// return response;
|
||||
// }
|
||||
//
|
||||
// if (state == State.Running) {
|
||||
// if (vm.getHostId() == null) {
|
||||
// resultDescription = "VM host is null (invalid VM)";
|
||||
// response = new OperationResponse(OperationResponse.STATUS_FAILED, resultDescription);
|
||||
// executor.getAsyncJobMgr().completeAsyncJob(executor.getJob().getId(),
|
||||
// AsyncJobResult.STATUS_FAILED, 0, resultDescription);
|
||||
// if(s_logger.isDebugEnabled())
|
||||
// s_logger.debug("Execute asynchronize destroy VM command: " + resultDescription);
|
||||
// return response;
|
||||
// }
|
||||
//
|
||||
// if (!_vmDao.updateIf(vm, Event.StopRequested, vm.getHostId())) {
|
||||
// resultDescription = "Failed to issue stop command, please re-try later";
|
||||
// response = new OperationResponse(OperationResponse.STATUS_FAILED, resultDescription);
|
||||
// executor.getAsyncJobMgr().completeAsyncJob(executor.getJob().getId(),
|
||||
// AsyncJobResult.STATUS_FAILED, 0, resultDescription);
|
||||
// if(s_logger.isDebugEnabled())
|
||||
// s_logger.debug("Execute asynchronize destroy VM command:" + resultDescription);
|
||||
// return response;
|
||||
// }
|
||||
// long childEventId = EventUtils.saveStartedEvent(param.getUserId(), param.getAccountId(),
|
||||
// EventTypes.EVENT_VM_STOP, "stopping vm " + vm.getName(), 0);
|
||||
// param.setChildEventId(childEventId);
|
||||
// StopCommand cmd = new StopCommand(vm, vm.getInstanceName(), vm.getVnet());
|
||||
// try {
|
||||
// long seq = _agentMgr.send(vm.getHostId(), new Command[] {cmd}, true,
|
||||
// new VMOperationListener(executor, param, vm, 0));
|
||||
// resultDescription = "Execute asynchronize destroy VM command: sending stop command to agent, seq - " + seq;
|
||||
// if(s_logger.isDebugEnabled())
|
||||
// s_logger.debug(resultDescription);
|
||||
// response = new OperationResponse(OperationResponse.STATUS_IN_PROGRESS, resultDescription);
|
||||
// return response;
|
||||
// } catch (AgentUnavailableException e) {
|
||||
// resultDescription = "Agent is not available";
|
||||
// response = new OperationResponse(OperationResponse.STATUS_FAILED, resultDescription);
|
||||
// executor.getAsyncJobMgr().completeAsyncJob(executor.getJob().getId(),
|
||||
// AsyncJobResult.STATUS_FAILED, 0, resultDescription);
|
||||
// return response;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// Transaction txn = Transaction.currentTxn();
|
||||
// txn.start();
|
||||
//
|
||||
// _accountMgr.decrementResourceCount(vm.getAccountId(), ResourceType.user_vm);
|
||||
// if (!_vmDao.updateIf(vm, VirtualMachine.Event.DestroyRequested, vm.getHostId()) ) {
|
||||
// resultDescription = "Unable to destroy the vm because it is not in the correct state";
|
||||
// s_logger.debug(resultDescription + vm.toString());
|
||||
//
|
||||
// txn.rollback();
|
||||
// response = new OperationResponse(OperationResponse.STATUS_FAILED, resultDescription);
|
||||
// executor.getAsyncJobMgr().completeAsyncJob(executor.getJob().getId(),
|
||||
// AsyncJobResult.STATUS_FAILED, 0, resultDescription);
|
||||
// return response;
|
||||
// }
|
||||
//
|
||||
// // Now that the VM is destroyed, clean the network rules associated with it.
|
||||
// cleanNetworkRules(param.getUserId(), vm.getId());
|
||||
//
|
||||
// // Mark the VM's root disk as destroyed
|
||||
// List<VolumeVO> volumes = _volsDao.findByInstanceAndType(vm.getId(), VolumeType.ROOT);
|
||||
// for (VolumeVO volume : volumes) {
|
||||
// _storageMgr.destroyVolume(volume);
|
||||
// }
|
||||
//
|
||||
// // Mark the VM's data disks as detached
|
||||
// volumes = _volsDao.findByInstanceAndType(vm.getId(), VolumeType.DATADISK);
|
||||
// for (VolumeVO volume : volumes) {
|
||||
// _volsDao.detachVolume(volume.getId());
|
||||
// }
|
||||
//
|
||||
// txn.commit();
|
||||
// response = new OperationResponse(OperationResponse.STATUS_SUCCEEDED, resultDescription);
|
||||
// executor.getAsyncJobMgr().completeAsyncJob(executor.getJob().getId(),
|
||||
// AsyncJobResult.STATUS_SUCCEEDED, 0, "success");
|
||||
// return response;
|
||||
// }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,26 +17,22 @@
|
|||
*/
|
||||
package com.cloud.vm;
|
||||
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.commands.AttachVolumeCmd;
|
||||
import com.cloud.api.commands.CreateTemplateCmd;
|
||||
import com.cloud.api.commands.CreateVMGroupCmd;
|
||||
import com.cloud.api.commands.DeleteVMGroupCmd;
|
||||
import com.cloud.api.commands.DeployVMCmd;
|
||||
import com.cloud.api.commands.DeployVm2Cmd;
|
||||
import com.cloud.api.commands.DestroyVMCmd;
|
||||
import com.cloud.api.commands.DestroyVm2Cmd;
|
||||
import com.cloud.api.commands.DetachVolumeCmd;
|
||||
import com.cloud.api.commands.RebootVMCmd;
|
||||
import com.cloud.api.commands.RecoverVMCmd;
|
||||
import com.cloud.api.commands.ResetVMPasswordCmd;
|
||||
import com.cloud.api.commands.StartVMCmd;
|
||||
import com.cloud.api.commands.StartVm2Cmd;
|
||||
import com.cloud.api.commands.StopVMCmd;
|
||||
import com.cloud.api.commands.StopVm2Cmd;
|
||||
import com.cloud.api.commands.UpdateVMCmd;
|
||||
import com.cloud.api.commands.UpgradeVMCmd;
|
||||
import com.cloud.async.executor.OperationResponse;
|
||||
import com.cloud.async.executor.RebootVMExecutor;
|
||||
import com.cloud.async.executor.VMOperationParam;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
|
|
@ -54,8 +50,10 @@ public interface UserVmService {
|
|||
* Destroys one virtual machine
|
||||
* @param userId the id of the user performing the action
|
||||
* @param vmId the id of the virtual machine.
|
||||
* @throws ConcurrentOperationException
|
||||
* @throws ResourceUnavailableException
|
||||
*/
|
||||
UserVm destroyVm(DestroyVMCmd cmd);
|
||||
UserVm destroyVm(DestroyVMCmd cmd) throws ResourceUnavailableException, ConcurrentOperationException;
|
||||
|
||||
/**
|
||||
* Destroys one virtual machine
|
||||
|
|
@ -64,7 +62,7 @@ public interface UserVmService {
|
|||
* @throws ConcurrentOperationException
|
||||
* @throws ResourceUnavailableException
|
||||
*/
|
||||
UserVm destroyVm(DestroyVm2Cmd cmd) throws ResourceUnavailableException, ConcurrentOperationException;
|
||||
UserVm destroyVm(long vmId) throws ResourceUnavailableException, ConcurrentOperationException;
|
||||
|
||||
/**
|
||||
* Resets the password of a virtual machine.
|
||||
|
|
@ -89,15 +87,12 @@ public interface UserVmService {
|
|||
*/
|
||||
Volume detachVolumeFromVM(DetachVolumeCmd cmmd);
|
||||
|
||||
UserVm startVirtualMachine(StartVMCmd cmd) throws StorageUnavailableException, ExecutionException, ConcurrentOperationException;
|
||||
UserVm stopVirtualMachine(StopVMCmd cmd);
|
||||
UserVm startVirtualMachine(StartVMCmd cmd) throws StorageUnavailableException, ExecutionException, ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException;
|
||||
UserVm stopVirtualMachine(StopVMCmd cmd) throws ServerApiException, ConcurrentOperationException;
|
||||
UserVm rebootVirtualMachine(RebootVMCmd cmd);
|
||||
UserVm updateVirtualMachine(UpdateVMCmd cmd);
|
||||
UserVm recoverVirtualMachine(RecoverVMCmd cmd) throws ResourceAllocationException;
|
||||
|
||||
@Deprecated
|
||||
OperationResponse executeRebootVM(RebootVMExecutor executor, VMOperationParam param);
|
||||
|
||||
/**
|
||||
* Create a template database record in preparation for creating a private template.
|
||||
* @param cmd the command object that defines the name, display text, snapshot/volume, bits, public/private, etc.
|
||||
|
|
@ -127,7 +122,7 @@ public interface UserVmService {
|
|||
* @throws PermissionDeniedException if the caller doesn't have any access rights to the VM.
|
||||
* @throws InvalidParameterValueException if the parameters are incorrect.
|
||||
*/
|
||||
UserVm createVirtualMachine(DeployVm2Cmd cmd) throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException;
|
||||
UserVm createVirtualMachine(DeployVMCmd cmd) throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException;
|
||||
|
||||
/**
|
||||
* Starts the virtual machine created from createVirtualMachine.
|
||||
|
|
@ -157,7 +152,7 @@ public interface UserVmService {
|
|||
*/
|
||||
UserVm upgradeVirtualMachine(UpgradeVMCmd cmd);
|
||||
|
||||
UserVm stopVirtualMachine(StopVm2Cmd cmd) throws ConcurrentOperationException;
|
||||
UserVm stopVirtualMachine(long vmId) throws ConcurrentOperationException;
|
||||
|
||||
UserVm startVirtualMachine(StartVm2Cmd cmd) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException;
|
||||
UserVm startVirtualMachine(long vmId) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -77,8 +77,8 @@ public class ComponentLocator implements ComponentLocatorMBean {
|
|||
protected static final Logger s_logger = Logger.getLogger(ComponentLocator.class);
|
||||
|
||||
protected static final ThreadLocal<ComponentLocator> s_tl = new ThreadLocal<ComponentLocator>();
|
||||
protected static ConcurrentHashMap<Class<?>, Singleton> s_singletons = new ConcurrentHashMap<Class<?>, Singleton>(111);
|
||||
static HashMap<String, ComponentLocator> s_locators = new HashMap<String, ComponentLocator>();
|
||||
protected static final ConcurrentHashMap<Class<?>, Singleton> s_singletons = new ConcurrentHashMap<Class<?>, Singleton>(111);
|
||||
protected static final HashMap<String, ComponentLocator> s_locators = new HashMap<String, ComponentLocator>();
|
||||
protected static final Callback[] s_callbacks = new Callback[] { NoOp.INSTANCE, new DatabaseCallback() };
|
||||
protected static final CallbackFilter s_callbackFilter = new DatabaseCallbackFilter();
|
||||
protected static final HashMap<Class<?>, InjectInfo> s_factories = new HashMap<Class<?>, InjectInfo>();
|
||||
|
|
@ -87,7 +87,6 @@ public class ComponentLocator implements ComponentLocatorMBean {
|
|||
protected HashMap<String, Adapters<? extends Adapter>> _adapterMap;
|
||||
protected HashMap<String, ComponentInfo<Manager>> _managerMap;
|
||||
protected LinkedHashMap<String, ComponentInfo<GenericDao<?, ?>>> _daoMap;
|
||||
protected ComponentLocator _parentLocator;
|
||||
protected String _serverName;
|
||||
protected Object _component;
|
||||
|
||||
|
|
@ -96,7 +95,6 @@ public class ComponentLocator implements ComponentLocatorMBean {
|
|||
}
|
||||
|
||||
public ComponentLocator(String server) {
|
||||
_parentLocator = null;
|
||||
_serverName = server;
|
||||
}
|
||||
|
||||
|
|
@ -109,7 +107,7 @@ public class ComponentLocator implements ComponentLocatorMBean {
|
|||
return getLocatorName();
|
||||
}
|
||||
|
||||
protected Pair<XmlHandler, ComponentLibrary> parse2(String filename) {
|
||||
protected Pair<XmlHandler, HashMap<String, List<ComponentInfo<Adapter>>>> parse2(String filename) {
|
||||
try {
|
||||
SAXParserFactory spfactory = SAXParserFactory.newInstance();
|
||||
SAXParser saxParser = spfactory.newSAXParser();
|
||||
|
|
@ -118,13 +116,14 @@ public class ComponentLocator implements ComponentLocatorMBean {
|
|||
_adapterMap = new HashMap<String, Adapters<? extends Adapter>>();
|
||||
File file = PropertiesUtil.findConfigFile(filename);
|
||||
if (file == null) {
|
||||
return null;
|
||||
s_logger.info("Unable to find " + filename);
|
||||
return null;
|
||||
}
|
||||
s_logger.info("Config file found at " + file.getAbsolutePath() + ". Configuring " + _serverName);
|
||||
XmlHandler handler = new XmlHandler(_serverName);
|
||||
saxParser.parse(file, handler);
|
||||
|
||||
|
||||
HashMap<String, List<ComponentInfo<Adapter>>> adapters = new HashMap<String, List<ComponentInfo<Adapter>>>();
|
||||
if (handler.parent != null) {
|
||||
String[] tokens = handler.parent.split(":");
|
||||
String parentFile = filename;
|
||||
|
|
@ -133,11 +132,10 @@ public class ComponentLocator implements ComponentLocatorMBean {
|
|||
parentFile = tokens[0];
|
||||
parentName = tokens[1];
|
||||
}
|
||||
_parentLocator = new ComponentLocator(parentName);
|
||||
_parentLocator.parse2(parentFile);
|
||||
_daoMap.putAll(_parentLocator._daoMap);
|
||||
_managerMap.putAll(_parentLocator._managerMap);
|
||||
_adapterMap.putAll(_parentLocator._adapterMap);
|
||||
ComponentLocator parentLocator = new ComponentLocator(parentName);
|
||||
adapters.putAll(parentLocator.parse2(parentFile).second());
|
||||
_daoMap.putAll(parentLocator._daoMap);
|
||||
_managerMap.putAll(parentLocator._managerMap);
|
||||
}
|
||||
|
||||
ComponentLibrary library = null;
|
||||
|
|
@ -146,12 +144,14 @@ public class ComponentLocator implements ComponentLocatorMBean {
|
|||
library = (ComponentLibrary)clazz.newInstance();
|
||||
_daoMap.putAll(library.getDaos());
|
||||
_managerMap.putAll(library.getManagers());
|
||||
adapters.putAll(library.getAdapters());
|
||||
}
|
||||
|
||||
_daoMap.putAll(handler.daos);
|
||||
_managerMap.putAll(handler.managers);
|
||||
adapters.putAll(handler.adapters);
|
||||
|
||||
return new Pair<XmlHandler, ComponentLibrary>(handler, library);
|
||||
return new Pair<XmlHandler, HashMap<String, List<ComponentInfo<Adapter>>>>(handler, adapters);
|
||||
|
||||
} catch (ParserConfigurationException e) {
|
||||
s_logger.error("Unable to load " + _serverName + " due to errors while parsing " + filename, e);
|
||||
|
|
@ -173,20 +173,17 @@ public class ComponentLocator implements ComponentLocatorMBean {
|
|||
}
|
||||
|
||||
protected void parse(String filename) {
|
||||
Pair<XmlHandler, ComponentLibrary> parseResults = parse2(filename);
|
||||
if (parseResults == null) {
|
||||
s_logger.info("Skipping configuration using components.xml");
|
||||
return;
|
||||
Pair<XmlHandler, HashMap<String, List<ComponentInfo<Adapter>>>> result = parse2(filename);
|
||||
if (result == null) {
|
||||
s_logger.info("Skipping configuration using " + filename);
|
||||
return;
|
||||
}
|
||||
XmlHandler handler = parseResults.first();
|
||||
ComponentLibrary library = parseResults.second();
|
||||
|
||||
|
||||
XmlHandler handler = result.first();
|
||||
HashMap<String, List<ComponentInfo<Adapter>>> adapters = result.second();
|
||||
try {
|
||||
startDaos(); // daos should not be using managers and adapters.
|
||||
if (library != null) {
|
||||
instantiateAdapters(library.getAdapters());
|
||||
}
|
||||
instantiateAdapters(handler.adapters);
|
||||
instantiateAdapters(adapters);
|
||||
instantiateManagers();
|
||||
_component = createInstance(handler.componentClass, true, true);
|
||||
configureManagers();
|
||||
|
|
@ -320,19 +317,10 @@ public class ComponentLocator implements ComponentLocatorMBean {
|
|||
|
||||
protected ComponentInfo<GenericDao<?, ?>> getDao(String name) {
|
||||
ComponentInfo<GenericDao<?, ?>> info = _daoMap.get(name);
|
||||
if (info != null) {
|
||||
return info;
|
||||
}
|
||||
|
||||
if (_parentLocator != null) {
|
||||
info = _parentLocator.getDao(name);
|
||||
}
|
||||
|
||||
if (info == null) {
|
||||
throw new CloudRuntimeException("Unable to find DAO " + name);
|
||||
}
|
||||
|
||||
_daoMap.put(name, info);
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
|
|
@ -492,19 +480,6 @@ public class ComponentLocator implements ComponentLocatorMBean {
|
|||
|
||||
protected ComponentInfo<Manager> getManager(String name) {
|
||||
ComponentInfo<Manager> mgr = _managerMap.get(name);
|
||||
if (mgr != null) {
|
||||
return mgr;
|
||||
}
|
||||
|
||||
if (_parentLocator != null) {
|
||||
mgr = _parentLocator.getManager(name);
|
||||
}
|
||||
|
||||
if (mgr == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
_managerMap.put(name, mgr);
|
||||
return mgr;
|
||||
}
|
||||
|
||||
|
|
@ -559,6 +534,18 @@ public class ComponentLocator implements ComponentLocatorMBean {
|
|||
}
|
||||
}
|
||||
|
||||
protected void populateAdapters(Map<String, List<ComponentInfo<Adapter>>> map) {
|
||||
Set<Map.Entry<String, List<ComponentInfo<Adapter>>>> entries = map.entrySet();
|
||||
for (Map.Entry<String, List<ComponentInfo<Adapter>>> entry : entries) {
|
||||
for (ComponentInfo<Adapter> info : entry.getValue()) {
|
||||
s_logger.info("Instantiating Adapter: " + info.name);
|
||||
info.instance = (Adapter)createInstance(info.clazz, false, info.singleton);
|
||||
}
|
||||
Adapters<Adapter> adapters = new Adapters<Adapter>(entry.getKey(), entry.getValue());
|
||||
_adapterMap.put(entry.getKey(), adapters);
|
||||
}
|
||||
}
|
||||
|
||||
protected void instantiateAdapters(Map<String, List<ComponentInfo<Adapter>>> map) {
|
||||
Set<Map.Entry<String, List<ComponentInfo<Adapter>>>> entries = map.entrySet();
|
||||
for (Map.Entry<String, List<ComponentInfo<Adapter>>> entry : entries) {
|
||||
|
|
@ -601,11 +588,6 @@ public class ComponentLocator implements ComponentLocatorMBean {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getParentName() {
|
||||
return _parentLocator != null ? _parentLocator.getName() : "None";
|
||||
}
|
||||
|
||||
public static <T> T inject(Class<T> clazz) {
|
||||
return (T)createInstance(clazz, true, false);
|
||||
}
|
||||
|
|
@ -631,8 +613,7 @@ public class ComponentLocator implements ComponentLocatorMBean {
|
|||
}
|
||||
|
||||
public Map<String, List<String>> getAllAccessibleAdapters() {
|
||||
Map<String, List<String>> parentResults = _parentLocator != null ? _parentLocator.getAllAccessibleAdapters()
|
||||
: new HashMap<String, List<String>>();
|
||||
Map<String, List<String>> parentResults = new HashMap<String, List<String>>();
|
||||
Map<String, List<String>> results = getAdapters();
|
||||
parentResults.putAll(results);
|
||||
return parentResults;
|
||||
|
|
@ -640,7 +621,7 @@ public class ComponentLocator implements ComponentLocatorMBean {
|
|||
|
||||
@Override
|
||||
public Collection<String> getManagers() {
|
||||
Collection<String> names = _parentLocator != null ? _parentLocator.getManagers() : new HashSet<String>();
|
||||
Collection<String> names = new HashSet<String>();
|
||||
for (Map.Entry<String, ComponentInfo<Manager>> entry : _managerMap.entrySet()) {
|
||||
names.add(entry.getValue().name);
|
||||
}
|
||||
|
|
@ -649,7 +630,7 @@ public class ComponentLocator implements ComponentLocatorMBean {
|
|||
|
||||
@Override
|
||||
public Collection<String> getDaos() {
|
||||
Collection<String> names = _parentLocator != null ? _parentLocator.getDaos() : new HashSet<String>();
|
||||
Collection<String> names = new HashSet<String>();
|
||||
for (Map.Entry<String, ComponentInfo<GenericDao<?, ?>>> entry : _daoMap.entrySet()) {
|
||||
names.add(entry.getValue().name);
|
||||
}
|
||||
|
|
@ -665,12 +646,6 @@ public class ComponentLocator implements ComponentLocatorMBean {
|
|||
if (adapters != null) {
|
||||
return adapters;
|
||||
}
|
||||
if (_parentLocator != null) {
|
||||
adapters = _parentLocator.getAdapters(key);
|
||||
if (adapters != null) {
|
||||
return adapters;
|
||||
}
|
||||
}
|
||||
return new Adapters<Adapter>(key, new ArrayList<ComponentInfo<Adapter>>());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,11 +26,6 @@ import com.cloud.utils.mgmt.ManagementBean;
|
|||
|
||||
public interface ComponentLocatorMBean extends ManagementBean {
|
||||
|
||||
/**
|
||||
* @return the name of the parent component locator.
|
||||
**/
|
||||
String getParentName();
|
||||
|
||||
/**
|
||||
* @return the list of adapters accessible by this component locator.
|
||||
**/
|
||||
|
|
|
|||
Loading…
Reference in New Issue