Merge branch '2.1.refactor' of ssh://git.cloud.com/var/lib/git/cloudstack-oss into 2.1.refactor

This commit is contained in:
alena 2010-09-15 16:45:59 -07:00
commit ec47f83a4a
40 changed files with 509 additions and 675 deletions

View File

@ -1,11 +1,26 @@
package com.cloud.api;
import java.util.ArrayList;
import java.util.List;
import com.cloud.agent.manager.AgentManager;
import com.cloud.async.AsyncJobManager;
import com.cloud.async.AsyncJobVO;
import com.cloud.configuration.ResourceCount.ResourceType;
import com.cloud.dc.AccountVlanMapVO;
import com.cloud.dc.ClusterVO;
import com.cloud.dc.DataCenterVO;
import com.cloud.dc.HostPodVO;
import com.cloud.dc.VlanVO;
import com.cloud.dc.dao.AccountVlanMapDao;
import com.cloud.dc.dao.ClusterDao;
import com.cloud.dc.dao.DataCenterDao;
import com.cloud.dc.dao.HostPodDao;
import com.cloud.dc.dao.VlanDao;
import com.cloud.domain.DomainVO;
import com.cloud.domain.dao.DomainDao;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.host.HostStats;
import com.cloud.host.HostVO;
import com.cloud.host.dao.HostDao;
import com.cloud.network.IPAddressVO;
@ -14,28 +29,74 @@ import com.cloud.network.security.NetworkGroupManager;
import com.cloud.offering.ServiceOffering;
import com.cloud.server.Criteria;
import com.cloud.server.ManagementServer;
import com.cloud.server.StatsCollector;
import com.cloud.service.dao.ServiceOfferingDao;
import com.cloud.storage.DiskOfferingVO;
import com.cloud.storage.GuestOS;
import com.cloud.storage.GuestOSCategoryVO;
import com.cloud.storage.Snapshot;
import com.cloud.storage.SnapshotPolicyVO;
import com.cloud.storage.SnapshotVO;
import com.cloud.storage.StorageManager;
import com.cloud.storage.StoragePoolVO;
import com.cloud.storage.StorageStats;
import com.cloud.storage.VMTemplateHostVO;
import com.cloud.storage.VMTemplateVO;
import com.cloud.storage.VolumeVO;
import com.cloud.storage.dao.DiskOfferingDao;
import com.cloud.storage.dao.GuestOSCategoryDao;
import com.cloud.storage.dao.GuestOSDao;
import com.cloud.storage.dao.SnapshotDao;
import com.cloud.storage.dao.StoragePoolDao;
import com.cloud.storage.dao.VMTemplateDao;
import com.cloud.storage.dao.VMTemplateHostDao;
import com.cloud.storage.dao.VolumeDao;
import com.cloud.storage.snapshot.SnapshotManager;
import com.cloud.user.Account;
import com.cloud.user.AccountManager;
import com.cloud.user.AccountVO;
import com.cloud.user.User;
import com.cloud.user.UserStatisticsVO;
import com.cloud.user.dao.AccountDao;
import com.cloud.user.dao.UserDao;
import com.cloud.user.dao.UserStatisticsDao;
import com.cloud.uservm.UserVm;
import com.cloud.utils.DateUtil;
import com.cloud.utils.component.ComponentLocator;
import com.cloud.vm.UserVmVO;
import com.cloud.vm.VMInstanceVO;
import com.cloud.vm.VmStats;
import com.cloud.vm.dao.UserVmDao;
public class ApiDBUtils {
private static ManagementServer _ms;
private static AccountManager _accountMgr;
private static AgentManager _agentMgr;
private static AsyncJobManager _asyncMgr;
private static NetworkGroupManager _networkGroupMgr;
private static SnapshotManager _snapMgr;
private static StorageManager _storageMgr;
private static StatsCollector _statsCollector;
private static AccountDao _accountDao;
private static AccountVlanMapDao _accountVlanMapDao;
private static ClusterDao _clusterDao;
private static DiskOfferingDao _diskOfferingDao;
private static DomainDao _domainDao;
private static GuestOSDao _guestOSDao;
private static GuestOSCategoryDao _guestOSCategoryDao;
private static HostDao _hostDao;
private static IPAddressDao _ipAddressDao;
private static HostPodDao _podDao;
private static ServiceOfferingDao _serviceOfferingDao;
private static SnapshotDao _snapshotDao;
private static StoragePoolDao _storagePoolDao;
private static VMTemplateDao _templateDao;
private static VMTemplateHostDao _templateHostDao;
private static UserDao _userDao;
private static UserStatisticsDao _userStatsDao;
private static UserVmDao _userVmDao;
private static VlanDao _vlanDao;
private static VolumeDao _volumeDao;
private static DataCenterDao _zoneDao;
@ -43,34 +104,140 @@ public class ApiDBUtils {
_ms = (ManagementServer)ComponentLocator.getComponent(ManagementServer.Name);
ComponentLocator locator = ComponentLocator.getLocator(ManagementServer.Name);
_accountMgr = locator.getManager(AccountManager.class);
_agentMgr = locator.getManager(AgentManager.class);
_asyncMgr = locator.getManager(AsyncJobManager.class);
_networkGroupMgr = locator.getManager(NetworkGroupManager.class);
_snapMgr = locator.getManager(SnapshotManager.class);
_storageMgr = locator.getManager(StorageManager.class);
_accountDao = locator.getDao(AccountDao.class);
_domainDao = locator.getDao(DomainDao.class);
_accountVlanMapDao = locator.getDao(AccountVlanMapDao.class);
_clusterDao = locator.getDao(ClusterDao.class);
_diskOfferingDao = locator.getDao(DiskOfferingDao.class);
_domainDao = locator.getDao(DomainDao.class);
_guestOSDao = locator.getDao(GuestOSDao.class);
_guestOSCategoryDao = locator.getDao(GuestOSCategoryDao.class);
_hostDao = locator.getDao(HostDao.class);
_ipAddressDao = locator.getDao(IPAddressDao.class);
_podDao = locator.getDao(HostPodDao.class);
_serviceOfferingDao = locator.getDao(ServiceOfferingDao.class);
_snapshotDao = locator.getDao(SnapshotDao.class);
_storagePoolDao = locator.getDao(StoragePoolDao.class);
_templateDao = locator.getDao(VMTemplateDao.class);
_templateHostDao = locator.getDao(VMTemplateHostDao.class);
_userDao = locator.getDao(UserDao.class);
_userStatsDao = locator.getDao(UserStatisticsDao.class);
_userVmDao = locator.getDao(UserVmDao.class);
_vlanDao = locator.getDao(VlanDao.class);
_volumeDao = locator.getDao(VolumeDao.class);
_zoneDao = locator.getDao(DataCenterDao.class);
// Note: stats collector should already have been initialized by this time, otherwise a null instance is returned
_statsCollector = StatsCollector.getInstance();
}
/////////////////////////////////////////////////////////////
// ManagementServer methods //
/////////////////////////////////////////////////////////////
public static VMInstanceVO findVMInstanceById(long vmId) {
return _ms.findVMInstanceById(vmId);
}
public static long getMemoryUsagebyHost(Long hostId) {
// TODO: This method is for the API only, but it has configuration values (ramSize for system vms)
// so if this Utils class can have some kind of config rather than a static initializer (maybe from
// management server instantiation?) then maybe the management server method can be moved entirely
// into this utils class.
return _ms.getMemoryUsagebyHost(hostId);
}
public static Long getPodIdForVlan(long vlanDbId) {
return _ms.getPodIdForVlan(vlanDbId);
}
public static List<UserVmVO> searchForUserVMs(Criteria c) {
return _ms.searchForUserVMs(c);
}
public static List<? extends StoragePoolVO> searchForStoragePools(Criteria c) {
return _ms.searchForStoragePools(c);
}
/////////////////////////////////////////////////////////////
// Manager methods //
/////////////////////////////////////////////////////////////
public static long findCorrectResourceLimit(ResourceType type, long accountId) {
AccountVO account = _accountDao.findById(accountId);
if (account == null) {
return -1;
}
return _accountMgr.findCorrectResourceLimit(account, type);
}
public static AsyncJobVO findInstancePendingAsyncJob(String instanceType, long instanceId) {
return _asyncMgr.findInstancePendingAsyncJob(instanceType, instanceId);
}
public static long getResourceCount(ResourceType type, long accountId) {
AccountVO account = _accountDao.findById(accountId);
if (account == null) {
return -1;
}
return _accountMgr.getResourceCount(account, type);
}
public static String getNetworkGroupsNamesForVm(long vmId) {
return _networkGroupMgr.getNetworkGroupsNamesForVm(vmId);
}
public static String getSnapshotIntervalTypes(long snapshotId){
String intervalTypes = "";
List<SnapshotPolicyVO> policies = _snapMgr.listPoliciesforSnapshot(snapshotId);
for (SnapshotPolicyVO policy : policies){
if(!intervalTypes.isEmpty()){
intervalTypes += ",";
}
if(policy.getId() == Snapshot.MANUAL_POLICY_ID){
intervalTypes+= "MANUAL";
}
else {
intervalTypes += DateUtil.getIntervalType(policy.getInterval()).toString();
}
}
return intervalTypes;
}
public static String getStoragePoolTags(long poolId) {
return _storageMgr.getStoragePoolTags(poolId);
}
public static boolean isLocalStorageActiveOnHost(HostVO host) {
return _storageMgr.isLocalStorageActiveOnHost(host);
}
/////////////////////////////////////////////////////////////
// Misc methods //
/////////////////////////////////////////////////////////////
public static HostStats getHostStatistics(long hostId) {
return _statsCollector.getHostStats(hostId);
}
public static StorageStats getStoragePoolStatistics(long id) {
return _statsCollector.getStoragePoolStats(id);
}
public static VmStats getVmStatistics(long hostId) {
return _statsCollector.getVmStats(hostId);
}
/////////////////////////////////////////////////////////////
// Dao methods //
/////////////////////////////////////////////////////////////
@ -79,10 +246,22 @@ public class ApiDBUtils {
return _accountDao.findById(accountId);
}
public static ClusterVO findClusterById(long clusterId) {
return _clusterDao.findById(clusterId);
}
public static DiskOfferingVO findDiskOfferingById(Long diskOfferingId) {
return _diskOfferingDao.findById(diskOfferingId);
}
public static DomainVO findDomainById(Long domainId) {
return _domainDao.findById(domainId);
}
public static GuestOS findGuestOSById(Long id) {
return _guestOSDao.findById(id);
}
public static HostVO findHostById(Long hostId) {
return _hostDao.findById(hostId);
}
@ -91,18 +270,63 @@ public class ApiDBUtils {
return _ipAddressDao.findById(address);
}
public static GuestOSCategoryVO getHostGuestOSCategory(long hostId) {
Long guestOSCategoryID = _agentMgr.getGuestOSCategoryId(hostId);
if (guestOSCategoryID != null) {
return _guestOSCategoryDao.findById(guestOSCategoryID);
} else {
return null;
}
}
public static HostPodVO findPodById(Long podId) {
return _podDao.findById(podId);
}
public static ServiceOffering findServiceOfferingById(Long serviceOfferingId) {
return _serviceOfferingDao.findById(serviceOfferingId);
}
public static Snapshot findSnapshotById(long snapshotId) {
SnapshotVO snapshot = _snapshotDao.findById(snapshotId);
if (snapshot != null && snapshot.getRemoved() == null && snapshot.getStatus() == Snapshot.Status.BackedUp) {
return snapshot;
}
else {
return null;
}
}
public static StoragePoolVO findStoragePoolById(Long storagePoolId) {
return _storagePoolDao.findById(storagePoolId);
}
public static VMTemplateVO findTemplateById(Long templateId) {
return _templateDao.findById(templateId);
}
public static VMTemplateHostVO findTemplateHostRef(long templateId, long zoneId) {
HostVO secondaryStorageHost = _storageMgr.getSecondaryStorageHost(zoneId);
if (secondaryStorageHost == null) {
return null;
} else {
return _templateHostDao.findByHostTemplate(secondaryStorageHost.getId(), templateId);
}
}
public static User findUserById(Long userId) {
return _userDao.findById(userId);
}
public static UserVm findUserVmById(Long vmId) {
return _userVmDao.findById(vmId);
}
public static VlanVO findVlanById(long vlanDbId) {
return _vlanDao.findById(vlanDbId);
}
public static VolumeVO findVolumeById(Long volumeId) {
return _volumeDao.findById(volumeId);
}
@ -110,4 +334,44 @@ public class ApiDBUtils {
public static DataCenterVO findZoneById(Long zoneId) {
return _zoneDao.findById(zoneId);
}
public static Long getAccountIdForVlan(long vlanDbId) {
List<AccountVlanMapVO> accountVlanMaps = _accountVlanMapDao.listAccountVlanMapsByVlan(vlanDbId);
if (accountVlanMaps.isEmpty()) {
return null;
} else {
return accountVlanMaps.get(0).getAccountId();
}
}
public static List<VMTemplateHostVO> listTemplateHostBy(long templateId, Long zoneId) {
if (zoneId != null) {
HostVO secondaryStorageHost = _storageMgr.getSecondaryStorageHost(zoneId);
if (secondaryStorageHost == null) {
return new ArrayList<VMTemplateHostVO>();
} else {
return _templateHostDao.listByHostTemplate(secondaryStorageHost.getId(), templateId);
}
} else {
return _templateHostDao.listByOnlyTemplateId(templateId);
}
}
public static List<UserStatisticsVO> listUserStatsBy(Long accountId) {
return _userStatsDao.listBy(accountId);
}
public static List<UserVmVO> listUserVMsByHostId(long hostId) {
return _userVmDao.listByHostId(hostId);
}
public static boolean volumeIsOnSharedStorage(long volumeId) throws InvalidParameterValueException {
// Check that the volume is valid
VolumeVO volume = _volumeDao.findById(volumeId);
if (volume == null) {
throw new InvalidParameterValueException("Please specify a valid volume ID.");
}
return _storageMgr.volumeOnSharedStoragePool(volume);
}
}

View File

@ -27,10 +27,6 @@ import java.util.Map;
import org.apache.log4j.Logger;
import com.cloud.async.AsyncJobResult;
import com.cloud.async.AsyncJobVO;
import com.cloud.serializer.SerializerHelper;
import com.cloud.server.ManagementServer;
import com.cloud.user.Account;
import com.cloud.utils.Pair;
@ -365,6 +361,7 @@ public abstract class BaseCmd {
}
}
@SuppressWarnings("rawtypes")
private void writeObjectArray(String responseType, StringBuffer sb, int propertyCount, String tagName, Object[] subObjects) {
if (RESPONSE_TYPE_JSON.equalsIgnoreCase(responseType)) {
String separator = ((propertyCount > 0) ? ", " : "");
@ -383,6 +380,7 @@ public abstract class BaseCmd {
}
}
@SuppressWarnings("rawtypes")
private void writeSubObject(StringBuffer sb, String tagName, List tagList, String responseType, int objectCount) {
if (RESPONSE_TYPE_JSON.equalsIgnoreCase(responseType)) {
sb.append(((objectCount == 0) ? "\"" + tagName + "\" : [ { " : ", { "));
@ -447,65 +445,6 @@ public abstract class BaseCmd {
return str.replace("\"", "\\\"");
}
protected long waitInstanceCreation(long jobId) {
ManagementServer mgr = getManagementServer();
long instanceId = 0;
AsyncJobVO job = null;
boolean interruped = false;
// as job may be executed in other management server, we need to do a database polling here
try {
boolean quit = false;
while(!quit) {
job = mgr.findAsyncJobById(jobId);
if(job == null) {
s_logger.error("Async command " + this.getClass().getName() + " waitInstanceCreation error: job-" + jobId + " no longer exists");
break;
}
switch(job.getStatus()) {
case AsyncJobResult.STATUS_IN_PROGRESS :
if(job.getProcessStatus() == BaseCmd.PROGRESS_INSTANCE_CREATED) {
Long id = (Long)SerializerHelper.fromSerializedString(job.getResult());
if(id != null) {
instanceId = id.longValue();
if(s_logger.isDebugEnabled())
s_logger.debug("Async command " + this.getClass().getName() + " succeeded in waiting for new instance to be created, instance Id: " + instanceId);
} else {
s_logger.warn("Async command " + this.getClass().getName() + " has new instance created, but value as null?");
}
quit = true;
}
break;
case AsyncJobResult.STATUS_SUCCEEDED :
instanceId = getInstanceIdFromJobSuccessResult(job.getResult());
quit = true;
break;
case AsyncJobResult.STATUS_FAILED :
s_logger.error("Async command " + this.getClass().getName() + " executing job-" + jobId + " failed, result: " + job.getResult());
quit = true;
break;
}
if(quit)
break;
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
interruped = true;
}
}
} finally {
if(interruped)
Thread.currentThread().interrupt();
}
return instanceId;
}
protected long getInstanceIdFromJobSuccessResult(String result) {
s_logger.debug("getInstanceIdFromJobSuccessResult not overridden in subclass " + this.getClass().getName());
return 0;
@ -516,62 +455,4 @@ public abstract class BaseCmd {
(accountType == Account.ACCOUNT_TYPE_DOMAIN_ADMIN) ||
(accountType == Account.ACCOUNT_TYPE_READ_ONLY_ADMIN));
}
private Account getAccount(Map<String, Object> params) throws ServerApiException {
// FIXME: This should go into the context!
Long domainId = (Long) params.get("domainid");
Account account = (Account)params.get("accountobj");
String accountName = (String) params.get("account");
Long accountId = null;
Account finalAccount = null;
ManagementServer managementServer = getManagementServer();
if ((account == null) || isAdmin(account.getType())) {
if (domainId != null) {
if ((account != null) && !managementServer.isChildDomain(account.getDomainId(), domainId)) {
throw new ServerApiException(PARAM_ERROR, "Invalid domain id (" + domainId + ") ");
}
if (accountName != null) {
Account userAccount = managementServer.findActiveAccount(accountName, domainId);
if (userAccount == null) {
throw new ServerApiException(PARAM_ERROR, "Unable to find account " + accountName + " in domain " + domainId);
}
accountId = userAccount.getId();
}
} else {
accountId = ((account != null) ? account.getId() : null);
}
} else {
accountId = account.getId();
}
if (accountId != null) {
finalAccount = managementServer.findAccountById(accountId);
}
return finalAccount;
}
protected Long checkAccountPermissions(Map<String, Object> params,
long targetAccountId,
long targetDomainId,
String targetDesc,
long targetId)
throws ServerApiException
{
Long accountId = null;
Account account = getAccount(params);
if (account != null) {
if (!isAdmin(account.getType())) {
if (account.getId().longValue() != targetAccountId) {
throw new ServerApiException(BaseCmd.PARAM_ERROR, "Unable to find a " + targetDesc + " with id " + targetId + " for this account");
}
} else if (!getManagementServer().isChildDomain(account.getDomainId(), targetDomainId)) {
throw new ServerApiException(BaseCmd.PARAM_ERROR, "Unable to perform operation for " + targetDesc + " with id " + targetId + ", permission denied.");
}
accountId = account.getId();
}
return accountId;
}
}

View File

@ -22,6 +22,7 @@ import org.apache.log4j.Logger;
import com.cloud.api.BaseCmd;
import com.cloud.api.BaseCmd.Manager;
import com.cloud.api.ApiDBUtils;
import com.cloud.api.Implementation;
import com.cloud.api.Parameter;
import com.cloud.api.ServerApiException;
@ -97,8 +98,7 @@ public class CreateDiskOfferingCmd extends BaseCmd {
response.setDiskSize(responseObject.getDiskSize());
response.setDisplayText(responseObject.getDisplayText());
response.setDomainId(responseObject.getDomainId());
// FIXME: domain name in the response
// response.setDomain(responseObject.getDomain());
response.setDomain(ApiDBUtils.findDomainById(responseObject.getDomainId()).getName());
response.setName(responseObject.getName());
response.setTags(responseObject.getTags());
} else {

View File

@ -20,6 +20,7 @@ package com.cloud.api.commands;
import org.apache.log4j.Logger;
import com.cloud.api.ApiDBUtils;
import com.cloud.api.BaseCmd;
import com.cloud.api.Implementation;
import com.cloud.api.Parameter;
@ -76,8 +77,7 @@ public class CreateDomainCmd extends BaseCmd {
response.setDomainName(responseObject.getName());
response.setLevel(responseObject.getLevel());
response.setParentDomainId(responseObject.getParent());
// FIXME: domain name from id for parent domain
// response.setParentDomainName(responseObject.getParentDomainName());
response.setParentDomainName(ApiDBUtils.findDomainById(responseObject.getParent()).getName());
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create domain");
}

View File

@ -20,6 +20,7 @@ package com.cloud.api.commands;
import org.apache.log4j.Logger;
import com.cloud.api.ApiDBUtils;
import com.cloud.api.BaseCmd;
import com.cloud.api.BaseCmd.Manager;
import com.cloud.api.Implementation;
@ -27,6 +28,7 @@ import com.cloud.api.Parameter;
import com.cloud.api.response.FirewallRuleResponse;
import com.cloud.network.FirewallRuleVO;
import com.cloud.serializer.SerializerHelper;
import com.cloud.uservm.UserVm;
@Implementation(method="createPortForwardingRule", manager=Manager.NetworkManager)
public class CreateIPForwardingRuleCmd extends BaseCmd {
@ -97,9 +99,10 @@ public class CreateIPForwardingRuleCmd extends BaseCmd {
fwResponse.setPrivatePort(fwRule.getPrivatePort());
fwResponse.setProtocol(fwRule.getProtocol());
fwResponse.setPublicPort(fwRule.getPublicPort());
// TODO: implement
// fwResponse.setVirtualMachineId(fwRule.getVirtualMachineId());
// fwResponse.setVirtualMachineName(fwRule.getVirtualMachineName());
UserVm vm = ApiDBUtils.findUserVmById(virtualMachineId);
fwResponse.setVirtualMachineId(vm.getId());
fwResponse.setVirtualMachineName(vm.getName());
return SerializerHelper.toSerializedString(fwResponse);
}

View File

@ -22,6 +22,7 @@ import org.apache.log4j.Logger;
import com.cloud.api.BaseCmd;
import com.cloud.api.BaseCmd.Manager;
import com.cloud.api.ApiDBUtils;
import com.cloud.api.Implementation;
import com.cloud.api.Parameter;
import com.cloud.api.response.LoadBalancerResponse;
@ -108,8 +109,7 @@ public class CreateLoadBalancerRuleCmd extends BaseCmd {
response.setPublicPort(responseObj.getPublicPort());
response.setAccountName(responseObj.getAccountName());
response.setDomainId(responseObj.getDomainId());
// TODO: implement
// response.setDomainName(responseObj.getDomainName());
response.setDomainName(ApiDBUtils.findDomainById(responseObj.getDomainId()).getName());
return SerializerHelper.toSerializedString(response);
}

View File

@ -22,6 +22,7 @@ import org.apache.log4j.Logger;
import com.cloud.api.BaseCmd;
import com.cloud.api.BaseCmd.Manager;
import com.cloud.api.ApiDBUtils;
import com.cloud.api.Implementation;
import com.cloud.api.Parameter;
import com.cloud.api.response.NetworkGroupResponse;
@ -88,8 +89,7 @@ public class CreateNetworkGroupCmd extends BaseCmd {
response.setAccountName(group.getAccountName());
response.setDescription(group.getDescription());
response.setDomainId(group.getDomainId());
// TODO: implement
// response.setDomainName(group.getDomainName());
response.setDomainName(ApiDBUtils.findDomainById(group.getDomainId()).getName());
response.setId(group.getId());
response.setName(group.getName());

View File

@ -22,6 +22,7 @@ import org.apache.log4j.Logger;
import com.cloud.api.BaseCmd;
import com.cloud.api.BaseCmd.Manager;
import com.cloud.api.ApiDBUtils;
import com.cloud.api.Implementation;
import com.cloud.api.Parameter;
import com.cloud.api.response.PodResponse;
@ -101,10 +102,9 @@ public class CreatePodCmd extends BaseCmd {
PodResponse response = new PodResponse();
response.setId(pod.getId());
response.setCidr(pod.getCidrAddress() + "/" + pod.getCidrSize());
// TODO: implement
// response.setEndIp(pod.getEndIp());
// response.setStartIp(pod.getStartIp());
// response.setZoneName(pod.getZoneName());
response.setEndIp(endIp == null ? "" : endIp);
response.setStartIp(startIp);
response.setZoneName(ApiDBUtils.findZoneById(pod.getDataCenterId()).getName());
response.setGateway(pod.getGateway());
response.setName(pod.getName());
response.setZoneId(pod.getDataCenterId());

View File

@ -20,6 +20,7 @@ package com.cloud.api.commands;
import org.apache.log4j.Logger;
import com.cloud.api.ApiDBUtils;
import com.cloud.api.BaseCmd;
import com.cloud.api.Implementation;
import com.cloud.api.Parameter;
@ -90,8 +91,7 @@ public class CreatePortForwardingServiceCmd extends BaseCmd {
response.setDescription(group.getDescription());
response.setAccountName(group.getAccountName());
response.setDomainId(group.getDomainId());
// TODO: implement
//response.setDomainName(group.getDomainName());
response.setDomainName(ApiDBUtils.findDomainById(group.getDomainId()).getName());
return SerializerHelper.toSerializedString(response);
}

View File

@ -22,6 +22,7 @@ import java.util.Map;
import org.apache.log4j.Logger;
import com.cloud.api.ApiDBUtils;
import com.cloud.api.BaseCmd;
import com.cloud.api.BaseCmd.Manager;
import com.cloud.api.Implementation;
@ -29,6 +30,7 @@ import com.cloud.api.Parameter;
import com.cloud.api.response.StoragePoolResponse;
import com.cloud.serializer.SerializerHelper;
import com.cloud.storage.StoragePoolVO;
import com.cloud.storage.StorageStats;
@SuppressWarnings("rawtypes")
@Implementation(method="createPool", manager=Manager.StorageManager)
@ -109,12 +111,8 @@ public class CreateStoragePoolCmd extends BaseCmd {
StoragePoolResponse response = new StoragePoolResponse();
response.setClusterId(pool.getClusterId());
// TODO: Implement
//response.setClusterName(pool.getClusterName());
//response.setDiskSizeAllocated(pool.getDiskSizeAllocated());
//response.setDiskSizeTotal(pool.getDiskSizeTotal());
//response.setPodName(pool.getPodName());
//response.setTags(pool.getTags());
response.setClusterName(ApiDBUtils.findClusterById(pool.getClusterId()).getName());
response.setPodName(ApiDBUtils.findPodById(pool.getPodId()).getName());
response.setCreated(pool.getCreated());
response.setId(pool.getId());
response.setIpAddress(pool.getHostAddress());
@ -122,6 +120,15 @@ public class CreateStoragePoolCmd extends BaseCmd {
response.setPath(pool.getPath());
response.setPodId(pool.getPodId());
response.setType(pool.getPoolType().toString());
response.setTags(ApiDBUtils.getStoragePoolTags(pool.getId()));
StorageStats stats = ApiDBUtils.getStoragePoolStatistics(pool.getId());
long used = pool.getCapacityBytes() - pool.getAvailableBytes();
if (stats != null) {
used = stats.getByteUsed();
}
response.setDiskSizeTotal(pool.getCapacityBytes());
response.setDiskSizeAllocated(used);
return SerializerHelper.toSerializedString(response);
}

View File

@ -22,11 +22,19 @@ import org.apache.log4j.Logger;
import com.cloud.api.BaseAsyncCreateCmd;
import com.cloud.api.BaseCmd.Manager;
import com.cloud.api.ApiDBUtils;
import com.cloud.api.Implementation;
import com.cloud.api.Parameter;
import com.cloud.api.response.TemplateResponse;
import com.cloud.dc.DataCenterVO;
import com.cloud.serializer.SerializerHelper;
import com.cloud.storage.GuestOS;
import com.cloud.storage.Snapshot;
import com.cloud.storage.VMTemplateHostVO;
import com.cloud.storage.VolumeVO;
import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
import com.cloud.storage.VMTemplateVO;
import com.cloud.user.Account;
@Implementation(method="createPrivateTemplate", createMethod="createPrivateTemplateRecord", manager=Manager.UserVmManager)
public class CreateTemplateCmd extends BaseAsyncCreateCmd {
@ -138,28 +146,39 @@ public class CreateTemplateCmd extends BaseAsyncCreateCmd {
response.setPasswordEnabled(template.getEnablePassword());
response.setCrossZones(template.isCrossZones());
// TODO: implement
// VMTemplateHostVO templateHostRef = managerServer.findTemplateHostRef(template.getId(), volume.getDataCenterId());
// response.setCreated(templateHostRef.getCreated());
// response.setReady(templateHostRef != null && templateHostRef.getDownloadState() == Status.DOWNLOADED);
// if (os != null) {
// resultObject.setOsTypeId(os.getId());
// resultObject.setOsTypeName(os.getDisplayName());
// } else {
// resultObject.setOsTypeId(-1L);
// resultObject.setOsTypeName("");
// }
// Account owner = managerServer.findAccountById(template.getAccountId());
// if (owner != null) {
// resultObject.setAccount(owner.getAccountName());
// resultObject.setDomainId(owner.getDomainId());
// resultObject.setDomainName(managerServer.findDomainIdById(owner.getDomainId()).getName());
// }
// DataCenterVO zone = managerServer.findDataCenterById(dataCenterId);
// if (zone != null) {
// resultObject.setZoneId(zone.getId());
// resultObject.setZoneName(zone.getName());
// }
VolumeVO volume = null;
if (snapshotId != null) {
Snapshot snapshot = ApiDBUtils.findSnapshotById(snapshotId);
volume = ApiDBUtils.findVolumeById(snapshot.getVolumeId());
} else {
volume = ApiDBUtils.findVolumeById(volumeId);
}
VMTemplateHostVO templateHostRef = ApiDBUtils.findTemplateHostRef(template.getId(), volume.getDataCenterId());
response.setCreated(templateHostRef.getCreated());
response.setReady(templateHostRef != null && templateHostRef.getDownloadState() == Status.DOWNLOADED);
GuestOS os = ApiDBUtils.findGuestOSById(template.getGuestOSId());
if (os != null) {
response.setOsTypeId(os.getId());
response.setOsTypeName(os.getDisplayName());
} else {
response.setOsTypeId(-1L);
response.setOsTypeName("");
}
Account owner = ApiDBUtils.findAccountById(template.getAccountId());
if (owner != null) {
response.setAccount(owner.getAccountName());
response.setDomainId(owner.getDomainId());
response.setDomainName(ApiDBUtils.findDomainById(owner.getDomainId()).getName());
}
DataCenterVO zone = ApiDBUtils.findZoneById(volume.getDataCenterId());
if (zone != null) {
response.setZoneId(zone.getId());
response.setZoneName(zone.getName());
}
return SerializerHelper.toSerializedString(response);
}

View File

@ -20,6 +20,7 @@ package com.cloud.api.commands;
import org.apache.log4j.Logger;
import com.cloud.api.ApiDBUtils;
import com.cloud.api.BaseCmd;
import com.cloud.api.Implementation;
import com.cloud.api.Parameter;
@ -125,8 +126,7 @@ public class CreateUserCmd extends BaseCmd {
response.setAccountType(user.getType());
response.setCreated(user.getCreated());
response.setDomainId(user.getDomainId());
// TODO: implement
// response.setDomainName(user.getDomainName());
response.setDomainName(ApiDBUtils.findDomainById(user.getDomainId()).getName());
response.setEmail(user.getEmail());
response.setFirstname(user.getFirstname());
response.setId(user.getId());

View File

@ -20,6 +20,7 @@ package com.cloud.api.commands;
import org.apache.log4j.Logger;
import com.cloud.api.ApiDBUtils;
import com.cloud.api.BaseCmd;
import com.cloud.api.BaseCmd.Manager;
import com.cloud.api.Implementation;
@ -127,6 +128,11 @@ public class CreateVlanIpRangeCmd extends BaseCmd {
public String getResponse() {
VlanVO vlan = (VlanVO)getResponseObject();
String domainNameResponse = null;
if ((accountName != null) && (domainId != null)) {
domainNameResponse = ApiDBUtils.findDomainById(domainId).getName();
}
VlanIpRangeResponse response = new VlanIpRangeResponse();
response.setAccountName(accountName);
response.setDescription(vlan.getIpRange());
@ -140,9 +146,10 @@ public class CreateVlanIpRangeCmd extends BaseCmd {
response.setStartIp(startIp);
response.setVlan(vlan.getVlanId());
response.setZoneId(vlan.getDataCenterId());
// TODO: implement
// response.setDomainName(vlan.getDomainName());
// response.setPodName(podName);
response.setDomainName(domainNameResponse);
if (podId != null) {
response.setPodName(ApiDBUtils.findPodById(podId).getName());
}
return SerializerHelper.toSerializedString(response);
}

View File

@ -22,10 +22,12 @@ import org.apache.log4j.Logger;
import com.cloud.api.BaseAsyncCreateCmd;
import com.cloud.api.BaseCmd.Manager;
import com.cloud.api.ApiDBUtils;
import com.cloud.api.Implementation;
import com.cloud.api.Parameter;
import com.cloud.api.response.VolumeResponse;
import com.cloud.serializer.SerializerHelper;
import com.cloud.storage.DiskOfferingVO;
import com.cloud.storage.VolumeVO;
@Implementation(createMethod="createVolumeDB", method="createVolume", manager=Manager.StorageManager)
@ -116,20 +118,22 @@ public class CreateVolumeCmd extends BaseAsyncCreateCmd {
response.setSize(volume.getSize());
response.setCreated(volume.getCreated());
response.setState(volume.getStatus().toString());
response.setAccountName(ggetManagementServer().findAccountById(volume.getAccountId()).getAccountName());
response.setAccountName(ApiDBUtils.findAccountById(volume.getAccountId()).getAccountName());
response.setDomainId(volume.getDomainId());
response.setDiskOfferingId(volume.getDiskOfferingId());
if (volume.getDiskOfferingId() != null) {
response.setDiskOfferingName(getManagementServer().findDiskOfferingById(volume.getDiskOfferingId()).getName());
response.setDiskOfferingDisplayText(getManagementServer().findDiskOfferingById(volume.getDiskOfferingId()).getDisplayText());
DiskOfferingVO diskOffering = ApiDBUtils.findDiskOfferingById(volume.getDiskOfferingId());
response.setDiskOfferingName(diskOffering.getName());
response.setDiskOfferingDisplayText(diskOffering.getDisplayText());
}
response.setDomain(getManagementServer().findDomainIdById(volume.getDomainId()).getName());
response.setDomainName(ApiDBUtils.findDomainById(volume.getDomainId()).getName());
response.setStorageType("shared"); // NOTE: You can never create a local disk volume but if that changes, we need to change this
if (volume.getPoolId() != null)
response.setStorage(getManagementServer().findPoolById(volume.getPoolId()).getName());
if (volume.getPoolId() != null) {
response.setStoragePoolName(ApiDBUtils.findStoragePoolById(volume.getPoolId()).getName());
}
response.setZoneId(volume.getDataCenterId());
response.setZoneName(getManagementServer().getDataCenterBy(volume.getDataCenterId()).getName());
response.setZoneName(ApiDBUtils.findZoneById(volume.getDataCenterId()).getName());
return SerializerHelper.toSerializedString(response);
}

View File

@ -15,19 +15,14 @@
* 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.BaseCmd;
import com.cloud.api.BaseCmd.Manager;
import com.cloud.api.Implementation;
import com.cloud.api.Parameter;
import com.cloud.utils.Pair;
@Implementation(method="disableAccount", manager=Manager.ManagementServer)
public class DisableAccountCmd extends BaseCmd {
@ -44,7 +39,6 @@ public class DisableAccountCmd extends BaseCmd {
@Parameter(name="domainid", type=CommandType.LONG)
private Long domainId;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
@ -57,7 +51,6 @@ public class DisableAccountCmd extends BaseCmd {
return domainId;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@ -66,10 +59,11 @@ public class DisableAccountCmd extends BaseCmd {
public String getName() {
return s_name;
}
@Override
public List<Pair<Enum, Boolean>> getProperties() {
return s_properties;
public String getResponse() {
// TODO: implement
return null;
}
// @Override

View File

@ -24,6 +24,7 @@ import java.util.List;
import org.apache.log4j.Logger;
import com.cloud.api.ApiDBUtils;
import com.cloud.api.BaseCmd;
import com.cloud.api.BaseListCmd;
import com.cloud.api.Implementation;
@ -125,10 +126,10 @@ public class ListAccountsCmd extends BaseListCmd {
acctResponse.setName(account.getAccountName());
acctResponse.setAccountType(account.getType());
acctResponse.setDomainId(account.getDomainId());
acctResponse.setDomainName(getManagementServer().findDomainIdById(account.getDomainId()).getName());
acctResponse.setDomainName(ApiDBUtils.findDomainById(account.getDomainId()).getName());
//get network stat
List<UserStatisticsVO> stats = getManagementServer().listUserStatsBy(account.getId());
List<UserStatisticsVO> stats = ApiDBUtils.listUserStatsBy(account.getId());
if (stats == null) {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Internal error searching for user stats");
}
@ -146,41 +147,41 @@ public class ListAccountsCmd extends BaseListCmd {
// Get resource limits and counts
long vmLimit = getManagementServer().findCorrectResourceLimit(ResourceType.user_vm, account.getId());
long vmLimit = ApiDBUtils.findCorrectResourceLimit(ResourceType.user_vm, account.getId());
String vmLimitDisplay = (accountIsAdmin || vmLimit == -1) ? "Unlimited" : String.valueOf(vmLimit);
long vmTotal = getManagementServer().getResourceCount(ResourceType.user_vm, account.getId());
long vmTotal = ApiDBUtils.getResourceCount(ResourceType.user_vm, account.getId());
String vmAvail = (accountIsAdmin || vmLimit == -1) ? "Unlimited" : String.valueOf(vmLimit - vmTotal);
acctResponse.setVmLimit(vmLimitDisplay);
acctResponse.setVmTotal(vmTotal);
acctResponse.setVmAvailable(vmAvail);
long ipLimit = getManagementServer().findCorrectResourceLimit(ResourceType.public_ip, account.getId());
long ipLimit = ApiDBUtils.findCorrectResourceLimit(ResourceType.public_ip, account.getId());
String ipLimitDisplay = (accountIsAdmin || ipLimit == -1) ? "Unlimited" : String.valueOf(ipLimit);
long ipTotal = getManagementServer().getResourceCount(ResourceType.public_ip, account.getId());
long ipTotal = ApiDBUtils.getResourceCount(ResourceType.public_ip, account.getId());
String ipAvail = (accountIsAdmin || ipLimit == -1) ? "Unlimited" : String.valueOf(ipLimit - ipTotal);
acctResponse.setIpLimit(ipLimitDisplay);
acctResponse.setIpTotal(ipTotal);
acctResponse.setIpAvailable(ipAvail);
long volumeLimit = getManagementServer().findCorrectResourceLimit(ResourceType.volume, account.getId());
long volumeLimit = ApiDBUtils.findCorrectResourceLimit(ResourceType.volume, account.getId());
String volumeLimitDisplay = (accountIsAdmin || volumeLimit == -1) ? "Unlimited" : String.valueOf(volumeLimit);
long volumeTotal = getManagementServer().getResourceCount(ResourceType.volume, account.getId());
long volumeTotal = ApiDBUtils.getResourceCount(ResourceType.volume, account.getId());
String volumeAvail = (accountIsAdmin || volumeLimit == -1) ? "Unlimited" : String.valueOf(volumeLimit - volumeTotal);
acctResponse.setVolumeLimit(volumeLimitDisplay);
acctResponse.setVolumeTotal(volumeTotal);
acctResponse.setVolumeAvailable(volumeAvail);
long snapshotLimit = getManagementServer().findCorrectResourceLimit(ResourceType.snapshot, account.getId());
long snapshotLimit = ApiDBUtils.findCorrectResourceLimit(ResourceType.snapshot, account.getId());
String snapshotLimitDisplay = (accountIsAdmin || snapshotLimit == -1) ? "Unlimited" : String.valueOf(snapshotLimit);
long snapshotTotal = getManagementServer().getResourceCount(ResourceType.snapshot, account.getId());
long snapshotTotal = ApiDBUtils.getResourceCount(ResourceType.snapshot, account.getId());
String snapshotAvail = (accountIsAdmin || snapshotLimit == -1) ? "Unlimited" : String.valueOf(snapshotLimit - snapshotTotal);
acctResponse.setSnapshotLimit(snapshotLimitDisplay);
acctResponse.setSnapshotTotal(snapshotTotal);
acctResponse.setSnapshotAvailable(snapshotAvail);
long templateLimit = getManagementServer().findCorrectResourceLimit(ResourceType.template, account.getId());
long templateLimit = ApiDBUtils.findCorrectResourceLimit(ResourceType.template, account.getId());
String templateLimitDisplay = (accountIsAdmin || templateLimit == -1) ? "Unlimited" : String.valueOf(templateLimit);
long templateTotal = getManagementServer().getResourceCount(ResourceType.template, account.getId());
long templateTotal = ApiDBUtils.getResourceCount(ResourceType.template, account.getId());
String templateAvail = (accountIsAdmin || templateLimit == -1) ? "Unlimited" : String.valueOf(templateLimit - templateTotal);
acctResponse.setTemplateLimit(templateLimitDisplay);
acctResponse.setTemplateTotal(templateTotal);
@ -195,7 +196,7 @@ public class ListAccountsCmd extends BaseListCmd {
Criteria c1 = new Criteria();
c1.addCriteria(Criteria.ACCOUNTID, accountIds);
List<? extends UserVm> virtualMachines = getManagementServer().searchForUserVMs(c1);
List<? extends UserVm> virtualMachines = ApiDBUtils.searchForUserVMs(c1);
//get Running/Stopped VMs
for (Iterator<? extends UserVm> iter = virtualMachines.iterator(); iter.hasNext();) {

View File

@ -29,6 +29,7 @@ import java.util.StringTokenizer;
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;
@ -116,9 +117,8 @@ public class ListCapacityCmd extends BaseListCmd {
capacityResponse.setCapacityUsed(summedCapacity.getUsedCapacity());
capacityResponse.setPodId(summedCapacity.getPodId());
capacityResponse.setZoneId(summedCapacity.getDataCenterId());
// TODO: implement
// capacityResponse.setPodName(podName);
// capacityResponse.setZoneName(zoneName);
capacityResponse.setPodName(ApiDBUtils.findPodById(summedCapacity.getPodId()).getName());
capacityResponse.setZoneName(ApiDBUtils.findZoneById(summedCapacity.getDataCenterId()).getName());
if (summedCapacity.getTotalCapacity() != 0) {
capacityResponse.setPercentUsed(s_percentFormat.format(summedCapacity.getUsedCapacity() / summedCapacity.getTotalCapacity()));
} else {
@ -136,7 +136,7 @@ public class ListCapacityCmd extends BaseListCmd {
Set<Long> poolIdsToIgnore = new HashSet<Long>();
Criteria c = new Criteria();
// TODO: implement
List<? extends StoragePoolVO> allStoragePools = getManagementServer().searchForStoragePools(c);
List<? extends StoragePoolVO> allStoragePools = ApiDBUtils.searchForStoragePools(c);
for (StoragePoolVO pool : allStoragePools) {
StoragePoolType poolType = pool.getPoolType();
if (!(poolType.equals(StoragePoolType.NetworkFilesystem) || poolType.equals(StoragePoolType.IscsiLUN))) {

View File

@ -27,6 +27,7 @@ import java.util.Set;
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;
@ -141,21 +142,21 @@ public class ListHostsCmd extends BaseListCmd {
hostResponse.setVersion(host.getVersion());
// TODO: implement
GuestOSCategoryVO guestOSCategory = getManagementServer().getHostGuestOSCategory(host.getId());
GuestOSCategoryVO guestOSCategory = ApiDBUtils.getHostGuestOSCategory(host.getId());
if (guestOSCategory != null) {
hostResponse.setOsCategoryId(guestOSCategory.getId());
hostResponse.setOsCategoryName(guestOSCategory.getName());
}
hostResponse.setZoneName(getManagementServer().getDataCenterBy(host.getDataCenterId()).getName());
hostResponse.setPodName(getManagementServer().findHostPodById(host.getPodId()).getName());
hostResponse.setZoneName(ApiDBUtils.findZoneById(host.getDataCenterId()).getName());
hostResponse.setPodName(ApiDBUtils.findPodById(host.getPodId()).getName());
// calculate cpu allocated by vm
int cpu = 0;
String cpuAlloc = null;
DecimalFormat decimalFormat = new DecimalFormat("#.##");
List<UserVmVO> instances = getManagementServer().listUserVMsByHostId(host.getId());
List<UserVmVO> instances = ApiDBUtils.listUserVMsByHostId(host.getId());
for (UserVmVO vm : instances) {
ServiceOffering so = getManagementServer().findServiceOfferingById(vm.getServiceOfferingId());
ServiceOffering so = ApiDBUtils.findServiceOfferingById(vm.getServiceOfferingId());
cpu += so.getCpu() * so.getSpeed();
}
cpuAlloc = decimalFormat.format(((float) cpu / (float) (host.getCpus() * host.getSpeed())) * 100f) + "%";
@ -163,7 +164,7 @@ public class ListHostsCmd extends BaseListCmd {
// calculate cpu utilized
String cpuUsed = null;
HostStats hostStats = getManagementServer().getHostStatistics(host.getId());
HostStats hostStats = ApiDBUtils.getHostStatistics(host.getId());
if (hostStats != null) {
float cpuUtil = (float) hostStats.getCpuUtilization();
cpuUsed = decimalFormat.format(cpuUtil) + "%";
@ -177,7 +178,7 @@ public class ListHostsCmd extends BaseListCmd {
hostResponse.setMemoryTotal(host.getTotalMemory());
// calculate memory allocated by systemVM and userVm
long mem = getManagementServer().getMemoryUsagebyHost(host.getId());
long mem = ApiDBUtils.getMemoryUsagebyHost(host.getId());
hostResponse.setMemoryAllocated(mem);
hostResponse.setMemoryUsed(mem);
} else if (host.getType().toString().equals("Storage")) {
@ -186,11 +187,11 @@ public class ListHostsCmd extends BaseListCmd {
}
if (host.getClusterId() != null) {
ClusterVO cluster = getManagementServer().findClusterById(host.getClusterId());
ClusterVO cluster = ApiDBUtils.findClusterById(host.getClusterId());
hostResponse.setClusterName(cluster.getName());
}
hostResponse.setLocalStorageActive(getManagementServer().isLocalStorageActiveOnHost(host));
hostResponse.setLocalStorageActive(ApiDBUtils.isLocalStorageActiveOnHost(host));
Set<Event> possibleEvents = host.getStatus().getPossibleEvents();
if ((possibleEvents != null) && !possibleEvents.isEmpty()) {

View File

@ -25,6 +25,7 @@ import java.util.Map;
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;
@ -163,14 +164,14 @@ public class ListIsosCmd extends BaseListCmd {
Map<Long, List<VMTemplateHostVO>> isoHostsMap = new HashMap<Long, List<VMTemplateHostVO>>();
for (VMTemplateVO iso : isos) {
// TODO: implement
List<VMTemplateHostVO> isoHosts = getManagementServer().listTemplateHostBy(iso.getId(), zoneId);
List<VMTemplateHostVO> isoHosts = ApiDBUtils.listTemplateHostBy(iso.getId(), zoneId);
if (iso.getName().equals("xs-tools.iso")) {
List<Long> xstoolsZones = new ArrayList<Long>();
// the xs-tools.iso is a special case since it will be available on every computing host in the zone and we want to return it once per zone
List<VMTemplateHostVO> xstoolsHosts = new ArrayList<VMTemplateHostVO>();
for (VMTemplateHostVO isoHost : isoHosts) {
// TODO: implement
HostVO host = getManagementServer().getHostBy(isoHost.getHostId());
HostVO host = ApiDBUtils.findHostById(isoHost.getHostId());
if (!xstoolsZones.contains(Long.valueOf(host.getDataCenterId()))) {
xstoolsZones.add(Long.valueOf(host.getDataCenterId()));
xstoolsHosts.add(isoHost);
@ -202,7 +203,7 @@ public class ListIsosCmd extends BaseListCmd {
isoResponse.setCrossZones(iso.isCrossZones());
// TODO: implement
GuestOS os = getManagementServer().findGuestOSById(iso.getGuestOSId());
GuestOS os = ApiDBUtils.findGuestOSById(iso.getGuestOSId());
if (os != null) {
isoResponse.setOsTypeId(os.getId());
isoResponse.setOsTypeName(os.getDisplayName());
@ -212,18 +213,18 @@ public class ListIsosCmd extends BaseListCmd {
}
// add account ID and name
Account owner = getManagementServer().findAccountById(iso.getAccountId());
Account owner = ApiDBUtils.findAccountById(iso.getAccountId());
if (owner != null) {
isoResponse.setAccount(owner.getAccountName());
isoResponse.setDomainId(owner.getDomainId());
// TODO: implement
isoResponse.setDomainName(getManagementServer().findDomainIdById(owner.getDomainId()).getName());
isoResponse.setDomainName(ApiDBUtils.findDomainById(owner.getDomainId()).getName());
}
// Add the zone ID
// TODO: implement
HostVO host = getManagementServer().getHostBy(isoHost.getHostId());
DataCenterVO datacenter = getManagementServer().getDataCenterBy(host.getDataCenterId());
HostVO host = ApiDBUtils.findHostById(isoHost.getHostId());
DataCenterVO datacenter = ApiDBUtils.findZoneById(host.getDataCenterId());
isoResponse.setZoneId(host.getDataCenterId());
isoResponse.setZoneName(datacenter.getName());
@ -254,7 +255,7 @@ public class ListIsosCmd extends BaseListCmd {
isoResponse.setSize(isoSize);
}
AsyncJobVO asyncJob = getManagementServer().findInstancePendingAsyncJob("vm_template", iso.getId());
AsyncJobVO asyncJob = ApiDBUtils.findInstancePendingAsyncJob("vm_template", iso.getId());
if(asyncJob != null) {
isoResponse.setJobId(asyncJob.getId());
isoResponse.setJobStatus(asyncJob.getStatus());

View File

@ -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;
@ -83,11 +84,11 @@ public class ListLoadBalancerRuleInstancesCmd extends BaseListCmd {
userVmResponse.setPrivateIp(instance.getPrivateIpAddress());
// TODO: implement
Account accountTemp = getManagementServer().findAccountById(instance.getAccountId());
Account accountTemp = ApiDBUtils.findAccountById(instance.getAccountId());
if (accountTemp != null) {
userVmResponse.setAccountName(accountTemp.getAccountName());
userVmResponse.setDomainId(accountTemp.getDomainId());
userVmResponse.setDomainName(getManagementServer().findDomainIdById(accountTemp.getDomainId()).getName());
userVmResponse.setDomainName(ApiDBUtils.findDomainById(accountTemp.getDomainId()).getName());
}
response.add(userVmResponse);

View File

@ -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;
@ -113,11 +114,11 @@ public class ListLoadBalancerRulesCmd extends BaseListCmd {
lbResponse.setAlgorithm(loadBalancer.getAlgorithm());
// TODO: implement
Account accountTemp = getManagementServer().findAccountById(loadBalancer.getAccountId());
Account accountTemp = ApiDBUtils.findAccountById(loadBalancer.getAccountId());
if (accountTemp != null) {
lbResponse.setAccountName(accountTemp.getAccountName());
lbResponse.setDomainId(accountTemp.getDomainId());
lbResponse.setDomainName(getManagementServer().findDomainIdById(accountTemp.getDomainId()).getName());
lbResponse.setDomainName(ApiDBUtils.findDomainById(accountTemp.getDomainId()).getName());
}
response.add(lbResponse);

View File

@ -6,6 +6,7 @@ import java.util.List;
import org.apache.log4j.Logger;
import com.cloud.api.BaseCmd.Manager;
import com.cloud.api.ApiDBUtils;
import com.cloud.api.BaseListCmd;
import com.cloud.api.Implementation;
import com.cloud.api.Parameter;
@ -81,7 +82,7 @@ public class ListNetworkGroupsCmd extends BaseListCmd {
netGrpResponse.setDescription(networkGroup.getDescription());
netGrpResponse.setAccountName(networkGroup.getAccountName());
netGrpResponse.setDomainId(networkGroup.getDomainId());
netGrpResponse.setDomainName(getManagementServer().findDomainIdById(networkGroup.getDomainId()).getName());
netGrpResponse.setDomainName(ApiDBUtils.findDomainById(networkGroup.getDomainId()).getName());
List<IngressRuleResultObject> ingressRules = networkGroup.getIngressRules();
if ((ingressRules != null) && !ingressRules.isEmpty()) {

View File

@ -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;
@ -96,7 +97,7 @@ public class ListPortForwardingServiceRulesCmd extends BaseListCmd {
ruleResponse.setPrivatePort(rule.getPrivatePort());
ruleResponse.setProtocol(rule.getProtocol());
AsyncJobVO asyncJob = getManagementServer().findInstancePendingAsyncJob("network_rule_config", rule.getId());
AsyncJobVO asyncJob = ApiDBUtils.findInstancePendingAsyncJob("network_rule_config", rule.getId());
if(asyncJob != null) {
ruleResponse.setJobId(asyncJob.getId());
ruleResponse.setJobStatus(asyncJob.getStatus());

View File

@ -24,6 +24,7 @@ import java.util.Map;
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;
@ -98,11 +99,11 @@ public class ListPortForwardingServicesByVmCmd extends BaseListCmd {
pfsData.setDescription(group.getDescription());
pfsData.setIpAddress(addr);
Account accountTemp = getManagementServer().findAccountById(group.getAccountId());
Account accountTemp = ApiDBUtils.findAccountById(group.getAccountId());
if (accountTemp != null) {
pfsData.setAccountName(accountTemp.getAccountName());
pfsData.setDomainId(accountTemp.getDomainId());
pfsData.setDomainName(getManagementServer().findDomainIdById(accountTemp.getDomainId()).getName());
pfsData.setDomainName(ApiDBUtils.findDomainById(accountTemp.getDomainId()).getName());
}
response.add(pfsData);

View File

@ -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;
@ -94,11 +95,11 @@ public class ListPortForwardingServicesCmd extends BaseListCmd {
pfsData.setName(group.getName());
pfsData.setDescription(group.getDescription());
Account accountTemp = getManagementServer().findAccountById(group.getAccountId());
Account accountTemp = ApiDBUtils.findAccountById(group.getAccountId());
if (accountTemp != null) {
pfsData.setAccountName(accountTemp.getAccountName());
pfsData.setDomainId(accountTemp.getDomainId());
pfsData.setDomainName(getManagementServer().findDomainIdById(accountTemp.getDomainId()).getName());
pfsData.setDomainName(ApiDBUtils.findDomainById(accountTemp.getDomainId()).getName());
}
response.add(pfsData);

View File

@ -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;
@ -112,7 +113,7 @@ public class ListPublicIpAddressesCmd extends BaseListCmd {
List<IPAddressResponse> response = new ArrayList<IPAddressResponse>();
for (IPAddressVO ipAddress : ipAddresses) {
VlanVO vlan = getManagementServer().findVlanById(ipAddress.getVlanDbId());
VlanVO vlan = ApiDBUtils.findVlanById(ipAddress.getVlanDbId());
boolean forVirtualNetworks = vlan.getVlanType().equals(VlanType.VirtualNetwork);
IPAddressResponse ipResponse = new IPAddressResponse();
@ -121,15 +122,15 @@ public class ListPublicIpAddressesCmd extends BaseListCmd {
ipResponse.setAllocated(ipAddress.getAllocated());
}
ipResponse.setZoneId(ipAddress.getDataCenterId());
ipResponse.setZoneName(getManagementServer().findDataCenterById(ipAddress.getDataCenterId()).getName());
ipResponse.setZoneName(ApiDBUtils.findZoneById(ipAddress.getDataCenterId()).getName());
ipResponse.setSourceNat(ipAddress.isSourceNat());
//get account information
Account accountTemp = getManagementServer().findAccountById(ipAddress.getAccountId());
Account accountTemp = ApiDBUtils.findAccountById(ipAddress.getAccountId());
if (accountTemp !=null){
ipResponse.setAccountName(accountTemp.getAccountName());
ipResponse.setDomainId(accountTemp.getDomainId());
ipResponse.setDomainName(getManagementServer().findDomainIdById(accountTemp.getDomainId()).getName());
ipResponse.setDomainName(ApiDBUtils.findDomainById(accountTemp.getDomainId()).getName());
}
ipResponse.setForVirtualNetwork(forVirtualNetworks);
@ -138,7 +139,7 @@ public class ListPublicIpAddressesCmd extends BaseListCmd {
Account account = (Account)UserContext.current().getAccountObject();
if ((account == null) || isAdmin(account.getType())) {
ipResponse.setVlanId(ipAddress.getVlanDbId());
ipResponse.setVlanName(getManagementServer().findVlanById(ipAddress.getVlanDbId()).getVlanId());
ipResponse.setVlanName(ApiDBUtils.findVlanById(ipAddress.getVlanDbId()).getVlanId());
}
response.add(ipResponse);

View File

@ -24,6 +24,7 @@ import java.util.List;
import org.apache.log4j.Logger;
import com.cloud.api.BaseCmd.Manager;
import com.cloud.api.ApiDBUtils;
import com.cloud.api.BaseListCmd;
import com.cloud.api.Implementation;
import com.cloud.api.Parameter;
@ -92,15 +93,15 @@ public class ListResourceLimitsCmd extends BaseListCmd {
ResourceLimitResponse resourceLimitResponse = new ResourceLimitResponse();
if (limit.getDomainId() != null) {
resourceLimitResponse.setDomainId(limit.getDomainId());
resourceLimitResponse.setDomainName(getManagementServer().findDomainIdById(limit.getDomainId()).getName());
resourceLimitResponse.setDomainName(ApiDBUtils.findDomainById(limit.getDomainId()).getName());
}
if (limit.getAccountId() != null) {
Account accountTemp = getManagementServer().findAccountById(limit.getAccountId());
Account accountTemp = ApiDBUtils.findAccountById(limit.getAccountId());
if (accountTemp != null) {
resourceLimitResponse.setAccountName(accountTemp.getAccountName());
resourceLimitResponse.setDomainId(accountTemp.getDomainId());
resourceLimitResponse.setDomainName(getManagementServer().findDomainIdById(accountTemp.getDomainId()).getName());
resourceLimitResponse.setDomainName(ApiDBUtils.findDomainById(accountTemp.getDomainId()).getName());
}
}

View File

@ -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;
@ -113,14 +114,14 @@ public class ListRoutersCmd extends BaseListCmd {
DomainRouterResponse routerResponse = new DomainRouterResponse();
routerResponse.setId(router.getId());
AsyncJobVO asyncJob = getManagementServer().findInstancePendingAsyncJob("domain_router", router.getId());
AsyncJobVO asyncJob = ApiDBUtils.findInstancePendingAsyncJob("domain_router", router.getId());
if (asyncJob != null) {
routerResponse.setJobId(asyncJob.getId());
routerResponse.setJobStatus(asyncJob.getStatus());
}
routerResponse.setZoneId(router.getDataCenterId());
routerResponse.setZoneName(getManagementServer().findDataCenterById(router.getDataCenterId()).getName());
routerResponse.setZoneName(ApiDBUtils.findZoneById(router.getDataCenterId()).getName());
routerResponse.setDns1(router.getDns1());
routerResponse.setDns2(router.getDns2());
routerResponse.setNetworkDomain(router.getDomain());
@ -130,7 +131,7 @@ public class ListRoutersCmd extends BaseListCmd {
if (router.getHostId() != null) {
routerResponse.setHostId(router.getHostId());
routerResponse.setHostName(getManagementServer().getHostBy(router.getHostId()).getName());
routerResponse.setHostName(ApiDBUtils.findHostById(router.getHostId()).getName());
}
routerResponse.setPrivateIp(router.getPrivateIpAddress());
@ -146,11 +147,11 @@ public class ListRoutersCmd extends BaseListCmd {
routerResponse.setCreated(router.getCreated());
routerResponse.setState(router.getState());
Account accountTemp = getManagementServer().findAccountById(router.getAccountId());
Account accountTemp = ApiDBUtils.findAccountById(router.getAccountId());
if (accountTemp != null) {
routerResponse.setAccountName(accountTemp.getAccountName());
routerResponse.setDomainId(accountTemp.getDomainId());
routerResponse.setDomain(getManagementServer().findDomainIdById(accountTemp.getDomainId()).getName());
routerResponse.setDomainName(ApiDBUtils.findDomainById(accountTemp.getDomainId()).getName());
}
response.add(routerResponse);

View File

@ -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;
@ -116,14 +117,14 @@ public class ListSnapshotsCmd extends BaseListCmd {
SnapshotResponse snapshotResponse = new SnapshotResponse();
snapshotResponse.setId(snapshot.getId());
Account acct = getManagementServer().findAccountById(Long.valueOf(snapshot.getAccountId()));
Account acct = ApiDBUtils.findAccountById(Long.valueOf(snapshot.getAccountId()));
if (acct != null) {
snapshotResponse.setAccountName(acct.getAccountName());
snapshotResponse.setDomainId(acct.getDomainId());
snapshotResponse.setDomain(getManagementServer().findDomainIdById(acct.getDomainId()).getName());
snapshotResponse.setDomainName(ApiDBUtils.findDomainById(acct.getDomainId()).getName());
}
VolumeVO volume = getManagementServer().findAnyVolumeById(snapshot.getVolumeId());
VolumeVO volume = ApiDBUtils.findVolumeById(snapshot.getVolumeId());
String snapshotTypeStr = SnapshotType.values()[snapshot.getSnapshotType()].name();
snapshotResponse.setSnapshotType(snapshotTypeStr);
snapshotResponse.setVolumeId(snapshot.getVolumeId());
@ -132,12 +133,12 @@ public class ListSnapshotsCmd extends BaseListCmd {
snapshotResponse.setCreated(snapshot.getCreated());
snapshotResponse.setName(snapshot.getName());
AsyncJobVO asyncJob = getManagementServer().findInstancePendingAsyncJob("snapshot", snapshot.getId());
AsyncJobVO asyncJob = ApiDBUtils.findInstancePendingAsyncJob("snapshot", snapshot.getId());
if (asyncJob != null) {
snapshotResponse.setJobId(asyncJob.getId());
snapshotResponse.setJobStatus(asyncJob.getStatus());
}
snapshotResponse.setIntervalType(getManagementServer().getSnapshotIntervalTypes(snapshot.getId()));
snapshotResponse.setIntervalType(ApiDBUtils.getSnapshotIntervalTypes(snapshot.getId()));
response.add(snapshotResponse);
}

View File

@ -27,6 +27,7 @@ import java.util.Set;
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;
@ -141,19 +142,19 @@ public class ListStoragePoolsAndHostsCmd extends BaseListCmd {
poolResponse.setPath(pool.getPath());
poolResponse.setIpAddress(pool.getHostAddress());
poolResponse.setZoneId(pool.getDataCenterId());
poolResponse.setZoneName(getManagementServer().getDataCenterBy(pool.getDataCenterId()).getName());
poolResponse.setZoneName(ApiDBUtils.findZoneById(pool.getDataCenterId()).getName());
if (pool.getPoolType() != null) {
poolResponse.setType(pool.getPoolType().toString());
}
if (pool.getPodId() != null) {
poolResponse.setPodId(pool.getPodId());
poolResponse.setPodName(getManagementServer().getPodBy(pool.getPodId()).getName());
poolResponse.setPodName(ApiDBUtils.findPodById(pool.getPodId()).getName());
}
if (pool.getCreated() != null) {
poolResponse.setCreated(pool.getCreated());
}
StorageStats stats = getManagementServer().getStoragePoolStatistics(pool.getId());
StorageStats stats = ApiDBUtils.getStoragePoolStatistics(pool.getId());
long capacity = pool.getCapacityBytes();
long available = pool.getAvailableBytes() ;
long used = capacity - available;
@ -167,12 +168,12 @@ public class ListStoragePoolsAndHostsCmd extends BaseListCmd {
poolResponse.setDiskSizeAllocated(used);
if (pool.getClusterId() != null) {
ClusterVO cluster = getManagementServer().findClusterById(pool.getClusterId());
ClusterVO cluster = ApiDBUtils.findClusterById(pool.getClusterId());
poolResponse.setClusterId(cluster.getId());
poolResponse.setClusterName(cluster.getName());
}
poolResponse.setTags(getManagementServer().getStoragePoolTags(pool.getId()));
poolResponse.setTags(ApiDBUtils.getStoragePoolTags(pool.getId()));
return poolResponse;
}
@ -198,21 +199,21 @@ public class ListStoragePoolsAndHostsCmd extends BaseListCmd {
hostResponse.setVersion(host.getVersion());
// TODO: implement
GuestOSCategoryVO guestOSCategory = getManagementServer().getHostGuestOSCategory(host.getId());
GuestOSCategoryVO guestOSCategory = ApiDBUtils.getHostGuestOSCategory(host.getId());
if (guestOSCategory != null) {
hostResponse.setOsCategoryId(guestOSCategory.getId());
hostResponse.setOsCategoryName(guestOSCategory.getName());
}
hostResponse.setZoneName(getManagementServer().getDataCenterBy(host.getDataCenterId()).getName());
hostResponse.setPodName(getManagementServer().findHostPodById(host.getPodId()).getName());
hostResponse.setZoneName(ApiDBUtils.findZoneById(host.getDataCenterId()).getName());
hostResponse.setPodName(ApiDBUtils.findPodById(host.getPodId()).getName());
// calculate cpu allocated by vm
int cpu = 0;
String cpuAlloc = null;
DecimalFormat decimalFormat = new DecimalFormat("#.##");
List<UserVmVO> instances = getManagementServer().listUserVMsByHostId(host.getId());
List<UserVmVO> instances = ApiDBUtils.listUserVMsByHostId(host.getId());
for (UserVmVO vm : instances) {
ServiceOffering so = getManagementServer().findServiceOfferingById(vm.getServiceOfferingId());
ServiceOffering so = ApiDBUtils.findServiceOfferingById(vm.getServiceOfferingId());
cpu += so.getCpu() * so.getSpeed();
}
cpuAlloc = decimalFormat.format(((float) cpu / (float) (host.getCpus() * host.getSpeed())) * 100f) + "%";
@ -220,7 +221,7 @@ public class ListStoragePoolsAndHostsCmd extends BaseListCmd {
// calculate cpu utilized
String cpuUsed = null;
HostStats hostStats = getManagementServer().getHostStatistics(host.getId());
HostStats hostStats = ApiDBUtils.getHostStatistics(host.getId());
if (hostStats != null) {
float cpuUtil = (float) hostStats.getCpuUtilization();
cpuUsed = decimalFormat.format(cpuUtil) + "%";
@ -234,7 +235,7 @@ public class ListStoragePoolsAndHostsCmd extends BaseListCmd {
hostResponse.setMemoryTotal(host.getTotalMemory());
// calculate memory allocated by systemVM and userVm
long mem = getManagementServer().getMemoryUsagebyHost(host.getId());
long mem = ApiDBUtils.getMemoryUsagebyHost(host.getId());
hostResponse.setMemoryAllocated(mem);
hostResponse.setMemoryUsed(mem);
} else if (host.getType().toString().equals("Storage")) {
@ -243,11 +244,11 @@ public class ListStoragePoolsAndHostsCmd extends BaseListCmd {
}
if (host.getClusterId() != null) {
ClusterVO cluster = getManagementServer().findClusterById(host.getClusterId());
ClusterVO cluster = ApiDBUtils.findClusterById(host.getClusterId());
hostResponse.setClusterName(cluster.getName());
}
hostResponse.setLocalStorageActive(getManagementServer().isLocalStorageActiveOnHost(host));
hostResponse.setLocalStorageActive(ApiDBUtils.isLocalStorageActiveOnHost(host));
Set<Event> possibleEvents = host.getStatus().getPossibleEvents();
if ((possibleEvents != null) && !possibleEvents.isEmpty()) {

View File

@ -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;
@ -109,19 +110,19 @@ public class ListStoragePoolsCmd extends BaseListCmd {
poolResponse.setPath(pool.getPath());
poolResponse.setIpAddress(pool.getHostAddress());
poolResponse.setZoneId(pool.getDataCenterId());
poolResponse.setZoneName(getManagementServer().getDataCenterBy(pool.getDataCenterId()).getName());
poolResponse.setZoneName(ApiDBUtils.findZoneById(pool.getDataCenterId()).getName());
if (pool.getPoolType() != null) {
poolResponse.setType(pool.getPoolType().toString());
}
if (pool.getPodId() != null) {
poolResponse.setPodId(pool.getPodId());
poolResponse.setPodName(getManagementServer().getPodBy(pool.getPodId()).getName());
poolResponse.setPodName(ApiDBUtils.findPodById(pool.getPodId()).getName());
}
if (pool.getCreated() != null) {
poolResponse.setCreated(pool.getCreated());
}
StorageStats stats = getManagementServer().getStoragePoolStatistics(pool.getId());
StorageStats stats = ApiDBUtils.getStoragePoolStatistics(pool.getId());
long capacity = pool.getCapacityBytes();
long available = pool.getAvailableBytes() ;
long used = capacity - available;
@ -135,12 +136,12 @@ public class ListStoragePoolsCmd extends BaseListCmd {
poolResponse.setDiskSizeAllocated(used);
if (pool.getClusterId() != null) {
ClusterVO cluster = getManagementServer().findClusterById(pool.getClusterId());
ClusterVO cluster = ApiDBUtils.findClusterById(pool.getClusterId());
poolResponse.setClusterId(cluster.getId());
poolResponse.setClusterName(cluster.getName());
}
poolResponse.setTags(getManagementServer().getStoragePoolTags(pool.getId()));
poolResponse.setTags(ApiDBUtils.getStoragePoolTags(pool.getId()));
response.add(poolResponse);
}

View File

@ -22,6 +22,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;
@ -124,14 +125,14 @@ public class ListSystemVMsCmd extends BaseListCmd {
// different instance types at the moment
}
AsyncJobVO asyncJob = getManagementServer().findInstancePendingAsyncJob(instanceType, vm.getId());
AsyncJobVO asyncJob = ApiDBUtils.findInstancePendingAsyncJob(instanceType, vm.getId());
if (asyncJob != null) {
vmResponse.setJobId(asyncJob.getId());
vmResponse.setJobStatus(asyncJob.getStatus());
}
vmResponse.setZoneId(vm.getDataCenterId());
vmResponse.setZoneName(getManagementServer().findDataCenterById(vm.getDataCenterId()).getName());
vmResponse.setZoneName(ApiDBUtils.findZoneById(vm.getDataCenterId()).getName());
vmResponse.setDns1(vm.getDns1());
vmResponse.setDns2(vm.getDns2());
vmResponse.setNetworkDomain(vm.getDomain());
@ -140,7 +141,7 @@ public class ListSystemVMsCmd extends BaseListCmd {
vmResponse.setPodId(vm.getPodId());
if (vm.getHostId() != null) {
vmResponse.setHostId(vm.getHostId());
vmResponse.setHostName(getManagementServer().getHostBy(vm.getHostId()).getName());
vmResponse.setHostName(ApiDBUtils.findHostById(vm.getHostId()).getName());
}
vmResponse.setPrivateIp(vm.getPrivateIpAddress());
vmResponse.setPrivateMacAddress(vm.getPrivateMacAddress());

View File

@ -4,6 +4,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;
@ -62,10 +63,10 @@ public class ListTemplateOrIsoPermissionsCmd extends BaseListCmd {
Account account = (Account)UserContext.current().getAccountObject();
boolean isAdmin = ((account == null) || isAdmin(account.getType()));
Long templateOwnerDomain = null;
VMTemplateVO template = getManagementServer().findTemplateById(id);
VMTemplateVO template = ApiDBUtils.findTemplateById(id);
if (isAdmin) {
// FIXME: we have just template id and need to get template owner from that
Account templateOwner = getManagementServer().findAccountById(template.getAccountId());
Account templateOwner = ApiDBUtils.findAccountById(template.getAccountId());
if (templateOwner != null) {
templateOwnerDomain = templateOwner.getDomainId();
}

View File

@ -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;
@ -142,7 +143,7 @@ public class ListTemplatesCmd extends BaseListCmd {
continue;
}
List<VMTemplateHostVO> templateHostRefsForTemplate = getManagementServer().listTemplateHostBy(template.getId(), zoneId);
List<VMTemplateHostVO> templateHostRefsForTemplate = ApiDBUtils.listTemplateHostBy(template.getId(), zoneId);
for (VMTemplateHostVO templateHostRef : templateHostRefsForTemplate) {
if (onlyReady && templateHostRef.getDownloadState() != Status.DOWNLOADED) {
@ -164,7 +165,7 @@ public class ListTemplatesCmd extends BaseListCmd {
templateResponse.setCrossZones(template.isCrossZones());
templateResponse.setFormat(template.getFormat());
GuestOS os = getManagementServer().findGuestOSById(template.getGuestOSId());
GuestOS os = ApiDBUtils.findGuestOSById(template.getGuestOSId());
if (os != null) {
templateResponse.setOsTypeId(os.getId());
templateResponse.setOsTypeName(os.getDisplayName());
@ -174,15 +175,15 @@ public class ListTemplatesCmd extends BaseListCmd {
}
// add account ID and name
Account owner = getManagementServer().findAccountById(template.getAccountId());
Account owner = ApiDBUtils.findAccountById(template.getAccountId());
if (owner != null) {
templateResponse.setAccount(owner.getAccountName());
templateResponse.setDomainId(owner.getDomainId());
templateResponse.setDomainName(getManagementServer().findDomainIdById(owner.getDomainId()).getName());
templateResponse.setDomainName(ApiDBUtils.findDomainById(owner.getDomainId()).getName());
}
HostVO host = getManagementServer().getHostBy(templateHostRef.getHostId());
DataCenterVO datacenter = getManagementServer().getDataCenterBy(host.getDataCenterId());
HostVO host = ApiDBUtils.findHostById(templateHostRef.getHostId());
DataCenterVO datacenter = ApiDBUtils.findZoneById(host.getDataCenterId());
// Add the zone ID
templateResponse.setZoneId(host.getDataCenterId());
@ -215,7 +216,7 @@ public class ListTemplatesCmd extends BaseListCmd {
templateResponse.setSize(templateSize);
}
AsyncJobVO asyncJob = getManagementServer().findInstancePendingAsyncJob("vm_template", template.getId());
AsyncJobVO asyncJob = ApiDBUtils.findInstancePendingAsyncJob("vm_template", template.getId());
if (asyncJob != null) {
templateResponse.setJobId(asyncJob.getId());
templateResponse.setJobStatus(asyncJob.getStatus());

View File

@ -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;
@ -112,7 +113,7 @@ public class ListUsersCmd extends BaseListCmd {
userResponse.setAccountName(user.getAccountName());
userResponse.setAccountType(user.getType());
userResponse.setDomainId(user.getDomainId());
userResponse.setDomainName(getManagementServer().findDomainIdById(user.getDomainId()).getName());
userResponse.setDomainName(ApiDBUtils.findDomainById(user.getDomainId()).getName());
userResponse.setTimezone(user.getTimezone());
userResponse.setApiKey(user.getApiKey());
userResponse.setSecretKey(user.getSecretKey());

View File

@ -29,8 +29,8 @@ import com.cloud.api.Implementation;
import com.cloud.api.Parameter;
import com.cloud.api.response.UserVmResponse;
import com.cloud.async.AsyncJobVO;
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.UserContext;
@ -124,7 +124,7 @@ public class ListVMsCmd extends BaseListCmd {
for (UserVmVO userVm : userVms) {
UserVmResponse userVmResponse = new UserVmResponse();
userVmResponse.setId(userVm.getId());
AsyncJobVO asyncJob = getManagementServer().findInstancePendingAsyncJob("vm_instance", userVm.getId());
AsyncJobVO asyncJob = ApiDBUtils.findInstancePendingAsyncJob("vm_instance", userVm.getId());
if (asyncJob != null) {
userVmResponse.setJobId(asyncJob.getId());
userVmResponse.setJobStatus(asyncJob.getStatus());
@ -137,11 +137,11 @@ public class ListVMsCmd extends BaseListCmd {
userVmResponse.setState(userVm.getState().toString());
}
Account acct = getManagementServer().findAccountById(Long.valueOf(userVm.getAccountId()));
Account acct = ApiDBUtils.findAccountById(Long.valueOf(userVm.getAccountId()));
if (acct != null) {
userVmResponse.setAccountName(acct.getAccountName());
userVmResponse.setDomainId(acct.getDomainId());
userVmResponse.setDomainName(getManagementServer().findDomainIdById(acct.getDomainId()).getName());
userVmResponse.setDomainName(ApiDBUtils.findDomainById(acct.getDomainId()).getName());
}
userVmResponse.setHaEnable(userVm.isHaEnabled());
@ -156,17 +156,17 @@ public class ListVMsCmd extends BaseListCmd {
// Data Center Info
userVmResponse.setZoneId(userVm.getDataCenterId());
userVmResponse.setZoneName(getManagementServer().findDataCenterById(userVm.getDataCenterId()).getName());
userVmResponse.setZoneName(ApiDBUtils.findZoneById(userVm.getDataCenterId()).getName());
Account account = (Account)UserContext.current().getAccountObject();
//if user is an admin, display host id
if (((account == null) || isAdmin(account.getType())) && (userVm.getHostId() != null)) {
userVmResponse.setHostId(userVm.getHostId());
userVmResponse.setHostName(getManagementServer().getHostBy(userVm.getHostId()).getName());
userVmResponse.setHostName(ApiDBUtils.findHostById(userVm.getHostId()).getName());
}
// Template Info
VMTemplateVO template = getManagementServer().findTemplateById(userVm.getTemplateId());
VMTemplateVO template = ApiDBUtils.findTemplateById(userVm.getTemplateId());
if (template != null) {
userVmResponse.setTemplateId(userVm.getTemplateId());
userVmResponse.setTemplateName(template.getName());
@ -181,7 +181,7 @@ public class ListVMsCmd extends BaseListCmd {
// ISO Info
if (userVm.getIsoId() != null) {
VMTemplateVO iso = getManagementServer().findTemplateById(userVm.getIsoId().longValue());
VMTemplateVO iso = ApiDBUtils.findTemplateById(userVm.getIsoId().longValue());
if (iso != null) {
userVmResponse.setIsoId(userVm.getIsoId());
userVmResponse.setIsoName(iso.getName());
@ -189,7 +189,7 @@ public class ListVMsCmd extends BaseListCmd {
}
// Service Offering Info
ServiceOfferingVO offering = getManagementServer().findServiceOfferingById(vmInstance.getServiceOfferingId());
ServiceOffering offering = ApiDBUtils.findServiceOfferingById(userVm.getServiceOfferingId());
userVmResponse.setServiceOfferingId(userVm.getServiceOfferingId());
userVmResponse.setServiceOfferingName(offering.getName());
userVmResponse.setCpuNumber(offering.getCpu());
@ -199,7 +199,7 @@ public class ListVMsCmd extends BaseListCmd {
//stats calculation
DecimalFormat decimalFormat = new DecimalFormat("#.##");
String cpuUsed = null;
VmStats vmStats = getManagementServer().getVmStatistics(userVm.getId());
VmStats vmStats = ApiDBUtils.getVmStatistics(userVm.getId());
if (vmStats != null) {
float cpuUtil = (float) vmStats.getCPUUtilization();
cpuUsed = decimalFormat.format(cpuUtil) + "%";

View File

@ -22,6 +22,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;
@ -103,8 +104,8 @@ public class ListVlanIpRangesCmd extends BaseListCmd {
List<VlanIpRangeResponse> response = new ArrayList<VlanIpRangeResponse>();
for (VlanVO vlan : vlans) {
Long accountId = getManagementServer().getAccountIdForVlan(vlan.getId());
Long podId = getManagementServer().getPodIdForVlan(vlan.getId());
Long accountId = ApiDBUtils.getAccountIdForVlan(vlan.getId());
Long podId = ApiDBUtils.getPodIdForVlan(vlan.getId());
VlanIpRangeResponse vlanResponse = new VlanIpRangeResponse();
vlanResponse.setId(vlan.getId());
@ -113,14 +114,14 @@ public class ListVlanIpRangesCmd extends BaseListCmd {
vlanResponse.setZoneId(vlan.getDataCenterId());
if (accountId != null) {
Account account = getManagementServer().findAccountById(accountId);
Account account = ApiDBUtils.findAccountById(accountId);
vlanResponse.setAccountName(account.getAccountName());
vlanResponse.setDomainId(account.getDomainId());
vlanResponse.setDomainName(getManagementServer().findDomainIdById(account.getDomainId()).getName());
vlanResponse.setDomainName(ApiDBUtils.findDomainById(account.getDomainId()).getName());
}
if (podId != null) {
HostPodVO pod = getManagementServer().findHostPodById(podId);
HostPodVO pod = ApiDBUtils.findPodById(podId);
vlanResponse.setPodId(podId);
vlanResponse.setPodName(pod.getName());
}

View File

@ -22,6 +22,7 @@ import java.util.List;
import org.apache.log4j.Logger;
import com.cloud.api.ApiDBUtils;
import com.cloud.api.BaseCmd;
import com.cloud.api.BaseListCmd;
import com.cloud.api.Implementation;
@ -131,7 +132,7 @@ public class ListVolumesCmd extends BaseListCmd {
VolumeResponse volResponse = new VolumeResponse();
volResponse.setId(volume.getId());
AsyncJobVO asyncJob = getManagementServer().findInstancePendingAsyncJob("volume", volume.getId());
AsyncJobVO asyncJob = ApiDBUtils.findInstancePendingAsyncJob("volume", volume.getId());
if (asyncJob != null) {
volResponse.setJobId(asyncJob.getId());
volResponse.setJobStatus(asyncJob.getStatus());
@ -144,14 +145,14 @@ public class ListVolumesCmd extends BaseListCmd {
}
volResponse.setZoneId(volume.getDataCenterId());
volResponse.setZoneName(getManagementServer().findDataCenterById(volume.getDataCenterId()).getName());
volResponse.setZoneName(ApiDBUtils.findZoneById(volume.getDataCenterId()).getName());
volResponse.setVolumeType(volume.getVolumeType().toString());
volResponse.setDeviceId(volume.getDeviceId());
Long instanceId = volume.getInstanceId();
if (instanceId != null) {
VMInstanceVO vm = getManagementServer().findVMInstanceById(instanceId);
VMInstanceVO vm = ApiDBUtils.findVMInstanceById(instanceId);
volResponse.setVirtualMachineId(vm.getId());
volResponse.setVirtualMachineName(vm.getName());
volResponse.setVirtualMachineDisplayName(vm.getName());
@ -164,11 +165,11 @@ public class ListVolumesCmd extends BaseListCmd {
volResponse.setCreated(volume.getCreated());
volResponse.setState(volume.getStatus().toString());
Account accountTemp = getManagementServer().findAccountById(volume.getAccountId());
Account accountTemp = ApiDBUtils.findAccountById(volume.getAccountId());
if (accountTemp != null) {
volResponse.setAccountName(accountTemp.getAccountName());
volResponse.setDomainId(accountTemp.getDomainId());
volResponse.setDomainName(getManagementServer().findDomainIdById(accountTemp.getDomainId()).getName());
volResponse.setDomainName(ApiDBUtils.findDomainById(accountTemp.getDomainId()).getName());
}
String storageType;
@ -176,7 +177,7 @@ public class ListVolumesCmd extends BaseListCmd {
if(volume.getPoolId() == null){
storageType = "unknown";
} else {
storageType = getManagementServer().volumeIsOnSharedStorage(volume.getId()) ? "shared" : "local";
storageType = ApiDBUtils.volumeIsOnSharedStorage(volume.getId()) ? "shared" : "local";
}
} catch (InvalidParameterValueException e) {
s_logger.error(e.getMessage(), e);
@ -187,13 +188,13 @@ public class ListVolumesCmd extends BaseListCmd {
volResponse.setDiskOfferingId(volume.getDiskOfferingId());
if (volume.getDiskOfferingId() != null) {
DiskOfferingVO diskOffering = getManagementServer().findDiskOfferingById(volume.getDiskOfferingId());
DiskOfferingVO diskOffering = ApiDBUtils.findDiskOfferingById(volume.getDiskOfferingId());
volResponse.setDiskOfferingName(diskOffering.getName());
volResponse.setDiskOfferingDisplayText(diskOffering.getDisplayText());
}
Long poolId = volume.getPoolId();
String poolName = (poolId == null) ? "none" : getManagementServer().findPoolById(poolId).getName();
String poolName = (poolId == null) ? "none" : ApiDBUtils.findStoragePoolById(poolId).getName();
volResponse.setStoragePoolName(poolName);
response.add(volResponse);

View File

@ -90,7 +90,6 @@ import com.cloud.async.AsyncJobResult;
import com.cloud.async.AsyncJobVO;
import com.cloud.capacity.CapacityVO;
import com.cloud.configuration.ConfigurationVO;
import com.cloud.configuration.ResourceCount.ResourceType;
import com.cloud.configuration.ResourceLimitVO;
import com.cloud.dc.ClusterVO;
import com.cloud.dc.DataCenterIpAddressVO;
@ -107,7 +106,6 @@ import com.cloud.exception.NetworkRuleConflictException;
import com.cloud.exception.PermissionDeniedException;
import com.cloud.exception.ResourceAllocationException;
import com.cloud.exception.StorageUnavailableException;
import com.cloud.host.HostStats;
import com.cloud.host.HostVO;
import com.cloud.info.ConsoleProxyInfo;
import com.cloud.network.FirewallRuleVO;
@ -119,15 +117,12 @@ import com.cloud.network.security.NetworkGroupVO;
import com.cloud.service.ServiceOfferingVO;
import com.cloud.storage.DiskOfferingVO;
import com.cloud.storage.DiskTemplateVO;
import com.cloud.storage.GuestOS;
import com.cloud.storage.GuestOSCategoryVO;
import com.cloud.storage.GuestOSVO;
import com.cloud.storage.Snapshot;
import com.cloud.storage.SnapshotPolicyVO;
import com.cloud.storage.SnapshotVO;
import com.cloud.storage.StoragePoolVO;
import com.cloud.storage.StorageStats;
import com.cloud.storage.VMTemplateHostVO;
import com.cloud.storage.VMTemplateVO;
import com.cloud.storage.VolumeStats;
import com.cloud.storage.VolumeVO;
@ -137,7 +132,6 @@ import com.cloud.user.AccountVO;
import com.cloud.user.User;
import com.cloud.user.UserAccount;
import com.cloud.user.UserAccountVO;
import com.cloud.user.UserStatisticsVO;
import com.cloud.uservm.UserVm;
import com.cloud.utils.Pair;
import com.cloud.utils.exception.ExecutionException;
@ -148,7 +142,6 @@ import com.cloud.vm.SecondaryStorageVmVO;
import com.cloud.vm.UserVmVO;
import com.cloud.vm.VMInstanceVO;
import com.cloud.vm.VirtualMachine;
import com.cloud.vm.VmStats;
/**
@ -166,7 +159,6 @@ public interface ManagementServer {
*/
UserAccount createUser(CreateUserCmd cmd);
ClusterVO findClusterById(long clusterId);
List<ClusterVO> listClusterByPodId(long podId);
/**
@ -302,29 +294,8 @@ public interface ManagementServer {
* @param hostId
* @return StorageStats
*/
StorageStats getStorageStatistics(long hostId);
/**
* Gets the guest OS category for a host
* @param hostId
* @return guest OS Category
*/
GuestOSCategoryVO getHostGuestOSCategory(long hostId);
StorageStats getStorageStatistics(long hostId);;
/** Get storage statistics (used/available) for a pool
* @param id pool id
* @return storage statistics
*/
StorageStats getStoragePoolStatistics(long id);
/**
* Gets Host/VM statistics for a given host
*
* @param hostId
* @return HostStats/VMStats depending on the id passed
*/
VmStats getVmStatistics(long hostId);
/**
* Gets Volume statistics. The array returned will contain VolumeStats in the same order
* as the array of volumes requested.
@ -348,13 +319,6 @@ public interface ManagementServer {
* @return pod ID, or null
*/
Long getPodIdForVlan(long vlanDbId);
/**
* If the specified VLAN is associated with a specific account, returns the account ID. Else, returns null.
* @param accountId
* @return account ID, or null
*/
Long getAccountIdForVlan(long vlanDbId);
/**
* Finds the root volume of the VM
@ -472,22 +436,6 @@ public interface ManagementServer {
* @return a domainRouter
*/
DomainRouterVO findDomainRouterById(long domainRouterId);
/**
* Retrieves a data center by id
*
* @param dataCenterId
* @return DataCenter
*/
DataCenterVO getDataCenterBy(long dataCenterId);
/**
* Retrieves a pod by id
*
* @param podId
* @return Pod
*/
HostPodVO getPodBy(long podId);
/**
* Retrieves the list of data centers with search criteria.
@ -594,15 +542,6 @@ public interface ManagementServer {
*/
List<VMTemplateVO> searchForTemplates(Criteria c);
/**
* Lists the template host records by template Id
*
* @param templateId
* @param zoneId
* @return List of VMTemplateHostVO
*/
List<VMTemplateHostVO> listTemplateHostBy(long templateId, Long zoneId);
/**
* Obtains pods that match the data center ID
* @param dataCenterId
@ -637,13 +576,6 @@ public interface ManagementServer {
*/
User getUser(long userId, boolean active);
/**
* Obtains a list of user statistics for the specified user ID.
* @param userId
* @return List of UserStatistics
*/
List<UserStatisticsVO> listUserStatsBy(Long userId);
/**
* Obtains a list of virtual machines that are similar to the VM with the specified name.
* @param vmInstanceName
@ -691,13 +623,6 @@ public interface ManagementServer {
*/
DataCenterVO findDataCenterById(long dataCenterId);
/**
* Finds a VLAN with the specified ID.
* @param vlanDbId
* @return VLAN
*/
VlanVO findVlanById(long vlanDbId);
/**
* Creates a new template
* @param cmd
@ -723,21 +648,6 @@ public interface ManagementServer {
*/
VMTemplateVO findTemplateById(long templateId);
/**
* Finds a template-host reference by the specified template and zone IDs
* @param templateId
* @param zoneId
* @return template-host reference
*/
VMTemplateHostVO findTemplateHostRef(long templateId, long zoneId);
/**
* Obtains a list of virtual machines that match the specified host ID.
* @param hostId
* @return List of UserVMs.
*/
List<UserVmVO> listUserVMsByHostId(long hostId);
/**
* Obtains a list of virtual machines by the specified search criteria.
* Can search by: "userId", "name", "state", "dataCenterId", "podId", "hostId"
@ -815,16 +725,6 @@ public interface ManagementServer {
List<ConsoleProxyVO> searchForConsoleProxy(Criteria c);
/**
* Finds a volume which is not destroyed or removed.
*/
VolumeVO findVolumeById(long id);
/**
* Return the volume with the given id even if its destroyed or removed.
*/
VolumeVO findAnyVolumeById(long volumeId);
/** revisit
* Obtains a list of storage volumes by the specified search criteria.
* Can search by: "userId", "vType", "instanceId", "dataCenterId", "podId", "hostId"
@ -832,14 +732,7 @@ public interface ManagementServer {
* @return List of Volumes.
*/
List<VolumeVO> searchForVolumes(ListVolumesCmd cmd) throws InvalidParameterValueException, PermissionDeniedException;
/**
* Checks that the volume is stored on a shared storage pool.
* @param volumeId
* @return true if the volume is on a shared storage pool, false otherwise
*/
boolean volumeIsOnSharedStorage(long volumeId) throws InvalidParameterValueException;
/**
* Finds a pod by the specified ID.
* @param podId
@ -984,12 +877,6 @@ public interface ManagementServer {
* @param accountId the id of the account to use to look up the domain
*/
Long findDomainIdByAccountId(Long accountId);
/**
* find the domain by id
* @param domainId the id of the domainId
*/
DomainVO findDomainIdById(Long domainId);
/**
* find the domain by its path
@ -1034,13 +921,6 @@ public interface ManagementServer {
* @return Account
*/
Account findAccountById(Long accountId);
/**
* Finds a GuestOS by the ID.
* @param id
* @return GuestOS
*/
GuestOS findGuestOSById(Long id);
/**
* Searches for accounts by the specified search criteria
@ -1072,21 +952,6 @@ public interface ManagementServer {
*/
ResourceLimitVO findLimitById(long limitId);
/**
* Finds the correct limit for an account. I.e. if an account's limit is not present, it will check the account's domain, and as a last resort use the global limit.
* @param type
* @param accountId
*/
long findCorrectResourceLimit(ResourceType type, long accountId);
/**
* Gets the count of resources for a resource type and account
* @param Type
* @param accountId
* @return count of resources
*/
long getResourceCount(ResourceType type, long accountId);
/**
* Lists ISOs that are available for the specified account ID.
* @param accountId
@ -1133,13 +998,6 @@ public interface ManagementServer {
*/
List<SnapshotVO> listSnapshots(ListSnapshotsCmd cmd) throws InvalidParameterValueException;
/**
* find a single snapshot by id
* @param snapshotId
* @return the snapshot if found, null otherwise
*/
Snapshot findSnapshotById(long snapshotId);
/**
* Finds a diskOffering by the specified ID.
* @param diskOfferingId
@ -1203,7 +1061,6 @@ public interface ManagementServer {
*/
AsyncJobResult queryAsyncJobResult(QueryAsyncJobResultCmd cmd) throws PermissionDeniedException;
AsyncJobVO findInstancePendingAsyncJob(String instanceType, long instanceId);
AsyncJobVO findAsyncJobById(long jobId);
/**
@ -1325,13 +1182,6 @@ public interface ManagementServer {
*/
boolean isChildDomain(Long parentId, Long childId);
/**
* List interval types the specified snapshot belongs to
* @param snapshotId
* @return
*/
String getSnapshotIntervalTypes(long snapshotId);
List<SecondaryStorageVmVO> searchForSecondaryStorageVm(Criteria c);
/**
@ -1372,8 +1222,6 @@ public interface ManagementServer {
*/
long revokeNetworkGroupIngressAsync(Long accountId, String groupName, String protocol, int startPort, int endPort, String [] cidrList, List<NetworkGroupVO> authorizedGroups);
HostStats getHostStatistics(long hostId);
/**
* Is the hypervisor snapshot capable.
* @return True if the hypervisor.type is XenServer
@ -1381,19 +1229,6 @@ public interface ManagementServer {
boolean isHypervisorSnapshotCapable();
List<String> searchForStoragePoolDetails(long poolId, String value);
/**
* Returns a comma separated list of tags for the specified storage pool
* @param poolId
* @return comma separated list of tags
*/
String getStoragePoolTags(long poolId);
/**
* Checks if a host has running VMs that are using its local storage pool.
* @return true if local storage is active on the host
*/
boolean isLocalStorageActiveOnHost(HostVO host);
public List<PreallocatedLunVO> getPreAllocatedLuns(ListPreallocatedLunsCmd cmd);
boolean checkLocalStorageConfigVal();

View File

@ -171,7 +171,6 @@ import com.cloud.exception.PermissionDeniedException;
import com.cloud.exception.ResourceAllocationException;
import com.cloud.exception.StorageUnavailableException;
import com.cloud.host.Host;
import com.cloud.host.HostStats;
import com.cloud.host.HostVO;
import com.cloud.host.dao.HostDao;
import com.cloud.hypervisor.Hypervisor;
@ -202,7 +201,6 @@ import com.cloud.service.ServiceOfferingVO;
import com.cloud.service.dao.ServiceOfferingDao;
import com.cloud.storage.DiskOfferingVO;
import com.cloud.storage.DiskTemplateVO;
import com.cloud.storage.GuestOS;
import com.cloud.storage.GuestOSCategoryVO;
import com.cloud.storage.GuestOSVO;
import com.cloud.storage.LaunchPermissionVO;
@ -215,7 +213,6 @@ import com.cloud.storage.Storage.ImageFormat;
import com.cloud.storage.StorageManager;
import com.cloud.storage.StoragePoolVO;
import com.cloud.storage.StorageStats;
import com.cloud.storage.VMTemplateHostVO;
import com.cloud.storage.VMTemplateVO;
import com.cloud.storage.Volume.VolumeType;
import com.cloud.storage.VolumeStats;
@ -230,7 +227,6 @@ import com.cloud.storage.dao.SnapshotPolicyDao;
import com.cloud.storage.dao.StoragePoolDao;
import com.cloud.storage.dao.VMTemplateDao;
import com.cloud.storage.dao.VMTemplateDao.TemplateFilter;
import com.cloud.storage.dao.VMTemplateHostDao;
import com.cloud.storage.dao.VolumeDao;
import com.cloud.storage.preallocatedlun.PreallocatedLunVO;
import com.cloud.storage.preallocatedlun.dao.PreallocatedLunDao;
@ -280,7 +276,6 @@ import com.cloud.vm.UserVmManager;
import com.cloud.vm.UserVmVO;
import com.cloud.vm.VMInstanceVO;
import com.cloud.vm.VirtualMachine;
import com.cloud.vm.VmStats;
import com.cloud.vm.dao.ConsoleProxyDao;
import com.cloud.vm.dao.DomainRouterDao;
import com.cloud.vm.dao.SecondaryStorageVmDao;
@ -323,7 +318,6 @@ public class ManagementServerImpl implements ManagementServer {
private final ServiceOfferingDao _offeringsDao;
private final DiskOfferingDao _diskOfferingDao;
private final VMTemplateDao _templateDao;
private final VMTemplateHostDao _templateHostDao;
private final LaunchPermissionDao _launchPermissionDao;
private final DomainDao _domainDao;
private final AccountDao _accountDao;
@ -416,7 +410,6 @@ public class ManagementServerImpl implements ManagementServer {
_offeringsDao = locator.getDao(ServiceOfferingDao.class);
_diskOfferingDao = locator.getDao(DiskOfferingDao.class);
_templateDao = locator.getDao(VMTemplateDao.class);
_templateHostDao = locator.getDao(VMTemplateHostDao.class);
_launchPermissionDao = locator.getDao(LaunchPermissionDao.class);
_domainDao = locator.getDao(DomainDao.class);
_accountDao = locator.getDao(AccountDao.class);
@ -508,17 +501,6 @@ public class ManagementServerImpl implements ManagementServer {
return _statsCollector.getStorageStats(hostId);
}
@Override
public GuestOSCategoryVO getHostGuestOSCategory(long hostId) {
Long guestOSCategoryID = _agentMgr.getGuestOSCategoryId(hostId);
if (guestOSCategoryID != null) {
return _guestOSCategoryDao.findById(guestOSCategoryID);
} else {
return null;
}
}
@Override
public PreallocatedLunVO registerPreallocatedLun(RegisterPreallocatedLunCmd cmd) {
Long zoneId = cmd.getZoneId();
@ -557,11 +539,6 @@ public class ManagementServerImpl implements ManagementServer {
return _lunDao.delete(id);
}
@Override
public VmStats getVmStatistics(long hostId) {
return _statsCollector.getVmStats(hostId);
}
@Override
public VolumeStats[] getVolumeStatistics(long[] volIds) {
return _statsCollector.getVolumeStats(volIds);
@ -1940,17 +1917,6 @@ public class ManagementServerImpl implements ManagementServer {
return _routerDao.findById(domainRouterId);
}
@Override
public DataCenterVO getDataCenterBy(long dataCenterId) {
return _dcDao.findById(dataCenterId);
}
@Override
public HostPodVO getPodBy(long podId) {
return _hostPodDao.findById(podId);
}
@Override
public List<DataCenterVO> listDataCenters(ListZonesByCmd cmd) {
List<DataCenterVO> dcs = _dcDao.listAllActive();
@ -3012,16 +2978,6 @@ public class ManagementServerImpl implements ManagementServer {
}
}
@Override
public Long getAccountIdForVlan(long vlanDbId) {
List<AccountVlanMapVO> accountVlanMaps = _accountVlanMapDao.listAccountVlanMapsByVlan(vlanDbId);
if (accountVlanMaps.isEmpty()) {
return null;
} else {
return accountVlanMaps.get(0).getAccountId();
}
}
@Override
public List<ConfigurationVO> searchForConfigurations(ListCfgsByCmd cmd) {
Filter searchFilter = new Filter(ConfigurationVO.class, "name", true, cmd.getStartIndex(), cmd.getPageSizeVal());
@ -3223,20 +3179,6 @@ public class ManagementServerImpl implements ManagementServer {
return _launchPermissionDao.listPermittedTemplates(accountId);
}
@Override
public List<VMTemplateHostVO> listTemplateHostBy(long templateId, Long zoneId) {
if (zoneId != null) {
HostVO secondaryStorageHost = _storageMgr.getSecondaryStorageHost(zoneId);
if (secondaryStorageHost == null) {
return new ArrayList<VMTemplateHostVO>();
} else {
return _templateHostDao.listByHostTemplate(secondaryStorageHost.getId(), templateId);
}
} else {
return _templateHostDao.listByOnlyTemplateId(templateId);
}
}
@Override
public List<HostPodVO> listPods(long dataCenterId) {
return _hostPodDao.listByDataCenterId(dataCenterId);
@ -3282,11 +3224,6 @@ public class ManagementServerImpl implements ManagementServer {
return _accountDao.findById(accountId);
}
@Override
public GuestOS findGuestOSById(Long id) {
return this._guestOSDao.findById(id);
}
@Override
public List<AccountVO> searchForAccounts(ListAccountsCmd cmd) {
Account account = (Account)UserContext.current().getAccountObject();
@ -3388,29 +3325,6 @@ public class ManagementServerImpl implements ManagementServer {
return _resourceLimitDao.findById(limitId);
}
@Override
public long findCorrectResourceLimit(ResourceType type, long accountId) {
AccountVO account = _accountDao.findById(accountId);
if (account == null) {
return -1;
}
return _accountMgr.findCorrectResourceLimit(account, type);
}
@Override
public long getResourceCount(ResourceType type, long accountId) {
AccountVO account = _accountDao.findById(accountId);
if (account == null) {
return -1;
}
return _accountMgr.getResourceCount(account, type);
}
@Override
public List<VMTemplateVO> listIsos(Criteria c) {
Filter searchFilter = new Filter(VMTemplateVO.class, c.getOrderBy(), c.getAscending(), c.getOffset(), c.getLimit());
@ -3444,11 +3358,6 @@ public class ManagementServerImpl implements ManagementServer {
return _templateDao.search(sc, searchFilter);
}
@Override
public List<UserStatisticsVO> listUserStatsBy(Long accountId) {
return _userStatsDao.listBy(accountId);
}
@Override
public List<VMInstanceVO> findVMInstancesLike(String vmInstanceName) {
return _vmInstanceDao.findVMInstancesLike(vmInstanceName);
@ -3484,11 +3393,6 @@ public class ManagementServerImpl implements ManagementServer {
return _dcDao.findById(dataCenterId);
}
@Override
public VlanVO findVlanById(long vlanDbId) {
return _vlanDao.findById(vlanDbId);
}
@Override
public boolean updateTemplate(UpdateTemplateOrIsoCmd cmd) throws InvalidParameterValueException {
Long id = cmd.getId();
@ -3591,21 +3495,6 @@ public class ManagementServerImpl implements ManagementServer {
return _templateDao.findById(templateId);
}
@Override
public VMTemplateHostVO findTemplateHostRef(long templateId, long zoneId) {
HostVO secondaryStorageHost = _storageMgr.getSecondaryStorageHost(zoneId);
if (secondaryStorageHost == null) {
return null;
} else {
return _templateHostDao.findByHostTemplate(secondaryStorageHost.getId(), templateId);
}
}
@Override
public List<UserVmVO> listUserVMsByHostId(long hostId) {
return _userVmDao.listByHostId(hostId);
}
@Override
public List<UserVmVO> searchForUserVMs(ListVMsCmd cmd) throws InvalidParameterValueException, PermissionDeniedException {
Account account = (Account)UserContext.current().getAccountObject();
@ -4205,22 +4094,6 @@ public class ManagementServerImpl implements ManagementServer {
return _consoleProxyDao.search(sc, searchFilter);
}
@Override
public VolumeVO findVolumeById(long id) {
VolumeVO volume = _volumeDao.findById(id);
if (volume != null && !volume.getDestroyed() && volume.getRemoved() == null) {
return volume;
}
else {
return null;
}
}
@Override
public VolumeVO findAnyVolumeById(long volumeId) {
return _volumeDao.findById(volumeId);
}
@Override
public List<VolumeVO> searchForVolumes(ListVolumesCmd cmd) throws InvalidParameterValueException, PermissionDeniedException {
Account account = (Account)UserContext.current().getAccountObject();
@ -4348,17 +4221,6 @@ public class ManagementServerImpl implements ManagementServer {
return _volumeDao.search(sc, searchFilter);
}
@Override
public boolean volumeIsOnSharedStorage(long volumeId) throws InvalidParameterValueException {
// Check that the volume is valid
VolumeVO volume = _volumeDao.findById(volumeId);
if (volume == null) {
throw new InvalidParameterValueException("Please specify a valid volume ID.");
}
return _storageMgr.volumeOnSharedStoragePool(volume);
}
@Override
public HostPodVO findHostPodById(long podId) {
return _hostPodDao.findById(podId);
@ -5070,7 +4932,7 @@ public class ManagementServerImpl implements ManagementServer {
String domainName = cmd.getName();
//check if domain exists in the system
DomainVO domain = findDomainIdById(domainId);
DomainVO domain = _domainDao.findById(domainId);
if (domain == null) {
throw new InvalidParameterValueException("Unable to find domain " + domainId);
} else if (domain.getParent() == null) {
@ -5115,10 +4977,6 @@ public class ManagementServerImpl implements ManagementServer {
return null;
}
public DomainVO findDomainIdById(Long domainId) {
return _domainDao.findById(domainId);
}
@Override
public DomainVO findDomainByPath(String domainPath) {
return _domainDao.findDomainByPath(domainPath);
@ -5303,17 +5161,6 @@ public class ManagementServerImpl implements ManagementServer {
return _snapshotDao.search(sc, searchFilter);
}
@Override
public Snapshot findSnapshotById(long snapshotId) {
SnapshotVO snapshot = _snapshotDao.findById(snapshotId);
if (snapshot != null && snapshot.getRemoved() == null && snapshot.getStatus() == Snapshot.Status.BackedUp) {
return snapshot;
}
else {
return null;
}
}
@Override
public DiskOfferingVO findDiskOfferingById(long diskOfferingId) {
return _diskOfferingDao.findById(diskOfferingId);
@ -5640,11 +5487,6 @@ public class ManagementServerImpl implements ManagementServer {
return _asyncMgr.queryAsyncJobResult(jobId);
}
@Override
public AsyncJobVO findInstancePendingAsyncJob(String instanceType, long instanceId) {
return _asyncMgr.findInstancePendingAsyncJob(instanceType, instanceId);
}
@Override
public AsyncJobVO findAsyncJobById(long jobId) {
return _asyncMgr.getAsyncJob(jobId);
@ -6212,11 +6054,6 @@ public class ManagementServerImpl implements ManagementServer {
return _poolDao.findById(id);
}
@Override
public ClusterVO findClusterById(long clusterId) {
return _clusterDao.findById(clusterId);
}
@Override
public List<ClusterVO> listClusterByPodId(long podId) {
return _clusterDao.listByPodId(podId);
@ -6309,22 +6146,12 @@ public class ManagementServerImpl implements ManagementServer {
return poolsAndHosts;
}
@Override
public StorageStats getStoragePoolStatistics(long id) {
return _statsCollector.getStoragePoolStats(id);
}
@Override
public List<String> searchForStoragePoolDetails(long poolId, String value)
{
return _poolDao.searchForStoragePoolDetails(poolId, value);
}
@Override
public String getStoragePoolTags(long poolId) {
return _storageMgr.getStoragePoolTags(poolId);
}
@Override
public List<AsyncJobVO> searchForAsyncJobs(ListAsyncJobsCmd cmd) throws InvalidParameterValueException, PermissionDeniedException {
Filter searchFilter = new Filter(AsyncJobVO.class, "id", true, cmd.getStartIndex(), cmd.getPageSizeVal());
@ -6389,24 +6216,6 @@ public class ManagementServerImpl implements ManagementServer {
return _snapshotPolicyDao.findById(policyId);
}
@Override
public String getSnapshotIntervalTypes(long snapshotId){
String intervalTypes = "";
List<SnapshotPolicyVO> policies = _snapMgr.listPoliciesforSnapshot(snapshotId);
for (SnapshotPolicyVO policy : policies){
if(!intervalTypes.isEmpty()){
intervalTypes += ",";
}
if(policy.getId() == Snapshot.MANUAL_POLICY_ID){
intervalTypes+= "MANUAL";
}
else {
intervalTypes += DateUtil.getIntervalType(policy.getInterval()).toString();
}
}
return intervalTypes;
}
@Override
public boolean isChildDomain(Long parentId, Long childId) {
return _domainDao.isChildDomain(parentId, childId);
@ -6711,11 +6520,6 @@ public class ManagementServerImpl implements ManagementServer {
return _asyncMgr.submitAsyncJob(job);
}
@Override
public HostStats getHostStatistics(long hostId) {
return _statsCollector.getHostStats(hostId);
}
/**
* {@inheritDoc}
*/
@ -6724,11 +6528,6 @@ public class ManagementServerImpl implements ManagementServer {
return _isHypervisorSnapshotCapable;
}
@Override
public boolean isLocalStorageActiveOnHost(HostVO host) {
return _storageMgr.isLocalStorageActiveOnHost(host);
}
@Override
public List<EventVO> listPendingEvents(int entryTime, int duration) {
Calendar calMin = Calendar.getInstance();