You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ek...@apache.org on 2015/06/29 10:43:42 UTC
[04/15] git commit: updated refs/heads/master to 527d6ee
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4406e2c8/server/src/com/cloud/server/ManagementServerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java
index 85a561f..78f0f5a 100644
--- a/server/src/com/cloud/server/ManagementServerImpl.java
+++ b/server/src/com/cloud/server/ManagementServerImpl.java
@@ -39,9 +39,6 @@ import javax.crypto.spec.SecretKeySpec;
import javax.inject.Inject;
import javax.naming.ConfigurationException;
-import org.apache.commons.codec.binary.Base64;
-import org.apache.log4j.Logger;
-
import org.apache.cloudstack.acl.ControlledEntity;
import org.apache.cloudstack.affinity.AffinityGroupProcessor;
import org.apache.cloudstack.affinity.dao.AffinityGroupVMMapDao;
@@ -518,6 +515,8 @@ import org.apache.cloudstack.storage.datastore.db.ImageStoreVO;
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
import org.apache.cloudstack.utils.identity.ManagementServerNode;
+import org.apache.commons.codec.binary.Base64;
+import org.apache.log4j.Logger;
import com.cloud.agent.AgentManager;
import com.cloud.agent.api.GetVncPortAnswer;
@@ -806,7 +805,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
return _planners;
}
- public void setPlanners(List<DeploymentPlanner> planners) {
+ public void setPlanners(final List<DeploymentPlanner> planners) {
_planners = planners;
}
@@ -822,7 +821,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
return _affinityProcessors;
}
- public void setAffinityGroupProcessors(List<AffinityGroupProcessor> affinityProcessors) {
+ public void setAffinityGroupProcessors(final List<AffinityGroupProcessor> affinityProcessors) {
_affinityProcessors = affinityProcessors;
}
@@ -834,7 +833,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
return _userAuthenticators;
}
- public void setUserAuthenticators(List<UserAuthenticator> authenticators) {
+ public void setUserAuthenticators(final List<UserAuthenticator> authenticators) {
_userAuthenticators = authenticators;
}
@@ -842,7 +841,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
return _userPasswordEncoders;
}
- public void setUserPasswordEncoders(List<UserAuthenticator> encoders) {
+ public void setUserPasswordEncoders(final List<UserAuthenticator> encoders) {
_userPasswordEncoders = encoders;
}
@@ -850,17 +849,17 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
return hostAllocators;
}
- public void setHostAllocators(List<HostAllocator> hostAllocators) {
+ public void setHostAllocators(final List<HostAllocator> hostAllocators) {
this.hostAllocators = hostAllocators;
}
@Override
- public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
+ public boolean configure(final String name, final Map<String, Object> params) throws ConfigurationException {
_configs = _configDao.getConfiguration();
- String value = _configs.get("event.purge.interval");
- int cleanup = NumbersUtil.parseInt(value, 60 * 60 * 24); // 1 day.
+ final String value = _configs.get("event.purge.interval");
+ final int cleanup = NumbersUtil.parseInt(value, 60 * 60 * 24); // 1 day.
_purgeDelay = NumbersUtil.parseInt(_configs.get("event.purge.delay"), 0);
if (_purgeDelay != 0) {
@@ -868,15 +867,15 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
}
//Alerts purge configurations
- int alertPurgeInterval = NumbersUtil.parseInt(_configDao.getValue(Config.AlertPurgeInterval.key()), 60 * 60 * 24); // 1 day.
+ final int alertPurgeInterval = NumbersUtil.parseInt(_configDao.getValue(Config.AlertPurgeInterval.key()), 60 * 60 * 24); // 1 day.
_alertPurgeDelay = NumbersUtil.parseInt(_configDao.getValue(Config.AlertPurgeDelay.key()), 0);
if (_alertPurgeDelay != 0) {
_alertExecutor.scheduleAtFixedRate(new AlertPurgeTask(), alertPurgeInterval, alertPurgeInterval, TimeUnit.SECONDS);
}
- String[] availableIds = TimeZone.getAvailableIDs();
+ final String[] availableIds = TimeZone.getAvailableIDs();
_availableIdsMap = new HashMap<String, Boolean>(availableIds.length);
- for (String id : availableIds) {
+ for (final String id : availableIds) {
_availableIdsMap.put(id, true);
}
@@ -903,17 +902,17 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
@Override
public String generateRandomPassword() {
- Integer passwordLength = Integer.parseInt(_configDao.getValue("vm.password.length"));
+ final Integer passwordLength = Integer.parseInt(_configDao.getValue("vm.password.length"));
return PasswordGenerator.generateRandomPassword(passwordLength);
}
@Override
- public HostVO getHostBy(long hostId) {
+ public HostVO getHostBy(final long hostId) {
return _hostDao.findById(hostId);
}
@Override
- public DetailVO findDetail(long hostId, String name) {
+ public DetailVO findDetail(final long hostId, final String name) {
return _detailsDao.findDetail(hostId, name);
}
@@ -922,7 +921,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
return MacAddress.getMacAddress().toLong();
}
- protected void checkPortParameters(String publicPort, String privatePort, String privateIp, String proto) {
+ protected void checkPortParameters(final String publicPort, final String privatePort, final String privateIp, final String proto) {
if (!NetUtils.isValidPort(publicPort)) {
throw new InvalidParameterValueException("publicPort is an invalid value");
@@ -946,22 +945,22 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
}
@Override
- public boolean archiveEvents(ArchiveEventsCmd cmd) {
- Account caller = getCaller();
- List<Long> ids = cmd.getIds();
+ public boolean archiveEvents(final ArchiveEventsCmd cmd) {
+ final Account caller = getCaller();
+ final List<Long> ids = cmd.getIds();
boolean result = true;
List<Long> permittedAccountIds = new ArrayList<Long>();
if (_accountService.isNormalUser(caller.getId()) || caller.getType() == Account.ACCOUNT_TYPE_PROJECT) {
permittedAccountIds.add(caller.getId());
} else {
- DomainVO domain = _domainDao.findById(caller.getDomainId());
- List<Long> permittedDomainIds = _domainDao.getDomainChildrenIds(domain.getPath());
+ final DomainVO domain = _domainDao.findById(caller.getDomainId());
+ final List<Long> permittedDomainIds = _domainDao.getDomainChildrenIds(domain.getPath());
permittedAccountIds = _accountDao.getAccountIdsForDomains(permittedDomainIds);
}
- List<EventVO> events = _eventDao.listToArchiveOrDeleteEvents(ids, cmd.getType(), cmd.getStartDate(), cmd.getEndDate(), permittedAccountIds);
- ControlledEntity[] sameOwnerEvents = events.toArray(new ControlledEntity[events.size()]);
+ final List<EventVO> events = _eventDao.listToArchiveOrDeleteEvents(ids, cmd.getType(), cmd.getStartDate(), cmd.getEndDate(), permittedAccountIds);
+ final ControlledEntity[] sameOwnerEvents = events.toArray(new ControlledEntity[events.size()]);
_accountMgr.checkAccess(CallContext.current().getCallingAccount(), null, false, sameOwnerEvents);
if (ids != null && events.size() < ids.size()) {
@@ -973,38 +972,38 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
}
@Override
- public boolean deleteEvents(DeleteEventsCmd cmd) {
- Account caller = getCaller();
- List<Long> ids = cmd.getIds();
+ public boolean deleteEvents(final DeleteEventsCmd cmd) {
+ final Account caller = getCaller();
+ final List<Long> ids = cmd.getIds();
boolean result = true;
List<Long> permittedAccountIds = new ArrayList<Long>();
if (_accountMgr.isNormalUser(caller.getId()) || caller.getType() == Account.ACCOUNT_TYPE_PROJECT) {
permittedAccountIds.add(caller.getId());
} else {
- DomainVO domain = _domainDao.findById(caller.getDomainId());
- List<Long> permittedDomainIds = _domainDao.getDomainChildrenIds(domain.getPath());
+ final DomainVO domain = _domainDao.findById(caller.getDomainId());
+ final List<Long> permittedDomainIds = _domainDao.getDomainChildrenIds(domain.getPath());
permittedAccountIds = _accountDao.getAccountIdsForDomains(permittedDomainIds);
}
- List<EventVO> events = _eventDao.listToArchiveOrDeleteEvents(ids, cmd.getType(), cmd.getStartDate(), cmd.getEndDate(), permittedAccountIds);
- ControlledEntity[] sameOwnerEvents = events.toArray(new ControlledEntity[events.size()]);
+ final List<EventVO> events = _eventDao.listToArchiveOrDeleteEvents(ids, cmd.getType(), cmd.getStartDate(), cmd.getEndDate(), permittedAccountIds);
+ final ControlledEntity[] sameOwnerEvents = events.toArray(new ControlledEntity[events.size()]);
_accountMgr.checkAccess(CallContext.current().getCallingAccount(), null, false, sameOwnerEvents);
if (ids != null && events.size() < ids.size()) {
result = false;
return result;
}
- for (EventVO event : events) {
+ for (final EventVO event : events) {
_eventDao.remove(event.getId());
}
return result;
}
@Override
- public List<? extends Cluster> searchForClusters(long zoneId, Long startIndex, Long pageSizeVal, String hypervisorType) {
- Filter searchFilter = new Filter(ClusterVO.class, "id", true, startIndex, pageSizeVal);
- SearchCriteria<ClusterVO> sc = _clusterDao.createSearchCriteria();
+ public List<? extends Cluster> searchForClusters(long zoneId, final Long startIndex, final Long pageSizeVal, final String hypervisorType) {
+ final Filter searchFilter = new Filter(ClusterVO.class, "id", true, startIndex, pageSizeVal);
+ final SearchCriteria<ClusterVO> sc = _clusterDao.createSearchCriteria();
zoneId = _accountMgr.checkAccessAndSpecifyAuthority(CallContext.current().getCallingAccount(), zoneId);
@@ -1015,20 +1014,20 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
}
@Override
- public Pair<List<? extends Cluster>, Integer> searchForClusters(ListClustersCmd cmd) {
- Object id = cmd.getId();
- Object name = cmd.getClusterName();
- Object podId = cmd.getPodId();
+ public Pair<List<? extends Cluster>, Integer> searchForClusters(final ListClustersCmd cmd) {
+ final Object id = cmd.getId();
+ final Object name = cmd.getClusterName();
+ final Object podId = cmd.getPodId();
Long zoneId = cmd.getZoneId();
- Object hypervisorType = cmd.getHypervisorType();
- Object clusterType = cmd.getClusterType();
- Object allocationState = cmd.getAllocationState();
- String keyword = cmd.getKeyword();
+ final Object hypervisorType = cmd.getHypervisorType();
+ final Object clusterType = cmd.getClusterType();
+ final Object allocationState = cmd.getAllocationState();
+ final String keyword = cmd.getKeyword();
zoneId = _accountMgr.checkAccessAndSpecifyAuthority(CallContext.current().getCallingAccount(), zoneId);
- Filter searchFilter = new Filter(ClusterVO.class, "id", true, cmd.getStartIndex(), cmd.getPageSizeVal());
+ final Filter searchFilter = new Filter(ClusterVO.class, "id", true, cmd.getStartIndex(), cmd.getPageSizeVal());
- SearchBuilder<ClusterVO> sb = _clusterDao.createSearchBuilder();
+ final SearchBuilder<ClusterVO> sb = _clusterDao.createSearchBuilder();
sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);
sb.and("name", sb.entity().getName(), SearchCriteria.Op.LIKE);
sb.and("podId", sb.entity().getPodId(), SearchCriteria.Op.EQ);
@@ -1037,7 +1036,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
sb.and("clusterType", sb.entity().getClusterType(), SearchCriteria.Op.EQ);
sb.and("allocationState", sb.entity().getAllocationState(), SearchCriteria.Op.EQ);
- SearchCriteria<ClusterVO> sc = sb.create();
+ final SearchCriteria<ClusterVO> sc = sb.create();
if (id != null) {
sc.setParameters("id", id);
}
@@ -1067,38 +1066,38 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
}
if (keyword != null) {
- SearchCriteria<ClusterVO> ssc = _clusterDao.createSearchCriteria();
+ final SearchCriteria<ClusterVO> ssc = _clusterDao.createSearchCriteria();
ssc.addOr("name", SearchCriteria.Op.LIKE, "%" + keyword + "%");
ssc.addOr("hypervisorType", SearchCriteria.Op.LIKE, "%" + keyword + "%");
sc.addAnd("name", SearchCriteria.Op.SC, ssc);
}
- Pair<List<ClusterVO>, Integer> result = _clusterDao.searchAndCount(sc, searchFilter);
+ final Pair<List<ClusterVO>, Integer> result = _clusterDao.searchAndCount(sc, searchFilter);
return new Pair<List<? extends Cluster>, Integer>(result.first(), result.second());
}
@Override
- public Pair<List<? extends Host>, Integer> searchForServers(ListHostsCmd cmd) {
+ public Pair<List<? extends Host>, Integer> searchForServers(final ListHostsCmd cmd) {
- Long zoneId = _accountMgr.checkAccessAndSpecifyAuthority(CallContext.current().getCallingAccount(), cmd.getZoneId());
- Object name = cmd.getHostName();
- Object type = cmd.getType();
- Object state = cmd.getState();
- Object pod = cmd.getPodId();
- Object cluster = cmd.getClusterId();
- Object id = cmd.getId();
- Object keyword = cmd.getKeyword();
- Object resourceState = cmd.getResourceState();
- Object haHosts = cmd.getHaHost();
+ final Long zoneId = _accountMgr.checkAccessAndSpecifyAuthority(CallContext.current().getCallingAccount(), cmd.getZoneId());
+ final Object name = cmd.getHostName();
+ final Object type = cmd.getType();
+ final Object state = cmd.getState();
+ final Object pod = cmd.getPodId();
+ final Object cluster = cmd.getClusterId();
+ final Object id = cmd.getId();
+ final Object keyword = cmd.getKeyword();
+ final Object resourceState = cmd.getResourceState();
+ final Object haHosts = cmd.getHaHost();
- Pair<List<HostVO>, Integer> result = searchForServers(cmd.getStartIndex(), cmd.getPageSizeVal(), name, type, state, zoneId, pod, cluster, id, keyword, resourceState,
+ final Pair<List<HostVO>, Integer> result = searchForServers(cmd.getStartIndex(), cmd.getPageSizeVal(), name, type, state, zoneId, pod, cluster, id, keyword, resourceState,
haHosts, null, null);
return new Pair<List<? extends Host>, Integer>(result.first(), result.second());
}
@Override
- public Ternary<Pair<List<? extends Host>, Integer>, List<? extends Host>, Map<Host, Boolean>> listHostsForMigrationOfVM(Long vmId, Long startIndex, Long pageSize) {
- Account caller = getCaller();
+ public Ternary<Pair<List<? extends Host>, Integer>, List<? extends Host>, Map<Host, Boolean>> listHostsForMigrationOfVM(final Long vmId, final Long startIndex, final Long pageSize) {
+ final Account caller = getCaller();
if (!_accountMgr.isRootAdmin(caller.getId())) {
if (s_logger.isDebugEnabled()) {
s_logger.debug("Caller is not a root admin, permission denied to migrate the VM");
@@ -1106,9 +1105,9 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
throw new PermissionDeniedException("No permission to migrate VM, Only Root Admin can migrate a VM!");
}
- VMInstanceVO vm = _vmInstanceDao.findById(vmId);
+ final VMInstanceVO vm = _vmInstanceDao.findById(vmId);
if (vm == null) {
- InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find the VM with given id");
+ final InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find the VM with given id");
throw ex;
}
@@ -1116,7 +1115,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
if (s_logger.isDebugEnabled()) {
s_logger.debug("VM is not running, cannot migrate the vm" + vm);
}
- InvalidParameterValueException ex = new InvalidParameterValueException("VM is not Running, cannot " + "migrate the vm with specified id");
+ final InvalidParameterValueException ex = new InvalidParameterValueException("VM is not Running, cannot " + "migrate the vm with specified id");
ex.addProxyObject(vm.getUuid(), "vmId");
throw ex;
}
@@ -1141,13 +1140,13 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
throw new InvalidParameterValueException("Unsupported Hypervisor Type for User VM migration, we support XenServer/VMware/KVM/Ovm/Hyperv/Ovm3 only");
}
- long srcHostId = vm.getHostId();
- Host srcHost = _hostDao.findById(srcHostId);
+ final long srcHostId = vm.getHostId();
+ final Host srcHost = _hostDao.findById(srcHostId);
if (srcHost == null) {
if (s_logger.isDebugEnabled()) {
s_logger.debug("Unable to find the host with id: " + srcHostId + " of this VM:" + vm);
}
- InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find the host (with specified id) of VM with specified id");
+ final InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find the host (with specified id) of VM with specified id");
ex.addProxyObject(String.valueOf(srcHostId), "hostId");
ex.addProxyObject(vm.getUuid(), "vmId");
throw ex;
@@ -1157,19 +1156,19 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
boolean canMigrateWithStorage = false;
if (vm.getType() == VirtualMachine.Type.User) {
- HypervisorCapabilitiesVO capabilities = _hypervisorCapabilitiesDao.findByHypervisorTypeAndVersion(srcHost.getHypervisorType(), srcHost.getHypervisorVersion());
+ final HypervisorCapabilitiesVO capabilities = _hypervisorCapabilitiesDao.findByHypervisorTypeAndVersion(srcHost.getHypervisorType(), srcHost.getHypervisorVersion());
if (capabilities != null) {
canMigrateWithStorage = capabilities.isStorageMotionSupported();
}
}
// Check if the vm is using any disks on local storage.
- VirtualMachineProfile vmProfile = new VirtualMachineProfileImpl(vm, null, _offeringDao.findById(vm.getId(), vm.getServiceOfferingId()), null, null);
- List<VolumeVO> volumes = _volumeDao.findCreatedByInstance(vmProfile.getId());
+ final VirtualMachineProfile vmProfile = new VirtualMachineProfileImpl(vm, null, _offeringDao.findById(vm.getId(), vm.getServiceOfferingId()), null, null);
+ final List<VolumeVO> volumes = _volumeDao.findCreatedByInstance(vmProfile.getId());
boolean usesLocal = false;
- for (VolumeVO volume : volumes) {
- DiskOfferingVO diskOffering = _diskOfferingDao.findById(volume.getDiskOfferingId());
- DiskProfile diskProfile = new DiskProfile(volume, diskOffering, vmProfile.getHypervisorType());
+ for (final VolumeVO volume : volumes) {
+ final DiskOfferingVO diskOffering = _diskOfferingDao.findById(volume.getDiskOfferingId());
+ final DiskProfile diskProfile = new DiskProfile(volume, diskOffering, vmProfile.getHypervisorType());
if (diskProfile.useLocalStorage()) {
usesLocal = true;
break;
@@ -1180,10 +1179,10 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
throw new InvalidParameterValueException("Unsupported operation, VM uses Local storage, cannot migrate");
}
- Type hostType = srcHost.getType();
+ final Type hostType = srcHost.getType();
Pair<List<HostVO>, Integer> allHostsPair = null;
List<HostVO> allHosts = null;
- Map<Host, Boolean> requiresStorageMotion = new HashMap<Host, Boolean>();
+ final Map<Host, Boolean> requiresStorageMotion = new HashMap<Host, Boolean>();
DataCenterDeployment plan = null;
if (canMigrateWithStorage) {
@@ -1191,12 +1190,12 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
srcHost.getHypervisorType(), srcHost.getHypervisorVersion());
allHosts = allHostsPair.first();
allHosts.remove(srcHost);
- for (VolumeVO volume : volumes) {
- Long volClusterId = _poolDao.findById(volume.getPoolId()).getClusterId();
+ for (final VolumeVO volume : volumes) {
+ final Long volClusterId = _poolDao.findById(volume.getPoolId()).getClusterId();
// only check for volume which are not in zone wide primary store, as only those may require storage motion
if (volClusterId != null) {
- for (Iterator<HostVO> iterator = allHosts.iterator(); iterator.hasNext();) {
- Host host = iterator.next();
+ for (final Iterator<HostVO> iterator = allHosts.iterator(); iterator.hasNext();) {
+ final Host host = iterator.next();
if (!host.getClusterId().equals(volClusterId) || usesLocal) {
if (hasSuitablePoolsForVolume(volume, host, vmProfile)) {
requiresStorageMotion.put(host, true);
@@ -1209,7 +1208,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
}
plan = new DataCenterDeployment(srcHost.getDataCenterId(), null, null, null, null, null);
} else {
- Long cluster = srcHost.getClusterId();
+ final Long cluster = srcHost.getClusterId();
if (s_logger.isDebugEnabled()) {
s_logger.debug("Searching for all hosts in cluster " + cluster + " for migrating VM " + vm);
}
@@ -1220,21 +1219,21 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
plan = new DataCenterDeployment(srcHost.getDataCenterId(), srcHost.getPodId(), srcHost.getClusterId(), null, null, null);
}
- Pair<List<? extends Host>, Integer> otherHosts = new Pair<List<? extends Host>, Integer>(allHosts, new Integer(allHosts.size()));
+ final Pair<List<? extends Host>, Integer> otherHosts = new Pair<List<? extends Host>, Integer>(allHosts, new Integer(allHosts.size()));
List<Host> suitableHosts = new ArrayList<Host>();
- ExcludeList excludes = new ExcludeList();
+ final ExcludeList excludes = new ExcludeList();
excludes.addHost(srcHostId);
// call affinitygroup chain
- long vmGroupCount = _affinityGroupVMMapDao.countAffinityGroupsForVm(vm.getId());
+ final long vmGroupCount = _affinityGroupVMMapDao.countAffinityGroupsForVm(vm.getId());
if (vmGroupCount > 0) {
- for (AffinityGroupProcessor processor : _affinityProcessors) {
+ for (final AffinityGroupProcessor processor : _affinityProcessors) {
processor.process(vmProfile, plan, excludes);
}
}
- for (HostAllocator allocator : hostAllocators) {
+ for (final HostAllocator allocator : hostAllocators) {
if (canMigrateWithStorage) {
suitableHosts = allocator.allocateTo(vmProfile, plan, Host.Type.Routing, excludes, allHosts, HostAllocator.RETURN_UPTO_ALL, false);
} else {
@@ -1257,14 +1256,14 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
return new Ternary<Pair<List<? extends Host>, Integer>, List<? extends Host>, Map<Host, Boolean>>(otherHosts, suitableHosts, requiresStorageMotion);
}
- private boolean hasSuitablePoolsForVolume(VolumeVO volume, Host host, VirtualMachineProfile vmProfile) {
- DiskOfferingVO diskOffering = _diskOfferingDao.findById(volume.getDiskOfferingId());
- DiskProfile diskProfile = new DiskProfile(volume, diskOffering, vmProfile.getHypervisorType());
- DataCenterDeployment plan = new DataCenterDeployment(host.getDataCenterId(), host.getPodId(), host.getClusterId(), host.getId(), null, null);
- ExcludeList avoid = new ExcludeList();
+ private boolean hasSuitablePoolsForVolume(final VolumeVO volume, final Host host, final VirtualMachineProfile vmProfile) {
+ final DiskOfferingVO diskOffering = _diskOfferingDao.findById(volume.getDiskOfferingId());
+ final DiskProfile diskProfile = new DiskProfile(volume, diskOffering, vmProfile.getHypervisorType());
+ final DataCenterDeployment plan = new DataCenterDeployment(host.getDataCenterId(), host.getPodId(), host.getClusterId(), host.getId(), null, null);
+ final ExcludeList avoid = new ExcludeList();
- for (StoragePoolAllocator allocator : _storagePoolAllocators) {
- List<StoragePool> poolList = allocator.allocateToPool(diskProfile, vmProfile, plan, avoid, 1);
+ for (final StoragePoolAllocator allocator : _storagePoolAllocators) {
+ final List<StoragePool> poolList = allocator.allocateToPool(diskProfile, vmProfile, plan, avoid, 1);
if (poolList != null && !poolList.isEmpty()) {
return true;
}
@@ -1274,8 +1273,8 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
}
@Override
- public Pair<List<? extends StoragePool>, List<? extends StoragePool>> listStoragePoolsForMigrationOfVolume(Long volumeId) {
- Account caller = getCaller();
+ public Pair<List<? extends StoragePool>, List<? extends StoragePool>> listStoragePoolsForMigrationOfVolume(final Long volumeId) {
+ final Account caller = getCaller();
if (!_accountMgr.isRootAdmin(caller.getId())) {
if (s_logger.isDebugEnabled()) {
s_logger.debug("Caller is not a root admin, permission denied to migrate the volume");
@@ -1283,16 +1282,16 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
throw new PermissionDeniedException("No permission to migrate volume, only root admin can migrate a volume");
}
- VolumeVO volume = _volumeDao.findById(volumeId);
+ final VolumeVO volume = _volumeDao.findById(volumeId);
if (volume == null) {
- InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find volume with" + " specified id.");
+ final InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find volume with" + " specified id.");
ex.addProxyObject(volumeId.toString(), "volumeId");
throw ex;
}
// Volume must be attached to an instance for live migration.
- List<StoragePool> allPools = new ArrayList<StoragePool>();
- List<StoragePool> suitablePools = new ArrayList<StoragePool>();
+ final List<StoragePool> allPools = new ArrayList<StoragePool>();
+ final List<StoragePool> suitablePools = new ArrayList<StoragePool>();
// Volume must be in Ready state to be migrated.
if (!Volume.State.Ready.equals(volume.getState())) {
@@ -1305,7 +1304,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
return new Pair<List<? extends StoragePool>, List<? extends StoragePool>>(allPools, suitablePools);
}
- Long instanceId = volume.getInstanceId();
+ final Long instanceId = volume.getInstanceId();
VMInstanceVO vm = null;
if (instanceId != null) {
vm = _vmInstanceDao.findById(instanceId);
@@ -1319,9 +1318,9 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
s_logger.info("Volume " + volume + " is attached to any running vm. Looking for storage pools in the " + "cluster to which this volumes can be migrated.");
boolean storageMotionSupported = false;
// Check if the underlying hypervisor supports storage motion.
- Long hostId = vm.getHostId();
+ final Long hostId = vm.getHostId();
if (hostId != null) {
- HostVO host = _hostDao.findById(hostId);
+ final HostVO host = _hostDao.findById(hostId);
HypervisorCapabilitiesVO capabilities = null;
if (host != null) {
capabilities = _hypervisorCapabilitiesDao.findByHypervisorTypeAndVersion(host.getHypervisorType(), host.getHypervisorVersion());
@@ -1343,7 +1342,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
}
// Source pool of the volume.
- StoragePoolVO srcVolumePool = _poolDao.findById(volume.getPoolId());
+ final StoragePoolVO srcVolumePool = _poolDao.findById(volume.getPoolId());
// Get all the pools available. Only shared pools are considered because only a volume on a shared pools
// can be live migrated while the virtual machine stays on the same host.
List<StoragePoolVO> storagePools = null;
@@ -1354,7 +1353,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
}
storagePools.remove(srcVolumePool);
- for (StoragePoolVO pool : storagePools) {
+ for (final StoragePoolVO pool : storagePools) {
if (pool.isShared()) {
allPools.add((StoragePool)dataStoreMgr.getPrimaryDataStore(pool.getId()));
}
@@ -1362,19 +1361,19 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
// Get all the suitable pools.
// Exclude the current pool from the list of pools to which the volume can be migrated.
- ExcludeList avoid = new ExcludeList();
+ final ExcludeList avoid = new ExcludeList();
avoid.addPool(srcVolumePool.getId());
// Volume stays in the same cluster after migration.
- DataCenterDeployment plan = new DataCenterDeployment(volume.getDataCenterId(), srcVolumePool.getPodId(), srcVolumePool.getClusterId(), null, null, null);
- VirtualMachineProfile profile = new VirtualMachineProfileImpl(vm);
+ final DataCenterDeployment plan = new DataCenterDeployment(volume.getDataCenterId(), srcVolumePool.getPodId(), srcVolumePool.getClusterId(), null, null, null);
+ final VirtualMachineProfile profile = new VirtualMachineProfileImpl(vm);
- DiskOfferingVO diskOffering = _diskOfferingDao.findById(volume.getDiskOfferingId());
- DiskProfile diskProfile = new DiskProfile(volume, diskOffering, profile.getHypervisorType());
+ final DiskOfferingVO diskOffering = _diskOfferingDao.findById(volume.getDiskOfferingId());
+ final DiskProfile diskProfile = new DiskProfile(volume, diskOffering, profile.getHypervisorType());
// Call the storage pool allocator to find the list of storage pools.
- for (StoragePoolAllocator allocator : _storagePoolAllocators) {
- List<StoragePool> pools = allocator.allocateToPool(diskProfile, profile, plan, avoid, StoragePoolAllocator.RETURN_UPTO_ALL);
+ for (final StoragePoolAllocator allocator : _storagePoolAllocators) {
+ final List<StoragePool> pools = allocator.allocateToPool(diskProfile, profile, plan, avoid, StoragePoolAllocator.RETURN_UPTO_ALL);
if (pools != null && !pools.isEmpty()) {
suitablePools.addAll(pools);
break;
@@ -1384,11 +1383,11 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
return new Pair<List<? extends StoragePool>, List<? extends StoragePool>>(allPools, suitablePools);
}
- private Pair<List<HostVO>, Integer> searchForServers(Long startIndex, Long pageSize, Object name, Object type, Object state, Object zone, Object pod, Object cluster,
- Object id, Object keyword, Object resourceState, Object haHosts, Object hypervisorType, Object hypervisorVersion) {
- Filter searchFilter = new Filter(HostVO.class, "id", Boolean.TRUE, startIndex, pageSize);
+ private Pair<List<HostVO>, Integer> searchForServers(final Long startIndex, final Long pageSize, final Object name, final Object type, final Object state, final Object zone, final Object pod, final Object cluster,
+ final Object id, final Object keyword, final Object resourceState, final Object haHosts, final Object hypervisorType, final Object hypervisorVersion) {
+ final Filter searchFilter = new Filter(HostVO.class, "id", Boolean.TRUE, startIndex, pageSize);
- SearchBuilder<HostVO> sb = _hostDao.createSearchBuilder();
+ final SearchBuilder<HostVO> sb = _hostDao.createSearchBuilder();
sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);
sb.and("name", sb.entity().getName(), SearchCriteria.Op.LIKE);
sb.and("type", sb.entity().getType(), SearchCriteria.Op.LIKE);
@@ -1400,7 +1399,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
sb.and("hypervisorType", sb.entity().getHypervisorType(), SearchCriteria.Op.EQ);
sb.and("hypervisorVersion", sb.entity().getHypervisorVersion(), SearchCriteria.Op.EQ);
- String haTag = _haMgr.getHaTag();
+ final String haTag = _haMgr.getHaTag();
SearchBuilder<HostTagVO> hostTagSearch = null;
if (haHosts != null && haTag != null && !haTag.isEmpty()) {
hostTagSearch = _hostTagsDao.createSearchBuilder();
@@ -1415,10 +1414,10 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
sb.join("hostTagSearch", hostTagSearch, sb.entity().getId(), hostTagSearch.entity().getHostId(), JoinBuilder.JoinType.LEFTOUTER);
}
- SearchCriteria<HostVO> sc = sb.create();
+ final SearchCriteria<HostVO> sc = sb.create();
if (keyword != null) {
- SearchCriteria<HostVO> ssc = _hostDao.createSearchCriteria();
+ final SearchCriteria<HostVO> ssc = _hostDao.createSearchCriteria();
ssc.addOr("name", SearchCriteria.Op.LIKE, "%" + keyword + "%");
ssc.addOr("status", SearchCriteria.Op.LIKE, "%" + keyword + "%");
ssc.addOr("type", SearchCriteria.Op.LIKE, "%" + keyword + "%");
@@ -1467,24 +1466,24 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
}
@Override
- public Pair<List<? extends Pod>, Integer> searchForPods(ListPodsByCmd cmd) {
- String podName = cmd.getPodName();
- Long id = cmd.getId();
+ public Pair<List<? extends Pod>, Integer> searchForPods(final ListPodsByCmd cmd) {
+ final String podName = cmd.getPodName();
+ final Long id = cmd.getId();
Long zoneId = cmd.getZoneId();
- Object keyword = cmd.getKeyword();
- Object allocationState = cmd.getAllocationState();
+ final Object keyword = cmd.getKeyword();
+ final Object allocationState = cmd.getAllocationState();
zoneId = _accountMgr.checkAccessAndSpecifyAuthority(CallContext.current().getCallingAccount(), zoneId);
- Filter searchFilter = new Filter(HostPodVO.class, "dataCenterId", true, cmd.getStartIndex(), cmd.getPageSizeVal());
- SearchBuilder<HostPodVO> sb = _hostPodDao.createSearchBuilder();
+ final Filter searchFilter = new Filter(HostPodVO.class, "dataCenterId", true, cmd.getStartIndex(), cmd.getPageSizeVal());
+ final SearchBuilder<HostPodVO> sb = _hostPodDao.createSearchBuilder();
sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);
sb.and("name", sb.entity().getName(), SearchCriteria.Op.LIKE);
sb.and("dataCenterId", sb.entity().getDataCenterId(), SearchCriteria.Op.EQ);
sb.and("allocationState", sb.entity().getAllocationState(), SearchCriteria.Op.EQ);
- SearchCriteria<HostPodVO> sc = sb.create();
+ final SearchCriteria<HostPodVO> sc = sb.create();
if (keyword != null) {
- SearchCriteria<HostPodVO> ssc = _hostPodDao.createSearchCriteria();
+ final SearchCriteria<HostPodVO> ssc = _hostPodDao.createSearchCriteria();
ssc.addOr("name", SearchCriteria.Op.LIKE, "%" + keyword + "%");
ssc.addOr("description", SearchCriteria.Op.LIKE, "%" + keyword + "%");
@@ -1507,32 +1506,32 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
sc.setParameters("allocationState", allocationState);
}
- Pair<List<HostPodVO>, Integer> result = _hostPodDao.searchAndCount(sc, searchFilter);
+ final Pair<List<HostPodVO>, Integer> result = _hostPodDao.searchAndCount(sc, searchFilter);
return new Pair<List<? extends Pod>, Integer>(result.first(), result.second());
}
@Override
- public Pair<List<? extends Vlan>, Integer> searchForVlans(ListVlanIpRangesCmd cmd) {
+ public Pair<List<? extends Vlan>, Integer> searchForVlans(final ListVlanIpRangesCmd cmd) {
// If an account name and domain ID are specified, look up the account
- String accountName = cmd.getAccountName();
- Long domainId = cmd.getDomainId();
+ final String accountName = cmd.getAccountName();
+ final Long domainId = cmd.getDomainId();
Long accountId = null;
- Long networkId = cmd.getNetworkId();
- Boolean forVirtual = cmd.getForVirtualNetwork();
+ final Long networkId = cmd.getNetworkId();
+ final Boolean forVirtual = cmd.getForVirtualNetwork();
String vlanType = null;
- Long projectId = cmd.getProjectId();
- Long physicalNetworkId = cmd.getPhysicalNetworkId();
+ final Long projectId = cmd.getProjectId();
+ final Long physicalNetworkId = cmd.getPhysicalNetworkId();
if (accountName != null && domainId != null) {
if (projectId != null) {
throw new InvalidParameterValueException("Account and projectId can't be specified together");
}
- Account account = _accountDao.findActiveAccount(accountName, domainId);
+ final Account account = _accountDao.findActiveAccount(accountName, domainId);
if (account == null) {
- InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find account " + accountName + " in specified domain");
+ final InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find account " + accountName + " in specified domain");
// Since we don't have a DomainVO object here, we directly set
// tablename to "domain".
- DomainVO domain = ApiDBUtils.findDomainById(domainId);
+ final DomainVO domain = ApiDBUtils.findDomainById(domainId);
String domainUuid = domainId.toString();
if (domain != null) {
domainUuid = domain.getUuid();
@@ -1554,24 +1553,24 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
// set project information
if (projectId != null) {
- Project project = _projectMgr.getProject(projectId);
+ final Project project = _projectMgr.getProject(projectId);
if (project == null) {
- InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find project by id " + projectId);
+ final InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find project by id " + projectId);
ex.addProxyObject(projectId.toString(), "projectId");
throw ex;
}
accountId = project.getProjectAccountId();
}
- Filter searchFilter = new Filter(VlanVO.class, "id", true, cmd.getStartIndex(), cmd.getPageSizeVal());
+ final Filter searchFilter = new Filter(VlanVO.class, "id", true, cmd.getStartIndex(), cmd.getPageSizeVal());
- Object id = cmd.getId();
- Object vlan = cmd.getVlan();
- Object dataCenterId = cmd.getZoneId();
- Object podId = cmd.getPodId();
- Object keyword = cmd.getKeyword();
+ final Object id = cmd.getId();
+ final Object vlan = cmd.getVlan();
+ final Object dataCenterId = cmd.getZoneId();
+ final Object podId = cmd.getPodId();
+ final Object keyword = cmd.getKeyword();
- SearchBuilder<VlanVO> sb = _vlanDao.createSearchBuilder();
+ final SearchBuilder<VlanVO> sb = _vlanDao.createSearchBuilder();
sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);
sb.and("vlan", sb.entity().getVlanTag(), SearchCriteria.Op.EQ);
sb.and("dataCenterId", sb.entity().getDataCenterId(), SearchCriteria.Op.EQ);
@@ -1581,20 +1580,20 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
sb.and("physicalNetworkId", sb.entity().getPhysicalNetworkId(), SearchCriteria.Op.EQ);
if (accountId != null) {
- SearchBuilder<AccountVlanMapVO> accountVlanMapSearch = _accountVlanMapDao.createSearchBuilder();
+ final SearchBuilder<AccountVlanMapVO> accountVlanMapSearch = _accountVlanMapDao.createSearchBuilder();
accountVlanMapSearch.and("accountId", accountVlanMapSearch.entity().getAccountId(), SearchCriteria.Op.EQ);
sb.join("accountVlanMapSearch", accountVlanMapSearch, sb.entity().getId(), accountVlanMapSearch.entity().getVlanDbId(), JoinBuilder.JoinType.INNER);
}
if (podId != null) {
- SearchBuilder<PodVlanMapVO> podVlanMapSearch = _podVlanMapDao.createSearchBuilder();
+ final SearchBuilder<PodVlanMapVO> podVlanMapSearch = _podVlanMapDao.createSearchBuilder();
podVlanMapSearch.and("podId", podVlanMapSearch.entity().getPodId(), SearchCriteria.Op.EQ);
sb.join("podVlanMapSearch", podVlanMapSearch, sb.entity().getId(), podVlanMapSearch.entity().getVlanDbId(), JoinBuilder.JoinType.INNER);
}
- SearchCriteria<VlanVO> sc = sb.create();
+ final SearchCriteria<VlanVO> sc = sb.create();
if (keyword != null) {
- SearchCriteria<VlanVO> ssc = _vlanDao.createSearchCriteria();
+ final SearchCriteria<VlanVO> ssc = _vlanDao.createSearchCriteria();
ssc.addOr("vlanId", SearchCriteria.Op.LIKE, "%" + keyword + "%");
ssc.addOr("ipRange", SearchCriteria.Op.LIKE, "%" + keyword + "%");
sc.addAnd("vlanId", SearchCriteria.Op.SC, ssc);
@@ -1631,22 +1630,22 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
}
}
- Pair<List<VlanVO>, Integer> result = _vlanDao.searchAndCount(sc, searchFilter);
+ final Pair<List<VlanVO>, Integer> result = _vlanDao.searchAndCount(sc, searchFilter);
return new Pair<List<? extends Vlan>, Integer>(result.first(), result.second());
}
@Override
- public Pair<List<? extends Configuration>, Integer> searchForConfigurations(ListCfgsByCmd cmd) {
- Filter searchFilter = new Filter(ConfigurationVO.class, "name", true, cmd.getStartIndex(), cmd.getPageSizeVal());
- SearchCriteria<ConfigurationVO> sc = _configDao.createSearchCriteria();
+ public Pair<List<? extends Configuration>, Integer> searchForConfigurations(final ListCfgsByCmd cmd) {
+ final Filter searchFilter = new Filter(ConfigurationVO.class, "name", true, cmd.getStartIndex(), cmd.getPageSizeVal());
+ final SearchCriteria<ConfigurationVO> sc = _configDao.createSearchCriteria();
- Object name = cmd.getConfigName();
- Object category = cmd.getCategory();
- Object keyword = cmd.getKeyword();
- Long zoneId = cmd.getZoneId();
- Long clusterId = cmd.getClusterId();
- Long storagepoolId = cmd.getStoragepoolId();
- Long accountId = cmd.getAccountId();
+ final Object name = cmd.getConfigName();
+ final Object category = cmd.getCategory();
+ final Object keyword = cmd.getKeyword();
+ final Long zoneId = cmd.getZoneId();
+ final Long clusterId = cmd.getClusterId();
+ final Long storagepoolId = cmd.getStoragepoolId();
+ final Long accountId = cmd.getAccountId();
String scope = null;
Long id = null;
int paramCountCheck = 0;
@@ -1677,7 +1676,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
}
if (keyword != null) {
- SearchCriteria<ConfigurationVO> ssc = _configDao.createSearchCriteria();
+ final SearchCriteria<ConfigurationVO> ssc = _configDao.createSearchCriteria();
ssc.addOr("name", SearchCriteria.Op.LIKE, "%" + keyword + "%");
ssc.addOr("instance", SearchCriteria.Op.LIKE, "%" + keyword + "%");
ssc.addOr("component", SearchCriteria.Op.LIKE, "%" + keyword + "%");
@@ -1704,15 +1703,15 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
sc.addAnd("scope", SearchCriteria.Op.EQ, scope);
}
- Pair<List<ConfigurationVO>, Integer> result = _configDao.searchAndCount(sc, searchFilter);
+ final Pair<List<ConfigurationVO>, Integer> result = _configDao.searchAndCount(sc, searchFilter);
if (scope != null && !scope.isEmpty()) {
// Populate values corresponding the resource id
- List<ConfigurationVO> configVOList = new ArrayList<ConfigurationVO>();
- for (ConfigurationVO param : result.first()) {
- ConfigurationVO configVo = _configDao.findByName(param.getName());
+ final List<ConfigurationVO> configVOList = new ArrayList<ConfigurationVO>();
+ for (final ConfigurationVO param : result.first()) {
+ final ConfigurationVO configVo = _configDao.findByName(param.getName());
if (configVo != null) {
- ConfigKey<?> key = _configDepot.get(param.getName());
+ final ConfigKey<?> key = _configDepot.get(param.getName());
if (key != null) {
configVo.setValue(key.valueIn(id).toString());
configVOList.add(configVo);
@@ -1731,23 +1730,23 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
}
@Override
- public Pair<List<? extends IpAddress>, Integer> searchForIPAddresses(ListPublicIpAddressesCmd cmd) {
- Object keyword = cmd.getKeyword();
- Long physicalNetworkId = cmd.getPhysicalNetworkId();
- Long associatedNetworkId = cmd.getAssociatedNetworkId();
- Long zone = cmd.getZoneId();
- String address = cmd.getIpAddress();
- Long vlan = cmd.getVlanId();
- Boolean forVirtualNetwork = cmd.isForVirtualNetwork();
- Boolean forLoadBalancing = cmd.isForLoadBalancing();
- Long ipId = cmd.getId();
- Boolean sourceNat = cmd.getIsSourceNat();
- Boolean staticNat = cmd.getIsStaticNat();
- Long vpcId = cmd.getVpcId();
- Boolean forDisplay = cmd.getDisplay();
- Map<String, String> tags = cmd.getTags();
-
- String state = cmd.getState();
+ public Pair<List<? extends IpAddress>, Integer> searchForIPAddresses(final ListPublicIpAddressesCmd cmd) {
+ final Object keyword = cmd.getKeyword();
+ final Long physicalNetworkId = cmd.getPhysicalNetworkId();
+ final Long associatedNetworkId = cmd.getAssociatedNetworkId();
+ final Long zone = cmd.getZoneId();
+ final String address = cmd.getIpAddress();
+ final Long vlan = cmd.getVlanId();
+ final Boolean forVirtualNetwork = cmd.isForVirtualNetwork();
+ final Boolean forLoadBalancing = cmd.isForLoadBalancing();
+ final Long ipId = cmd.getId();
+ final Boolean sourceNat = cmd.getIsSourceNat();
+ final Boolean staticNat = cmd.getIsStaticNat();
+ final Long vpcId = cmd.getVpcId();
+ final Boolean forDisplay = cmd.getDisplay();
+ final Map<String, String> tags = cmd.getTags();
+
+ final String state = cmd.getState();
Boolean isAllocated = cmd.isAllocatedOnly();
if (isAllocated == null) {
isAllocated = Boolean.TRUE;
@@ -1757,16 +1756,16 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
}
}
- Filter searchFilter = new Filter(IPAddressVO.class, "address", false, cmd.getStartIndex(), cmd.getPageSizeVal());
- SearchBuilder<IPAddressVO> sb = _publicIpAddressDao.createSearchBuilder();
+ final Filter searchFilter = new Filter(IPAddressVO.class, "address", false, cmd.getStartIndex(), cmd.getPageSizeVal());
+ final SearchBuilder<IPAddressVO> sb = _publicIpAddressDao.createSearchBuilder();
Long domainId = null;
Boolean isRecursive = null;
- List<Long> permittedAccounts = new ArrayList<Long>();
+ final List<Long> permittedAccounts = new ArrayList<Long>();
ListProjectResourcesCriteria listProjectResourcesCriteria = null;
if (isAllocated) {
- Account caller = getCaller();
+ final Account caller = getCaller();
- Ternary<Long, Boolean, ListProjectResourcesCriteria> domainIdRecursiveListProject = new Ternary<Long, Boolean, ListProjectResourcesCriteria>(
+ final Ternary<Long, Boolean, ListProjectResourcesCriteria> domainIdRecursiveListProject = new Ternary<Long, Boolean, ListProjectResourcesCriteria>(
cmd.getDomainId(), cmd.isRecursive(), null);
_accountMgr.buildACLSearchParameters(caller, cmd.getId(), cmd.getAccountName(), cmd.getProjectId(), permittedAccounts,
domainIdRecursiveListProject, cmd.listAll(), false);
@@ -1789,7 +1788,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
sb.and("display", sb.entity().isDisplay(), SearchCriteria.Op.EQ);
if (forLoadBalancing != null && forLoadBalancing) {
- SearchBuilder<LoadBalancerVO> lbSearch = _loadbalancerDao.createSearchBuilder();
+ final SearchBuilder<LoadBalancerVO> lbSearch = _loadbalancerDao.createSearchBuilder();
sb.join("lbSearch", lbSearch, sb.entity().getId(), lbSearch.entity().getSourceIpAddressId(), JoinType.INNER);
sb.groupBy(sb.entity().getId());
}
@@ -1799,7 +1798,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
}
if (tags != null && !tags.isEmpty()) {
- SearchBuilder<ResourceTagVO> tagSearch = _resourceTagDao.createSearchBuilder();
+ final SearchBuilder<ResourceTagVO> tagSearch = _resourceTagDao.createSearchBuilder();
for (int count = 0; count < tags.size(); count++) {
tagSearch.or().op("key" + String.valueOf(count), tagSearch.entity().getKey(), SearchCriteria.Op.EQ);
tagSearch.and("value" + String.valueOf(count), tagSearch.entity().getValue(), SearchCriteria.Op.EQ);
@@ -1810,12 +1809,12 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
sb.join("tagSearch", tagSearch, sb.entity().getId(), tagSearch.entity().getResourceId(), JoinBuilder.JoinType.INNER);
}
- SearchBuilder<VlanVO> vlanSearch = _vlanDao.createSearchBuilder();
+ final SearchBuilder<VlanVO> vlanSearch = _vlanDao.createSearchBuilder();
vlanSearch.and("vlanType", vlanSearch.entity().getVlanType(), SearchCriteria.Op.EQ);
sb.join("vlanSearch", vlanSearch, sb.entity().getVlanId(), vlanSearch.entity().getId(), JoinBuilder.JoinType.INNER);
boolean allocatedOnly = false;
- if ((isAllocated != null) && (isAllocated == true)) {
+ if (isAllocated != null && isAllocated == true) {
sb.and("allocated", sb.entity().getAllocatedTime(), SearchCriteria.Op.NNULL);
allocatedOnly = true;
}
@@ -1827,7 +1826,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
vlanType = VlanType.VirtualNetwork;
}
- SearchCriteria<IPAddressVO> sc = sb.create();
+ final SearchCriteria<IPAddressVO> sc = sb.create();
if (isAllocated) {
_accountMgr.buildACLSearchCriteria(sc, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria);
}
@@ -1837,7 +1836,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
if (tags != null && !tags.isEmpty()) {
int count = 0;
sc.setJoinParameters("tagSearch", "resourceType", ResourceObjectType.PublicIpAddress.toString());
- for (String key : tags.keySet()) {
+ for (final String key : tags.keySet()) {
sc.setJoinParameters("tagSearch", "key" + String.valueOf(count), key);
sc.setJoinParameters("tagSearch", "value" + String.valueOf(count), tags.get(key));
count++;
@@ -1892,19 +1891,19 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
sc.setParameters("state", state);
}
- Pair<List<IPAddressVO>, Integer> result = _publicIpAddressDao.searchAndCount(sc, searchFilter);
+ final Pair<List<IPAddressVO>, Integer> result = _publicIpAddressDao.searchAndCount(sc, searchFilter);
return new Pair<List<? extends IpAddress>, Integer>(result.first(), result.second());
}
@Override
- public Pair<List<? extends GuestOS>, Integer> listGuestOSByCriteria(ListGuestOsCmd cmd) {
- Filter searchFilter = new Filter(GuestOSVO.class, "displayName", true, cmd.getStartIndex(), cmd.getPageSizeVal());
- Long id = cmd.getId();
- Long osCategoryId = cmd.getOsCategoryId();
- String description = cmd.getDescription();
- String keyword = cmd.getKeyword();
+ public Pair<List<? extends GuestOS>, Integer> listGuestOSByCriteria(final ListGuestOsCmd cmd) {
+ final Filter searchFilter = new Filter(GuestOSVO.class, "displayName", true, cmd.getStartIndex(), cmd.getPageSizeVal());
+ final Long id = cmd.getId();
+ final Long osCategoryId = cmd.getOsCategoryId();
+ final String description = cmd.getDescription();
+ final String keyword = cmd.getKeyword();
- SearchCriteria<GuestOSVO> sc = _guestOSDao.createSearchCriteria();
+ final SearchCriteria<GuestOSVO> sc = _guestOSDao.createSearchCriteria();
if (id != null) {
sc.addAnd("id", SearchCriteria.Op.EQ, id);
@@ -1922,18 +1921,18 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
sc.addAnd("displayName", SearchCriteria.Op.LIKE, "%" + keyword + "%");
}
- Pair<List<GuestOSVO>, Integer> result = _guestOSDao.searchAndCount(sc, searchFilter);
+ final Pair<List<GuestOSVO>, Integer> result = _guestOSDao.searchAndCount(sc, searchFilter);
return new Pair<List<? extends GuestOS>, Integer>(result.first(), result.second());
}
@Override
- public Pair<List<? extends GuestOsCategory>, Integer> listGuestOSCategoriesByCriteria(ListGuestOsCategoriesCmd cmd) {
- Filter searchFilter = new Filter(GuestOSCategoryVO.class, "id", true, cmd.getStartIndex(), cmd.getPageSizeVal());
- Long id = cmd.getId();
- String name = cmd.getName();
- String keyword = cmd.getKeyword();
+ public Pair<List<? extends GuestOsCategory>, Integer> listGuestOSCategoriesByCriteria(final ListGuestOsCategoriesCmd cmd) {
+ final Filter searchFilter = new Filter(GuestOSCategoryVO.class, "id", true, cmd.getStartIndex(), cmd.getPageSizeVal());
+ final Long id = cmd.getId();
+ final String name = cmd.getName();
+ final String keyword = cmd.getKeyword();
- SearchCriteria<GuestOSCategoryVO> sc = _guestOSCategoryDao.createSearchCriteria();
+ final SearchCriteria<GuestOSCategoryVO> sc = _guestOSCategoryDao.createSearchCriteria();
if (id != null) {
sc.addAnd("id", SearchCriteria.Op.EQ, id);
@@ -1947,24 +1946,24 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
sc.addAnd("name", SearchCriteria.Op.LIKE, "%" + keyword + "%");
}
- Pair<List<GuestOSCategoryVO>, Integer> result = _guestOSCategoryDao.searchAndCount(sc, searchFilter);
+ final Pair<List<GuestOSCategoryVO>, Integer> result = _guestOSCategoryDao.searchAndCount(sc, searchFilter);
return new Pair<List<? extends GuestOsCategory>, Integer>(result.first(), result.second());
}
@Override
- public Pair<List<? extends GuestOSHypervisor>, Integer> listGuestOSMappingByCriteria(ListGuestOsMappingCmd cmd) {
- Filter searchFilter = new Filter(GuestOSHypervisorVO.class, "hypervisorType", true, cmd.getStartIndex(), cmd.getPageSizeVal());
- Long id = cmd.getId();
- Long osTypeId = cmd.getOsTypeId();
- String hypervisor = cmd.getHypervisor();
- String hypervisorVersion = cmd.getHypervisorVersion();
+ public Pair<List<? extends GuestOSHypervisor>, Integer> listGuestOSMappingByCriteria(final ListGuestOsMappingCmd cmd) {
+ final Filter searchFilter = new Filter(GuestOSHypervisorVO.class, "hypervisorType", true, cmd.getStartIndex(), cmd.getPageSizeVal());
+ final Long id = cmd.getId();
+ final Long osTypeId = cmd.getOsTypeId();
+ final String hypervisor = cmd.getHypervisor();
+ final String hypervisorVersion = cmd.getHypervisorVersion();
//throw exception if hypervisor name is not passed, but version is
if (hypervisorVersion != null && (hypervisor == null || hypervisor.isEmpty())) {
throw new InvalidParameterValueException("Hypervisor version parameter cannot be used without specifying a hypervisor : XenServer, KVM or VMware");
}
- SearchCriteria<GuestOSHypervisorVO> sc = _guestOSHypervisorDao.createSearchCriteria();
+ final SearchCriteria<GuestOSHypervisorVO> sc = _guestOSHypervisorDao.createSearchCriteria();
if (id != null) {
sc.addAnd("id", SearchCriteria.Op.EQ, id);
@@ -1982,32 +1981,32 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
sc.addAnd("hypervisorVersion", SearchCriteria.Op.EQ, hypervisorVersion);
}
- Pair<List<GuestOSHypervisorVO>, Integer> result = _guestOSHypervisorDao.searchAndCount(sc, searchFilter);
+ final Pair<List<GuestOSHypervisorVO>, Integer> result = _guestOSHypervisorDao.searchAndCount(sc, searchFilter);
return new Pair<List<? extends GuestOSHypervisor>, Integer>(result.first(), result.second());
}
@Override
@DB
@ActionEvent(eventType = EventTypes.EVENT_GUEST_OS_MAPPING_ADD, eventDescription = "Adding new guest OS to hypervisor name mapping", create = true)
- public GuestOSHypervisor addGuestOsMapping(AddGuestOsMappingCmd cmd) {
- Long osTypeId = cmd.getOsTypeId();
- String osStdName = cmd.getOsStdName();
- String hypervisor = cmd.getHypervisor();
- String hypervisorVersion = cmd.getHypervisorVersion();
- String osNameForHypervisor = cmd.getOsNameForHypervisor();
+ public GuestOSHypervisor addGuestOsMapping(final AddGuestOsMappingCmd cmd) {
+ final Long osTypeId = cmd.getOsTypeId();
+ final String osStdName = cmd.getOsStdName();
+ final String hypervisor = cmd.getHypervisor();
+ final String hypervisorVersion = cmd.getHypervisorVersion();
+ final String osNameForHypervisor = cmd.getOsNameForHypervisor();
GuestOS guestOs = null;
- if ((osTypeId == null) && (osStdName == null || osStdName.isEmpty())) {
+ if (osTypeId == null && (osStdName == null || osStdName.isEmpty())) {
throw new InvalidParameterValueException("Please specify either a guest OS name or UUID");
}
- HypervisorType hypervisorType = HypervisorType.getType(hypervisor);
+ final HypervisorType hypervisorType = HypervisorType.getType(hypervisor);
if (!(hypervisorType == HypervisorType.KVM || hypervisorType == HypervisorType.XenServer || hypervisorType == HypervisorType.VMware)) {
throw new InvalidParameterValueException("Please specify a valid hypervisor : XenServer, KVM or VMware");
}
- HypervisorCapabilitiesVO hypervisorCapabilities = _hypervisorCapabilitiesDao.findByHypervisorTypeAndVersion(hypervisorType, hypervisorVersion);
+ final HypervisorCapabilitiesVO hypervisorCapabilities = _hypervisorCapabilitiesDao.findByHypervisorTypeAndVersion(hypervisorType, hypervisorVersion);
if (hypervisorCapabilities == null) {
throw new InvalidParameterValueException("Please specify a valid hypervisor and supported version");
}
@@ -2024,13 +2023,13 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
throw new InvalidParameterValueException("Unable to find the guest OS by name or UUID");
}
//check for duplicates
- GuestOSHypervisorVO duplicate = _guestOSHypervisorDao.findByOsIdAndHypervisorAndUserDefined(guestOs.getId(), hypervisorType.toString(), hypervisorVersion, true);
+ final GuestOSHypervisorVO duplicate = _guestOSHypervisorDao.findByOsIdAndHypervisorAndUserDefined(guestOs.getId(), hypervisorType.toString(), hypervisorVersion, true);
if (duplicate != null) {
throw new InvalidParameterValueException("Mapping from hypervisor : " + hypervisorType.toString() + ", version : " + hypervisorVersion + " and guest OS : "
+ guestOs.getDisplayName() + " already exists!");
}
- GuestOSHypervisorVO guestOsMapping = new GuestOSHypervisorVO();
+ final GuestOSHypervisorVO guestOsMapping = new GuestOSHypervisorVO();
guestOsMapping.setGuestOsId(guestOs.getId());
guestOsMapping.setGuestOsName(osNameForHypervisor);
guestOsMapping.setHypervisorType(hypervisorType.toString());
@@ -2042,29 +2041,29 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
@Override
@ActionEvent(eventType = EventTypes.EVENT_GUEST_OS_MAPPING_ADD, eventDescription = "Adding a new guest OS to hypervisor name mapping", async = true)
- public GuestOSHypervisor getAddedGuestOsMapping(Long guestOsMappingId) {
+ public GuestOSHypervisor getAddedGuestOsMapping(final Long guestOsMappingId) {
return getGuestOsHypervisor(guestOsMappingId);
}
@Override
@DB
@ActionEvent(eventType = EventTypes.EVENT_GUEST_OS_ADD, eventDescription = "Adding new guest OS type", create = true)
- public GuestOS addGuestOs(AddGuestOsCmd cmd) {
- Long categoryId = cmd.getOsCategoryId();
- String displayName = cmd.getOsDisplayName();
- String name = cmd.getOsName();
+ public GuestOS addGuestOs(final AddGuestOsCmd cmd) {
+ final Long categoryId = cmd.getOsCategoryId();
+ final String displayName = cmd.getOsDisplayName();
+ final String name = cmd.getOsName();
- GuestOSCategoryVO guestOsCategory = ApiDBUtils.findGuestOsCategoryById(categoryId);
+ final GuestOSCategoryVO guestOsCategory = ApiDBUtils.findGuestOsCategoryById(categoryId);
if (guestOsCategory == null) {
throw new InvalidParameterValueException("Guest OS category not found. Please specify a valid Guest OS category");
}
- GuestOS guestOs = ApiDBUtils.findGuestOSByDisplayName(displayName);
+ final GuestOS guestOs = ApiDBUtils.findGuestOSByDisplayName(displayName);
if (guestOs != null) {
throw new InvalidParameterValueException("The specified Guest OS name : " + displayName + " already exists. Please specify a unique name");
}
- GuestOSVO guestOsVo = new GuestOSVO();
+ final GuestOSVO guestOsVo = new GuestOSVO();
guestOsVo.setCategoryId(categoryId.longValue());
guestOsVo.setDisplayName(displayName);
guestOsVo.setName(name);
@@ -2074,19 +2073,19 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
@Override
@ActionEvent(eventType = EventTypes.EVENT_GUEST_OS_ADD, eventDescription = "Adding a new guest OS type", async = true)
- public GuestOS getAddedGuestOs(Long guestOsId) {
+ public GuestOS getAddedGuestOs(final Long guestOsId) {
return getGuestOs(guestOsId);
}
@Override
@DB
@ActionEvent(eventType = EventTypes.EVENT_GUEST_OS_UPDATE, eventDescription = "updating guest OS type", async = true)
- public GuestOS updateGuestOs(UpdateGuestOsCmd cmd) {
- Long id = cmd.getId();
- String displayName = cmd.getOsDisplayName();
+ public GuestOS updateGuestOs(final UpdateGuestOsCmd cmd) {
+ final Long id = cmd.getId();
+ final String displayName = cmd.getOsDisplayName();
//check if guest OS exists
- GuestOS guestOsHandle = ApiDBUtils.findGuestOSById(id);
+ final GuestOS guestOsHandle = ApiDBUtils.findGuestOSById(id);
if (guestOsHandle == null) {
throw new InvalidParameterValueException("Guest OS not found. Please specify a valid ID for the Guest OS");
}
@@ -2101,11 +2100,11 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
}
//Check if another Guest OS by same name exists
- GuestOS duplicate = ApiDBUtils.findGuestOSByDisplayName(displayName);
+ final GuestOS duplicate = ApiDBUtils.findGuestOSByDisplayName(displayName);
if(duplicate != null) {
throw new InvalidParameterValueException("The specified Guest OS name : " + displayName + " already exists. Please specify a unique guest OS name");
}
- GuestOSVO guestOs = _guestOSDao.createForUpdate(id);
+ final GuestOSVO guestOs = _guestOSDao.createForUpdate(id);
guestOs.setDisplayName(displayName);
if (_guestOSDao.update(id, guestOs)) {
return _guestOSDao.findById(id);
@@ -2117,11 +2116,11 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
@Override
@DB
@ActionEvent(eventType = EventTypes.EVENT_GUEST_OS_REMOVE, eventDescription = "removing guest OS type", async = true)
- public boolean removeGuestOs(RemoveGuestOsCmd cmd) {
- Long id = cmd.getId();
+ public boolean removeGuestOs(final RemoveGuestOsCmd cmd) {
+ final Long id = cmd.getId();
//check if guest OS exists
- GuestOS guestOs = ApiDBUtils.findGuestOSById(id);
+ final GuestOS guestOs = ApiDBUtils.findGuestOSById(id);
if (guestOs == null) {
throw new InvalidParameterValueException("Guest OS not found. Please specify a valid ID for the Guest OS");
}
@@ -2136,12 +2135,12 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
@Override
@DB
@ActionEvent(eventType = EventTypes.EVENT_GUEST_OS_MAPPING_UPDATE, eventDescription = "updating guest OS mapping", async = true)
- public GuestOSHypervisor updateGuestOsMapping(UpdateGuestOsMappingCmd cmd) {
- Long id = cmd.getId();
- String osNameForHypervisor = cmd.getOsNameForHypervisor();
+ public GuestOSHypervisor updateGuestOsMapping(final UpdateGuestOsMappingCmd cmd) {
+ final Long id = cmd.getId();
+ final String osNameForHypervisor = cmd.getOsNameForHypervisor();
//check if mapping exists
- GuestOSHypervisor guestOsHypervisorHandle = _guestOSHypervisorDao.findById(id);
+ final GuestOSHypervisor guestOsHypervisorHandle = _guestOSHypervisorDao.findById(id);
if (guestOsHypervisorHandle == null) {
throw new InvalidParameterValueException("Guest OS Mapping not found. Please specify a valid ID for the Guest OS Mapping");
}
@@ -2150,7 +2149,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
throw new InvalidParameterValueException("Unable to modify system defined Guest OS mapping");
}
- GuestOSHypervisorVO guestOsHypervisor = _guestOSHypervisorDao.createForUpdate(id);
+ final GuestOSHypervisorVO guestOsHypervisor = _guestOSHypervisorDao.createForUpdate(id);
guestOsHypervisor.setGuestOsName(osNameForHypervisor);
if (_guestOSHypervisorDao.update(id, guestOsHypervisor)) {
return _guestOSHypervisorDao.findById(id);
@@ -2162,11 +2161,11 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
@Override
@DB
@ActionEvent(eventType = EventTypes.EVENT_GUEST_OS_MAPPING_REMOVE, eventDescription = "removing guest OS mapping", async = true)
- public boolean removeGuestOsMapping(RemoveGuestOsMappingCmd cmd) {
- Long id = cmd.getId();
+ public boolean removeGuestOsMapping(final RemoveGuestOsMappingCmd cmd) {
+ final Long id = cmd.getId();
//check if mapping exists
- GuestOSHypervisor guestOsHypervisorHandle = _guestOSHypervisorDao.findById(id);
+ final GuestOSHypervisor guestOsHypervisorHandle = _guestOSHypervisorDao.findById(id);
if (guestOsHypervisorHandle == null) {
throw new InvalidParameterValueException("Guest OS Mapping not found. Please specify a valid ID for the Guest OS Mapping");
}
@@ -2179,27 +2178,27 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
}
- protected ConsoleProxyInfo getConsoleProxyForVm(long dataCenterId, long userVmId) {
+ protected ConsoleProxyInfo getConsoleProxyForVm(final long dataCenterId, final long userVmId) {
return _consoleProxyMgr.assignProxy(dataCenterId, userVmId);
}
- private ConsoleProxyVO startConsoleProxy(long instanceId) {
+ private ConsoleProxyVO startConsoleProxy(final long instanceId) {
return _consoleProxyMgr.startProxy(instanceId, true);
}
- private ConsoleProxyVO stopConsoleProxy(VMInstanceVO systemVm, boolean isForced) throws ResourceUnavailableException, OperationTimedoutException, ConcurrentOperationException {
+ private ConsoleProxyVO stopConsoleProxy(final VMInstanceVO systemVm, final boolean isForced) throws ResourceUnavailableException, OperationTimedoutException, ConcurrentOperationException {
_itMgr.advanceStop(systemVm.getUuid(), isForced);
return _consoleProxyDao.findById(systemVm.getId());
}
- private ConsoleProxyVO rebootConsoleProxy(long instanceId) {
+ private ConsoleProxyVO rebootConsoleProxy(final long instanceId) {
_consoleProxyMgr.rebootProxy(instanceId);
return _consoleProxyDao.findById(instanceId);
}
- protected ConsoleProxyVO destroyConsoleProxy(long instanceId) {
- ConsoleProxyVO proxy = _consoleProxyDao.findById(instanceId);
+ protected ConsoleProxyVO destroyConsoleProxy(final long instanceId) {
+ final ConsoleProxyVO proxy = _consoleProxyDao.findById(instanceId);
if (_consoleProxyMgr.destroyProxy(instanceId)) {
return proxy;
@@ -2208,10 +2207,10 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
}
@Override
- public String getConsoleAccessUrlRoot(long vmId) {
- VMInstanceVO vm = _vmInstanceDao.findById(vmId);
+ public String getConsoleAccessUrlRoot(final long vmId) {
+ final VMInstanceVO vm = _vmInstanceDao.findById(vmId);
if (vm != null) {
- ConsoleProxyInfo proxy = getConsoleProxyForVm(vm.getDataCenterId(), vmId);
+ final ConsoleProxyInfo proxy = getConsoleProxyForVm(vm.getDataCenterId(), vmId);
if (proxy != null) {
return proxy.getProxyImageUrl();
}
@@ -2220,7 +2219,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
}
@Override
- public Pair<String, Integer> getVncPort(VirtualMachine vm) {
+ public Pair<String, Integer> getVncPort(final VirtualMachine vm) {
if (vm.getHostId() == null) {
s_logger.warn("VM " + vm.getHostName() + " does not have host, return -1 for its VNC port");
return new Pair<String, Integer>(null, -1);
@@ -2230,7 +2229,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
s_logger.trace("Trying to retrieve VNC port from agent about VM " + vm.getHostName());
}
- GetVncPortAnswer answer = (GetVncPortAnswer)_agentMgr.easySend(vm.getHostId(), new GetVncPortCommand(vm.getId(), vm.getInstanceName()));
+ final GetVncPortAnswer answer = (GetVncPortAnswer)_agentMgr.easySend(vm.getHostId(), new GetVncPortCommand(vm.getId(), vm.getInstanceName()));
if (answer != null && answer.getResult()) {
return new Pair<String, Integer>(answer.getAddress(), answer.getPort());
}
@@ -2240,7 +2239,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
@Override
@DB
- public DomainVO updateDomain(UpdateDomainCmd cmd) {
+ public DomainVO updateDomain(final UpdateDomainCmd cmd) {
final Long domainId = cmd.getId();
final String domainName = cmd.getDomainName();
final String networkDomain = cmd.getNetworkDomain();
@@ -2248,7 +2247,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
// check if domain exists in the system
final DomainVO domain = _domainDao.findById(domainId);
if (domain == null) {
- InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find domain with specified domain id");
+ final InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find domain with specified domain id");
ex.addProxyObject(domainId.toString(), "domainId");
throw ex;
} else if (domain.getParent() == null && domainName != null) {
@@ -2257,20 +2256,20 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
throw new InvalidParameterValueException("ROOT domain can not be edited with a new name");
}
- Account caller = getCaller();
+ final Account caller = getCaller();
_accountMgr.checkAccess(caller, domain);
// domain name is unique under the parent domain
if (domainName != null) {
- SearchCriteria<DomainVO> sc = _domainDao.createSearchCriteria();
+ final SearchCriteria<DomainVO> sc = _domainDao.createSearchCriteria();
sc.addAnd("name", SearchCriteria.Op.EQ, domainName);
sc.addAnd("parent", SearchCriteria.Op.EQ, domain.getParent());
- List<DomainVO> domains = _domainDao.search(sc, null);
+ final List<DomainVO> domains = _domainDao.search(sc, null);
- boolean sameDomain = (domains.size() == 1 && domains.get(0).getId() == domainId);
+ final boolean sameDomain = domains.size() == 1 && domains.get(0).getId() == domainId;
if (!domains.isEmpty() && !sameDomain) {
- InvalidParameterValueException ex = new InvalidParameterValueException("Failed to update specified domain id with name '" + domainName
+ final InvalidParameterValueException ex = new InvalidParameterValueException("Failed to update specified domain id with name '" + domainName
+ "' since it already exists in the system");
ex.addProxyObject(domain.getUuid(), "domainId");
throw ex;
@@ -2288,22 +2287,22 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
Transaction.execute(new TransactionCallbackNoReturn() {
@Override
- public void doInTransactionWithoutResult(TransactionStatus status) {
- if (domainName != null) {
- String updatedDomainPath = getUpdatedDomainPath(domain.getPath(), domainName);
- updateDomainChildren(domain, updatedDomainPath);
- domain.setName(domainName);
- domain.setPath(updatedDomainPath);
- }
+ public void doInTransactionWithoutResult(final TransactionStatus status) {
+ if (domainName != null) {
+ final String updatedDomainPath = getUpdatedDomainPath(domain.getPath(), domainName);
+ updateDomainChildren(domain, updatedDomainPath);
+ domain.setName(domainName);
+ domain.setPath(updatedDomainPath);
+ }
- if (networkDomain != null) {
- if (networkDomain.isEmpty()) {
- domain.setNetworkDomain(null);
- } else {
- domain.setNetworkDomain(networkDomain);
- }
- }
- _domainDao.update(domainId, domain);
+ if (networkDomain != null) {
+ if (networkDomain.isEmpty()) {
+ domain.setNetworkDomain(null);
+ } else {
+ domain.setNetworkDomain(networkDomain);
+ }
+ }
+ _domainDao.update(domainId, domain);
}
});
@@ -2311,37 +2310,37 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
}
- private String getUpdatedDomainPath(String oldPath, String newName) {
- String[] tokenizedPath = oldPath.split("/");
+ private String getUpdatedDomainPath(final String oldPath, final String newName) {
+ final String[] tokenizedPath = oldPath.split("/");
tokenizedPath[tokenizedPath.length - 1] = newName;
- StringBuilder finalPath = new StringBuilder();
- for (String token : tokenizedPath) {
+ final StringBuilder finalPath = new StringBuilder();
+ for (final String token : tokenizedPath) {
finalPath.append(token);
finalPath.append("/");
}
return finalPath.toString();
}
- private void updateDomainChildren(DomainVO domain, String updatedDomainPrefix) {
- List<DomainVO> domainChildren = _domainDao.findAllChildren(domain.getPath(), domain.getId());
+ private void updateDomainChildren(final DomainVO domain, final String updatedDomainPrefix) {
+ final List<DomainVO> domainChildren = _domainDao.findAllChildren(domain.getPath(), domain.getId());
// for each child, update the path
- for (DomainVO dom : domainChildren) {
+ for (final DomainVO dom : domainChildren) {
dom.setPath(dom.getPath().replaceFirst(domain.getPath(), updatedDomainPrefix));
_domainDao.update(dom.getId(), dom);
}
}
@Override
- public Pair<List<? extends Alert>, Integer> searchForAlerts(ListAlertsCmd cmd) {
- Filter searchFilter = new Filter(AlertVO.class, "lastSent", false, cmd.getStartIndex(), cmd.getPageSizeVal());
- SearchCriteria<AlertVO> sc = _alertDao.createSearchCriteria();
+ public Pair<List<? extends Alert>, Integer> searchForAlerts(final ListAlertsCmd cmd) {
+ final Filter searchFilter = new Filter(AlertVO.class, "lastSent", false, cmd.getStartIndex(), cmd.getPageSizeVal());
+ final SearchCriteria<AlertVO> sc = _alertDao.createSearchCriteria();
- Object id = cmd.getId();
- Object type = cmd.getType();
- Object keyword = cmd.getKeyword();
- Object name = cmd.getName();
+ final Object id = cmd.getId();
+ final Object type = cmd.getType();
+ final Object keyword = cmd.getKeyword();
+ final Object name = cmd.getName();
- Long zoneId = _accountMgr.checkAccessAndSpecifyAuthority(CallContext.current().getCallingAccount(), null);
+ final Long zoneId = _accountMgr.checkAccessAndSpecifyAuthority(CallContext.current().getCallingAccount(), null);
if (id != null) {
sc.addAnd("id", SearchCriteria.Op.EQ, id);
}
@@ -2350,7 +2349,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
}
if (keyword != null) {
- SearchCriteria<AlertVO> ssc = _alertDao.createSearchCriteria();
+ final SearchCriteria<AlertVO> ssc = _alertDao.createSearchCriteria();
ssc.addOr("subject", SearchCriteria.Op.LIKE, "%" + keyword + "%");
sc.addAnd("subject", SearchCriteria.Op.SC, ssc);
@@ -2365,32 +2364,32 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
}
sc.addAnd("archived", SearchCriteria.Op.EQ, false);
- Pair<List<AlertVO>, Integer> result = _alertDao.searchAndCount(sc, searchFilter);
+ final Pair<List<AlertVO>, Integer> result = _alertDao.searchAndCount(sc, searchFilter);
return new Pair<List<? extends Alert>, Integer>(result.first(), result.second());
}
@Override
- public boolean archiveAlerts(ArchiveAlertsCmd cmd) {
- Long zoneId = _accountMgr.checkAccessAndSpecifyAuthority(CallContext.current().getCallingAccount(), null);
- boolean result = _alertDao.archiveAlert(cmd.getIds(), cmd.getType(), cmd.getStartDate(), cmd.getEndDate(), zoneId);
+ public boolean archiveAlerts(final ArchiveAlertsCmd cmd) {
+ final Long zoneId = _accountMgr.checkAccessAndSpecifyAuthority(CallContext.current().getCallingAccount(), null);
+ final boolean result = _alertDao.archiveAlert(cmd.getIds(), cmd.getType(), cmd.getStartDate(), cmd.getEndDate(), zoneId);
return result;
}
@Override
- public boolean deleteAlerts(DeleteAlertsCmd cmd) {
- Long zoneId = _accountMgr.checkAccessAndSpecifyAuthority(CallContext.current().getCallingAccount(), null);
- boolean result = _alertDao.deleteAlert(cmd.getIds(), cmd.getType(), cmd.getStartDate(), cmd.getEndDate(), zoneId);
+ public boolean deleteAlerts(final DeleteAlertsCmd cmd) {
+ final Long zoneId = _accountMgr.checkAccessAndSpecifyAuthority(CallContext.current().getCallingAccount(), null);
+ final boolean result = _alertDao.deleteAlert(cmd.getIds(), cmd.getType(), cmd.getStartDate(), cmd.getEndDate(), zoneId);
return result;
}
@Override
- public List<CapacityVO> listTopConsumedResources(ListCapacityCmd cmd) {
+ public List<CapacityVO> listTopConsumedResources(final ListCapacityCmd cmd) {
- Integer capacityType = cmd.getType();
+ final Integer capacityType = cmd.getType();
Long zoneId = cmd.getZoneId();
- Long podId = cmd.getPodId();
- Long clusterId = cmd.getClusterId();
- Boolean fetchLatest = cmd.getFetchLatest();
+ final Long podId = cmd.getPodId();
+ final Long clusterId = cmd.getClusterId();
+ final Boolean fetchLatest = cmd.getFetchLatest();
if (clusterId != null) {
throw new InvalidParameterValueException("Currently clusterId param is not suppoerted");
@@ -2403,23 +2402,23 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
List<SummedCapacity> summedCapacities = new ArrayList<SummedCapacity>();
if (zoneId == null && podId == null) {// Group by Zone, capacity type
- List<SummedCapacity> summedCapacitiesAtZone = _capacityDao.listCapacitiesGroupedByLevelAndType(capacityType, zoneId, podId, clusterId, 1, cmd.getPageSizeVal());
+ final List<SummedCapacity> summedCapacitiesAtZone = _capacityDao.listCapacitiesGroupedByLevelAndType(capacityType, zoneId, podId, clusterId, 1, cmd.getPageSizeVal());
if (summedCapacitiesAtZone != null) {
summedCapacities.addAll(summedCapacitiesAtZone);
}
} else if (podId == null) {// Group by Pod, capacity type
- List<SummedCapacity> summedCapacitiesAtPod = _capacityDao.listCapacitiesGroupedByLevelAndType(capacityType, zoneId, podId, clusterId, 2, cmd.getPageSizeVal());
+ final List<SummedCapacity> summedCapacitiesAtPod = _capacityDao.listCapacitiesGroupedByLevelAndType(capacityType, zoneId, podId, clusterId, 2, cmd.getPageSizeVal());
if (summedCapacitiesAtPod != null) {
summedCapacities.addAll(summedCapacitiesAtPod);
}
} else { // Group by Cluster, capacity type
- List<SummedCapacity> summedCapacitiesAtCluster = _capacityDao.listCapacitiesGroupedByLevelAndType(capacityType, zoneId, podId, clusterId, 3, cmd.getPageSizeVal());
+ final List<SummedCapacity> summedCapacitiesAtCluster = _capacityDao.listCapacitiesGroupedByLevelAndType(capacityType, zoneId, podId, clusterId, 3, cmd.getPageSizeVal());
if (summedCapacitiesAtCluster != null) {
summedCapacities.addAll(summedCapacitiesAtCluster);
}
}
- List<SummedCapacity> summedCapacitiesForSecStorage = getSecStorageUsed(zoneId, capacityType);
+ final List<SummedCapacity> summedCapacitiesForSecStorage = getSecStorageUsed(zoneId, capacityType);
if (summedCapacitiesForSecStorage != null) {
summedCapacities.addAll(summedCapacitiesForSecStorage);
}
@@ -2427,7 +2426,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
// Sort Capacities
Collections.sort(summedCapacities, new Comparator<SummedCapacity>() {
@Override
- public int compare(SummedCapacity arg0, SummedCapacity arg1) {
+ public int compare(final SummedCapacity arg0, final SummedCapacity arg1) {
if (arg0.getPercentUsed() < arg1.getPercentUsed()) {
return 1;
} else if (arg0.getPercentUsed().equals(arg1.getPercentUsed())) {
@@ -2437,18 +2436,18 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
}
});
- List<CapacityVO> capacities = new ArrayList<CapacityVO>();
+ final List<CapacityVO> capacities = new ArrayList<CapacityVO>();
Integer pageSize = null;
try {
pageSize = Integer.valueOf(cmd.getPageSizeVal().toString());
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
throw new InvalidParameterValueException("pageSize " + cmd.getPageSizeVal() + " is out of Integer range is not supported for this call");
}
summedCapacities = summedCapacities.subList(0, summedCapacities.size() < cmd.getPageSizeVal() ? summedCapacities.size() : pageSize);
- for (SummedCapacity summedCapacity : summedCapacities) {
- CapacityVO capacity = new CapacityVO(summedCapacity.getDataCenterId(), summedCapacity.getPodId(), summedCapacity.getClusterId(), summedCapacity.getCapacityType(),
+ for (final SummedCapacity summedCapacity : summedCapacities) {
+ final CapacityVO capacity = new CapacityVO(summedCapacity.getDataCenterId(), summedCapacity.getPodId(), summedCapacity.getClusterId(), summedCapacity.getCapacityType(),
summedCapacity.getPercentUsed());
capacity.setUsedCapacity(summedCapacity.getUsedCapacity() + summedCapacity.getReservedCapacity());
capacity.setTotalCapacity(summedCapacity.getTotalCapacity());
@@ -2457,33 +2456,33 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
return capacities;
}
- List<SummedCapacity> getSecStorageUsed(Long zoneId, Integer capacityType) {
+
<TRUNCATED>