@Override 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(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 void execute() { try { _mgr.cleanupVMReservations(); SuccessResponse response = new SuccessResponse(getCommandName()); this.setResponseObject(response); } catch (Exception ex) { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to clean vm reservations"); } } }
@Override public List<CapacityVO> listTopConsumedResources(final ListCapacityCmd cmd) { final Integer capacityType = cmd.getType(); Long zoneId = cmd.getZoneId(); final Long podId = cmd.getPodId(); final Long clusterId = cmd.getClusterId(); final Boolean fetchLatest = cmd.getFetchLatest(); final List<SummedCapacity> summedCapacitiesAtZone = _capacityDao.listCapacitiesGroupedByLevelAndType(capacityType, zoneId, podId, clusterId, 1, cmd.getPageSizeVal()); if (summedCapacitiesAtZone != null) { summedCapacities.addAll(summedCapacitiesAtZone); final List<SummedCapacity> summedCapacitiesAtPod = _capacityDao.listCapacitiesGroupedByLevelAndType(capacityType, zoneId, podId, clusterId, 2, cmd.getPageSizeVal()); if (summedCapacitiesAtPod != null) { summedCapacities.addAll(summedCapacitiesAtPod); final List<SummedCapacity> summedCapacitiesAtCluster = _capacityDao.listCapacitiesGroupedByLevelAndType(capacityType, zoneId, podId, clusterId, 3, cmd.getPageSizeVal()); if (summedCapacitiesAtCluster != null) { summedCapacities.addAll(summedCapacitiesAtCluster); pageSize = Integer.valueOf(cmd.getPageSizeVal().toString()); } 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 (final SummedCapacity summedCapacity : summedCapacities) { final CapacityVO capacity = new CapacityVO(summedCapacity.getDataCenterId(), summedCapacity.getPodId(), summedCapacity.getClusterId(), summedCapacity.getCapacityType(),
@Override 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(); final Object id = cmd.getId(); final Object type = cmd.getType(); final Object keyword = cmd.getKeyword(); final Object name = cmd.getName(); final Long zoneId = _accountMgr.checkAccessAndSpecifyAuthority(CallContext.current().getCallingAccount(), null); if (id != null) { sc.addAnd("id", SearchCriteria.Op.EQ, id); } if (zoneId != null) { sc.addAnd("data_center_id", SearchCriteria.Op.EQ, zoneId); } if (keyword != null) { final SearchCriteria<AlertVO> ssc = _alertDao.createSearchCriteria(); ssc.addOr("subject", SearchCriteria.Op.LIKE, "%" + keyword + "%"); sc.addAnd("subject", SearchCriteria.Op.SC, ssc); } if (type != null) { sc.addAnd("type", SearchCriteria.Op.EQ, type); } if (name != null) { sc.addAnd("name", SearchCriteria.Op.EQ, name); } sc.addAnd("archived", SearchCriteria.Op.EQ, false); final Pair<List<AlertVO>, Integer> result = _alertDao.searchAndCount(sc, searchFilter); return new Pair<List<? extends Alert>, Integer>(result.first(), result.second()); }
@Override @DB public String uploadCertificate(final UploadCustomCertificateCmd cmd) { if (cmd.getPrivateKey() != null && cmd.getAlias() != null) { throw new InvalidParameterValueException("Can't change the alias for private key certification"); if (cmd.getPrivateKey() == null) { if (cmd.getAlias() == null) { throw new InvalidParameterValueException("alias can't be empty, if it's a certification chain"); if (cmd.getCertIndex() == null) { throw new InvalidParameterValueException("index can't be empty, if it's a certifciation chain"); final String certificate = cmd.getCertificate(); final String key = cmd.getPrivateKey(); if (cmd.getPrivateKey() != null && !_ksMgr.validateCertificate(certificate, key, cmd.getDomainSuffix())) { throw new InvalidParameterValueException("Failed to pass certificate validation check"); if (cmd.getPrivateKey() != null) { _ksMgr.saveCertificate(ConsoleProxyManager.CERTIFICATE_NAME, certificate, key, cmd.getDomainSuffix()); _ksMgr.saveCertificate(cmd.getAlias(), certificate, cmd.getCertIndex(), cmd.getDomainSuffix());
@Override public void execute() { List<? extends Capacity> result = null; if (getSortBy() != null) { result = _mgr.listTopConsumedResources(this); } else { result = _mgr.listCapacities(this); } ListResponse<CapacityResponse> response = new ListResponse<CapacityResponse>(); List<CapacityResponse> capacityResponses = _responseGenerator.createCapacityResponse(result, s_percentFormat); Collections.sort(capacityResponses, new Comparator<CapacityResponse>() { public int compare(CapacityResponse resp1, CapacityResponse resp2) { int res = resp1.getZoneName().compareTo(resp2.getZoneName()); if (res != 0) { return res; } else { return resp1.getCapacityType().compareTo(resp2.getCapacityType()); } } }); response.setResponses(capacityResponses); response.setResponseName(getCommandName()); this.setResponseObject(response); } }
@Override public void execute() { String result = _mgr.uploadCertificate(this); if (result != null) { CustomCertificateResponse response = new CustomCertificateResponse(); response.setResponseName(getCommandName()); response.setResultMessage(result); response.setObjectName("customcertificate"); this.setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to upload custom certificate"); } }
@Override public void execute() { if (ids == null && type == null && endDate == null) { throw new InvalidParameterValueException("either ids, type or enddate must be specified"); } else if (startDate != null && endDate == null) { throw new InvalidParameterValueException("enddate must be specified with startdate parameter"); } boolean result = _mgr.deleteAlerts(this); if (result) { SuccessResponse response = new SuccessResponse(getCommandName()); this.setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Unable to delete Alerts, one or more parameters has invalid values"); } } }
@Override public void execute() { if (ids == null && type == null && endDate == null) { throw new InvalidParameterValueException("either ids, type, startdate or enddate must be specified"); } else if (startDate != null && endDate == null) { throw new InvalidParameterValueException("enddate must be specified with startdate parameter"); } boolean result = _mgr.archiveAlerts(this); if (result) { SuccessResponse response = new SuccessResponse(getCommandName()); this.setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Unable to archive Alerts, one or more parameters has invalid values"); } } }
@Override public void execute() { Pair<List<? extends Alert>, Integer> result = _mgr.searchForAlerts(this); ListResponse<AlertResponse> response = new ListResponse<AlertResponse>(); List<AlertResponse> alertResponseList = new ArrayList<AlertResponse>(); for (Alert alert : result.first()) { AlertResponse alertResponse = new AlertResponse(); alertResponse.setId(alert.getUuid()); alertResponse.setAlertType(alert.getType()); alertResponse.setDescription(alert.getSubject()); alertResponse.setLastSent(alert.getLastSent()); alertResponse.setName(alert.getName()); alertResponse.setObjectName("alert"); alertResponseList.add(alertResponse); } response.setResponses(alertResponseList, result.second()); response.setResponseName(getCommandName()); this.setResponseObject(response); } }
@Override public List<CapacityVO> listCapacities(final ListCapacityCmd cmd) { final Integer capacityType = cmd.getType(); Long zoneId = cmd.getZoneId(); final Long podId = cmd.getPodId(); final Long clusterId = cmd.getClusterId(); final Boolean fetchLatest = cmd.getFetchLatest();