mirror of
https://github.com/apache/cloudstack.git
synced 2025-12-16 10:32:34 +01:00
Cleaning up some TODOs related to generating API command responses. Now that the ApiDBUtils class is available, setting things like domainNames is possible, so make use of that.
This commit is contained in:
parent
be6a4612a4
commit
e18898ae4d
@ -7,14 +7,19 @@ 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;
|
||||
@ -30,6 +35,7 @@ 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;
|
||||
@ -45,6 +51,7 @@ 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;
|
||||
@ -54,8 +61,11 @@ 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 {
|
||||
@ -64,10 +74,12 @@ public class ApiDBUtils {
|
||||
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;
|
||||
@ -84,6 +96,7 @@ public class ApiDBUtils {
|
||||
private static UserDao _userDao;
|
||||
private static UserStatisticsDao _userStatsDao;
|
||||
private static UserVmDao _userVmDao;
|
||||
private static VlanDao _vlanDao;
|
||||
private static VolumeDao _volumeDao;
|
||||
private static DataCenterDao _zoneDao;
|
||||
|
||||
@ -95,9 +108,11 @@ public class ApiDBUtils {
|
||||
_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);
|
||||
_accountVlanMapDao = locator.getDao(AccountVlanMapDao.class);
|
||||
_clusterDao = locator.getDao(ClusterDao.class);
|
||||
_diskOfferingDao = locator.getDao(DiskOfferingDao.class);
|
||||
_domainDao = locator.getDao(DomainDao.class);
|
||||
@ -114,6 +129,7 @@ public class ApiDBUtils {
|
||||
_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);
|
||||
|
||||
@ -125,6 +141,10 @@ public class ApiDBUtils {
|
||||
// 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
|
||||
@ -133,6 +153,10 @@ public class ApiDBUtils {
|
||||
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);
|
||||
}
|
||||
@ -173,6 +197,23 @@ public class ApiDBUtils {
|
||||
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);
|
||||
}
|
||||
@ -193,6 +234,10 @@ public class ApiDBUtils {
|
||||
return _statsCollector.getStoragePoolStats(id);
|
||||
}
|
||||
|
||||
public static VmStats getVmStatistics(long hostId) {
|
||||
return _statsCollector.getVmStats(hostId);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////
|
||||
// Dao methods //
|
||||
/////////////////////////////////////////////////////////////
|
||||
@ -278,6 +323,10 @@ public class ApiDBUtils {
|
||||
return _userVmDao.findById(vmId);
|
||||
}
|
||||
|
||||
public static VlanVO findVlanById(long vlanDbId) {
|
||||
return _vlanDao.findById(vlanDbId);
|
||||
}
|
||||
|
||||
public static VolumeVO findVolumeById(Long volumeId) {
|
||||
return _volumeDao.findById(volumeId);
|
||||
}
|
||||
@ -286,6 +335,15 @@ public class ApiDBUtils {
|
||||
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);
|
||||
@ -306,4 +364,14 @@ public class ApiDBUtils {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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()) {
|
||||
|
||||
@ -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());
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -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()) {
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -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());
|
||||
|
||||
@ -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();
|
||||
}
|
||||
|
||||
@ -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());
|
||||
|
||||
@ -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());
|
||||
|
||||
@ -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) + "%";
|
||||
|
||||
@ -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());
|
||||
}
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -142,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;
|
||||
|
||||
|
||||
/**
|
||||
@ -292,16 +291,8 @@ public interface ManagementServer {
|
||||
* @param hostId
|
||||
* @return StorageStats
|
||||
*/
|
||||
StorageStats getStorageStatistics(long hostId);
|
||||
StorageStats getStorageStatistics(long hostId);;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
@ -325,13 +316,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
|
||||
@ -449,22 +433,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.
|
||||
@ -652,13 +620,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
|
||||
@ -761,16 +722,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"
|
||||
@ -778,14 +729,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
|
||||
@ -930,12 +874,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
|
||||
@ -1241,13 +1179,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);
|
||||
|
||||
/**
|
||||
|
||||
@ -276,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;
|
||||
@ -540,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);
|
||||
@ -1911,17 +1905,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();
|
||||
@ -2983,16 +2966,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());
|
||||
@ -3408,11 +3381,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();
|
||||
@ -4114,22 +4082,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();
|
||||
@ -4257,17 +4209,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);
|
||||
@ -4979,7 +4920,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) {
|
||||
@ -5024,10 +4965,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);
|
||||
@ -6267,24 +6204,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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user