mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Added more changes to the api
This commit is contained in:
parent
d4207060b4
commit
d5d8f27cad
@ -0,0 +1,32 @@
|
||||
/**
|
||||
* 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.exception;
|
||||
|
||||
import com.cloud.utils.SerialVersionUID;
|
||||
|
||||
public class ResourceUnavailableException extends Exception {
|
||||
private static final long serialVersionUID = SerialVersionUID.ResourceUnavailableException;
|
||||
|
||||
public ResourceUnavailableException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
public ResourceUnavailableException(String msg, Throwable cause) {
|
||||
super(msg, cause);
|
||||
}
|
||||
}
|
||||
@ -26,7 +26,7 @@ import com.cloud.utils.SerialVersionUID;
|
||||
* problem with.
|
||||
*
|
||||
*/
|
||||
public class StorageUnavailableException extends Exception {
|
||||
public class StorageUnavailableException extends ResourceUnavailableException {
|
||||
Object _obj;
|
||||
|
||||
private static final long serialVersionUID = SerialVersionUID.StorageUnavailableException;
|
||||
|
||||
@ -3,6 +3,9 @@
|
||||
*/
|
||||
package com.cloud.network.element;
|
||||
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.NetworkConfiguration;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.user.Account;
|
||||
@ -20,18 +23,11 @@ public interface NetworkElement extends Adapter {
|
||||
* @param offering network offering that originated the network configuration.
|
||||
* @return true if network configuration is now usable; false if not; null if not handled by this element.
|
||||
*/
|
||||
Boolean implement(NetworkConfiguration config, NetworkOffering offering, Account user);
|
||||
Boolean implement(NetworkConfiguration config, NetworkOffering offering, Account user) throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException;
|
||||
|
||||
/**
|
||||
* Prepare the nic profile to be used within the network.
|
||||
* @param config
|
||||
* @param nic
|
||||
* @param offering
|
||||
* @return
|
||||
*/
|
||||
Boolean prepare(NetworkConfiguration config, NicProfile nic, VirtualMachineProfile vm, NetworkOffering offering, Account user);
|
||||
Boolean prepare(NetworkConfiguration config, NicProfile nic, VirtualMachineProfile vm, NetworkOffering offering, Account user) throws ConcurrentOperationException, ResourceUnavailableException;
|
||||
|
||||
Boolean release(NetworkConfiguration config, NicProfile nic, VirtualMachineProfile vm, NetworkOffering offering, Account user);
|
||||
Boolean release(NetworkConfiguration config, NicProfile nic, VirtualMachineProfile vm, NetworkOffering offering, Account user) throws ConcurrentOperationException, ResourceUnavailableException;
|
||||
|
||||
Boolean shutdown(NetworkConfiguration config, NetworkOffering offering, Account user);
|
||||
Boolean shutdown(NetworkConfiguration config, NetworkOffering offering, Account user) throws ConcurrentOperationException, ResourceUnavailableException;
|
||||
}
|
||||
|
||||
@ -35,11 +35,16 @@ public class VirtualMachineProfile {
|
||||
List<DiskProfile> _disks;
|
||||
List<NicProfile> _nics;
|
||||
String _os;
|
||||
String _password;
|
||||
|
||||
public VirtualMachineProfile(VirtualMachine.Type type) {
|
||||
this._type = type;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return _password;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return _vm.getInstanceName();
|
||||
}
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
|
||||
package com.cloud.user;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.utils.ProcessUtil;
|
||||
|
||||
@ -32,7 +32,8 @@ public class UserContext {
|
||||
private Long accountId;
|
||||
private Long domainId;
|
||||
private String sessionId;
|
||||
private Object accountObject;
|
||||
private Account accountObject;
|
||||
private Long eventId;
|
||||
|
||||
private boolean apiServer;
|
||||
|
||||
@ -41,13 +42,14 @@ public class UserContext {
|
||||
public UserContext() {
|
||||
}
|
||||
|
||||
public UserContext(Long userId, Object accountObject, String accountName, Long accountId, Long domainId, String sessionId, boolean apiServer) {
|
||||
public UserContext(Long userId, Account accountObject, String accountName, Long accountId, Long domainId, String sessionId, boolean apiServer) {
|
||||
this.userId = userId;
|
||||
this.accountObject = accountObject;
|
||||
this.accountId = accountId;
|
||||
this.domainId = domainId;
|
||||
this.sessionId = sessionId;
|
||||
this.apiServer = apiServer;
|
||||
this.apiServer = apiServer;
|
||||
this.eventId = null;
|
||||
}
|
||||
|
||||
public Long getUserId() {
|
||||
@ -60,6 +62,14 @@ public class UserContext {
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setEventId(long eventId) {
|
||||
this.eventId = eventId;
|
||||
}
|
||||
|
||||
public Long getEventId() {
|
||||
return eventId;
|
||||
}
|
||||
|
||||
public void setUserId(Long userId) {
|
||||
@ -102,11 +112,11 @@ public class UserContext {
|
||||
return sessionId;
|
||||
}
|
||||
|
||||
public Object getAccountObject() {
|
||||
public Account getAccount() {
|
||||
return accountObject;
|
||||
}
|
||||
|
||||
public void setAccountObject(Object accountObject) {
|
||||
public void setAccount(Account accountObject) {
|
||||
this.accountObject = accountObject;
|
||||
}
|
||||
|
||||
@ -130,19 +140,19 @@ public class UserContext {
|
||||
return context;
|
||||
}
|
||||
|
||||
public static void updateContext(Long userId, Object accountObject, String accountName, Long accountId, Long domainId, String sessionId) {
|
||||
public static void updateContext(Long userId, Account accountObject, String accountName, Long accountId, Long domainId, String sessionId) {
|
||||
UserContext context = current();
|
||||
assert(context != null) : "Context should be already setup before you can call this one";
|
||||
|
||||
context.setUserId(userId);
|
||||
context.setAccountObject(accountObject);
|
||||
context.setAccount(accountObject);
|
||||
context.setAccountName(accountName);
|
||||
context.setAccountId(accountId);
|
||||
context.setDomainId(domainId);
|
||||
context.setSessionKey(sessionId);
|
||||
}
|
||||
|
||||
public static void registerContext(Long userId, Object accountObject, String accountName, Long accountId, Long domainId, String sessionId, boolean apiServer) {
|
||||
public static void registerContext(Long userId, Account accountObject, String accountName, Long accountId, Long domainId, String sessionId, boolean apiServer) {
|
||||
s_currentContext.set(new UserContext(userId, accountObject, accountName, accountId, domainId, sessionId, apiServer));
|
||||
}
|
||||
|
||||
|
||||
25
server/src/com/cloud/account/SecurityManager.java
Normal file
25
server/src/com/cloud/account/SecurityManager.java
Normal file
@ -0,0 +1,25 @@
|
||||
/**
|
||||
* 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.account;
|
||||
|
||||
import com.cloud.utils.component.Manager;
|
||||
|
||||
public interface SecurityManager extends Manager {
|
||||
|
||||
|
||||
}
|
||||
@ -17,7 +17,6 @@
|
||||
*/
|
||||
package com.cloud.agent;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@ -156,7 +155,7 @@ public interface AgentManager extends Manager {
|
||||
* @return HostStats
|
||||
* @throws InternalErrorException
|
||||
*/
|
||||
HostStats getHostStatistics(long hostId) throws InternalErrorException;
|
||||
HostStats getHostStatistics(long hostId);
|
||||
|
||||
Long getGuestOSCategoryId(long hostId);
|
||||
|
||||
|
||||
@ -97,7 +97,6 @@ import com.cloud.dc.dao.VlanDao;
|
||||
import com.cloud.event.dao.EventDao;
|
||||
import com.cloud.exception.AgentUnavailableException;
|
||||
import com.cloud.exception.DiscoveryException;
|
||||
import com.cloud.exception.InternalErrorException;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.OperationTimedoutException;
|
||||
import com.cloud.exception.UnsupportedVersionException;
|
||||
@ -1246,8 +1245,7 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory {
|
||||
}
|
||||
|
||||
@Override
|
||||
public HostStats getHostStatistics(long hostId) throws InternalErrorException
|
||||
{
|
||||
public HostStats getHostStatistics(long hostId) {
|
||||
Answer answer = easySend(hostId, new GetHostStatsCommand(_hostDao.findById(hostId).getGuid(), _hostDao.findById(hostId).getName(),hostId));
|
||||
|
||||
if (answer != null && (answer instanceof UnsupportedAnswer)) {
|
||||
|
||||
@ -36,6 +36,7 @@ import com.cloud.configuration.ConfigurationManager;
|
||||
import com.cloud.consoleproxy.ConsoleProxyManager;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.PermissionDeniedException;
|
||||
import com.cloud.network.DomainRouterService;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.security.NetworkGroupManager;
|
||||
import com.cloud.server.ManagementServer;
|
||||
@ -65,6 +66,7 @@ public class ApiDispatcher {
|
||||
private StorageManager _storageMgr;
|
||||
private TemplateManager _templateMgr;
|
||||
private UserVmManager _userVmMgr;
|
||||
private DomainRouterService _domainRouterService;
|
||||
|
||||
// singleton class
|
||||
private static ApiDispatcher s_instance = new ApiDispatcher();
|
||||
@ -86,6 +88,7 @@ public class ApiDispatcher {
|
||||
_storageMgr = locator.getManager(StorageManager.class);
|
||||
_templateMgr = locator.getManager(TemplateManager.class);
|
||||
_userVmMgr = locator.getManager(UserVmManager.class);
|
||||
_domainRouterService = locator.getManager(DomainRouterService.class);
|
||||
}
|
||||
|
||||
public Long dispatchCreateCmd(BaseAsyncCreateCmd cmd, Map<String, String> params) {
|
||||
@ -129,6 +132,9 @@ public class ApiDispatcher {
|
||||
case UserVmManager:
|
||||
mgr = _userVmMgr;
|
||||
break;
|
||||
case DomainRouterService:
|
||||
mgr = _domainRouterService;
|
||||
break;
|
||||
}
|
||||
|
||||
try {
|
||||
@ -201,6 +207,9 @@ public class ApiDispatcher {
|
||||
case UserVmManager:
|
||||
mgr = _userVmMgr;
|
||||
break;
|
||||
case DomainRouterService:
|
||||
mgr = _domainRouterService;
|
||||
break;
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
@ -363,7 +363,7 @@ public class ApiServer implements HttpRequestHandler {
|
||||
|
||||
UserContext ctx = UserContext.current();
|
||||
Long userId = ctx.getUserId();
|
||||
Account account = (Account)ctx.getAccountObject();
|
||||
Account account = (Account)ctx.getAccount();
|
||||
if (userId != null) {
|
||||
params.put("ctxUserId", userId.toString());
|
||||
}
|
||||
|
||||
@ -52,7 +52,8 @@ public class ApiServlet extends HttpServlet {
|
||||
}
|
||||
}
|
||||
|
||||
protected void doGet(HttpServletRequest req, HttpServletResponse resp) {
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest req, HttpServletResponse resp) {
|
||||
try {
|
||||
processRequest(req, resp);
|
||||
} finally {
|
||||
@ -60,6 +61,7 @@ public class ApiServlet extends HttpServlet {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doPost(HttpServletRequest req, HttpServletResponse resp) {
|
||||
try {
|
||||
processRequest(req, resp);
|
||||
@ -198,7 +200,7 @@ public class ApiServlet extends HttpServlet {
|
||||
resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "no command specified");
|
||||
return;
|
||||
}
|
||||
UserContext.updateContext(userId, accountObj, account, ((Account)accountObj).getId(), domainId, session.getId());
|
||||
UserContext.updateContext(userId, (Account)accountObj, account, ((Account)accountObj).getId(), domainId, session.getId());
|
||||
} else {
|
||||
// Invalidate the session to ensure we won't allow a request across management server restarts if the userId was serialized to the
|
||||
// stored session
|
||||
|
||||
@ -42,7 +42,7 @@ public abstract class BaseCmd {
|
||||
}
|
||||
|
||||
public enum Manager {
|
||||
AccountManager, AgentManager, ConfigManager, ManagementServer, NetworkGroupManager, NetworkManager, StorageManager, UserVmManager, SnapshotManager, TemplateManager, ConsoleProxyManager
|
||||
AccountManager, AgentManager, ConfigManager, ManagementServer, NetworkGroupManager, NetworkManager, StorageManager, UserVmManager, SnapshotManager, TemplateManager, ConsoleProxyManager, DomainRouterService
|
||||
}
|
||||
|
||||
// FIXME: Extract these out into a separate file
|
||||
|
||||
@ -106,7 +106,7 @@ public class AssociateIPAddrCmd extends BaseCmd {
|
||||
ipResponse.setForVirtualNetwork(forVirtualNetworks);
|
||||
|
||||
//show this info to admin only
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = (Account)UserContext.current().getAccount();
|
||||
if ((account == null) || isAdmin(account.getType())) {
|
||||
ipResponse.setVlanId(ipAddress.getVlanDbId());
|
||||
ipResponse.setVlanName(ApiDBUtils.findVlanById(ipAddress.getVlanDbId()).getVlanId());
|
||||
|
||||
@ -153,7 +153,7 @@ public class AuthorizeNetworkGroupIngressCmd extends BaseAsyncCmd {
|
||||
|
||||
@Override
|
||||
public long getAccountId() {
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = (Account)UserContext.current().getAccount();
|
||||
if ((account == null) || isAdmin(account.getType())) {
|
||||
if ((domainId != null) && (accountName != null)) {
|
||||
Account userAccount = ApiDBUtils.findAccountByNameDomain(accountName, domainId);
|
||||
|
||||
@ -82,7 +82,7 @@ public class CancelMaintenanceCmd extends BaseAsyncCmd {
|
||||
|
||||
@Override
|
||||
public long getAccountId() {
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = (Account)UserContext.current().getAccount();
|
||||
if (account != null) {
|
||||
return account.getId();
|
||||
}
|
||||
|
||||
@ -71,7 +71,7 @@ public class CancelPrimaryStorageMaintenanceCmd extends BaseAsyncCmd {
|
||||
|
||||
@Override
|
||||
public long getAccountId() {
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = (Account)UserContext.current().getAccount();
|
||||
if (account != null) {
|
||||
return account.getId();
|
||||
}
|
||||
|
||||
@ -139,7 +139,7 @@ public class CopyIsoCmd extends BaseAsyncCmd {
|
||||
}
|
||||
|
||||
//set status
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = (Account)UserContext.current().getAccount();
|
||||
boolean isAdmin = false;
|
||||
if ((account == null) || (account.getType() == Account.ACCOUNT_TYPE_ADMIN) || (account.getType() == Account.ACCOUNT_TYPE_DOMAIN_ADMIN)) {
|
||||
isAdmin = true;
|
||||
|
||||
@ -142,7 +142,7 @@ public class CopyTemplateCmd extends BaseAsyncCmd {
|
||||
}
|
||||
|
||||
//set status
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = (Account)UserContext.current().getAccount();
|
||||
boolean isAdmin = false;
|
||||
if ((account == null) || (account.getType() == Account.ACCOUNT_TYPE_ADMIN) || (account.getType() == Account.ACCOUNT_TYPE_DOMAIN_ADMIN)) {
|
||||
isAdmin = true;
|
||||
|
||||
@ -112,7 +112,7 @@ public class CreateVolumeCmd extends BaseAsyncCreateCmd {
|
||||
|
||||
@Override
|
||||
public long getAccountId() {
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = (Account)UserContext.current().getAccount();
|
||||
if ((account == null) || isAdmin(account.getType())) {
|
||||
if ((domainId != null) && (accountName != null)) {
|
||||
Account userAccount = ApiDBUtils.findAccountByNameDomain(accountName, domainId);
|
||||
|
||||
@ -68,7 +68,7 @@ public class DeleteUserCmd extends BaseAsyncCmd {
|
||||
|
||||
@Override
|
||||
public long getAccountId() {
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = (Account)UserContext.current().getAccount();
|
||||
if (account != null) {
|
||||
return account.getId();
|
||||
}
|
||||
|
||||
@ -163,7 +163,7 @@ public class DeployVMCmd extends BaseAsyncCmd {
|
||||
|
||||
@Override
|
||||
public long getAccountId() {
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = (Account)UserContext.current().getAccount();
|
||||
if ((account == null) || isAdmin(account.getType())) {
|
||||
if ((domainId != null) && (accountName != null)) {
|
||||
Account userAccount = ApiDBUtils.findAccountByNameDomain(accountName, domainId);
|
||||
|
||||
299
server/src/com/cloud/api/commands/DeployVmCmd.java
Normal file
299
server/src/com/cloud/api/commands/DeployVmCmd.java
Normal file
@ -0,0 +1,299 @@
|
||||
/**
|
||||
* 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 java.util.List;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiDBUtils;
|
||||
import com.cloud.api.BaseAsyncCmd;
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.api.BaseCmd.Manager;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.response.UserVmResponse;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.offering.ServiceOffering;
|
||||
import com.cloud.storage.VMTemplateVO;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.User;
|
||||
import com.cloud.user.UserContext;
|
||||
import com.cloud.uservm.UserVm;
|
||||
import com.cloud.vm.InstanceGroupVO;
|
||||
|
||||
@Implementation(createMethod="createVirtualMachine", method="startVirtualMachine", manager=Manager.UserVmManager, description="Creates and automatically starts a virtual machine based on a service offering, disk offering, and template.")
|
||||
public class DeployVmCmd extends BaseAsyncCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(DeployVMCmd.class.getName());
|
||||
|
||||
private static final String s_name = "deployvirtualmachineresponse";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Parameter(name="account", type=CommandType.STRING, description="an optional account for the virtual machine. Must be used with domainId.")
|
||||
private String accountName;
|
||||
|
||||
@Parameter(name="diskofferingid", type=CommandType.LONG, description="the ID of the disk offering for the virtual machine. If the template is of ISO format, the diskOfferingId is for the root disk volume. Otherwise this parameter is used to dinidcate the offering for the data disk volume. If the templateId parameter passed is from a Template object, the diskOfferingId refers to a DATA Disk Volume created. If the templateId parameter passed is from an ISO object, the diskOfferingId refers to a ROOT Disk Volume created.")
|
||||
private Long diskOfferingId;
|
||||
|
||||
@Parameter(name="displayname", type=CommandType.STRING, description="an optional user generated name for the virtual machine")
|
||||
private String displayName;
|
||||
|
||||
@Parameter(name="domainid", type=CommandType.LONG, description="an optional domainId for the virtual machine. If the account parameter is used, domainId must also be used.")
|
||||
private Long domainId;
|
||||
|
||||
@Parameter(name="group", type=CommandType.STRING, description="an optional group for the virtual machine")
|
||||
private String group;
|
||||
|
||||
@Parameter(name="hypervisor", type=CommandType.STRING, description="the hypervisor on which to deploy the virtual machine")
|
||||
private String hypervisor;
|
||||
|
||||
@Parameter(name="networkgrouplist", type=CommandType.LIST, collectionType=CommandType.STRING, description="comma separated list of network groups that going to be applied to the virtual machine. Should be passed only when vm is created from service offering with Direct Attach Network support")
|
||||
private List<String> networkGroupList;
|
||||
|
||||
@Parameter(name="serviceofferingid", type=CommandType.LONG, required=true, description="the ID of the service offering for the virtual machine")
|
||||
private Long serviceOfferingId;
|
||||
|
||||
@Parameter(name="size", type=CommandType.LONG, description="the arbitrary size for the DATADISK volume. Mutually exclusive with diskOfferingId")
|
||||
private Long size;
|
||||
|
||||
@Parameter(name="templateid", type=CommandType.LONG, required=true, description="the ID of the template for the virtual machine")
|
||||
private Long templateId;
|
||||
|
||||
@Parameter(name="userdata", type=CommandType.STRING, description="an optional binary data that can be sent to the virtual machine upon a successful deployment. This binary data must be base64 encoded before adding it to the request. Currently only HTTP GET is supported. Using HTTP GET (via querystring), you can send up to 2KB of data after base64 encoding.")
|
||||
private String userData;
|
||||
|
||||
@Parameter(name="zoneid", type=CommandType.LONG, required=true, description="availability zone for the virtual machine")
|
||||
private Long zoneId;
|
||||
|
||||
// unexposed parameter needed for serializing/deserializing the command
|
||||
@Parameter(name="password", type=CommandType.STRING, expose=false)
|
||||
private String password;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public String getAccountName() {
|
||||
return accountName;
|
||||
}
|
||||
|
||||
public Long getDiskOfferingId() {
|
||||
return diskOfferingId;
|
||||
}
|
||||
|
||||
public String getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
public Long getDomainId() {
|
||||
return domainId;
|
||||
}
|
||||
|
||||
public String getGroup() {
|
||||
return group;
|
||||
}
|
||||
|
||||
public String getHypervisor() {
|
||||
return hypervisor;
|
||||
}
|
||||
|
||||
public List<String> getNetworkGroupList() {
|
||||
return networkGroupList;
|
||||
}
|
||||
|
||||
public Long getServiceOfferingId() {
|
||||
return serviceOfferingId;
|
||||
}
|
||||
|
||||
public Long getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public Long getTemplateId() {
|
||||
return templateId;
|
||||
}
|
||||
|
||||
public String getUserData() {
|
||||
return userData;
|
||||
}
|
||||
|
||||
public Long getZoneId() {
|
||||
return zoneId;
|
||||
}
|
||||
|
||||
// not exposed parameter
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
public static String getResultObjectName() {
|
||||
return "virtualmachine";
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getAccountId() {
|
||||
Account account = (Account)UserContext.current().getAccount();
|
||||
if ((account == null) || isAdmin(account.getType())) {
|
||||
if ((domainId != null) && (accountName != null)) {
|
||||
Account userAccount = ApiDBUtils.findAccountByNameDomain(accountName, domainId);
|
||||
if (userAccount != null) {
|
||||
return userAccount.getId();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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_VM_CREATE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
return "deploying Vm";
|
||||
}
|
||||
|
||||
@Override @SuppressWarnings("unchecked")
|
||||
public UserVmResponse getResponse() {
|
||||
UserVm userVm = (UserVm)getResponseObject();
|
||||
|
||||
UserVmResponse response = new UserVmResponse();
|
||||
response.setId(userVm.getId());
|
||||
response.setName(userVm.getName());
|
||||
response.setCreated(userVm.getCreated());
|
||||
response.setZoneId(userVm.getDataCenterId());
|
||||
response.setZoneName(ApiDBUtils.findZoneById(userVm.getDataCenterId()).getName());
|
||||
response.setIpAddress(userVm.getPrivateIpAddress());
|
||||
response.setServiceOfferingId(userVm.getServiceOfferingId());
|
||||
response.setHaEnable(userVm.isHaEnabled());
|
||||
|
||||
InstanceGroupVO group = ApiDBUtils.findInstanceGroupForVM(userVm.getId());
|
||||
if (group != null) {
|
||||
response.setGroup(group.getName());
|
||||
response.setGroupId(group.getId());
|
||||
}
|
||||
|
||||
if (userVm.getDisplayName() == null || userVm.getDisplayName().length() == 0) {
|
||||
response.setDisplayName(userVm.getName());
|
||||
} else {
|
||||
response.setDisplayName(userVm.getDisplayName());
|
||||
}
|
||||
|
||||
if (userVm.getState() != null) {
|
||||
response.setState(userVm.getState().toString());
|
||||
}
|
||||
|
||||
VMTemplateVO template = ApiDBUtils.findTemplateById(userVm.getTemplateId());
|
||||
|
||||
Account acct = ApiDBUtils.findAccountById(Long.valueOf(userVm.getAccountId()));
|
||||
if (acct != null) {
|
||||
response.setAccountName(acct.getAccountName());
|
||||
response.setDomainId(acct.getDomainId());
|
||||
response.setDomainName(ApiDBUtils.findDomainById(acct.getDomainId()).getName());
|
||||
}
|
||||
|
||||
Long userId = UserContext.current().getUserId();
|
||||
if (userId == null) {
|
||||
userId = User.UID_SYSTEM;
|
||||
}
|
||||
|
||||
//this is for the case where the admin deploys a vm for a normal user
|
||||
User userExecutingCmd = ApiDBUtils.findUserById(userId);
|
||||
Account acctForUserExecutingCmd = ApiDBUtils.findAccountById(Long.valueOf(userExecutingCmd.getAccountId()));
|
||||
if ((BaseCmd.isAdmin(acctForUserExecutingCmd.getType()) && (userVm.getHostId() != null)) || (BaseCmd.isAdmin(acct.getType()) && (userVm.getHostId() != null))) {
|
||||
response.setHostName(ApiDBUtils.findHostById(userVm.getHostId()).getName());
|
||||
response.setHostId(userVm.getHostId());
|
||||
}
|
||||
|
||||
String templateName = "none";
|
||||
boolean templatePasswordEnabled = false;
|
||||
String templateDisplayText = null;
|
||||
|
||||
if (template != null) {
|
||||
templateName = template.getName();
|
||||
templatePasswordEnabled = template.getEnablePassword();
|
||||
templateDisplayText = template.getDisplayText();
|
||||
if (templateDisplayText == null) {
|
||||
templateDisplayText = templateName;
|
||||
}
|
||||
}
|
||||
|
||||
if (templatePasswordEnabled) { // FIXME: where will the password come from in this case?
|
||||
response.setPassword(getPassword());
|
||||
}
|
||||
|
||||
// ISO Info
|
||||
Long isoId = userVm.getIsoId();
|
||||
if (isoId != null) {
|
||||
VMTemplateVO iso = ApiDBUtils.findTemplateById(isoId.longValue());
|
||||
if (iso != null) {
|
||||
response.setIsoId(isoId.longValue());
|
||||
response.setIsoName(iso.getName());
|
||||
response.setTemplateId(isoId.longValue());
|
||||
response.setTemplateName(iso.getName());
|
||||
|
||||
templateDisplayText = iso.getDisplayText();
|
||||
if(templateDisplayText == null)
|
||||
templateDisplayText = iso.getName();
|
||||
response.setIsoDisplayText(templateDisplayText);
|
||||
response.setTemplateDisplayText(templateDisplayText);
|
||||
}
|
||||
} else {
|
||||
response.setTemplateId(userVm.getTemplateId());
|
||||
response.setTemplateName(templateName);
|
||||
response.setTemplateDisplayText(templateDisplayText);
|
||||
response.setPasswordEnabled(templatePasswordEnabled);
|
||||
}
|
||||
|
||||
ServiceOffering offering = ApiDBUtils.findServiceOfferingById(userVm.getServiceOfferingId());
|
||||
response.setServiceOfferingId(userVm.getServiceOfferingId());
|
||||
response.setServiceOfferingName(offering.getName());
|
||||
|
||||
response.setCpuNumber(offering.getCpu());
|
||||
response.setCpuSpeed(offering.getSpeed());
|
||||
response.setMemory(offering.getRamSize());
|
||||
|
||||
response.setNetworkGroupList(ApiDBUtils.getNetworkGroupsNamesForVm(userVm.getId()));
|
||||
|
||||
response.setResponseName(getName());
|
||||
return response;
|
||||
}
|
||||
}
|
||||
@ -63,7 +63,7 @@ public class DestroyConsoleProxyCmd extends BaseAsyncCmd {
|
||||
|
||||
@Override
|
||||
public long getAccountId() {
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = (Account)UserContext.current().getAccount();
|
||||
if (account != null) {
|
||||
return account.getId();
|
||||
}
|
||||
|
||||
@ -71,7 +71,7 @@ public class DisableAccountCmd extends BaseAsyncCmd {
|
||||
|
||||
@Override
|
||||
public long getAccountId() {
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = (Account)UserContext.current().getAccount();
|
||||
if (account != null) {
|
||||
return account.getId();
|
||||
}
|
||||
|
||||
@ -63,7 +63,7 @@ public class DisableUserCmd extends BaseAsyncCmd {
|
||||
|
||||
@Override
|
||||
public long getAccountId() {
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = (Account)UserContext.current().getAccount();
|
||||
if (account != null) {
|
||||
return account.getId();
|
||||
}
|
||||
|
||||
@ -215,7 +215,7 @@ public class ListAccountsCmd extends BaseListCmd {
|
||||
acctResponse.setVmRunning(vmRunning);
|
||||
|
||||
//show this info to admins only
|
||||
Account ctxAccount = (Account)UserContext.current().getAccountObject();
|
||||
Account ctxAccount = (Account)UserContext.current().getAccount();
|
||||
if ((ctxAccount == null) || isAdmin(ctxAccount.getType())) {
|
||||
acctResponse.setState(account.getState());
|
||||
acctResponse.setCleanupRequired(account.getNeedsCleanup());
|
||||
|
||||
@ -157,7 +157,7 @@ public class ListIsosCmd extends BaseListCmd {
|
||||
|
||||
boolean isAdmin = false;
|
||||
boolean isAccountSpecific = true;
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = (Account)UserContext.current().getAccount();
|
||||
if ((account == null) || (account.getType() == Account.ACCOUNT_TYPE_ADMIN) || (account.getType() == Account.ACCOUNT_TYPE_DOMAIN_ADMIN)) {
|
||||
isAdmin = true;
|
||||
if ((accountName == null) || (domainId == null)) {
|
||||
|
||||
@ -137,7 +137,7 @@ public class ListPublicIpAddressesCmd extends BaseListCmd {
|
||||
ipResponse.setForVirtualNetwork(forVirtualNetworks);
|
||||
|
||||
//show this info to admin only
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = (Account)UserContext.current().getAccount();
|
||||
if ((account == null) || isAdmin(account.getType())) {
|
||||
ipResponse.setVlanId(ipAddress.getVlanDbId());
|
||||
ipResponse.setVlanName(ApiDBUtils.findVlanById(ipAddress.getVlanDbId()).getVlanId());
|
||||
|
||||
@ -76,7 +76,7 @@ public class ListTemplateOrIsoPermissionsCmd extends BaseListCmd {
|
||||
@Override @SuppressWarnings("unchecked")
|
||||
public TemplatePermissionsResponse getResponse() {
|
||||
List<String> accountNames = (List<String>)getResponseObject();
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = (Account)UserContext.current().getAccount();
|
||||
boolean isAdmin = ((account == null) || isAdmin(account.getType()));
|
||||
Long templateOwnerDomain = null;
|
||||
VMTemplateVO template = ApiDBUtils.findTemplateById(id);
|
||||
|
||||
@ -129,7 +129,7 @@ public class ListTemplatesCmd extends BaseListCmd {
|
||||
|
||||
boolean isAdmin = false;
|
||||
boolean isAccountSpecific = true;
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = (Account)UserContext.current().getAccount();
|
||||
if ((account == null) || (account.getType() == Account.ACCOUNT_TYPE_ADMIN) || (account.getType() == Account.ACCOUNT_TYPE_DOMAIN_ADMIN)) {
|
||||
isAdmin = true;
|
||||
if ((accountName == null) || (domainId == null)) {
|
||||
|
||||
@ -164,7 +164,7 @@ public class ListVMsCmd extends BaseListCmd {
|
||||
userVmResponse.setZoneId(userVm.getDataCenterId());
|
||||
userVmResponse.setZoneName(ApiDBUtils.findZoneById(userVm.getDataCenterId()).getName());
|
||||
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = (Account)UserContext.current().getAccount();
|
||||
//if user is an admin, display host id
|
||||
if (((account == null) || isAdmin(account.getType())) && (userVm.getHostId() != null)) {
|
||||
userVmResponse.setHostId(userVm.getHostId());
|
||||
|
||||
@ -64,7 +64,7 @@ public class ListZonesByCmd extends BaseListCmd {
|
||||
@Override @SuppressWarnings("unchecked")
|
||||
public ListResponse<ZoneResponse> getResponse() {
|
||||
List<DataCenterVO> dataCenters = (List<DataCenterVO>)getResponseObject();
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = (Account)UserContext.current().getAccount();
|
||||
|
||||
ListResponse<ZoneResponse> response = new ListResponse<ZoneResponse>();
|
||||
List<ZoneResponse> zoneResponses = new ArrayList<ZoneResponse>();
|
||||
|
||||
@ -64,7 +64,7 @@ public class PrepareForMaintenanceCmd extends BaseAsyncCmd {
|
||||
|
||||
@Override
|
||||
public long getAccountId() {
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = (Account)UserContext.current().getAccount();
|
||||
if (account != null) {
|
||||
return account.getId();
|
||||
}
|
||||
|
||||
@ -63,7 +63,7 @@ public class PreparePrimaryStorageForMaintenanceCmd extends BaseAsyncCmd {
|
||||
|
||||
@Override
|
||||
public long getAccountId() {
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = (Account)UserContext.current().getAccount();
|
||||
if (account != null) {
|
||||
return account.getId();
|
||||
}
|
||||
|
||||
@ -61,7 +61,7 @@ public class RebootSystemVmCmd extends BaseAsyncCmd {
|
||||
|
||||
@Override
|
||||
public long getAccountId() {
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = (Account)UserContext.current().getAccount();
|
||||
if (account != null) {
|
||||
return account.getId();
|
||||
}
|
||||
|
||||
@ -80,7 +80,7 @@ public class ReconnectHostCmd extends BaseAsyncCmd {
|
||||
|
||||
@Override
|
||||
public long getAccountId() {
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = (Account)UserContext.current().getAccount();
|
||||
if (account != null) {
|
||||
return account.getId();
|
||||
}
|
||||
|
||||
@ -127,7 +127,7 @@ public class RevokeNetworkGroupIngressCmd extends BaseAsyncCmd {
|
||||
|
||||
@Override
|
||||
public long getAccountId() {
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = (Account)UserContext.current().getAccount();
|
||||
if ((account == null) || isAdmin(account.getType())) {
|
||||
if ((domainId != null) && (accountName != null)) {
|
||||
Account userAccount = ApiDBUtils.findAccountByNameDomain(accountName, domainId);
|
||||
|
||||
@ -32,7 +32,7 @@ import com.cloud.uservm.UserVm;
|
||||
import com.cloud.vm.DomainRouterVO;
|
||||
|
||||
|
||||
@Implementation(method="startRouter", manager=Manager.NetworkManager, description="Starts a router.")
|
||||
@Implementation(method="startRouter", manager=Manager.DomainRouterService, description="Starts a router.")
|
||||
public class StartRouterCmd extends BaseAsyncCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(StartRouterCmd.class.getName());
|
||||
private static final String s_name = "startrouterresponse";
|
||||
@ -57,6 +57,7 @@ public class StartRouterCmd extends BaseAsyncCmd {
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@ -69,7 +69,7 @@ public class StartSystemVMCmd extends BaseAsyncCmd {
|
||||
|
||||
@Override
|
||||
public long getAccountId() {
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = (Account)UserContext.current().getAccount();
|
||||
if (account != null) {
|
||||
return account.getId();
|
||||
}
|
||||
|
||||
@ -32,7 +32,7 @@ import com.cloud.uservm.UserVm;
|
||||
import com.cloud.vm.DomainRouterVO;
|
||||
|
||||
|
||||
@Implementation(method="stopRouter", manager=Manager.NetworkManager, description="Stops a router.")
|
||||
@Implementation(method="stopRouter", manager=Manager.DomainRouterService, description="Stops a router.")
|
||||
public class StopRouterCmd extends BaseAsyncCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(StopRouterCmd.class.getName());
|
||||
private static final String s_name = "stoprouterresponse";
|
||||
@ -56,6 +56,7 @@ public class StopRouterCmd extends BaseAsyncCmd {
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@ -65,7 +65,7 @@ public class StopSystemVmCmd extends BaseAsyncCmd {
|
||||
|
||||
@Override
|
||||
public long getAccountId() {
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = (Account)UserContext.current().getAccount();
|
||||
if (account != null) {
|
||||
return account.getId();
|
||||
}
|
||||
|
||||
@ -93,6 +93,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.ha.HighAvailabilityManager;
|
||||
import com.cloud.host.Host;
|
||||
@ -537,7 +538,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, VirtualMach
|
||||
}
|
||||
}
|
||||
|
||||
public ConsoleProxyVO start2(long proxyVmId, long startEventId) throws StorageUnavailableException, InsufficientCapacityException, ConcurrentOperationException {
|
||||
public ConsoleProxyVO start2(long proxyVmId, long startEventId) throws ResourceUnavailableException, InsufficientCapacityException, ConcurrentOperationException {
|
||||
ConsoleProxyVO proxy = _consoleProxyDao.findById(proxyVmId);
|
||||
DeploymentPlan plan = new DataCenterDeployment(proxy.getDataCenterId(), 1);
|
||||
AccountVO systemAcct = _accountMgr.getSystemAccount();
|
||||
|
||||
43
server/src/com/cloud/network/DomainRouterService.java
Normal file
43
server/src/com/cloud/network/DomainRouterService.java
Normal file
@ -0,0 +1,43 @@
|
||||
/**
|
||||
* 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.network;
|
||||
|
||||
import com.cloud.api.commands.StartRouterCmd;
|
||||
import com.cloud.api.commands.StopRouterCmd;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.PermissionDeniedException;
|
||||
import com.cloud.utils.component.Manager;
|
||||
import com.cloud.vm.DomainRouterVO;
|
||||
|
||||
public interface DomainRouterService extends Manager {
|
||||
/**
|
||||
* Starts domain router
|
||||
* @param cmd the command specifying router's id
|
||||
* @return DomainRouter object
|
||||
* @throws InvalidParameterValueException, PermissionDeniedException
|
||||
*/
|
||||
DomainRouterVO startRouter(StartRouterCmd cmd) throws InvalidParameterValueException, PermissionDeniedException;
|
||||
|
||||
/**
|
||||
* Stops domain router
|
||||
* @param cmd the command specifying router's id
|
||||
* @return router if successful, null otherwise
|
||||
* @throws InvalidParameterValueException, PermissionDeniedException
|
||||
*/
|
||||
DomainRouterVO stopRouter(StopRouterCmd cmd) throws InvalidParameterValueException, PermissionDeniedException;
|
||||
}
|
||||
@ -50,6 +50,7 @@ import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.NetworkRuleConflictException;
|
||||
import com.cloud.exception.PermissionDeniedException;
|
||||
import com.cloud.exception.ResourceAllocationException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.offerings.NetworkOfferingVO;
|
||||
import com.cloud.service.ServiceOfferingVO;
|
||||
@ -305,7 +306,7 @@ public interface NetworkManager extends Manager {
|
||||
|
||||
List<NicProfile> allocate(VirtualMachineProfile vm, List<Pair<NetworkConfigurationVO, NicProfile>> networks) throws InsufficientCapacityException;
|
||||
|
||||
NicTO[] prepare(VirtualMachineProfile profile, DeployDestination dest, Account user) throws InsufficientAddressCapacityException, InsufficientVirtualNetworkCapcityException;
|
||||
NicTO[] prepare(VirtualMachineProfile profile, DeployDestination dest, Account user) throws InsufficientAddressCapacityException, InsufficientVirtualNetworkCapcityException, ConcurrentOperationException, ResourceUnavailableException;
|
||||
void release(VirtualMachineProfile vmProfile);
|
||||
|
||||
<K extends VMInstanceVO> List<NicVO> getNics(K vm);
|
||||
|
||||
@ -90,6 +90,7 @@ import com.cloud.exception.NetworkRuleConflictException;
|
||||
import com.cloud.exception.OperationTimedoutException;
|
||||
import com.cloud.exception.PermissionDeniedException;
|
||||
import com.cloud.exception.ResourceAllocationException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.dao.HostDao;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
@ -156,8 +157,8 @@ import com.cloud.vm.dao.UserVmDao;
|
||||
/**
|
||||
* NetworkManagerImpl implements NetworkManager.
|
||||
*/
|
||||
@Local(value={NetworkManager.class})
|
||||
public class NetworkManagerImpl implements NetworkManager {
|
||||
@Local(value={NetworkManager.class, DomainRouterService.class})
|
||||
public class NetworkManagerImpl implements NetworkManager, DomainRouterService {
|
||||
private static final Logger s_logger = Logger.getLogger(NetworkManagerImpl.class);
|
||||
|
||||
String _name;
|
||||
@ -493,7 +494,7 @@ public class NetworkManagerImpl implements NetworkManager {
|
||||
String accountName = cmd.getAccountName();
|
||||
Long domainId = cmd.getDomainId();
|
||||
Long zoneId = cmd.getZoneId();
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = UserContext.current().getAccount();
|
||||
Long userId = UserContext.current().getUserId();
|
||||
Long accountId = null;
|
||||
|
||||
@ -823,7 +824,7 @@ public class NetworkManagerImpl implements NetworkManager {
|
||||
}
|
||||
|
||||
// if an admin account was passed in, or no account was passed in, make sure we honor the accountName/domainId parameters
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = UserContext.current().getAccount();
|
||||
if (account != null) {
|
||||
if ((account.getType() == Account.ACCOUNT_TYPE_ADMIN) || (account.getType() == Account.ACCOUNT_TYPE_DOMAIN_ADMIN)) {
|
||||
if (!_domainDao.isChildDomain(account.getDomainId(), userVM.getDomainId())) {
|
||||
@ -916,7 +917,7 @@ public class NetworkManagerImpl implements NetworkManager {
|
||||
@Override
|
||||
public List<FirewallRuleVO> listPortForwardingRules(ListPortForwardingRulesCmd cmd) throws InvalidParameterValueException, PermissionDeniedException {
|
||||
String ipAddress = cmd.getIpAddress();
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = UserContext.current().getAccount();
|
||||
|
||||
IPAddressVO ipAddressVO = _ipAddressDao.findById(ipAddress);
|
||||
if (ipAddressVO == null) {
|
||||
@ -971,7 +972,7 @@ public class NetworkManagerImpl implements NetworkManager {
|
||||
cmd.synchronizeCommand("Router", syncObject.getId());
|
||||
|
||||
// Permission check...
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = UserContext.current().getAccount();
|
||||
if (account != null) {
|
||||
if ((account.getType() == Account.ACCOUNT_TYPE_DOMAIN_ADMIN) || (account.getType() == Account.ACCOUNT_TYPE_READ_ONLY_ADMIN)) {
|
||||
if (!_domainDao.isChildDomain(account.getDomainId(), loadBalancer.getDomainId())) {
|
||||
@ -1213,7 +1214,7 @@ public class NetworkManagerImpl implements NetworkManager {
|
||||
throw new InvalidParameterValueException("Unable to create load balancer rule, cannot find account owner for ip " + publicIp);
|
||||
}
|
||||
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = UserContext.current().getAccount();
|
||||
if (account != null) {
|
||||
if ((account.getType() == Account.ACCOUNT_TYPE_ADMIN) || (account.getType() == Account.ACCOUNT_TYPE_DOMAIN_ADMIN)) {
|
||||
if (!_domainDao.isChildDomain(account.getDomainId(), ipAddr.getDomainId())) {
|
||||
@ -1773,7 +1774,7 @@ public class NetworkManagerImpl implements NetworkManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NicTO[] prepare(VirtualMachineProfile vmProfile, DeployDestination dest, Account user) throws InsufficientAddressCapacityException, InsufficientVirtualNetworkCapcityException {
|
||||
public NicTO[] prepare(VirtualMachineProfile vmProfile, DeployDestination dest, Account user) throws InsufficientAddressCapacityException, InsufficientVirtualNetworkCapcityException, ConcurrentOperationException, ResourceUnavailableException {
|
||||
List<NicVO> nics = _nicDao.listBy(vmProfile.getId());
|
||||
NicTO[] nicTos = new NicTO[nics.size()];
|
||||
int i = 0;
|
||||
@ -1856,7 +1857,7 @@ public class NetworkManagerImpl implements NetworkManager {
|
||||
public boolean removeFromLoadBalancer(RemoveFromLoadBalancerRuleCmd cmd) throws InvalidParameterValueException {
|
||||
|
||||
Long userId = UserContext.current().getUserId();
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = UserContext.current().getAccount();
|
||||
Long loadBalancerId = cmd.getId();
|
||||
Long vmInstanceId = cmd.getVirtualMachineId();
|
||||
List<Long> instanceIds = cmd.getVirtualMachineIds();
|
||||
@ -1968,7 +1969,7 @@ public class NetworkManagerImpl implements NetworkManager {
|
||||
public boolean deleteLoadBalancerRule(DeleteLoadBalancerRuleCmd cmd) throws InvalidParameterValueException, PermissionDeniedException{
|
||||
Long loadBalancerId = cmd.getId();
|
||||
Long userId = UserContext.current().getUserId();
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = UserContext.current().getAccount();
|
||||
|
||||
///verify input parameters
|
||||
LoadBalancerVO loadBalancer = _loadBalancerDao.findById(loadBalancerId);
|
||||
@ -2084,7 +2085,7 @@ public class NetworkManagerImpl implements NetworkManager {
|
||||
String algorithm = cmd.getAlgorithm();
|
||||
String name = cmd.getName();
|
||||
String description = cmd.getDescription();
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = UserContext.current().getAccount();
|
||||
|
||||
//Verify input parameters
|
||||
LoadBalancerVO loadBalancer = _loadBalancerDao.findById(loadBalancerId);
|
||||
@ -2172,7 +2173,7 @@ public class NetworkManagerImpl implements NetworkManager {
|
||||
public boolean deleteNetworkRuleConfig(DeletePortForwardingServiceRuleCmd cmd) throws PermissionDeniedException {
|
||||
Long userId = UserContext.current().getUserId();
|
||||
Long netRuleId = cmd.getId();
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = UserContext.current().getAccount();
|
||||
|
||||
//If command is executed via 8096 port, set userId to the id of System account (1)
|
||||
if (userId == null) {
|
||||
@ -2259,7 +2260,7 @@ public class NetworkManagerImpl implements NetworkManager {
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
|
||||
Long userId = UserContext.current().getUserId();
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = UserContext.current().getAccount();
|
||||
String ipAddress = cmd.getIpAddress();
|
||||
|
||||
// Verify input parameters
|
||||
@ -2349,7 +2350,7 @@ public class NetworkManagerImpl implements NetworkManager {
|
||||
public boolean deleteIpForwardingRule(DeleteIPForwardingRuleCmd cmd) throws PermissionDeniedException, InvalidParameterValueException {
|
||||
Long ruleId = cmd.getId();
|
||||
Long userId = UserContext.current().getUserId();
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = UserContext.current().getAccount();
|
||||
|
||||
//verify input parameters here
|
||||
FirewallRuleVO rule = _firewallRulesDao.findById(ruleId);
|
||||
|
||||
@ -23,6 +23,9 @@ import javax.ejb.Local;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.Network.TrafficType;
|
||||
import com.cloud.network.NetworkConfiguration;
|
||||
import com.cloud.network.NetworkConfiguration.State;
|
||||
@ -35,8 +38,14 @@ import com.cloud.offering.NetworkOffering.GuestIpType;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.utils.component.AdapterBase;
|
||||
import com.cloud.utils.component.Inject;
|
||||
import com.cloud.vm.DomainRouterVO;
|
||||
import com.cloud.vm.NicProfile;
|
||||
import com.cloud.vm.UserVmManager;
|
||||
import com.cloud.vm.UserVmVO;
|
||||
import com.cloud.vm.VirtualMachine.Type;
|
||||
import com.cloud.vm.VirtualMachineProfile;
|
||||
import com.cloud.vm.dao.DomainRouterDao;
|
||||
import com.cloud.vm.dao.UserVmDao;
|
||||
|
||||
|
||||
@Local(value=NetworkElement.class)
|
||||
@ -46,9 +55,12 @@ public class DomainRouterElement extends AdapterBase implements NetworkElement {
|
||||
@Inject NetworkConfigurationDao _networkConfigDao;
|
||||
@Inject NetworkManager _networkMgr;
|
||||
@Inject DomainRouterManager _routerMgr;
|
||||
@Inject UserVmManager _userVmMgr;
|
||||
@Inject UserVmDao _userVmDao;
|
||||
@Inject DomainRouterDao _routerDao;
|
||||
|
||||
@Override
|
||||
public Boolean implement(NetworkConfiguration config, NetworkOffering offering, Account user) {
|
||||
public Boolean implement(NetworkConfiguration config, NetworkOffering offering, Account user) throws InsufficientCapacityException, ResourceUnavailableException, ConcurrentOperationException {
|
||||
if (offering.getGuestIpType() != GuestIpType.Virtualized) {
|
||||
s_logger.trace("Not handling guest ip type = " + offering.getGuestIpType());
|
||||
return null;
|
||||
@ -79,25 +91,50 @@ public class DomainRouterElement extends AdapterBase implements NetworkElement {
|
||||
return null;
|
||||
}
|
||||
|
||||
DomainRouterVO router;
|
||||
router = _routerMgr.deploy(publicConfig, guestConfig, offering, user);
|
||||
if (router == null) {
|
||||
s_logger.debug("Unable to deploy the router for " + guestConfig);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean prepare(NetworkConfiguration config, NicProfile nic, VirtualMachineProfile vm, NetworkOffering offering, Account user) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
public Boolean prepare(NetworkConfiguration config, NicProfile nic, VirtualMachineProfile vm, NetworkOffering offering, Account user) throws ConcurrentOperationException {
|
||||
if (config.getTrafficType() != TrafficType.Guest || vm.getType() != Type.User) {
|
||||
s_logger.trace("Domain Router only cares about guest network and User VMs");
|
||||
return null;
|
||||
}
|
||||
|
||||
UserVmVO userVm = _userVmDao.findById(vm.getId());
|
||||
|
||||
return _routerMgr.addVirtualMachineToGuestNetwork(userVm, vm.getPassword(), 1) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean release(NetworkConfiguration config, NicProfile nic, VirtualMachineProfile vm, NetworkOffering offering, Account user) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
if (config.getTrafficType() != TrafficType.Guest || vm.getType() != Type.User) {
|
||||
s_logger.trace("Domain Router only cares about guest network and User VMs");
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean shutdown(NetworkConfiguration config, NetworkOffering offering, Account user) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
public Boolean shutdown(NetworkConfiguration config, NetworkOffering offering, Account user) throws ConcurrentOperationException {
|
||||
if (config.getTrafficType() != TrafficType.Guest) {
|
||||
s_logger.trace("Domain Router only cares about guet network.");
|
||||
return null;
|
||||
}
|
||||
DomainRouterVO router = _routerDao.findByNetworkConfiguration(config.getId());
|
||||
if (router == null) {
|
||||
return true;
|
||||
}
|
||||
return _routerMgr.stopRouter(router.getId(), 1);
|
||||
}
|
||||
|
||||
protected DomainRouterElement() {
|
||||
|
||||
@ -31,7 +31,7 @@ import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.PermissionDeniedException;
|
||||
import com.cloud.exception.StorageUnavailableException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.NetworkConfiguration;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.service.ServiceOfferingVO;
|
||||
@ -167,5 +167,5 @@ public interface DomainRouterManager extends Manager {
|
||||
DomainRouterVO getRouter(long accountId, long zoneId);
|
||||
DomainRouterVO getRouter(String publicIpAddress);
|
||||
|
||||
DomainRouterVO deploy(NetworkConfiguration publicConfig, NetworkConfiguration virtualConfig, NetworkOffering offering, Account owner) throws InsufficientCapacityException, StorageUnavailableException, ConcurrentOperationException;
|
||||
DomainRouterVO deploy(NetworkConfiguration publicConfig, NetworkConfiguration virtualConfig, NetworkOffering offering, Account owner) throws InsufficientCapacityException, ResourceUnavailableException, ConcurrentOperationException;
|
||||
}
|
||||
|
||||
@ -95,6 +95,7 @@ import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.OperationTimedoutException;
|
||||
import com.cloud.exception.PermissionDeniedException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.exception.StorageUnavailableException;
|
||||
import com.cloud.ha.HighAvailabilityManager;
|
||||
import com.cloud.host.Host;
|
||||
@ -657,7 +658,7 @@ public class DomainRouterManagerImpl implements DomainRouterManager, VirtualMach
|
||||
public boolean upgradeRouter(UpgradeRouterCmd cmd) throws InvalidParameterValueException, PermissionDeniedException {
|
||||
Long routerId = cmd.getId();
|
||||
Long serviceOfferingId = cmd.getServiceOfferingId();
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = UserContext.current().getAccount();
|
||||
|
||||
DomainRouterVO router = _routerDao.findById(routerId);
|
||||
if (router == null) {
|
||||
@ -747,7 +748,7 @@ public class DomainRouterManagerImpl implements DomainRouterManager, VirtualMach
|
||||
@Override
|
||||
public DomainRouterVO startRouter(StartRouterCmd cmd) throws InvalidParameterValueException, PermissionDeniedException{
|
||||
Long routerId = cmd.getId();
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = UserContext.current().getAccount();
|
||||
|
||||
//verify parameters
|
||||
DomainRouterVO router = _routerDao.findById(routerId);
|
||||
@ -1226,7 +1227,7 @@ public class DomainRouterManagerImpl implements DomainRouterManager, VirtualMach
|
||||
@Override
|
||||
public DomainRouterVO stopRouter(StopRouterCmd cmd) throws InvalidParameterValueException, PermissionDeniedException{
|
||||
Long routerId = cmd.getId();
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = UserContext.current().getAccount();
|
||||
|
||||
// verify parameters
|
||||
DomainRouterVO router = _routerDao.findById(routerId);
|
||||
@ -1374,7 +1375,7 @@ public class DomainRouterManagerImpl implements DomainRouterManager, VirtualMach
|
||||
@Override
|
||||
public boolean rebootRouter(RebootRouterCmd cmd) throws InvalidParameterValueException, PermissionDeniedException{
|
||||
Long routerId = cmd.getId();
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = UserContext.current().getAccount();
|
||||
|
||||
//verify parameters
|
||||
DomainRouterVO router = _routerDao.findById(routerId);
|
||||
@ -1995,7 +1996,7 @@ public class DomainRouterManagerImpl implements DomainRouterManager, VirtualMach
|
||||
}
|
||||
|
||||
@Override @DB
|
||||
public DomainRouterVO deploy(NetworkConfiguration publicConfig, NetworkConfiguration virtualConfig, NetworkOffering offering, Account owner) throws InsufficientCapacityException, StorageUnavailableException, ConcurrentOperationException {
|
||||
public DomainRouterVO deploy(NetworkConfiguration publicConfig, NetworkConfiguration virtualConfig, NetworkOffering offering, Account owner) throws InsufficientCapacityException, StorageUnavailableException, ConcurrentOperationException, ResourceUnavailableException {
|
||||
long dcId = publicConfig.getDataCenterId();
|
||||
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
|
||||
@ -428,7 +428,7 @@ public class NetworkGroupManagerImpl implements NetworkGroupManager {
|
||||
Integer icmpCode = cmd.getIcmpCode();
|
||||
List<String> cidrList = cmd.getCidrList();
|
||||
Map groupList = cmd.getUserNetworkGroupList();
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = (Account)UserContext.current().getAccount();
|
||||
String accountName = cmd.getAccountName();
|
||||
Long domainId = cmd.getDomainId();
|
||||
Integer startPortOrType = null;
|
||||
@ -638,7 +638,7 @@ public class NetworkGroupManagerImpl implements NetworkGroupManager {
|
||||
public boolean revokeNetworkGroupIngress(RevokeNetworkGroupIngressCmd cmd) {
|
||||
|
||||
//input validation
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = (Account)UserContext.current().getAccount();
|
||||
Long userId = UserContext.current().getUserId();
|
||||
Long domainId = cmd.getDomainId();
|
||||
Integer startPort = cmd.getStartPort();
|
||||
@ -855,7 +855,7 @@ public class NetworkGroupManagerImpl implements NetworkGroupManager {
|
||||
Long domainId = cmd.getDomainId();
|
||||
Long accountId = null;
|
||||
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = (Account)UserContext.current().getAccount();
|
||||
if (account != null) {
|
||||
if ((account.getType() == Account.ACCOUNT_TYPE_ADMIN) || (account.getType() == Account.ACCOUNT_TYPE_DOMAIN_ADMIN)) {
|
||||
if ((domainId != null) && (accountName != null)) {
|
||||
@ -1115,7 +1115,7 @@ public class NetworkGroupManagerImpl implements NetworkGroupManager {
|
||||
String name = cmd.getName();
|
||||
String accountName = cmd.getAccountName();
|
||||
Long domainId = cmd.getDomainId();
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = (Account)UserContext.current().getAccount();
|
||||
|
||||
if (!_enabled) {
|
||||
return ;
|
||||
@ -1193,7 +1193,7 @@ public class NetworkGroupManagerImpl implements NetworkGroupManager {
|
||||
|
||||
@Override
|
||||
public List<NetworkGroupRulesVO> searchForNetworkGroupRules(ListNetworkGroupsCmd cmd) throws PermissionDeniedException, InvalidParameterValueException {
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = (Account)UserContext.current().getAccount();
|
||||
Long domainId = cmd.getDomainId();
|
||||
String accountName = cmd.getAccountName();
|
||||
Long accountId = null;
|
||||
|
||||
@ -998,7 +998,7 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
@Override
|
||||
public boolean enableUser(EnableUserCmd cmd) throws InvalidParameterValueException, PermissionDeniedException{
|
||||
Long userId = cmd.getId();
|
||||
Account adminAccount = (Account)UserContext.current().getAccountObject();
|
||||
Account adminAccount = UserContext.current().getAccount();
|
||||
boolean success = false;
|
||||
|
||||
//Check if user exists in the system
|
||||
@ -1028,7 +1028,7 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
public boolean lockUser(LockUserCmd cmd) {
|
||||
boolean success = false;
|
||||
|
||||
Account adminAccount = (Account)UserContext.current().getAccountObject();
|
||||
Account adminAccount = UserContext.current().getAccount();
|
||||
Long id = cmd.getId();
|
||||
|
||||
// Check if user with id exists in the system
|
||||
@ -1088,7 +1088,7 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
String accountName = cmd.getAccountName();
|
||||
Long domainId = cmd.getDomainId();
|
||||
|
||||
Account adminAccount = (Account)UserContext.current().getAccountObject();
|
||||
Account adminAccount = UserContext.current().getAccount();
|
||||
if ((adminAccount != null) && !_domainDao.isChildDomain(adminAccount.getDomainId(), domainId)) {
|
||||
throw new PermissionDeniedException("Failed to disable account " + accountName + " in domain " + domainId + ", permission denied.");
|
||||
}
|
||||
@ -1148,7 +1148,7 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
}
|
||||
|
||||
//Check if user performing the action is allowed to modify this account
|
||||
Account adminAccount = (Account)UserContext.current().getAccountObject();
|
||||
Account adminAccount = UserContext.current().getAccount();
|
||||
if ((adminAccount != null) && isChildDomain(adminAccount.getDomainId(), account.getDomainId())) {
|
||||
throw new PermissionDeniedException("Invalid account " + accountName + " in domain " + domainId + " given, permission denied");
|
||||
}
|
||||
@ -1211,7 +1211,7 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
}
|
||||
|
||||
//Check if user performing the action is allowed to modify this account
|
||||
Account adminAccount = (Account)UserContext.current().getAccountObject();
|
||||
Account adminAccount = UserContext.current().getAccount();
|
||||
if ((adminAccount != null) && isChildDomain(adminAccount.getDomainId(), account.getDomainId())) {
|
||||
throw new PermissionDeniedException("Invalid account " + accountName + " in domain " + domainId + " given, permission denied");
|
||||
}
|
||||
@ -1265,7 +1265,7 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
}
|
||||
|
||||
// If the account is an admin type, return an error. We do not allow this
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = UserContext.current().getAccount();
|
||||
|
||||
if (account != null && (account.getId() == Account.ACCOUNT_ID_SYSTEM)) {
|
||||
throw new ServerApiException(BaseCmd.ACCOUNT_ERROR, "user id : " + id + " is system account, update is not allowed");
|
||||
@ -1756,7 +1756,7 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
public UserVm deployVirtualMachine(DeployVMCmd cmd) throws InvalidParameterValueException, PermissionDeniedException, ResourceAllocationException,
|
||||
InternalErrorException, InsufficientStorageCapacityException, ExecutionException,
|
||||
StorageUnavailableException, ConcurrentOperationException {
|
||||
Account ctxAccount = (Account)UserContext.current().getAccountObject();
|
||||
Account ctxAccount = UserContext.current().getAccount();
|
||||
Long userId = UserContext.current().getUserId();
|
||||
String accountName = cmd.getAccountName();
|
||||
Long domainId = cmd.getDomainId();
|
||||
@ -1962,7 +1962,7 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
public List<DataCenterVO> listDataCenters(ListZonesByCmd cmd) {
|
||||
List<DataCenterVO> dcs = _dcDao.listAll();
|
||||
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = UserContext.current().getAccount();
|
||||
Boolean available = cmd.isAvailable();
|
||||
if (account != null) {
|
||||
if ((available != null) && Boolean.FALSE.equals(available)) {
|
||||
@ -2019,7 +2019,7 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
public void assignSecurityGroup(AssignPortForwardingServiceCmd cmd) throws PermissionDeniedException,
|
||||
NetworkRuleConflictException, InvalidParameterValueException, InternalErrorException {
|
||||
Long userId = UserContext.current().getUserId();
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = UserContext.current().getAccount();
|
||||
Long securityGroupId = cmd.getId();
|
||||
List<Long> sgIdList = cmd.getIds();
|
||||
String publicIp = cmd.getPublicIp();
|
||||
@ -2305,7 +2305,7 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
@Override
|
||||
public void removeSecurityGroup(RemovePortForwardingServiceCmd cmd) throws InvalidParameterValueException, PermissionDeniedException{
|
||||
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = UserContext.current().getAccount();
|
||||
Long userId = UserContext.current().getUserId();
|
||||
Long securityGroupId = cmd.getId();
|
||||
String publicIp = cmd.getPublicIp();
|
||||
@ -2659,7 +2659,7 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
|
||||
@Override
|
||||
public List<UserAccountVO> searchForUsers(ListUsersCmd cmd) throws PermissionDeniedException {
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = UserContext.current().getAccount();
|
||||
Long domainId = cmd.getDomainId();
|
||||
if (domainId != null) {
|
||||
if ((account != null) && !_domainDao.isChildDomain(account.getDomainId(), domainId)) {
|
||||
@ -2754,7 +2754,7 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
|
||||
sc.addAnd("name", SearchCriteria.Op.SC, ssc);
|
||||
} else if (vmId != null) {
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = UserContext.current().getAccount();
|
||||
|
||||
UserVmVO vmInstance = _userVmDao.findById(vmId);
|
||||
if ((vmInstance == null) || (vmInstance.getRemoved() != null)) {
|
||||
@ -3106,7 +3106,7 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
public List<VMTemplateVO> listIsos(ListIsosCmd cmd) throws IllegalArgumentException, InvalidParameterValueException {
|
||||
TemplateFilter isoFilter = TemplateFilter.valueOf(cmd.getIsoFilter());
|
||||
Long accountId = null;
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = UserContext.current().getAccount();
|
||||
Long domainId = cmd.getDomainId();
|
||||
String accountName = cmd.getAccountName();
|
||||
if ((account == null) || (account.getType() == Account.ACCOUNT_TYPE_ADMIN)) {
|
||||
@ -3137,7 +3137,7 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
public List<VMTemplateVO> listTemplates(ListTemplatesCmd cmd) throws IllegalArgumentException, InvalidParameterValueException {
|
||||
TemplateFilter templateFilter = TemplateFilter.valueOf(cmd.getTemplateFilter());
|
||||
Long accountId = null;
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = UserContext.current().getAccount();
|
||||
Long domainId = cmd.getDomainId();
|
||||
String accountName = cmd.getAccountName();
|
||||
if ((account == null) || (account.getType() == Account.ACCOUNT_TYPE_ADMIN)) {
|
||||
@ -3254,7 +3254,7 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
|
||||
@Override
|
||||
public List<AccountVO> searchForAccounts(ListAccountsCmd cmd) {
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = UserContext.current().getAccount();
|
||||
Long domainId = cmd.getDomainId();
|
||||
Long accountId = cmd.getId();
|
||||
String accountName = null;
|
||||
@ -3436,7 +3436,7 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
Long guestOSId = cmd.getOsTypeId();
|
||||
Boolean passwordEnabled = cmd.isPasswordEnabled();
|
||||
Boolean bootable = cmd.isBootable();
|
||||
Account account= (Account)UserContext.current().getAccountObject();
|
||||
Account account= UserContext.current().getAccount();
|
||||
|
||||
//verify that template exists
|
||||
VMTemplateVO template = findTemplateById(id);
|
||||
@ -3531,7 +3531,7 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
|
||||
@Override
|
||||
public List<UserVmVO> searchForUserVMs(ListVMsCmd cmd) throws InvalidParameterValueException, PermissionDeniedException {
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = UserContext.current().getAccount();
|
||||
Long domainId = cmd.getDomainId();
|
||||
String accountName = cmd.getAccountName();
|
||||
Long accountId = null;
|
||||
@ -3734,7 +3734,7 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
String protocol = cmd.getProtocol();
|
||||
Long vmId = cmd.getVirtualMachineId();
|
||||
Long userId = UserContext.current().getUserId();
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = UserContext.current().getAccount();
|
||||
UserVmVO userVM = null;
|
||||
|
||||
if (userId == null) {
|
||||
@ -3820,7 +3820,7 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
@Override
|
||||
public List<NetworkRuleConfigVO> searchForNetworkRules(ListPortForwardingServiceRulesCmd cmd) throws InvalidParameterValueException, PermissionDeniedException {
|
||||
Long accountId = null;
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = UserContext.current().getAccount();
|
||||
Long domainId = cmd.getDomainId();
|
||||
String accountName = cmd.getAccountName();
|
||||
Long groupId = cmd.getPortForwardingServiceId();
|
||||
@ -3894,7 +3894,7 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
|
||||
@Override
|
||||
public List<EventVO> searchForEvents(ListEventsCmd cmd) throws PermissionDeniedException, InvalidParameterValueException {
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = UserContext.current().getAccount();
|
||||
Long accountId = null;
|
||||
boolean isAdmin = false;
|
||||
String accountName = cmd.getAccountName();
|
||||
@ -4018,7 +4018,7 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
Long domainId = cmd.getDomainId();
|
||||
String accountName = cmd.getAccountName();
|
||||
Long accountId = null;
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = UserContext.current().getAccount();
|
||||
|
||||
// validate domainId before proceeding
|
||||
if (domainId != null) {
|
||||
@ -4147,7 +4147,7 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
|
||||
@Override
|
||||
public List<VolumeVO> searchForVolumes(ListVolumesCmd cmd) throws InvalidParameterValueException, PermissionDeniedException {
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = UserContext.current().getAccount();
|
||||
Long domainId = cmd.getDomainId();
|
||||
String accountName = cmd.getAccountName();
|
||||
Long accountId = null;
|
||||
@ -4312,7 +4312,7 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
|
||||
@Override
|
||||
public List<IPAddressVO> searchForIPAddresses(ListPublicIpAddressesCmd cmd) throws InvalidParameterValueException, PermissionDeniedException {
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = UserContext.current().getAccount();
|
||||
Long domainId = cmd.getDomainId();
|
||||
String accountName = cmd.getAccountName();
|
||||
Long accountId = null;
|
||||
@ -4560,7 +4560,7 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
}
|
||||
|
||||
// validate permissions
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = UserContext.current().getAccount();
|
||||
if (account != null) {
|
||||
if (isAdmin(account.getType())) {
|
||||
if (!_domainDao.isChildDomain(account.getDomainId(), sg.getDomainId())) {
|
||||
@ -4738,7 +4738,7 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
@Override
|
||||
public List<DomainVO> searchForDomains(ListDomainsCmd cmd) throws PermissionDeniedException {
|
||||
Long domainId = cmd.getId();
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = UserContext.current().getAccount();
|
||||
if (account != null) {
|
||||
if (domainId != null) {
|
||||
if (!_domainDao.isChildDomain(account.getDomainId(), domainId)) {
|
||||
@ -4793,7 +4793,7 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
String domainName = cmd.getDomainName();
|
||||
Object keyword = cmd.getKeyword();
|
||||
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = UserContext.current().getAccount();
|
||||
if (account != null) {
|
||||
if (domainId != null) {
|
||||
if (!_domainDao.isChildDomain(account.getDomainId(), domainId)) {
|
||||
@ -4829,7 +4829,7 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
String name = cmd.getDomainName();
|
||||
Long parentId = cmd.getParentDomainId();
|
||||
Long ownerId = UserContext.current().getAccountId();
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = UserContext.current().getAccount();
|
||||
|
||||
if (ownerId == null) {
|
||||
ownerId = Long.valueOf(1);
|
||||
@ -4873,7 +4873,7 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
|
||||
@Override
|
||||
public boolean deleteDomain(DeleteDomainCmd cmd) throws InvalidParameterValueException, PermissionDeniedException {
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = UserContext.current().getAccount();
|
||||
Long domainId = cmd.getId();
|
||||
Boolean cleanup = cmd.getCleanup();
|
||||
|
||||
@ -4967,7 +4967,7 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
}
|
||||
|
||||
// check permissions
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = UserContext.current().getAccount();
|
||||
if ((account != null) && !isChildDomain(account.getDomainId(), domain.getId())) {
|
||||
throw new PermissionDeniedException("Unable to update domain " + domainId + ", permission denied");
|
||||
}
|
||||
@ -5107,7 +5107,7 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
checkAccountPermissions(volume.getAccountId(), volume.getDomainId(), "volume", volumeId);
|
||||
}
|
||||
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = UserContext.current().getAccount();
|
||||
Long domainId = cmd.getDomainId();
|
||||
String accountName = cmd.getAccountName();
|
||||
Long accountId = null;
|
||||
@ -5229,7 +5229,7 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
|
||||
//Input validation
|
||||
Long id = cmd.getId();
|
||||
Account account = (Account) UserContext.current().getAccountObject();
|
||||
Account account = UserContext.current().getAccount();
|
||||
List<String> accountNames = cmd.getAccountNames();
|
||||
Long userId = UserContext.current().getUserId();
|
||||
Boolean isFeatured = cmd.isFeatured();
|
||||
@ -5374,7 +5374,7 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
|
||||
@Override
|
||||
public List<String> listTemplatePermissions(ListTemplateOrIsoPermissionsCmd cmd) throws InvalidParameterValueException, PermissionDeniedException {
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = UserContext.current().getAccount();
|
||||
Long domainId = cmd.getDomainId();
|
||||
String acctName = cmd.getAccountName();
|
||||
Long id = cmd.getId();
|
||||
@ -5510,7 +5510,7 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
s_logger.debug("Mismatched account id in job and user context, perform further securty check. job id: "
|
||||
+ jobId + ", job owner account: " + job.getAccountId() + ", accound id in current context: " + UserContext.current().getAccountId());
|
||||
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = UserContext.current().getAccount();
|
||||
if (account != null) {
|
||||
if (isAdmin(account.getType())) {
|
||||
Account jobAccount = _accountDao.findById(job.getAccountId());
|
||||
@ -5550,7 +5550,7 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
|
||||
@Override
|
||||
public SecurityGroupVO createPortForwardingService(CreatePortForwardingServiceCmd cmd) throws InvalidParameterValueException {
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = UserContext.current().getAccount();
|
||||
Long domainId = cmd.getDomainId();
|
||||
String accountName = cmd.getAccountName();
|
||||
Long accountId = null;
|
||||
@ -5596,7 +5596,7 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
public boolean deleteSecurityGroup(DeletePortForwardingServiceCmd cmd) throws InvalidParameterValueException, PermissionDeniedException {
|
||||
Long securityGroupId = cmd.getId();
|
||||
Long userId = UserContext.current().getUserId();
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = UserContext.current().getAccount();
|
||||
|
||||
//Verify input parameters
|
||||
if (userId == null) {
|
||||
@ -5666,7 +5666,7 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
@Override
|
||||
public List<SecurityGroupVO> searchForSecurityGroups(ListPortForwardingServicesCmd cmd) throws InvalidParameterValueException, PermissionDeniedException {
|
||||
// if an admin account was passed in, or no account was passed in, make sure we honor the accountName/domainId parameters
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = UserContext.current().getAccount();
|
||||
Long accountId = null;
|
||||
Long domainId = cmd.getDomainId();
|
||||
String accountName = cmd.getAccountName();
|
||||
@ -5730,7 +5730,7 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
if (accountId != null) {
|
||||
sc.addAnd("accountId", SearchCriteria.Op.EQ, accountId);
|
||||
} else if (domainId != null) {
|
||||
DomainVO domain = _domainDao.findById((Long)domainId);
|
||||
DomainVO domain = _domainDao.findById(domainId);
|
||||
sc.setJoinParameters("domainSearch", "path", domain.getPath() + "%");
|
||||
}
|
||||
|
||||
@ -5739,7 +5739,7 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
|
||||
@Override
|
||||
public Map<String, List<SecurityGroupVO>> searchForSecurityGroupsByVM(ListPortForwardingServicesByVmCmd cmd) throws InvalidParameterValueException, PermissionDeniedException {
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = UserContext.current().getAccount();
|
||||
Long domainId = cmd.getDomainId();
|
||||
String accountName = cmd.getAccountName();
|
||||
Long accountId = null;
|
||||
@ -5846,7 +5846,7 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
|
||||
@Override
|
||||
public List<UserVmVO> listLoadBalancerInstances(ListLoadBalancerRuleInstancesCmd cmd) throws PermissionDeniedException {
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = UserContext.current().getAccount();
|
||||
Long loadBalancerId = cmd.getId();
|
||||
Boolean applied = cmd.isApplied();
|
||||
|
||||
@ -5915,7 +5915,7 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
@Override
|
||||
public List<LoadBalancerVO> searchForLoadBalancers(ListLoadBalancerRulesCmd cmd) throws InvalidParameterValueException, PermissionDeniedException {
|
||||
// do some parameter validation
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = UserContext.current().getAccount();
|
||||
String accountName = cmd.getAccountName();
|
||||
Long domainId = cmd.getDomainId();
|
||||
Long accountId = null;
|
||||
@ -6010,7 +6010,7 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
if (accountId != null) {
|
||||
sc.setParameters("accountId", accountId);
|
||||
} else if (domainId != null) {
|
||||
DomainVO domain = _domainDao.findById((Long)domainId);
|
||||
DomainVO domain = _domainDao.findById(domainId);
|
||||
sc.setJoinParameters("domainSearch", "path", domain.getPath() + "%");
|
||||
}
|
||||
|
||||
@ -6189,7 +6189,7 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
|
||||
Object accountId = null;
|
||||
Long domainId = cmd.getDomainId();
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = UserContext.current().getAccount();
|
||||
if ((account == null) || isAdmin(account.getType())) {
|
||||
String accountName = cmd.getAccountName();
|
||||
|
||||
@ -6337,7 +6337,7 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
systemVMs.addAll(searchForConsoleProxy(c));
|
||||
}
|
||||
|
||||
return (List<? extends VMInstanceVO>)systemVMs;
|
||||
return systemVMs;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -6432,6 +6432,7 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getCloudIdentifierResponse(GetCloudIdentifierCmd cmd) throws InvalidParameterValueException{
|
||||
Long userId = cmd.getUserId();
|
||||
|
||||
@ -6544,7 +6545,7 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
|
||||
@Override
|
||||
public boolean lockAccount(LockAccountCmd cmd) {
|
||||
Account adminAccount = (Account)UserContext.current().getAccountObject();
|
||||
Account adminAccount = UserContext.current().getAccount();
|
||||
Long domainId = cmd.getDomainId();
|
||||
String accountName = cmd.getAccountName();
|
||||
|
||||
@ -6744,7 +6745,7 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
|
||||
@Override
|
||||
public InstanceGroupVO updateVmGroup(UpdateVMGroupCmd cmd) {
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = UserContext.current().getAccount();
|
||||
Long groupId = cmd.getId();
|
||||
String groupName = cmd.getGroupName();
|
||||
|
||||
@ -6779,7 +6780,7 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
|
||||
@Override
|
||||
public List<InstanceGroupVO> searchForVmGroups(ListVMGroupsCmd cmd) {
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = UserContext.current().getAccount();
|
||||
Long domainId = cmd.getDomainId();
|
||||
String accountName = cmd.getAccountName();
|
||||
Long accountId = null;
|
||||
@ -6840,7 +6841,7 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
if (accountId != null) {
|
||||
sc.setParameters("accountId", accountId);
|
||||
} else if (domainId != null) {
|
||||
DomainVO domain = _domainDao.findById((Long)domainId);
|
||||
DomainVO domain = _domainDao.findById(domainId);
|
||||
if (domain != null){
|
||||
sc.setJoinParameters("domainSearch", "path", domain.getPath() + "%");
|
||||
}
|
||||
@ -6902,7 +6903,7 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
private Long checkAccountPermissions(long targetAccountId, long targetDomainId, String targetDesc, long targetId) throws ServerApiException {
|
||||
Long accountId = null;
|
||||
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = UserContext.current().getAccount();
|
||||
if (account != null) {
|
||||
if (!isAdmin(account.getType())) {
|
||||
if (account.getId() != targetAccountId) {
|
||||
|
||||
@ -1635,7 +1635,7 @@ public class StorageManagerImpl implements StorageManager {
|
||||
@Override
|
||||
public VolumeVO createVolumeDB(CreateVolumeCmd cmd) throws InvalidParameterValueException, PermissionDeniedException, ResourceAllocationException {
|
||||
// FIXME: some of the scheduled event stuff might be missing here...
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = (Account)UserContext.current().getAccount();
|
||||
String accountName = cmd.getAccountName();
|
||||
Long domainId = cmd.getDomainId();
|
||||
Account targetAccount = null;
|
||||
@ -2438,7 +2438,7 @@ public class StorageManagerImpl implements StorageManager {
|
||||
|
||||
@Override
|
||||
public boolean deleteVolume(DeleteVolumeCmd cmd) throws InvalidParameterValueException {
|
||||
Account account = (Account) UserContext.current().getAccountObject();
|
||||
Account account = (Account) UserContext.current().getAccount();
|
||||
Long volumeId = cmd.getId();
|
||||
|
||||
boolean isAdmin;
|
||||
|
||||
@ -653,7 +653,7 @@ public class SnapshotManagerImpl implements SnapshotManager {
|
||||
private Long checkAccountPermissions(long targetAccountId, long targetDomainId, String targetDesc, long targetId) throws ServerApiException {
|
||||
Long accountId = null;
|
||||
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = (Account)UserContext.current().getAccount();
|
||||
if (account != null) {
|
||||
if (!isAdmin(account.getType())) {
|
||||
if (account.getId() != targetAccountId) {
|
||||
@ -1073,7 +1073,7 @@ public class SnapshotManagerImpl implements SnapshotManager {
|
||||
public List<SnapshotScheduleVO> findRecurringSnapshotSchedule(ListRecurringSnapshotScheduleCmd cmd) throws InvalidParameterValueException, PermissionDeniedException {
|
||||
Long volumeId = cmd.getVolumeId();
|
||||
Long policyId = cmd.getSnapshotPolicyId();
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = (Account)UserContext.current().getAccount();
|
||||
|
||||
//Verify parameters
|
||||
VolumeVO volume = _volsDao.findById(volumeId);
|
||||
|
||||
@ -18,18 +18,14 @@
|
||||
|
||||
package com.cloud.storage.upload;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import com.cloud.async.AsyncJobManager;
|
||||
import com.cloud.exception.InternalErrorException;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.storage.Upload.Status;
|
||||
import com.cloud.storage.Upload.Type;
|
||||
import com.cloud.storage.UploadVO;
|
||||
import com.cloud.storage.VMTemplateHostVO;
|
||||
import com.cloud.storage.VMTemplateVO;
|
||||
import com.cloud.storage.VolumeVO;
|
||||
import com.cloud.storage.Upload.Status;
|
||||
import com.cloud.storage.Upload.Type;
|
||||
import com.cloud.storage.template.TemplateInfo;
|
||||
import com.cloud.utils.component.Manager;
|
||||
|
||||
/**
|
||||
@ -57,6 +53,6 @@ public interface UploadMonitor extends Manager{
|
||||
long asyncJobId, AsyncJobManager asyncMgr);
|
||||
|
||||
UploadVO createEntityDownloadURL(VMTemplateVO template,
|
||||
VMTemplateHostVO vmTemplateHost, Long dataCenterId, long eventId) throws InternalErrorException;
|
||||
VMTemplateHostVO vmTemplateHost, Long dataCenterId, long eventId);
|
||||
|
||||
}
|
||||
@ -29,19 +29,18 @@ import com.cloud.configuration.dao.ConfigurationDao;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.event.EventVO;
|
||||
import com.cloud.event.dao.EventDao;
|
||||
import com.cloud.exception.InternalErrorException;
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.dao.HostDao;
|
||||
import com.cloud.storage.Storage.ImageFormat;
|
||||
import com.cloud.storage.Upload;
|
||||
import com.cloud.storage.Upload.Mode;
|
||||
import com.cloud.storage.Upload.Status;
|
||||
import com.cloud.storage.Upload.Type;
|
||||
import com.cloud.storage.UploadVO;
|
||||
import com.cloud.storage.VMTemplateHostVO;
|
||||
import com.cloud.storage.VMTemplateVO;
|
||||
import com.cloud.storage.VolumeVO;
|
||||
import com.cloud.storage.Storage.ImageFormat;
|
||||
import com.cloud.storage.Upload.Mode;
|
||||
import com.cloud.storage.Upload.Status;
|
||||
import com.cloud.storage.Upload.Type;
|
||||
import com.cloud.storage.dao.UploadDao;
|
||||
import com.cloud.storage.dao.VMTemplateDao;
|
||||
import com.cloud.storage.dao.VMTemplateHostDao;
|
||||
@ -49,6 +48,7 @@ import com.cloud.utils.NumbersUtil;
|
||||
import com.cloud.utils.component.Inject;
|
||||
import com.cloud.utils.concurrency.NamedThreadFactory;
|
||||
import com.cloud.utils.db.GlobalLock;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.vm.SecondaryStorageVmVO;
|
||||
import com.cloud.vm.State;
|
||||
import com.cloud.vm.dao.SecondaryStorageVmDao;
|
||||
@ -176,11 +176,11 @@ public class UploadMonitorImpl implements UploadMonitor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public UploadVO createEntityDownloadURL(VMTemplateVO template, VMTemplateHostVO vmTemplateHost, Long dataCenterId, long eventId) throws InternalErrorException{
|
||||
public UploadVO createEntityDownloadURL(VMTemplateVO template, VMTemplateHostVO vmTemplateHost, Long dataCenterId, long eventId) {
|
||||
|
||||
List<HostVO> storageServers = _serverDao.listByTypeDataCenter(Host.Type.SecondaryStorage, dataCenterId);
|
||||
if(storageServers == null )
|
||||
throw new InternalErrorException("No Storage Server found at the datacenter - " +dataCenterId);
|
||||
throw new CloudRuntimeException("No Storage Server found at the datacenter - " +dataCenterId);
|
||||
|
||||
Type type = (template.getFormat() == ImageFormat.ISO) ? Type.ISO : Type.TEMPLATE ;
|
||||
|
||||
@ -201,7 +201,7 @@ public class UploadMonitorImpl implements UploadMonitor {
|
||||
long result = send(sserver.getId(), cmd, null);
|
||||
if (result == -1){
|
||||
s_logger.warn("Unable to create a link for the template/iso ");
|
||||
throw new InternalErrorException("Unable to create a link at the SSVM");
|
||||
throw new CloudRuntimeException("Unable to create a link at the SSVM");
|
||||
}
|
||||
|
||||
//Construct actual URL locally now that the symlink exists at SSVM
|
||||
@ -210,7 +210,7 @@ public class UploadMonitorImpl implements UploadMonitor {
|
||||
SecondaryStorageVmVO ssVm = ssVms.get(0);
|
||||
if (ssVm.getPublicIpAddress() == null) {
|
||||
s_logger.warn("A running secondary storage vm has a null public ip?");
|
||||
throw new InternalErrorException("SSVM has null public IP - couldnt create the URL");
|
||||
throw new CloudRuntimeException("SSVM has null public IP - couldnt create the URL");
|
||||
}
|
||||
String extractURL = generateCopyUrl(ssVm.getPublicIpAddress(), vmTemplateHost.getInstallPath());
|
||||
UploadVO vo = _uploadDao.createForUpdate();
|
||||
@ -225,7 +225,7 @@ public class UploadMonitorImpl implements UploadMonitor {
|
||||
_uploadDao.update(uploadTemplateObj.getId(), vo);
|
||||
return _uploadDao.findById(uploadTemplateObj.getId(), true);
|
||||
}
|
||||
throw new InternalErrorException("Couldnt find a running SSVM in the zone" + dataCenterId+ ".couldnt create the extraction URL.");
|
||||
throw new CloudRuntimeException("Couldnt find a running SSVM in the zone" + dataCenterId+ ".couldnt create the extraction URL.");
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -79,8 +79,8 @@ import com.cloud.storage.StoragePool;
|
||||
import com.cloud.storage.StoragePoolHostVO;
|
||||
import com.cloud.storage.StoragePoolVO;
|
||||
import com.cloud.storage.Upload;
|
||||
import com.cloud.storage.UploadVO;
|
||||
import com.cloud.storage.Upload.Type;
|
||||
import com.cloud.storage.UploadVO;
|
||||
import com.cloud.storage.VMTemplateHostVO;
|
||||
import com.cloud.storage.VMTemplateStoragePoolVO;
|
||||
import com.cloud.storage.VMTemplateStorageResourceAssoc;
|
||||
@ -160,7 +160,7 @@ public class TemplateManagerImpl implements TemplateManager {
|
||||
|
||||
@Override
|
||||
public VMTemplateVO registerIso(RegisterIsoCmd cmd) throws InvalidParameterValueException, IllegalArgumentException, ResourceAllocationException{
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = UserContext.current().getAccount();
|
||||
Long userId = UserContext.current().getUserId();
|
||||
String name = cmd.getName();
|
||||
String displayText = cmd.getDisplayText();
|
||||
@ -231,7 +231,7 @@ public class TemplateManagerImpl implements TemplateManager {
|
||||
@Override
|
||||
public VMTemplateVO registerTemplate(RegisterTemplateCmd cmd) throws InvalidParameterValueException, URISyntaxException, ResourceAllocationException{
|
||||
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = UserContext.current().getAccount();
|
||||
Long userId = UserContext.current().getUserId();
|
||||
String name = cmd.getName();
|
||||
String displayText = cmd.getDisplayText();
|
||||
@ -411,8 +411,8 @@ public class TemplateManagerImpl implements TemplateManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long extract(ExtractIsoCmd cmd) throws InvalidParameterValueException, PermissionDeniedException, InternalErrorException {
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
public Long extract(ExtractIsoCmd cmd) throws InvalidParameterValueException, PermissionDeniedException {
|
||||
Account account = UserContext.current().getAccount();
|
||||
Long templateId = cmd.getId();
|
||||
Long zoneId = cmd.getZoneId();
|
||||
String url = cmd.getUrl();
|
||||
@ -423,8 +423,8 @@ public class TemplateManagerImpl implements TemplateManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long extract(ExtractTemplateCmd cmd) throws InvalidParameterValueException, PermissionDeniedException, InternalErrorException {
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
public Long extract(ExtractTemplateCmd cmd) throws InvalidParameterValueException, PermissionDeniedException {
|
||||
Account account = UserContext.current().getAccount();
|
||||
Long templateId = cmd.getId();
|
||||
Long zoneId = cmd.getZoneId();
|
||||
String url = cmd.getUrl();
|
||||
@ -434,7 +434,7 @@ public class TemplateManagerImpl implements TemplateManager {
|
||||
return extract(account, templateId, url, zoneId, mode, eventId, false, cmd.getJob(), cmd.getAsyncJobManager());
|
||||
}
|
||||
|
||||
private Long extract(Account account, Long templateId, String url, Long zoneId, String mode, Long eventId, boolean isISO, AsyncJobVO job, AsyncJobManager mgr) throws InvalidParameterValueException, PermissionDeniedException, InternalErrorException {
|
||||
private Long extract(Account account, Long templateId, String url, Long zoneId, String mode, Long eventId, boolean isISO, AsyncJobVO job, AsyncJobManager mgr) throws InvalidParameterValueException, PermissionDeniedException {
|
||||
String desc = "template";
|
||||
if (isISO) {
|
||||
desc = "ISO";
|
||||
@ -779,7 +779,7 @@ public class TemplateManagerImpl implements TemplateManager {
|
||||
Long userId = UserContext.current().getUserId();
|
||||
Long sourceZoneId = cmd.getSourceZoneId();
|
||||
Long destZoneId = cmd.getDestinationZoneId();
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = UserContext.current().getAccount();
|
||||
|
||||
//Verify parameters
|
||||
VMTemplateVO iso = _tmpltDao.findById(isoId);
|
||||
@ -813,7 +813,7 @@ public class TemplateManagerImpl implements TemplateManager {
|
||||
Long userId = UserContext.current().getUserId();
|
||||
Long sourceZoneId = cmd.getSourceZoneId();
|
||||
Long destZoneId = cmd.getDestinationZoneId();
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = UserContext.current().getAccount();
|
||||
|
||||
//Verify parameters
|
||||
VMTemplateVO template = _tmpltDao.findById(templateId);
|
||||
@ -1132,7 +1132,7 @@ public class TemplateManagerImpl implements TemplateManager {
|
||||
|
||||
@Override
|
||||
public boolean detachIso(DetachIsoCmd cmd) throws InternalErrorException, InvalidParameterValueException, PermissionDeniedException {
|
||||
Account account = (Account) UserContext.current().getAccountObject();
|
||||
Account account = UserContext.current().getAccount();
|
||||
Long userId = UserContext.current().getUserId();
|
||||
Long vmId = cmd.getVirtualMachineId();
|
||||
|
||||
@ -1166,7 +1166,7 @@ public class TemplateManagerImpl implements TemplateManager {
|
||||
|
||||
@Override
|
||||
public boolean attachIso(AttachIsoCmd cmd) throws InternalErrorException, InvalidParameterValueException, PermissionDeniedException {
|
||||
Account account = (Account) UserContext.current().getAccountObject();
|
||||
Account account = UserContext.current().getAccount();
|
||||
Long userId = UserContext.current().getUserId();
|
||||
Long vmId = cmd.getVirtualMachineId();
|
||||
Long isoId = cmd.getId();
|
||||
@ -1272,7 +1272,7 @@ public class TemplateManagerImpl implements TemplateManager {
|
||||
public boolean deleteTemplate(DeleteTemplateCmd cmd) throws InvalidParameterValueException, InternalErrorException, PermissionDeniedException {
|
||||
Long templateId = cmd.getId();
|
||||
Long userId = UserContext.current().getUserId();
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = UserContext.current().getAccount();
|
||||
Long zoneId = cmd.getZoneId();
|
||||
|
||||
VMTemplateVO template = _tmpltDao.findById(templateId.longValue());
|
||||
@ -1305,7 +1305,7 @@ public class TemplateManagerImpl implements TemplateManager {
|
||||
public boolean deleteIso(DeleteIsoCmd cmd) throws InvalidParameterValueException, InternalErrorException, PermissionDeniedException {
|
||||
Long templateId = cmd.getId();
|
||||
Long userId = UserContext.current().getUserId();
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = UserContext.current().getAccount();
|
||||
Long zoneId = cmd.getZoneId();
|
||||
|
||||
VMTemplateVO template = _tmpltDao.findById(templateId.longValue());
|
||||
|
||||
@ -342,7 +342,7 @@ public class AccountManagerImpl implements AccountManager {
|
||||
String accountName = cmd.getAccountName();
|
||||
Long domainId = cmd.getDomainId();
|
||||
Long accountId = null;
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = (Account)UserContext.current().getAccount();
|
||||
|
||||
if ((account == null) ||
|
||||
(account.getType() == Account.ACCOUNT_TYPE_ADMIN) ||
|
||||
@ -409,7 +409,7 @@ public class AccountManagerImpl implements AccountManager {
|
||||
@Override
|
||||
public ResourceLimitVO updateResourceLimit(UpdateResourceLimitCmd cmd) throws InvalidParameterValueException {
|
||||
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = (Account)UserContext.current().getAccount();
|
||||
Long domainId = cmd.getDomainId();
|
||||
Long max = cmd.getMax();
|
||||
Integer type = cmd.getResourceType();
|
||||
|
||||
@ -45,6 +45,7 @@ import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.InsufficientServerCapacityException;
|
||||
import com.cloud.exception.OperationTimedoutException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.exception.StorageUnavailableException;
|
||||
import com.cloud.network.NetworkConfigurationVO;
|
||||
import com.cloud.network.NetworkManager;
|
||||
@ -211,7 +212,7 @@ public class MauriceMoss implements VmManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends VMInstanceVO> T start(T vm, DeploymentPlan plan, Account acct, VirtualMachineGuru<T> guru) throws InsufficientCapacityException, ConcurrentOperationException {
|
||||
public <T extends VMInstanceVO> T start(T vm, DeploymentPlan plan, Account acct, VirtualMachineGuru<T> guru) throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException {
|
||||
State state = vm.getState();
|
||||
if (state == State.Starting || state == State.Running) {
|
||||
s_logger.debug("VM is already started: " + vm);
|
||||
|
||||
@ -26,6 +26,7 @@ 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.DestroyVMCmd;
|
||||
import com.cloud.api.commands.DetachVolumeCmd;
|
||||
import com.cloud.api.commands.RebootVMCmd;
|
||||
@ -48,6 +49,7 @@ 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.network.security.NetworkGroupVO;
|
||||
import com.cloud.offerings.NetworkOfferingVO;
|
||||
@ -250,4 +252,8 @@ public interface UserVmManager extends Manager, VirtualMachineManager<UserVmVO>
|
||||
void removeInstanceFromGroup(long vmId);
|
||||
|
||||
void updateVirtualMachine(UpdateVMCmd cmd);
|
||||
|
||||
UserVm createVirtualMachine(DeployVmCmd cmd) throws InvalidParameterValueException, PermissionDeniedException, InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException;
|
||||
|
||||
UserVm startVirtualMachine(DeployVmCmd cmd) throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException;
|
||||
}
|
||||
|
||||
@ -69,6 +69,7 @@ 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.DestroyVMCmd;
|
||||
import com.cloud.api.commands.DetachVolumeCmd;
|
||||
import com.cloud.api.commands.RebootVMCmd;
|
||||
@ -117,6 +118,7 @@ import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.OperationTimedoutException;
|
||||
import com.cloud.exception.PermissionDeniedException;
|
||||
import com.cloud.exception.ResourceAllocationException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.exception.StorageUnavailableException;
|
||||
import com.cloud.ha.HighAvailabilityManager;
|
||||
import com.cloud.host.Host;
|
||||
@ -302,7 +304,7 @@ public class UserVmManagerImpl implements UserVmManager {
|
||||
|
||||
private boolean resetVMPasswordInternal(ResetVMPasswordCmd cmd) {
|
||||
//Input validation
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = UserContext.current().getAccount();
|
||||
Long userId = UserContext.current().getUserId();
|
||||
Long id = cmd.getId();
|
||||
|
||||
@ -359,7 +361,7 @@ public class UserVmManagerImpl implements UserVmManager {
|
||||
Long vmId = command.getVirtualMachineId();
|
||||
Long volumeId = command.getId();
|
||||
Long deviceId = command.getDeviceId();
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = UserContext.current().getAccount();
|
||||
|
||||
// Check that the volume ID is valid
|
||||
VolumeVO volume = _volsDao.findById(volumeId);
|
||||
@ -588,7 +590,7 @@ public class UserVmManagerImpl implements UserVmManager {
|
||||
|
||||
@Override
|
||||
public void detachVolumeFromVM(DetachVolumeCmd cmmd) throws InternalErrorException, InvalidParameterValueException {
|
||||
Account account = (Account) UserContext.current().getAccountObject();
|
||||
Account account = UserContext.current().getAccount();
|
||||
if ((cmmd.getId() == null && cmmd.getDeviceId() == null && cmmd.getVirtualMachineId() == null) ||
|
||||
(cmmd.getId() != null && (cmmd.getDeviceId() != null || cmmd.getVirtualMachineId() != null)) ||
|
||||
(cmmd.getId() == null && (cmmd.getDeviceId()==null || cmmd.getVirtualMachineId() == null))) {
|
||||
@ -1327,7 +1329,7 @@ public class UserVmManagerImpl implements UserVmManager {
|
||||
public UserVm upgradeVirtualMachine(UpgradeVMCmd cmd) throws ServerApiException, InvalidParameterValueException {
|
||||
Long virtualMachineId = cmd.getId();
|
||||
Long serviceOfferingId = cmd.getServiceOfferingId();
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = UserContext.current().getAccount();
|
||||
Long userId = UserContext.current().getUserId();
|
||||
|
||||
// Verify input parameters
|
||||
@ -2034,7 +2036,7 @@ public class UserVmManagerImpl implements UserVmManager {
|
||||
public boolean recoverVirtualMachine(RecoverVMCmd cmd) throws ResourceAllocationException, InternalErrorException {
|
||||
|
||||
Long vmId = cmd.getId();
|
||||
Account accountHandle = (Account)UserContext.current().getAccountObject();
|
||||
Account accountHandle = UserContext.current().getAccount();
|
||||
|
||||
//if account is removed, return error
|
||||
if(accountHandle!=null && accountHandle.getRemoved() != null)
|
||||
@ -2667,7 +2669,7 @@ public class UserVmManagerImpl implements UserVmManager {
|
||||
userId = User.UID_SYSTEM;
|
||||
}
|
||||
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = UserContext.current().getAccount();
|
||||
boolean isAdmin = ((account == null) || isAdmin(account.getType()));
|
||||
|
||||
VMTemplateVO privateTemplate = null;
|
||||
@ -3403,7 +3405,7 @@ public class UserVmManagerImpl implements UserVmManager {
|
||||
String displayName = cmd.getDisplayName();
|
||||
Boolean ha = cmd.getHaEnable();
|
||||
Long id = cmd.getId();
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = UserContext.current().getAccount();
|
||||
Long userId = UserContext.current().getUserId();
|
||||
|
||||
//Input validation
|
||||
@ -3460,7 +3462,7 @@ public class UserVmManagerImpl implements UserVmManager {
|
||||
public UserVmVO stopVirtualMachine(StopVMCmd cmd) throws ServerApiException{
|
||||
|
||||
//Input validation
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = UserContext.current().getAccount();
|
||||
Long userId = UserContext.current().getUserId();
|
||||
Long id = cmd.getId();
|
||||
|
||||
@ -3488,7 +3490,7 @@ public class UserVmManagerImpl implements UserVmManager {
|
||||
@Override
|
||||
public UserVmVO startVirtualMachine(StartVMCmd cmd) throws StorageUnavailableException, ExecutionException, ConcurrentOperationException {
|
||||
//Input validation
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = UserContext.current().getAccount();
|
||||
Long userId = UserContext.current().getUserId();
|
||||
Long id = cmd.getId();
|
||||
|
||||
@ -3511,7 +3513,7 @@ public class UserVmManagerImpl implements UserVmManager {
|
||||
|
||||
@Override
|
||||
public boolean rebootVirtualMachine(RebootVMCmd cmd) {
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = UserContext.current().getAccount();
|
||||
Long userId = UserContext.current().getUserId();
|
||||
Long vmId = cmd.getId();
|
||||
|
||||
@ -3542,7 +3544,7 @@ public class UserVmManagerImpl implements UserVmManager {
|
||||
@Override
|
||||
public boolean destroyVm(DestroyVMCmd cmd) {
|
||||
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = UserContext.current().getAccount();
|
||||
Long userId = UserContext.current().getUserId();
|
||||
Long vmId = cmd.getId();
|
||||
|
||||
@ -3572,7 +3574,7 @@ public class UserVmManagerImpl implements UserVmManager {
|
||||
|
||||
@Override @DB
|
||||
public InstanceGroupVO createVmGroup(CreateVMGroupCmd cmd) throws InvalidParameterValueException, PermissionDeniedException {
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = UserContext.current().getAccount();
|
||||
Long domainId = cmd.getDomainId();
|
||||
String accountName = cmd.getAccountName();
|
||||
Long accountId = null;
|
||||
@ -3641,7 +3643,7 @@ public class UserVmManagerImpl implements UserVmManager {
|
||||
|
||||
@Override
|
||||
public boolean deleteVmGroup(DeleteVMGroupCmd cmd) throws InvalidParameterValueException, PermissionDeniedException {
|
||||
Account account = (Account)UserContext.current().getAccountObject();
|
||||
Account account = UserContext.current().getAccount();
|
||||
Long groupId = cmd.getId();
|
||||
|
||||
// Verify input parameters
|
||||
@ -3761,4 +3763,194 @@ public class UserVmManagerImpl implements UserVmManager {
|
||||
s_logger.warn("Error trying to remove vm from group: "+e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserVm createVirtualMachine(DeployVmCmd cmd)
|
||||
throws InsufficientCapacityException, ResourceUnavailableException, ConcurrentOperationException, InvalidParameterValueException, PermissionDeniedException {
|
||||
// Account ctxAccount = UserContext.current().getAccount();
|
||||
// Long userId = UserContext.current().getUserId();
|
||||
// String accountName = cmd.getAccountName();
|
||||
// Long domainId = cmd.getDomainId();
|
||||
// Long accountId = null;
|
||||
// long dataCenterId = cmd.getZoneId();
|
||||
// long serviceOfferingId = cmd.getServiceOfferingId();
|
||||
// long templateId = cmd.getTemplateId();
|
||||
// Long diskOfferingId = cmd.getDiskOfferingId();
|
||||
// String domain = null; // FIXME: this was hardcoded to null in DeployVMCmd in the old framework, do we need it?
|
||||
// String password = generateRandomPassword();
|
||||
// String displayName = cmd.getDisplayName();
|
||||
// String group = cmd.getGroup();
|
||||
// String userData = cmd.getUserData();
|
||||
// String[] networkGroups = null;
|
||||
// Long sizeObj = cmd.getSize();
|
||||
// long size = (sizeObj == null) ? 0 : sizeObj;
|
||||
//
|
||||
// if ((ctxAccount == null) || isAdmin(ctxAccount.getType())) {
|
||||
// if (domainId != null) {
|
||||
// if ((ctxAccount != null) && !_domainDao.isChildDomain(ctxAccount.getDomainId(), domainId)) {
|
||||
// throw new PermissionDeniedException("Failed to deploy VM, invalid domain id (" + domainId + ") given.");
|
||||
// }
|
||||
// if (accountName != null) {
|
||||
// Account userAccount = _accountDao.findActiveAccount(accountName, domainId);
|
||||
// if (userAccount == null) {
|
||||
// throw new InvalidParameterValueException("Unable to find account " + accountName + " in domain " + domainId);
|
||||
// }
|
||||
// accountId = userAccount.getId();
|
||||
// }
|
||||
// } else {
|
||||
// accountId = ((ctxAccount != null) ? ctxAccount.getId() : null);
|
||||
// }
|
||||
// } else {
|
||||
// accountId = ctxAccount.getId();
|
||||
// }
|
||||
//
|
||||
// if (accountId == null) {
|
||||
// throw new InvalidParameterValueException("No valid account specified for deploying a virtual machine.");
|
||||
// }
|
||||
//
|
||||
// List<String> netGrpList = cmd.getNetworkGroupList();
|
||||
// if ((netGrpList != null) && !netGrpList.isEmpty()) {
|
||||
// networkGroups = netGrpList.toArray(new String[netGrpList.size()]);
|
||||
// }
|
||||
//
|
||||
// AccountVO account = _accountDao.findById(accountId);
|
||||
// if (account == null) {
|
||||
// throw new InvalidParameterValueException("Unable to find account: " + accountId);
|
||||
// }
|
||||
//
|
||||
// DataCenterVO dc = _dcDao.findById(dataCenterId);
|
||||
// if (dc == null) {
|
||||
// throw new InvalidParameterValueException("Unable to find zone: " + dataCenterId);
|
||||
// }
|
||||
//
|
||||
// ServiceOfferingVO offering = _offeringsDao.findById(serviceOfferingId);
|
||||
// if (offering == null) {
|
||||
// throw new InvalidParameterValueException("Unable to find service offering: " + serviceOfferingId);
|
||||
// }
|
||||
//
|
||||
// VMTemplateVO template = _templateDao.findById(templateId);
|
||||
// // Make sure a valid template ID was specified
|
||||
// if (template == null) {
|
||||
// throw new InvalidParameterValueException("Please specify a valid template or ISO ID.");
|
||||
// }
|
||||
//
|
||||
// boolean isIso = Storage.ImageFormat.ISO.equals(template.getFormat());
|
||||
//
|
||||
// if (isIso && !template.isBootable()) {
|
||||
// throw new InvalidParameterValueException("Please specify a bootable ISO.");
|
||||
// }
|
||||
//
|
||||
// // If the template represents an ISO, a disk offering must be passed in, and will be used to create the root disk
|
||||
// // Else, a disk offering is optional, and if present will be used to create the data disk
|
||||
// DiskOfferingVO diskOffering = null;
|
||||
//
|
||||
// if (diskOfferingId != null) {
|
||||
// diskOffering = _diskOfferingDao.findById(diskOfferingId);
|
||||
// }
|
||||
//
|
||||
// if (isIso && diskOffering == null) {
|
||||
// throw new InvalidParameterValueException("Please specify a valid disk offering ID.");
|
||||
// }
|
||||
//
|
||||
// // validate that the template is usable by the account
|
||||
// if (!template.isPublicTemplate()) {
|
||||
// Long templateOwner = template.getAccountId();
|
||||
// if (!BaseCmd.isAdmin(account.getType()) && ((templateOwner == null) || (templateOwner.longValue() != accountId))) {
|
||||
// // since the current account is not the owner of the template, check the launch permissions table to see if the
|
||||
// // account can launch a VM from this template
|
||||
// LaunchPermissionVO permission = _launchPermissionDao.findByTemplateAndAccount(templateId, account.getId());
|
||||
// if (permission == null) {
|
||||
// throw new PermissionDeniedException("Account " + account.getAccountName() + " does not have permission to launch instances from template " + template.getName());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// byte [] decodedUserData = null;
|
||||
// if (userData != null) {
|
||||
// if (userData.length() >= 2* UserVmManager.MAX_USER_DATA_LENGTH_BYTES) {
|
||||
// throw new InvalidParameterValueException("User data is too long");
|
||||
// }
|
||||
// decodedUserData = org.apache.commons.codec.binary.Base64.decodeBase64(userData.getBytes());
|
||||
// if (decodedUserData.length > UserVmManager.MAX_USER_DATA_LENGTH_BYTES){
|
||||
// throw new InvalidParameterValueException("User data is too long");
|
||||
// }
|
||||
// if (decodedUserData.length < 1) {
|
||||
// throw new InvalidParameterValueException("User data is too short");
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// if (offering.getGuestIpType() != NetworkOffering.GuestIpType.Virtualized) {
|
||||
// _networkGroupMgr.createDefaultNetworkGroup(accountId);
|
||||
// }
|
||||
//
|
||||
// if (networkGroups != null) {
|
||||
// if (offering.getGuestIpType() == NetworkOffering.GuestIpType.Virtualized) {
|
||||
// throw new InvalidParameterValueException("Network groups are not compatible with service offering " + offering.getName());
|
||||
// }
|
||||
// Set<String> nameSet = new HashSet<String>(); //handle duplicate names -- allowed
|
||||
// nameSet.addAll(Arrays.asList(networkGroups));
|
||||
// nameSet.add(NetworkGroupManager.DEFAULT_GROUP_NAME);
|
||||
// networkGroups = nameSet.toArray(new String[nameSet.size()]);
|
||||
// List<NetworkGroupVO> networkGroupVOs = _networkSecurityGroupDao.findByAccountAndNames(accountId, networkGroups);
|
||||
// if (networkGroupVOs.size() != nameSet.size()) {
|
||||
// throw new InvalidParameterValueException("Some network group names do not exist");
|
||||
// }
|
||||
// } else { //create a default group if necessary
|
||||
// if (offering.getGuestIpType() != NetworkOffering.GuestIpType.Virtualized && _networkGroupsEnabled) {
|
||||
// networkGroups = new String[]{NetworkGroupManager.DEFAULT_GROUP_NAME};
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// Long eventId = cmd.getStartEventId();
|
||||
// try {
|
||||
// return deployVirtualMachineImpl(userId, accountId, dataCenterId, serviceOfferingId, templateId, diskOfferingId, domain, password, displayName, group, userData, networkGroups, eventId, size);
|
||||
// } catch (ResourceAllocationException e) {
|
||||
// if(s_logger.isDebugEnabled())
|
||||
// s_logger.debug("Unable to deploy VM: " + e.getMessage());
|
||||
// EventUtils.saveEvent(userId, accountId, EventVO.LEVEL_ERROR, EventTypes.EVENT_VM_CREATE, "Unable to deploy VM: VM_INSUFFICIENT_CAPACITY", null, eventId);
|
||||
// throw e;
|
||||
// } catch (ExecutionException e) {
|
||||
// if(s_logger.isDebugEnabled())
|
||||
// s_logger.debug("Unable to deploy VM: " + e.getMessage());
|
||||
// EventUtils.saveEvent(userId, accountId, EventVO.LEVEL_ERROR, EventTypes.EVENT_VM_CREATE, "Unable to deploy VM: VM_HOST_LICENSE_EXPIRED", null, eventId);
|
||||
// throw e;
|
||||
// } catch (InvalidParameterValueException e) {
|
||||
// if(s_logger.isDebugEnabled())
|
||||
// s_logger.debug("Unable to deploy VM: " + e.getMessage());
|
||||
// EventUtils.saveEvent(userId, accountId, EventVO.LEVEL_ERROR, EventTypes.EVENT_VM_CREATE, "Unable to deploy VM: VM_INVALID_PARAM_ERROR", null, eventId);
|
||||
// throw e;
|
||||
// } catch (InternalErrorException e) {
|
||||
// if(s_logger.isDebugEnabled())
|
||||
// s_logger.debug("Unable to deploy VM: " + e.getMessage());
|
||||
// EventUtils.saveEvent(userId, accountId, EventVO.LEVEL_ERROR, EventTypes.EVENT_VM_CREATE, "Unable to deploy VM: INTERNAL_ERROR", null, eventId);
|
||||
// throw e;
|
||||
// } catch (InsufficientStorageCapacityException e) {
|
||||
// if(s_logger.isDebugEnabled())
|
||||
// s_logger.debug("Unable to deploy VM: " + e.getMessage());
|
||||
// EventUtils.saveEvent(userId, accountId, EventVO.LEVEL_ERROR, EventTypes.EVENT_VM_CREATE, "Unable to deploy VM: VM_INSUFFICIENT_CAPACITY", null, eventId);
|
||||
// throw e;
|
||||
// } catch (PermissionDeniedException e) {
|
||||
// if(s_logger.isDebugEnabled())
|
||||
// s_logger.debug("Unable to deploy VM: " + e.getMessage());
|
||||
// EventUtils.saveEvent(userId, accountId, EventVO.LEVEL_ERROR, EventTypes.EVENT_VM_CREATE, "Unable to deploy VM: ACCOUNT_ERROR", null, eventId);
|
||||
// throw e;
|
||||
// } catch (ConcurrentOperationException e) {
|
||||
// if(s_logger.isDebugEnabled())
|
||||
// s_logger.debug("Unable to deploy VM: " + e.getMessage());
|
||||
// EventUtils.saveEvent(userId, accountId, EventVO.LEVEL_ERROR, EventTypes.EVENT_VM_CREATE, "Unable to deploy VM: INTERNAL_ERROR", null, eventId);
|
||||
// throw e;
|
||||
// } catch(Exception e) {
|
||||
// s_logger.warn("Unable to deploy VM : " + e.getMessage(), e);
|
||||
// EventUtils.saveEvent(userId, accountId, EventVO.LEVEL_ERROR, EventTypes.EVENT_VM_CREATE, "Unable to deploy VM: INTERNAL_ERROR", null, eventId);
|
||||
// throw new CloudRuntimeException("Unable to deploy VM : " + e.getMessage());
|
||||
// }
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserVm startVirtualMachine(DeployVmCmd cmd) {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -23,6 +23,7 @@ import com.cloud.deploy.DeploymentPlan;
|
||||
import com.cloud.exception.AgentUnavailableException;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.exception.StorageUnavailableException;
|
||||
import com.cloud.network.NetworkConfigurationVO;
|
||||
import com.cloud.service.ServiceOfferingVO;
|
||||
@ -62,7 +63,7 @@ public interface VmManager extends Manager {
|
||||
DeploymentPlan plan,
|
||||
Account owner) throws InsufficientCapacityException, StorageUnavailableException;
|
||||
|
||||
<T extends VMInstanceVO> T start(T vm, DeploymentPlan plan, Account user, VirtualMachineGuru<T> checker) throws InsufficientCapacityException, StorageUnavailableException, ConcurrentOperationException;
|
||||
<T extends VMInstanceVO> T start(T vm, DeploymentPlan plan, Account user, VirtualMachineGuru<T> checker) throws InsufficientCapacityException, StorageUnavailableException, ConcurrentOperationException, ResourceUnavailableException;
|
||||
|
||||
<T extends VMInstanceVO> T stop(T vm) throws AgentUnavailableException, ConcurrentOperationException;
|
||||
|
||||
|
||||
@ -58,4 +58,5 @@ public interface SerialVersionUID {
|
||||
public static final long ConflictingNetworkSettingException = Base | 0x1c;
|
||||
public static final long CloudAuthenticationException = Base | 0x1d;
|
||||
public static final long AsyncCommandQueued = Base | 0x1e;
|
||||
public static final long ResourceUnavailableException = Base | 0x1f;
|
||||
}
|
||||
|
||||
@ -72,6 +72,8 @@ import com.cloud.utils.mgmt.ManagementBean;
|
||||
@SuppressWarnings("unchecked")
|
||||
public class ComponentLocator extends Thread implements ComponentLocatorMBean {
|
||||
protected static final Logger s_logger = Logger.getLogger(ComponentLocator.class);
|
||||
|
||||
protected static HashMap<String, Object> s_singletons = new HashMap<String, Object>(111);
|
||||
|
||||
protected HashMap<String, Adapters<? extends Adapter>> _adapterMap;
|
||||
protected HashMap<String, Info<Manager>> _managerMap;
|
||||
@ -103,11 +105,11 @@ public class ComponentLocator extends Thread implements ComponentLocatorMBean {
|
||||
public synchronized void run() {
|
||||
Iterator<Adapters<? extends Adapter>> itAdapters = _adapterMap.values().iterator();
|
||||
while (itAdapters.hasNext()) {
|
||||
Adapters adapters = itAdapters.next();
|
||||
Adapters<? extends Adapter> adapters = itAdapters.next();
|
||||
itAdapters.remove();
|
||||
Enumeration it = adapters.enumeration();
|
||||
Enumeration<? extends Adapter> it = adapters.enumeration();
|
||||
while (it.hasMoreElements()) {
|
||||
Adapter adapter = (Adapter)it.nextElement();
|
||||
Adapter adapter = it.nextElement();
|
||||
adapter.stop();
|
||||
}
|
||||
}
|
||||
@ -182,7 +184,7 @@ public class ComponentLocator extends Thread implements ComponentLocatorMBean {
|
||||
Info<GenericDao<?, ?>> info = entry.getValue();
|
||||
s_logger.info("Starting DAO: " + info.name);
|
||||
try {
|
||||
info.instance = (GenericDao<?, ?>)createInstance(info.clazz, true);
|
||||
info.instance = (GenericDao<?, ?>)createInstance(info.clazz, true, info.singleton);
|
||||
inject(info.clazz, info.instance);
|
||||
if (!info.instance.configure(info.name, info.params)) {
|
||||
s_logger.error("Unable to configure DAO: " + info.name);
|
||||
@ -201,9 +203,17 @@ public class ComponentLocator extends Thread implements ComponentLocatorMBean {
|
||||
}
|
||||
}
|
||||
|
||||
private static Object createInstance(Class<?> clazz, boolean inject, Object... args) {
|
||||
private static Object createInstance(Class<?> clazz, boolean inject, boolean singleton, Object... args) {
|
||||
Factory factory = null;
|
||||
Object entity = null;
|
||||
synchronized(s_factories) {
|
||||
if (singleton) {
|
||||
entity = s_singletons.get(clazz.toString());
|
||||
if (entity != null) {
|
||||
s_logger.debug("Found singleton instantiation for " + clazz.toString());
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
InjectInfo info = s_factories.get(clazz);
|
||||
if (info == null) {
|
||||
Enhancer enhancer = new Enhancer();
|
||||
@ -219,11 +229,10 @@ public class ComponentLocator extends Thread implements ComponentLocatorMBean {
|
||||
}
|
||||
|
||||
|
||||
Class[] argTypes = null;
|
||||
Object entity;
|
||||
Class<?>[] argTypes = null;
|
||||
if (args != null && args.length > 0) {
|
||||
Constructor<?>[] constructors = clazz.getConstructors();
|
||||
for (Constructor constructor : constructors) {
|
||||
for (Constructor<?> constructor : constructors) {
|
||||
Class<?>[] paramTypes = constructor.getParameterTypes();
|
||||
if (paramTypes.length == args.length) {
|
||||
boolean found = true;
|
||||
@ -253,6 +262,12 @@ public class ComponentLocator extends Thread implements ComponentLocatorMBean {
|
||||
inject(clazz, entity);
|
||||
}
|
||||
|
||||
if (singleton) {
|
||||
synchronized(s_factories) {
|
||||
s_singletons.put(clazz.toString(), entity);
|
||||
}
|
||||
}
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
||||
@ -275,13 +290,13 @@ public class ComponentLocator extends Thread implements ComponentLocatorMBean {
|
||||
return info;
|
||||
}
|
||||
|
||||
private static synchronized Object getComponent(Class clazz) {
|
||||
private static synchronized Object getComponent(Class<?> clazz) {
|
||||
String name = clazz.getName();
|
||||
try {
|
||||
Object component = _componentMap.get(name);
|
||||
if (component == null) {
|
||||
Class<?> impl = Class.forName(name);
|
||||
component = createInstance(impl, true);
|
||||
component = createInstance(impl, true, true);
|
||||
_componentMap.put(name, component);
|
||||
}
|
||||
return component;
|
||||
@ -300,7 +315,7 @@ public class ComponentLocator extends Thread implements ComponentLocatorMBean {
|
||||
String implementationClass = _implementationClassMap.get(componentName);
|
||||
if (implementationClass != null) {
|
||||
try {
|
||||
Class clazz = Class.forName(implementationClass);
|
||||
Class<?> clazz = Class.forName(implementationClass);
|
||||
return getComponent(clazz);
|
||||
} catch (Exception ex) {
|
||||
s_logger.error("Failed to get component " + componentName + ", caused by exception " + ex, ex);
|
||||
@ -322,7 +337,7 @@ public class ComponentLocator extends Thread implements ComponentLocatorMBean {
|
||||
Info<Manager> info = entry.getValue();
|
||||
if (info.instance == null) {
|
||||
s_logger.info("Instantiating Manager: " + info.name);
|
||||
info.instance = (Manager)createInstance(info.clazz, false);
|
||||
info.instance = (Manager)createInstance(info.clazz, false, info.singleton);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -434,7 +449,7 @@ public class ComponentLocator extends Thread implements ComponentLocatorMBean {
|
||||
return null;
|
||||
}
|
||||
if (info.instance == null) {
|
||||
info.instance = (Manager)createInstance(info.clazz, false);
|
||||
info.instance = (Manager)createInstance(info.clazz, false, info.singleton);
|
||||
}
|
||||
return (T)info.instance;
|
||||
}
|
||||
@ -446,7 +461,7 @@ public class ComponentLocator extends Thread implements ComponentLocatorMBean {
|
||||
List<Adapter> lst = new ArrayList<Adapter>();
|
||||
for (Info<Adapter> info : entry.getValue()) {
|
||||
s_logger.info("Instantiating Adapter: " + info.name);
|
||||
info.instance = (Adapter)createInstance(info.clazz, true);
|
||||
info.instance = (Adapter)createInstance(info.clazz, true, info.singleton);
|
||||
try {
|
||||
if (!info.instance.configure(info.name, info.params)) {
|
||||
s_logger.error("Unable to configure adapter: " + info.name);
|
||||
@ -496,11 +511,11 @@ public class ComponentLocator extends Thread implements ComponentLocatorMBean {
|
||||
}
|
||||
|
||||
public static <T> T inject(Class<T> clazz) {
|
||||
return (T)createInstance(clazz, true);
|
||||
return (T)createInstance(clazz, true, false);
|
||||
}
|
||||
|
||||
public static <T> T inject(Class<T> clazz, Object... args) {
|
||||
return (T)createInstance(clazz, true, args);
|
||||
return (T)createInstance(clazz, true, false, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -621,8 +636,9 @@ public class ComponentLocator extends Thread implements ComponentLocatorMBean {
|
||||
Class<?> clazz;
|
||||
HashMap<String, Object> params = new HashMap<String, Object>();
|
||||
String name;
|
||||
String key;
|
||||
List<String> keys = new ArrayList<String>();
|
||||
T instance;
|
||||
boolean singleton = true;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -634,7 +650,6 @@ public class ComponentLocator extends Thread implements ComponentLocatorMBean {
|
||||
public HashMap<String, Info<Manager>> managers;
|
||||
public LinkedHashMap<String, Info<GenericDao<?, ?>>> daos;
|
||||
public String parent;
|
||||
public
|
||||
|
||||
List<Info<Adapter>> lst;
|
||||
String paramName;
|
||||
@ -680,13 +695,14 @@ public class ComponentLocator extends Thread implements ComponentLocatorMBean {
|
||||
Class<?>[] classes = local.value();
|
||||
for (int i = 0; i < classes.length; i++) {
|
||||
if (findInterfaceInHierarchy(classes[i].getInterfaces(), interphace)) {
|
||||
info.key = classes[i].getName();
|
||||
info.keys.add(classes[i].getName());
|
||||
s_logger.info("Found component: " + interphace.getName() + " - " + clazzName + " - " + info.name);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
throw new CloudRuntimeException("Class " + clazzName + " does not implement " + interphace.getName());
|
||||
|
||||
if (info.keys.size() != classes.length) {
|
||||
throw new CloudRuntimeException("Class " + clazzName + " does not implement " + interphace.getName());
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean findInterfaceInHierarchy(Class<?>[] interphaces, Class<?> interphace) {
|
||||
@ -732,7 +748,9 @@ public class ComponentLocator extends Thread implements ComponentLocatorMBean {
|
||||
Info<Manager> info = new Info<Manager>();
|
||||
fillInfo(atts, Manager.class, info);
|
||||
s_logger.info("Adding Manager: " + info.name);
|
||||
managers.put(info.key, info);
|
||||
for (String key : info.keys) {
|
||||
managers.put(key, info);
|
||||
}
|
||||
currentInfo = info;
|
||||
} else if (qName.equals("param")) {
|
||||
paramName = getAttribute(atts, "name");
|
||||
@ -740,7 +758,9 @@ public class ComponentLocator extends Thread implements ComponentLocatorMBean {
|
||||
} else if (qName.equals("dao")) {
|
||||
Info<GenericDao<?, ?>> info = new Info<GenericDao<?, ?>>();
|
||||
fillInfo(atts, GenericDao.class, info);
|
||||
daos.put(info.key, info);
|
||||
for (String key : info.keys) {
|
||||
daos.put(key, info);
|
||||
}
|
||||
currentInfo = info;
|
||||
} else {
|
||||
// ignore
|
||||
|
||||
@ -1031,15 +1031,15 @@ public abstract class GenericDaoBase<T, ID extends Serializable> implements Gene
|
||||
str.insert(fromIndex, onClause);
|
||||
str.append(" (").append(join.getT().getWhereClause()).append(") AND ");
|
||||
fromIndex+=onClause.length();
|
||||
}
|
||||
}
|
||||
|
||||
for (JoinBuilder<SearchCriteria<?>> join : joins) {
|
||||
if (join.getT().getJoins() != null) {
|
||||
addJoins(str, join.getT().getJoins());
|
||||
str.delete(str.length() - 4, str.length());
|
||||
for (JoinBuilder<SearchCriteria<?>> join : joins) {
|
||||
if (join.getT().getJoins() != null) {
|
||||
addJoins(str, join.getT().getJoins());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
str.delete(str.length() - 4, str.length());
|
||||
}
|
||||
|
||||
@Override @DB(txn=false)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user