protected DistributionSetAssignmentResult assignDistributionSetWithMaintenanceWindowTimeForced(final long dsID, final String controllerId, final String maintenanceWindowSchedule, final String maintenanceWindowDuration, final String maintenanceWindowTimeZone) { return deploymentManagement.assignDistributionSet(dsID, Arrays.asList(new TargetWithActionType(controllerId, ActionType.TIMEFORCED, System.currentTimeMillis(), maintenanceWindowSchedule, maintenanceWindowDuration, maintenanceWindowTimeZone))); }
protected DistributionSetAssignmentResult assignDistributionSet(final DistributionSet pset, final List<Target> targets) { return deploymentManagement.assignDistributionSet(pset.getId(), targets.stream().map(Target::getTargetWithActionType).collect(Collectors.toList())); }
protected DistributionSetAssignmentResult assignDistributionSetWithMaintenanceWindowTimeForced(final long dsID, final String controllerId, final String maintenanceWindowSchedule, final String maintenanceWindowDuration, final String maintenanceWindowTimeZone) { return deploymentManagement.assignDistributionSet(dsID, Arrays.asList(new TargetWithActionType(controllerId, ActionType.TIMEFORCED, System.currentTimeMillis(), maintenanceWindowSchedule, maintenanceWindowDuration, maintenanceWindowTimeZone))); }
protected DistributionSetAssignmentResult assignDistributionSet(final DistributionSet pset, final List<Target> targets) { return deploymentManagement.assignDistributionSet(pset.getId(), targets.stream().map(Target::getTargetWithActionType).collect(Collectors.toList())); }
protected DistributionSetAssignmentResult assignDistributionSet(final long dsID, final String controllerId) { return deploymentManagement.assignDistributionSet(dsID, Arrays.asList( new TargetWithActionType(controllerId, ActionType.FORCED, RepositoryModelConstants.NO_FORCE_TIME))); }
protected DistributionSetAssignmentResult assignDistributionSet(final long dsID, final String controllerId) { return deploymentManagement.assignDistributionSet(dsID, Arrays.asList( new TargetWithActionType(controllerId, ActionType.FORCED, RepositoryModelConstants.NO_FORCE_TIME))); }
protected DistributionSetAssignmentResult assignDistributionSetTimeForced(final DistributionSet pset, final Target target) { return deploymentManagement.assignDistributionSet(pset.getId(), Arrays.asList( new TargetWithActionType(target.getControllerId(), ActionType.TIMEFORCED, System.currentTimeMillis()))); }
final String controllerId, final String maintenanceWindowSchedule, final String maintenanceWindowDuration, final String maintenanceWindowTimeZone) { return deploymentManagement.assignDistributionSet(dsID, Arrays.asList(new TargetWithActionType(controllerId, ActionType.FORCED, RepositoryModelConstants.NO_FORCE_TIME, maintenanceWindowSchedule, maintenanceWindowDuration,
protected DistributionSetAssignmentResult assignDistributionSetTimeForced(final DistributionSet pset, final Target target) { return deploymentManagement.assignDistributionSet(pset.getId(), Arrays.asList( new TargetWithActionType(target.getControllerId(), ActionType.TIMEFORCED, System.currentTimeMillis()))); }
/** * Runs one page of target assignments within a dedicated transaction * * @param targetFilterQuery * the target filter query * @param dsId * distribution set id to assign * @return count of targets */ private int runTransactionalAssignment(final TargetFilterQuery targetFilterQuery, final Long dsId) { final String actionMessage = String.format(ACTION_MESSAGE, targetFilterQuery.getName()); return transactionTemplate.execute(status -> { final List<TargetWithActionType> targets = getTargetsWithActionType(targetFilterQuery.getQuery(), dsId, PAGE_SIZE); final int count = targets.size(); if (count > 0) { deploymentManagement.assignDistributionSet(dsId, targets, actionMessage); } return count; }); }
/** * Runs one page of target assignments within a dedicated transaction * * @param targetFilterQuery * the target filter query * @param dsId * distribution set id to assign * @return count of targets */ private int runTransactionalAssignment(final TargetFilterQuery targetFilterQuery, final Long dsId) { final String actionMessage = String.format(ACTION_MESSAGE, targetFilterQuery.getName()); return transactionTemplate.execute(status -> { final List<TargetWithActionType> targets = getTargetsWithActionType(targetFilterQuery.getQuery(), dsId, PAGE_SIZE); final int count = targets.size(); if (count > 0) { deploymentManagement.assignDistributionSet(dsId, targets, actionMessage); } return count; }); }
private String saveAllAssignments() { final ActionType actionType = ActionType.FORCED; final long forcedTimeStamp = new Date().getTime(); final TargetBulkUpload targetBulkUpload = managementUIState.getTargetTableFilters().getBulkUpload(); final List<String> targetsList = targetBulkUpload.getTargetsCreated(); final Long dsSelected = (Long) comboBox.getValue(); if (!distributionSetManagement.get(dsSelected).isPresent()) { return i18n.getMessage("message.bulk.upload.assignment.failed"); } deploymentManagement.assignDistributionSet(targetBulkUpload.getDsNameAndVersion(), actionType, forcedTimeStamp, targetsList); return null; }
private String saveAllAssignments() { final ActionType actionType = ActionType.FORCED; final long forcedTimeStamp = new Date().getTime(); final TargetBulkUpload targetBulkUpload = managementUIState.getTargetTableFilters().getBulkUpload(); final List<String> targetsList = targetBulkUpload.getTargetsCreated(); final Long dsSelected = (Long) comboBox.getValue(); if (!distributionSetManagement.get(dsSelected).isPresent()) { return i18n.getMessage("message.bulk.upload.assignment.failed"); } deploymentManagement.assignDistributionSet(targetBulkUpload.getDsNameAndVersion(), actionType, forcedTimeStamp, targetsList); return null; }
@Override public ResponseEntity<MgmtTargetAssignmentResponseBody> createAssignedTarget( @PathVariable("distributionSetId") final Long distributionSetId, @RequestBody final List<MgmtTargetAssignmentRequestBody> assignments, @RequestParam(value = "offline", required = false) final boolean offline) { if (offline) { return ResponseEntity.ok(MgmtDistributionSetMapper .toResponse(this.deployManagament.offlineAssignedDistributionSet(distributionSetId, assignments .stream().map(MgmtTargetAssignmentRequestBody::getId).collect(Collectors.toList())))); } final DistributionSetAssignmentResult assignDistributionSet = this.deployManagament .assignDistributionSet(distributionSetId, assignments.stream().map(t -> { final MgmtMaintenanceWindowRequestBody maintenanceWindow = t.getMaintenanceWindow(); if (maintenanceWindow == null) { return new TargetWithActionType(t.getId(), MgmtRestModelMapper.convertActionType(t.getType()), t.getForcetime()); } final String cronSchedule = maintenanceWindow.getSchedule(); final String duration = maintenanceWindow.getDuration(); final String timezone = maintenanceWindow.getTimezone(); MaintenanceScheduleHelper.validateMaintenanceSchedule(cronSchedule, duration, timezone); return new TargetWithActionType(t.getId(), MgmtRestModelMapper.convertActionType(t.getType()), t.getForcetime(), cronSchedule, duration, timezone); }).collect(Collectors.toList())); return ResponseEntity.ok(MgmtDistributionSetMapper.toResponse(assignDistributionSet)); }
@Override public ResponseEntity<MgmtTargetAssignmentResponseBody> postAssignedDistributionSet( @PathVariable("targetId") final String targetId, @RequestBody final MgmtDistributionSetAssignment dsId, @RequestParam(value = "offline", required = false) final boolean offline) { if (offline) { return ResponseEntity.ok(MgmtDistributionSetMapper.toResponse( deploymentManagement.offlineAssignedDistributionSet(dsId.getId(), Arrays.asList(targetId)))); } findTargetWithExceptionIfNotFound(targetId); final MgmtMaintenanceWindowRequestBody maintenanceWindow = dsId.getMaintenanceWindow(); if (maintenanceWindow == null) { return ResponseEntity.ok(MgmtDistributionSetMapper.toResponse(this.deploymentManagement .assignDistributionSet(dsId.getId(), Arrays.asList(new TargetWithActionType(targetId, MgmtRestModelMapper.convertActionType(dsId.getType()), dsId.getForcetime()))))); } final String cronSchedule = maintenanceWindow.getSchedule(); final String duration = maintenanceWindow.getDuration(); final String timezone = maintenanceWindow.getTimezone(); MaintenanceScheduleHelper.validateMaintenanceSchedule(cronSchedule, duration, timezone); return ResponseEntity .ok(MgmtDistributionSetMapper.toResponse(this.deploymentManagement.assignDistributionSet(dsId.getId(), Arrays.asList(new TargetWithActionType(targetId, MgmtRestModelMapper.convertActionType(dsId.getType()), dsId.getForcetime(), cronSchedule, duration, timezone))))); }
.assignDistributionSet(set.getId(), Arrays.asList(target.getTargetWithActionType())).getActions() .get(0); final Action cancelAction = deploymentManagement.cancelAction(actionId);
@Test @Description("This base resource can be regularly polled by the controller on the provisiong target or device " + "in order to retrieve actions that need to be executed. In this case including a config pull request and a cancellation. " + "Note: as with deployments the cancel action has to be confirmed or rejected in order to move on to the next action.") @WithUser(tenantId = "TENANT_ID", authorities = "ROLE_CONTROLLER", allSpPermissions = true) public void getControllerBaseWithOpenDeploymentCancellation() throws Exception { final DistributionSet set = testdataFactory.createDistributionSet("one"); final DistributionSet setTwo = testdataFactory.createDistributionSet("two"); final Target target = targetManagement.create(entityFactory.target().create().controllerId(CONTROLLER_ID)); deploymentManagement.assignDistributionSet(set.getId(), Arrays.asList(target.getTargetWithActionType())); deploymentManagement.assignDistributionSet(setTwo.getId(), Arrays.asList(target.getTargetWithActionType())); mockMvc.perform(get(DdiRestConstants.BASE_V1_REQUEST_MAPPING + "/{controllerId}", tenantAware.getCurrentTenant(), target.getControllerId()).accept(MediaTypes.HAL_JSON_VALUE)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andExpect(content().contentType(MediaTypes.HAL_JSON_UTF8)) .andDo(this.document.document( pathParameters(parameterWithName("tenant").description(ApiModelPropertiesGeneric.TENANT), parameterWithName("controllerId").description(DdiApiModelProperties.CONTROLLER_ID)), responseFields( fieldWithPath("config.polling").description(DdiApiModelProperties.TARGET_POLL_TIME), fieldWithPath("config.polling.sleep").description(DdiApiModelProperties.TARGET_SLEEP), fieldWithPath("_links").description(DdiApiModelProperties.TARGET_OPEN_ACTIONS), fieldWithPath("_links.cancelAction").description(DdiApiModelProperties.DEPLOYMENT), fieldWithPath("_links.configData") .description(DdiApiModelProperties.TARGET_CONFIG_DATA)))); }
deploymentManagement.assignDistributionSet(set.getId(), Arrays.asList(target.getTargetWithActionType()));
@Test @Description("This base resource can be regularly polled by the controller on the provisiong target or device " + "in order to retrieve actions that need to be executed. In this case including a config pull request and a deployment. The resource supports Etag based modification " + "checks in order to save traffic.") @WithUser(tenantId = "TENANT_ID", authorities = "ROLE_CONTROLLER", allSpPermissions = true) public void getControllerBaseWithOpenDeplyoment() throws Exception { final DistributionSet set = testdataFactory.createDistributionSet("one"); final Target target = targetManagement.create(entityFactory.target().create().controllerId(CONTROLLER_ID)); deploymentManagement.assignDistributionSet(set.getId(), Arrays.asList(target.getTargetWithActionType())); mockMvc.perform(get(DdiRestConstants.BASE_V1_REQUEST_MAPPING + "/{controllerId}", tenantAware.getCurrentTenant(), target.getControllerId()).accept(MediaTypes.HAL_JSON_VALUE)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andExpect(content().contentType(MediaTypes.HAL_JSON_UTF8)) .andDo(this.document.document( pathParameters(parameterWithName("tenant").description(ApiModelPropertiesGeneric.TENANT), parameterWithName("controllerId").description(DdiApiModelProperties.CONTROLLER_ID)), responseFields( fieldWithPath("config.polling").description(DdiApiModelProperties.TARGET_POLL_TIME), fieldWithPath("config.polling.sleep").description(DdiApiModelProperties.TARGET_SLEEP), fieldWithPath("_links").description(DdiApiModelProperties.TARGET_OPEN_ACTIONS), fieldWithPath("_links.deploymentBase").description(DdiApiModelProperties.DEPLOYMENT), fieldWithPath("_links.configData") .description(DdiApiModelProperties.TARGET_CONFIG_DATA)))); }
.assignDistributionSet(set.getId(), Arrays.asList(target.getTargetWithActionType())).getActions() .get(0); final Action cancelAction = deploymentManagement.cancelAction(actionId);