|
107 | 107 | import com.cloud.api.commands.ListRemoteAccessVpnsCmd; |
108 | 108 | import com.cloud.api.commands.ListRoutersCmd; |
109 | 109 | import com.cloud.api.commands.ListServiceOfferingsCmd; |
110 | | -import com.cloud.api.commands.ListSnapshotsCmd; |
111 | 110 | import com.cloud.api.commands.ListStoragePoolsCmd; |
112 | 111 | import com.cloud.api.commands.ListSystemVMsCmd; |
113 | 112 | import com.cloud.api.commands.ListTemplateOrIsoPermissionsCmd; |
|
218 | 217 | import com.cloud.storage.GuestOSCategoryVO; |
219 | 218 | import com.cloud.storage.GuestOSVO; |
220 | 219 | import com.cloud.storage.LaunchPermissionVO; |
221 | | -import com.cloud.storage.Snapshot; |
222 | | -import com.cloud.storage.Snapshot.Type; |
223 | | -import com.cloud.storage.SnapshotPolicyVO; |
224 | | -import com.cloud.storage.SnapshotVO; |
225 | 220 | import com.cloud.storage.Storage; |
226 | 221 | import com.cloud.storage.Storage.ImageFormat; |
227 | 222 | import com.cloud.storage.Storage.TemplateType; |
|
234 | 229 | import com.cloud.storage.UploadVO; |
235 | 230 | import com.cloud.storage.VMTemplateVO; |
236 | 231 | import com.cloud.storage.Volume; |
237 | | -import com.cloud.storage.Volume.VolumeType; |
238 | 232 | import com.cloud.storage.VolumeStats; |
239 | 233 | import com.cloud.storage.VolumeVO; |
240 | 234 | import com.cloud.storage.dao.DiskOfferingDao; |
241 | 235 | import com.cloud.storage.dao.GuestOSCategoryDao; |
242 | 236 | import com.cloud.storage.dao.GuestOSDao; |
243 | 237 | import com.cloud.storage.dao.LaunchPermissionDao; |
244 | | -import com.cloud.storage.dao.SnapshotDao; |
245 | | -import com.cloud.storage.dao.SnapshotPolicyDao; |
246 | 238 | import com.cloud.storage.dao.StoragePoolDao; |
247 | 239 | import com.cloud.storage.dao.StoragePoolHostDao; |
248 | 240 | import com.cloud.storage.dao.UploadDao; |
@@ -346,8 +338,6 @@ public class ManagementServerImpl implements ManagementServer { |
346 | 338 | private final UserAccountDao _userAccountDao; |
347 | 339 | private final AlertDao _alertDao; |
348 | 340 | private final CapacityDao _capacityDao; |
349 | | - private final SnapshotDao _snapshotDao; |
350 | | - private final SnapshotPolicyDao _snapshotPolicyDao; |
351 | 341 | private final GuestOSDao _guestOSDao; |
352 | 342 | private final GuestOSCategoryDao _guestOSCategoryDao; |
353 | 343 | private final StoragePoolDao _poolDao; |
@@ -443,8 +433,6 @@ protected ManagementServerImpl() { |
443 | 433 | _userAccountDao = locator.getDao(UserAccountDao.class); |
444 | 434 | _alertDao = locator.getDao(AlertDao.class); |
445 | 435 | _capacityDao = locator.getDao(CapacityDao.class); |
446 | | - _snapshotDao = locator.getDao(SnapshotDao.class); |
447 | | - _snapshotPolicyDao = locator.getDao(SnapshotPolicyDao.class); |
448 | 436 | _guestOSDao = locator.getDao(GuestOSDao.class); |
449 | 437 | _guestOSCategoryDao = locator.getDao(GuestOSCategoryDao.class); |
450 | 438 | _poolDao = locator.getDao(StoragePoolDao.class); |
@@ -4121,117 +4109,6 @@ public long getMemoryUsagebyHost(Long hostId) { |
4121 | 4109 | return mem; |
4122 | 4110 | } |
4123 | 4111 |
|
4124 | | - @Override |
4125 | | - public boolean destroyTemplateSnapshot(Long userId, long snapshotId) { |
4126 | | - return _vmMgr.destroyTemplateSnapshot(userId, snapshotId); |
4127 | | - } |
4128 | | - |
4129 | | - @Override |
4130 | | - public List<SnapshotVO> listSnapshots(ListSnapshotsCmd cmd) throws InvalidParameterValueException, PermissionDeniedException { |
4131 | | - Long volumeId = cmd.getVolumeId(); |
4132 | | - |
4133 | | - // Verify parameters |
4134 | | - if(volumeId != null){ |
4135 | | - VolumeVO volume = _volumeDao.findById(volumeId); |
4136 | | - if (volume == null) { |
4137 | | - throw new InvalidParameterValueException("unable to find a volume with id " + volumeId); |
4138 | | - } |
4139 | | - checkAccountPermissions(volume.getAccountId(), volume.getDomainId(), "volume", volumeId); |
4140 | | - } |
4141 | | - |
4142 | | - Account account = UserContext.current().getAccount(); |
4143 | | - Long domainId = cmd.getDomainId(); |
4144 | | - String accountName = cmd.getAccountName(); |
4145 | | - Long accountId = null; |
4146 | | - if ((account == null) || isAdmin(account.getType())) { |
4147 | | - if (domainId != null) { |
4148 | | - if ((account != null) && !_domainDao.isChildDomain(account.getDomainId(), domainId)) { |
4149 | | - throw new PermissionDeniedException("Unable to list templates for domain " + domainId + ", permission denied."); |
4150 | | - } |
4151 | | - } else if ((account != null) && (account.getType() == Account.ACCOUNT_TYPE_DOMAIN_ADMIN)) { |
4152 | | - domainId = account.getDomainId(); |
4153 | | - } |
4154 | | - |
4155 | | - if (domainId != null && accountName != null) { |
4156 | | - Account userAccount = _accountDao.findActiveAccount(accountName, domainId); |
4157 | | - if (userAccount != null) { |
4158 | | - accountId = userAccount.getId(); |
4159 | | - } |
4160 | | - } |
4161 | | - } else { |
4162 | | - accountId = account.getId(); |
4163 | | - } |
4164 | | - |
4165 | | - Object name = cmd.getSnapshotName(); |
4166 | | - Object id = cmd.getId(); |
4167 | | - Object keyword = cmd.getKeyword(); |
4168 | | - Object snapshotTypeStr = cmd.getSnapshotType(); |
4169 | | - |
4170 | | - Filter searchFilter = new Filter(SnapshotVO.class, "created", false, cmd.getStartIndex(), cmd.getPageSizeVal()); |
4171 | | - SearchBuilder<SnapshotVO> sb = _snapshotDao.createSearchBuilder(); |
4172 | | - sb.and("status", sb.entity().getStatus(), SearchCriteria.Op.EQ); |
4173 | | - sb.and("volumeId", sb.entity().getVolumeId(), SearchCriteria.Op.EQ); |
4174 | | - sb.and("name", sb.entity().getName(), SearchCriteria.Op.LIKE); |
4175 | | - sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ); |
4176 | | - sb.and("accountId", sb.entity().getAccountId(), SearchCriteria.Op.EQ); |
4177 | | - sb.and("snapshotTypeEQ", sb.entity().getSnapshotType(), SearchCriteria.Op.EQ); |
4178 | | - sb.and("snapshotTypeNEQ", sb.entity().getSnapshotType(), SearchCriteria.Op.NEQ); |
4179 | | - |
4180 | | - if ((accountId == null) && (domainId != null)) { |
4181 | | - // if accountId isn't specified, we can do a domain match for the admin case |
4182 | | - SearchBuilder<AccountVO> accountSearch = _accountDao.createSearchBuilder(); |
4183 | | - sb.join("accountSearch", accountSearch, sb.entity().getAccountId(), accountSearch.entity().getId(), JoinType.INNER); |
4184 | | - |
4185 | | - SearchBuilder<DomainVO> domainSearch = _domainDao.createSearchBuilder(); |
4186 | | - domainSearch.and("path", domainSearch.entity().getPath(), SearchCriteria.Op.LIKE); |
4187 | | - accountSearch.join("domainSearch", domainSearch, accountSearch.entity().getDomainId(), domainSearch.entity().getId(), JoinType.INNER); |
4188 | | - } |
4189 | | - |
4190 | | - SearchCriteria<SnapshotVO> sc = sb.create(); |
4191 | | - |
4192 | | - sc.setParameters("status", Snapshot.Status.BackedUp); |
4193 | | - |
4194 | | - if (volumeId != null) { |
4195 | | - sc.setParameters("volumeId", volumeId); |
4196 | | - } |
4197 | | - |
4198 | | - if (name != null) { |
4199 | | - sc.setParameters("name", "%" + name + "%"); |
4200 | | - } |
4201 | | - |
4202 | | - if (id != null) { |
4203 | | - sc.setParameters("id", id); |
4204 | | - } |
4205 | | - |
4206 | | - if (keyword != null) { |
4207 | | - SearchCriteria<SnapshotVO> ssc = _snapshotDao.createSearchCriteria(); |
4208 | | - ssc.addOr("name", SearchCriteria.Op.LIKE, "%" + keyword + "%"); |
4209 | | - |
4210 | | - sc.addAnd("name", SearchCriteria.Op.SC, ssc); |
4211 | | - } |
4212 | | - |
4213 | | - if (accountId != null) { |
4214 | | - sc.setParameters("accountId", accountId); |
4215 | | - } else if (domainId != null) { |
4216 | | - DomainVO domain = _domainDao.findById(domainId); |
4217 | | - SearchCriteria<?> joinSearch = sc.getJoin("accountSearch"); |
4218 | | - joinSearch.setJoinParameters("domainSearch", "path", domain.getPath() + "%"); |
4219 | | - } |
4220 | | - |
4221 | | - if (snapshotTypeStr != null) { |
4222 | | - Type snapshotType = SnapshotVO.getSnapshotType((String)snapshotTypeStr); |
4223 | | - if (snapshotType == null) { |
4224 | | - throw new InvalidParameterValueException("Unsupported snapshot type " + snapshotTypeStr); |
4225 | | - } |
4226 | | - sc.setParameters("snapshotTypeEQ", snapshotType.ordinal()); |
4227 | | - } else { |
4228 | | - // Show only MANUAL and RECURRING snapshot types |
4229 | | - sc.setParameters("snapshotTypeNEQ", Snapshot.Type.TEMPLATE.ordinal()); |
4230 | | - } |
4231 | | - |
4232 | | - return _snapshotDao.search(sc, searchFilter); |
4233 | | - } |
4234 | | - |
4235 | 4112 | @Override |
4236 | 4113 | public DiskOfferingVO findDiskOfferingById(long diskOfferingId) { |
4237 | 4114 | return _diskOfferingDao.findById(diskOfferingId); |
@@ -5082,11 +4959,6 @@ public List<AsyncJobVO> searchForAsyncJobs(ListAsyncJobsCmd cmd) throws InvalidP |
5082 | 4959 | return _jobDao.search(sc, searchFilter); |
5083 | 4960 | } |
5084 | 4961 |
|
5085 | | - @Override |
5086 | | - public SnapshotPolicyVO findSnapshotPolicyById(Long policyId) { |
5087 | | - return _snapshotPolicyDao.findById(policyId); |
5088 | | - } |
5089 | | - |
5090 | 4962 | @Override |
5091 | 4963 | public boolean isChildDomain(Long parentId, Long childId) { |
5092 | 4964 | return _domainDao.isChildDomain(parentId, childId); |
@@ -5261,25 +5133,6 @@ public VirtualMachine stopSystemVm(long vmId) { |
5261 | 5133 | return stopSecondaryStorageVm(vmId, eventId); |
5262 | 5134 | } |
5263 | 5135 | } |
5264 | | - |
5265 | | - private void checkIfStoragePoolAvailable(Long id) throws StorageUnavailableException { |
5266 | | - //check if the sp is up before starting |
5267 | | - List<VolumeVO> rootVolList = _volumeDao.findByInstanceAndType(id, VolumeType.ROOT); |
5268 | | - if(rootVolList == null || rootVolList.size() == 0){ |
5269 | | - throw new StorageUnavailableException("Could not find the root disk for this vm to verify if the pool on which it exists is Up or not"); |
5270 | | - }else{ |
5271 | | - Long poolId = rootVolList.get(0).getPoolId();//each vm has 1 root vol |
5272 | | - StoragePoolVO sp = _poolDao.findById(poolId); |
5273 | | - if(sp == null){ |
5274 | | - throw new StorageUnavailableException("Could not find the pool for the root disk of vm"+id+", to confirm if it is Up or not"); |
5275 | | - }else{ |
5276 | | - //found pool |
5277 | | - if(!sp.getStatus().equals(com.cloud.host.Status.Up)){ |
5278 | | - throw new StorageUnavailableException("Could not start the vm; the associated storage pool is in:"+sp.getStatus().toString()+" state"); |
5279 | | - } |
5280 | | - } |
5281 | | - } |
5282 | | - } |
5283 | 5136 |
|
5284 | 5137 | @Override |
5285 | 5138 | public VMInstanceVO stopSystemVM(StopSystemVmCmd cmd) { |
@@ -5963,25 +5816,7 @@ public String[] getHypervisors(ListHypervisorsCmd cmd) { |
5963 | 5816 | return hypers.split(","); |
5964 | 5817 | } |
5965 | 5818 |
|
5966 | | - private Long checkAccountPermissions(long targetAccountId, long targetDomainId, String targetDesc, long targetId) throws ServerApiException { |
5967 | | - Long accountId = null; |
5968 | | - |
5969 | | - Account account = UserContext.current().getAccount(); |
5970 | | - if (account != null) { |
5971 | | - if (!isAdmin(account.getType())) { |
5972 | | - if (account.getId() != targetAccountId) { |
5973 | | - throw new ServerApiException(BaseCmd.PARAM_ERROR, "Unable to find a " + targetDesc + " with id " + targetId + " for this account"); |
5974 | | - } |
5975 | | - } else if (!_domainDao.isChildDomain(account.getDomainId(), targetDomainId)) { |
5976 | | - throw new ServerApiException(BaseCmd.PARAM_ERROR, "Unable to perform operation for " + targetDesc + " with id " + targetId + ", permission denied."); |
5977 | | - } |
5978 | | - accountId = account.getId(); |
5979 | | - } |
5980 | | - |
5981 | | - return accountId; |
5982 | | - } |
5983 | | - |
5984 | | - @Override |
| 5819 | + @Override |
5985 | 5820 | public List<RemoteAccessVpnVO> searchForRemoteAccessVpns(ListRemoteAccessVpnsCmd cmd) throws InvalidParameterValueException, |
5986 | 5821 | PermissionDeniedException { |
5987 | 5822 | // do some parameter validation |
|
0 commit comments