mirror of
				https://github.com/apache/cloudstack.git
				synced 2025-11-04 00:02:37 +01:00 
			
		
		
		
	Unexposed parameters can now be assigned to commands. This are for internal use of the command, and will be serialized/deserialized during execution/response phases, but will not be accepted as part of the API request. Also create a DB utility file for the API to use which delegates requests to the DAOs. Mostly this utility class will look up objects by ID, and it allows the removal of similar methods from ManagementServer, thereby reducing some of the clutter in ManagementServer.
This commit is contained in:
		
							parent
							
								
									f4caf145c3
								
							
						
					
					
						commit
						dbb2897626
					
				
							
								
								
									
										113
									
								
								server/src/com/cloud/api/ApiDBUtils.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										113
									
								
								server/src/com/cloud/api/ApiDBUtils.java
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,113 @@
 | 
			
		||||
package com.cloud.api;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
import com.cloud.dc.DataCenterVO;
 | 
			
		||||
import com.cloud.dc.dao.DataCenterDao;
 | 
			
		||||
import com.cloud.domain.DomainVO;
 | 
			
		||||
import com.cloud.domain.dao.DomainDao;
 | 
			
		||||
import com.cloud.host.HostVO;
 | 
			
		||||
import com.cloud.host.dao.HostDao;
 | 
			
		||||
import com.cloud.network.IPAddressVO;
 | 
			
		||||
import com.cloud.network.dao.IPAddressDao;
 | 
			
		||||
import com.cloud.network.security.NetworkGroupManager;
 | 
			
		||||
import com.cloud.offering.ServiceOffering;
 | 
			
		||||
import com.cloud.server.Criteria;
 | 
			
		||||
import com.cloud.server.ManagementServer;
 | 
			
		||||
import com.cloud.service.dao.ServiceOfferingDao;
 | 
			
		||||
import com.cloud.storage.VMTemplateVO;
 | 
			
		||||
import com.cloud.storage.VolumeVO;
 | 
			
		||||
import com.cloud.storage.dao.VMTemplateDao;
 | 
			
		||||
import com.cloud.storage.dao.VolumeDao;
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.User;
 | 
			
		||||
import com.cloud.user.dao.AccountDao;
 | 
			
		||||
import com.cloud.user.dao.UserDao;
 | 
			
		||||
import com.cloud.utils.component.ComponentLocator;
 | 
			
		||||
import com.cloud.vm.UserVmVO;
 | 
			
		||||
 | 
			
		||||
public class ApiDBUtils {
 | 
			
		||||
    private static ManagementServer _ms;
 | 
			
		||||
    private static NetworkGroupManager _networkGroupMgr;
 | 
			
		||||
    private static AccountDao _accountDao;
 | 
			
		||||
    private static DomainDao _domainDao;
 | 
			
		||||
    private static HostDao _hostDao;
 | 
			
		||||
    private static IPAddressDao _ipAddressDao;
 | 
			
		||||
    private static ServiceOfferingDao _serviceOfferingDao;
 | 
			
		||||
    private static VMTemplateDao _templateDao;
 | 
			
		||||
    private static UserDao _userDao;
 | 
			
		||||
    private static VolumeDao _volumeDao;
 | 
			
		||||
    private static DataCenterDao _zoneDao;
 | 
			
		||||
 | 
			
		||||
    static {
 | 
			
		||||
        _ms = (ManagementServer)ComponentLocator.getComponent(ManagementServer.Name);
 | 
			
		||||
 | 
			
		||||
        ComponentLocator locator = ComponentLocator.getLocator(ManagementServer.Name);
 | 
			
		||||
        _networkGroupMgr = locator.getManager(NetworkGroupManager.class);
 | 
			
		||||
        _accountDao = locator.getDao(AccountDao.class);
 | 
			
		||||
        _domainDao = locator.getDao(DomainDao.class);
 | 
			
		||||
        _hostDao = locator.getDao(HostDao.class);
 | 
			
		||||
        _ipAddressDao = locator.getDao(IPAddressDao.class);
 | 
			
		||||
        _serviceOfferingDao = locator.getDao(ServiceOfferingDao.class);
 | 
			
		||||
        _templateDao = locator.getDao(VMTemplateDao.class);
 | 
			
		||||
        _userDao = locator.getDao(UserDao.class);
 | 
			
		||||
        _volumeDao = locator.getDao(VolumeDao.class);
 | 
			
		||||
        _zoneDao = locator.getDao(DataCenterDao.class);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /////////////////////////////////////////////////////////////
 | 
			
		||||
    //               ManagementServer methods                  //
 | 
			
		||||
    /////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    public static List<UserVmVO> searchForUserVMs(Criteria c) {
 | 
			
		||||
        return _ms.searchForUserVMs(c);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /////////////////////////////////////////////////////////////
 | 
			
		||||
    //                   Manager methods                       //
 | 
			
		||||
    /////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    public static String getNetworkGroupsNamesForVm(long vmId) {
 | 
			
		||||
        return _networkGroupMgr.getNetworkGroupsNamesForVm(vmId);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /////////////////////////////////////////////////////////////
 | 
			
		||||
    //                     Dao methods                         //
 | 
			
		||||
    /////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    public static Account findAccountById(Long accountId) {
 | 
			
		||||
        return _accountDao.findById(accountId);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static DomainVO findDomainById(Long domainId) {
 | 
			
		||||
        return _domainDao.findById(domainId);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static HostVO findHostById(Long hostId) {
 | 
			
		||||
        return _hostDao.findById(hostId);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static IPAddressVO findIpAddressById(String address) {
 | 
			
		||||
        return _ipAddressDao.findById(address);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static ServiceOffering findServiceOfferingById(Long serviceOfferingId) {
 | 
			
		||||
        return _serviceOfferingDao.findById(serviceOfferingId);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static VMTemplateVO findTemplateById(Long templateId) {
 | 
			
		||||
        return _templateDao.findById(templateId);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static User findUserById(Long userId) {
 | 
			
		||||
        return _userDao.findById(userId);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static VolumeVO findVolumeById(Long volumeId) {
 | 
			
		||||
        return _volumeDao.findById(volumeId);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static DataCenterVO findZoneById(Long zoneId) {
 | 
			
		||||
        return _zoneDao.findById(zoneId);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@ -152,9 +152,10 @@ public class ApiDispatcher {
 | 
			
		||||
        Field[] fields = cmd.getClass().getDeclaredFields();
 | 
			
		||||
        for (Field field : fields) {
 | 
			
		||||
            Parameter parameterAnnotation = field.getAnnotation(Parameter.class);
 | 
			
		||||
            if (parameterAnnotation == null) {
 | 
			
		||||
            if ((parameterAnnotation == null) || !parameterAnnotation.expose()) {
 | 
			
		||||
                continue;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            Object paramObj = unpackedParams.get(parameterAnnotation.name());
 | 
			
		||||
            if (paramObj == null) {
 | 
			
		||||
                if (parameterAnnotation.required()) {
 | 
			
		||||
 | 
			
		||||
@ -349,7 +349,9 @@ public class ApiServer implements HttpRequestHandler {
 | 
			
		||||
        if (cmdObj instanceof BaseAsyncCmd) {
 | 
			
		||||
            Long objectId = null;
 | 
			
		||||
            if (cmdObj instanceof BaseAsyncCreateCmd) {
 | 
			
		||||
                objectId = _dispatcher.dispatchCreateCmd((BaseAsyncCreateCmd)cmdObj, params);
 | 
			
		||||
                BaseAsyncCreateCmd createCmd = (BaseAsyncCreateCmd)cmdObj;
 | 
			
		||||
                objectId = _dispatcher.dispatchCreateCmd(createCmd, params);
 | 
			
		||||
                createCmd.setId(objectId);
 | 
			
		||||
            }
 | 
			
		||||
            BaseAsyncCmd asyncCmd = (BaseAsyncCmd)cmdObj;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -33,5 +33,6 @@ public @interface Parameter {
 | 
			
		||||
    boolean required() default false;
 | 
			
		||||
    CommandType type() default CommandType.OBJECT;
 | 
			
		||||
    CommandType collectionType() default CommandType.OBJECT;
 | 
			
		||||
    boolean expose() default true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -20,6 +20,7 @@ package com.cloud.api.commands;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.api.ApiDBUtils;
 | 
			
		||||
import com.cloud.api.BaseAsyncCreateCmd;
 | 
			
		||||
import com.cloud.api.BaseCmd.Manager;
 | 
			
		||||
import com.cloud.api.Implementation;
 | 
			
		||||
@ -85,14 +86,14 @@ public class CreateSnapshotCmd extends BaseAsyncCreateCmd {
 | 
			
		||||
        SnapshotResponse response = new SnapshotResponse();
 | 
			
		||||
        response.setId(snapshot.getId());
 | 
			
		||||
 | 
			
		||||
        Account account = getAsyncJobMgr().getExecutorContext().getAccountDao().findById(snapshot.getAccountId());
 | 
			
		||||
        Account account = ApiDBUtils.findAccountById(snapshot.getAccountId());
 | 
			
		||||
        if (account != null) {
 | 
			
		||||
            response.setAccountName(account.getAccountName());
 | 
			
		||||
            response.setDomainId(account.getDomainId());
 | 
			
		||||
            response.setDomainName(getAsyncJobMgr().getExecutorContext().getManagementServer().findDomainIdById(account.getDomainId()).getName());
 | 
			
		||||
            response.setDomainName(ApiDBUtils.findDomainById(account.getDomainId()).getName());
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        VolumeVO volume = managementServer.findVolumeById(snapshot.getVolumeId());
 | 
			
		||||
        VolumeVO volume = ApiDBUtils.findVolumeById(snapshot.getVolumeId());
 | 
			
		||||
        String snapshotTypeStr = SnapshotType.values()[snapshot.getSnapshotType()].name();
 | 
			
		||||
        response.setSnapshotType(snapshotTypeStr);
 | 
			
		||||
        response.setVolumeId(snapshot.getVolumeId());
 | 
			
		||||
 | 
			
		||||
@ -22,16 +22,18 @@ 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.Implementation;
 | 
			
		||||
import com.cloud.api.Parameter;
 | 
			
		||||
import com.cloud.api.response.UserVmResponse;
 | 
			
		||||
import com.cloud.offering.ServiceOffering;
 | 
			
		||||
import com.cloud.serializer.SerializerHelper;
 | 
			
		||||
import com.cloud.service.ServiceOfferingVO;
 | 
			
		||||
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;
 | 
			
		||||
 | 
			
		||||
@Implementation(method="deployVirtualMachine")
 | 
			
		||||
@ -77,6 +79,9 @@ public class DeployVMCmd extends BaseAsyncCmd {
 | 
			
		||||
    @Parameter(name="zoneid", type=CommandType.LONG, required=true)
 | 
			
		||||
    private Long zoneId;
 | 
			
		||||
 | 
			
		||||
    // unexposed parameter needed for serializing/deserializing the command
 | 
			
		||||
    @Parameter(name="password", type=CommandType.STRING, expose=false)
 | 
			
		||||
    private String password;
 | 
			
		||||
 | 
			
		||||
    /////////////////////////////////////////////////////
 | 
			
		||||
    /////////////////// Accessors ///////////////////////
 | 
			
		||||
@ -126,6 +131,14 @@ public class DeployVMCmd extends BaseAsyncCmd {
 | 
			
		||||
        return zoneId;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // not exposed parameter
 | 
			
		||||
    public String getPassword() {
 | 
			
		||||
        return password;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setPassword(String password) {
 | 
			
		||||
        this.password = password;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /////////////////////////////////////////////////////
 | 
			
		||||
    /////////////// API Implementation///////////////////
 | 
			
		||||
@ -149,7 +162,7 @@ public class DeployVMCmd extends BaseAsyncCmd {
 | 
			
		||||
        response.setName(userVm.getName());
 | 
			
		||||
        response.setCreated(userVm.getCreated());
 | 
			
		||||
        response.setZoneId(userVm.getDataCenterId());
 | 
			
		||||
        response.setZoneName(getManagementServer().findDataCenterById(userVm.getDataCenterId()).getName());
 | 
			
		||||
        response.setZoneName(ApiDBUtils.findZoneById(userVm.getDataCenterId()).getName());
 | 
			
		||||
        response.setPrivateIp(userVm.getPrivateIpAddress());
 | 
			
		||||
        response.setServiceOfferingId(userVm.getServiceOfferingId());
 | 
			
		||||
        response.setHaEnable(userVm.isHaEnabled());
 | 
			
		||||
@ -164,20 +177,25 @@ public class DeployVMCmd extends BaseAsyncCmd {
 | 
			
		||||
            response.setState(userVm.getState().toString());
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        VMTemplateVO template = managementServer.findTemplateById(userVm.getTemplateId());
 | 
			
		||||
        VMTemplateVO template = ApiDBUtils.findTemplateById(userVm.getTemplateId());
 | 
			
		||||
        
 | 
			
		||||
        Account acct = managementServer.findAccountById(Long.valueOf(userVm.getAccountId()));
 | 
			
		||||
        Account acct = ApiDBUtils.findAccountById(Long.valueOf(userVm.getAccountId()));
 | 
			
		||||
        if (acct != null) {
 | 
			
		||||
            response.setAccountName(acct.getAccountName());
 | 
			
		||||
            response.setDomainId(acct.getDomainId());
 | 
			
		||||
            response.setDomain(managementServer.findDomainIdById(acct.getDomainId()).getName());
 | 
			
		||||
            response.setDomainName(ApiDBUtils.findDomainById(acct.getDomainId()).getName());
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        User userExecutingCmd = managementServer.getUser(userId);
 | 
			
		||||
 | 
			
		||||
        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
 | 
			
		||||
        Account acctForUserExecutingCmd = managementServer.findAccountById(Long.valueOf(userExecutingCmd.getAccountId()));
 | 
			
		||||
        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(managementServer.getHostBy(userVm.getHostId()).getName());
 | 
			
		||||
            response.setHostName(ApiDBUtils.findHostById(userVm.getHostId()).getName());
 | 
			
		||||
            response.setHostId(userVm.getHostId());
 | 
			
		||||
        }
 | 
			
		||||
            
 | 
			
		||||
@ -195,13 +213,13 @@ public class DeployVMCmd extends BaseAsyncCmd {
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (templatePasswordEnabled) { // FIXME:  where will the password come from in this case?
 | 
			
		||||
            response.setPassword(param.getPassword());
 | 
			
		||||
            response.setPassword(getPassword());
 | 
			
		||||
        } 
 | 
			
		||||
        
 | 
			
		||||
        // ISO Info
 | 
			
		||||
        Long isoId = userVm.getIsoId();
 | 
			
		||||
        if (isoId != null) {
 | 
			
		||||
            VMTemplateVO iso = getManagementServer().findTemplateById(isoId.longValue());
 | 
			
		||||
            VMTemplateVO iso = ApiDBUtils.findTemplateById(isoId.longValue());
 | 
			
		||||
            if (iso != null) {
 | 
			
		||||
                response.setIsoId(isoId.longValue());
 | 
			
		||||
                response.setIsoName(iso.getName());
 | 
			
		||||
@ -221,7 +239,7 @@ public class DeployVMCmd extends BaseAsyncCmd {
 | 
			
		||||
            response.setPasswordEnabled(templatePasswordEnabled);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        ServiceOfferingVO offering = managementServer.findServiceOfferingById(userVm.getServiceOfferingId());
 | 
			
		||||
        ServiceOffering offering = ApiDBUtils.findServiceOfferingById(userVm.getServiceOfferingId());
 | 
			
		||||
        response.setServiceOfferingId(userVm.getServiceOfferingId());
 | 
			
		||||
        response.setServiceOfferingName(offering.getName());
 | 
			
		||||
 | 
			
		||||
@ -229,7 +247,7 @@ public class DeployVMCmd extends BaseAsyncCmd {
 | 
			
		||||
        response.setCpuSpeed(offering.getSpeed());
 | 
			
		||||
        response.setMemory(offering.getRamSize());
 | 
			
		||||
        
 | 
			
		||||
        response.setNetworkGroupList(managementServer.getNetworkGroupsNamesForVm(userVm.getId()));
 | 
			
		||||
        response.setNetworkGroupList(ApiDBUtils.getNetworkGroupsNamesForVm(userVm.getId()));
 | 
			
		||||
 | 
			
		||||
        return SerializerHelper.toSerializedString(response);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -25,12 +25,14 @@ import java.util.Map;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.api.ApiDBUtils;
 | 
			
		||||
import com.cloud.api.BaseCmd.Manager;
 | 
			
		||||
import com.cloud.api.BaseListCmd;
 | 
			
		||||
import com.cloud.api.Implementation;
 | 
			
		||||
import com.cloud.api.Parameter;
 | 
			
		||||
import com.cloud.api.response.FirewallRuleResponse;
 | 
			
		||||
import com.cloud.network.FirewallRuleVO;
 | 
			
		||||
import com.cloud.network.IPAddressVO;
 | 
			
		||||
import com.cloud.serializer.SerializerHelper;
 | 
			
		||||
import com.cloud.server.Criteria;
 | 
			
		||||
import com.cloud.vm.UserVmVO;
 | 
			
		||||
@ -70,6 +72,7 @@ public class ListPortForwardingRulesCmd extends BaseListCmd {
 | 
			
		||||
    public String getResponse() {
 | 
			
		||||
        List<FirewallRuleVO> firewallRules = (List<FirewallRuleVO>)getResponseObject();
 | 
			
		||||
        Map<String, UserVmVO> userVmCache = new HashMap<String, UserVmVO>();
 | 
			
		||||
        IPAddressVO ipAddr = ApiDBUtils.findIpAddressById(ipAddress);
 | 
			
		||||
 | 
			
		||||
        List<FirewallRuleResponse> response = new ArrayList<FirewallRuleResponse>();
 | 
			
		||||
        for (FirewallRuleVO fwRule : firewallRules) {
 | 
			
		||||
@ -83,10 +86,10 @@ public class ListPortForwardingRulesCmd extends BaseListCmd {
 | 
			
		||||
            UserVmVO userVM = userVmCache.get(fwRule.getPrivateIpAddress());
 | 
			
		||||
            if (userVM == null) {
 | 
			
		||||
                Criteria c = new Criteria();
 | 
			
		||||
                c.addCriteria(Criteria.ACCOUNTID, new Object[] {addrOwner.getId()});
 | 
			
		||||
                c.addCriteria(Criteria.DATACENTERID, ipAddressVO.getDataCenterId());
 | 
			
		||||
                c.addCriteria(Criteria.ACCOUNTID, new Object[] {ipAddr.getAccountId()});
 | 
			
		||||
                c.addCriteria(Criteria.DATACENTERID, ipAddr.getDataCenterId());
 | 
			
		||||
                c.addCriteria(Criteria.IPADDRESS, fwRule.getPrivateIpAddress());
 | 
			
		||||
                List<UserVmVO> userVMs = getManagementServer().searchForUserVMs(c);
 | 
			
		||||
                List<UserVmVO> userVMs = ApiDBUtils.searchForUserVMs(c);
 | 
			
		||||
 | 
			
		||||
                if ((userVMs != null) && (userVMs.size() > 0)) {
 | 
			
		||||
                    userVM = userVMs.get(0);
 | 
			
		||||
 | 
			
		||||
@ -23,6 +23,7 @@ import java.util.List;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.api.ApiDBUtils;
 | 
			
		||||
import com.cloud.api.BaseListCmd;
 | 
			
		||||
import com.cloud.api.Implementation;
 | 
			
		||||
import com.cloud.api.Parameter;
 | 
			
		||||
@ -214,7 +215,7 @@ public class ListVMsCmd extends BaseListCmd {
 | 
			
		||||
            userVmResponse.setOsTypeId(userVm.getGuestOSId());
 | 
			
		||||
 | 
			
		||||
            //network groups
 | 
			
		||||
            userVmResponse.setNetworkGroupList(getManagementServer().getNetworkGroupsNamesForVm(userVm.getId()));
 | 
			
		||||
            userVmResponse.setNetworkGroupList(ApiDBUtils.getNetworkGroupsNamesForVm(userVm.getId()));
 | 
			
		||||
 | 
			
		||||
            response.add(userVmResponse);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@ -33,7 +33,7 @@ public class SnapshotResponse implements ResponseObject {
 | 
			
		||||
    private Long domainId;
 | 
			
		||||
 | 
			
		||||
    @Param(name="domain")
 | 
			
		||||
    private String domain;
 | 
			
		||||
    private String domainName;
 | 
			
		||||
 | 
			
		||||
    @Param(name="snapshottype")
 | 
			
		||||
    private String snapshotType;
 | 
			
		||||
@ -86,12 +86,12 @@ public class SnapshotResponse implements ResponseObject {
 | 
			
		||||
        this.domainId = domainId;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public String getDomain() {
 | 
			
		||||
        return domain;
 | 
			
		||||
    public String getDomainName() {
 | 
			
		||||
        return domainName;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setDomain(String domain) {
 | 
			
		||||
        this.domain = domain;
 | 
			
		||||
    public void setDomainName(String domainName) {
 | 
			
		||||
        this.domainName = domainName;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public String getSnapshotType() {
 | 
			
		||||
 | 
			
		||||
@ -86,6 +86,9 @@ public class UserVmResponse implements ResponseObject {
 | 
			
		||||
    @Param(name="isoname")
 | 
			
		||||
    private String isoName;
 | 
			
		||||
 | 
			
		||||
    @Param(name="isodisplaytext")
 | 
			
		||||
    private String isoDisplayText;
 | 
			
		||||
 | 
			
		||||
    @Param(name="serviceofferingid")
 | 
			
		||||
    private Long serviceOfferingId;
 | 
			
		||||
 | 
			
		||||
@ -116,6 +119,9 @@ public class UserVmResponse implements ResponseObject {
 | 
			
		||||
    @Param(name="networkgrouplist")
 | 
			
		||||
    private String networkGroupList;
 | 
			
		||||
 | 
			
		||||
    @Param(name="password")
 | 
			
		||||
    private String password;
 | 
			
		||||
 | 
			
		||||
    @Param(name="jobid")
 | 
			
		||||
    private Long jobId;
 | 
			
		||||
 | 
			
		||||
@ -290,6 +296,14 @@ public class UserVmResponse implements ResponseObject {
 | 
			
		||||
        this.isoName = isoName;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public String getIsoDisplayText() {
 | 
			
		||||
        return isoDisplayText;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setIsoDisplayText(String isoDisplayText) {
 | 
			
		||||
        this.isoDisplayText = isoDisplayText;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Long getServiceOfferingId() {
 | 
			
		||||
        return serviceOfferingId;
 | 
			
		||||
    }
 | 
			
		||||
@ -370,6 +384,14 @@ public class UserVmResponse implements ResponseObject {
 | 
			
		||||
        this.networkGroupList = networkGroupList;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public String getPassword() {
 | 
			
		||||
        return password;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setPassword(String password) {
 | 
			
		||||
        this.password = password;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Long getJobId() {
 | 
			
		||||
        return jobId;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -144,11 +144,11 @@ public class AsyncJobManagerImpl implements AsyncJobManager {
 | 
			
		||||
    			txt.rollback();
 | 
			
		||||
    			return;
 | 
			
		||||
    		}
 | 
			
		||||
    		
 | 
			
		||||
 | 
			
		||||
    		job.setCompleteMsid(getMsid());
 | 
			
		||||
    		job.setStatus(jobStatus);
 | 
			
		||||
    		job.setResultCode(resultCode);
 | 
			
		||||
    		
 | 
			
		||||
 | 
			
		||||
    		// reset attached object
 | 
			
		||||
    		job.setInstanceType(null);
 | 
			
		||||
    		job.setInstanceId(null);
 | 
			
		||||
@ -164,7 +164,7 @@ public class AsyncJobManagerImpl implements AsyncJobManager {
 | 
			
		||||
    		txt.rollback();
 | 
			
		||||
    	}
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override @DB
 | 
			
		||||
    public void updateAsyncJobStatus(long jobId, int processStatus, Object resultObject) {
 | 
			
		||||
    	if(s_logger.isDebugEnabled())
 | 
			
		||||
@ -194,7 +194,7 @@ public class AsyncJobManagerImpl implements AsyncJobManager {
 | 
			
		||||
    		txt.rollback();
 | 
			
		||||
    	}
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override @DB
 | 
			
		||||
    public void updateAsyncJobAttachment(long jobId, String instanceType, Long instanceId) {
 | 
			
		||||
    	if(s_logger.isDebugEnabled())
 | 
			
		||||
@ -204,27 +204,27 @@ public class AsyncJobManagerImpl implements AsyncJobManager {
 | 
			
		||||
    	Transaction txt = Transaction.currentTxn();
 | 
			
		||||
    	try {
 | 
			
		||||
    		txt.start();
 | 
			
		||||
    	
 | 
			
		||||
 | 
			
		||||
	    	AsyncJobVO job = _jobDao.createForUpdate();
 | 
			
		||||
	    	job.setInstanceType(instanceType);
 | 
			
		||||
	    	job.setInstanceId(instanceId);
 | 
			
		||||
			job.setLastUpdated(DateUtil.currentGMTTime());
 | 
			
		||||
			_jobDao.update(jobId, job);
 | 
			
		||||
			
 | 
			
		||||
 | 
			
		||||
    		txt.commit();
 | 
			
		||||
    	} catch(Exception e) {
 | 
			
		||||
    		s_logger.error("Unexpected exception while updating async job-" + jobId + " attachment: ", e);
 | 
			
		||||
    		txt.rollback();
 | 
			
		||||
    	}
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void syncAsyncJobExecution(long jobId, String syncObjType, long syncObjId) {
 | 
			
		||||
    	if(s_logger.isDebugEnabled())
 | 
			
		||||
    		s_logger.debug("Sync job-" + jobId + " execution on object " + syncObjType + "." + syncObjId);
 | 
			
		||||
    	
 | 
			
		||||
    	SyncQueueVO queue = null;
 | 
			
		||||
    	
 | 
			
		||||
 | 
			
		||||
		// to deal with temporary DB exceptions like DB deadlock/Lock-wait time out cased rollbacks
 | 
			
		||||
    	// we retry five times until we throw an exception
 | 
			
		||||
		Random random = new Random();    		
 | 
			
		||||
@ -246,9 +246,7 @@ public class AsyncJobManagerImpl implements AsyncJobManager {
 | 
			
		||||
			throw new CloudRuntimeException("Unable to insert queue item into database, DB is full?");
 | 
			
		||||
		}
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override @DB
 | 
			
		||||
    public AsyncJobResult queryAsyncJobResult(long jobId) {
 | 
			
		||||
    	if(s_logger.isTraceEnabled())
 | 
			
		||||
 | 
			
		||||
@ -6756,13 +6756,6 @@ public class ManagementServerImpl implements ManagementServer {
 | 
			
		||||
		return null;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	public String getNetworkGroupsNamesForVm(long vmId) 
 | 
			
		||||
	{
 | 
			
		||||
 | 
			
		||||
		return _networkGroupMgr.getNetworkGroupsNamesForVm(vmId);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public boolean checkLocalStorageConfigVal()
 | 
			
		||||
	{
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user