use of alien4cloud.model.deployment.Deployment in project alien4cloud by alien4cloud.
the class ApplicationVersionService method failIfAnyEnvironmentDeployed.
private void failIfAnyEnvironmentDeployed(ApplicationEnvironment[] relatedEnvironments) {
Usage[] usages = Arrays.stream(relatedEnvironments).map(environment -> {
Usage usage = null;
Deployment deployment = applicationEnvironmentService.getActiveDeployment(environment.getId());
if (deployment != null) {
String usageName = " App (" + deployment.getSourceName() + "), Env (" + environment.getName() + ")";
usage = new Usage(usageName, "Deployment", deployment.getId(), null);
}
return usage;
}).filter(Objects::nonNull).toArray(Usage[]::new);
if (ArrayUtils.isNotEmpty(usages)) {
throw new ReferencedResourceException("Application versions deployed cannot be updated", usages);
}
}
use of alien4cloud.model.deployment.Deployment in project alien4cloud by alien4cloud.
the class DeploymentRuntimeStateService method getDeploymentEvents.
/**
* Get events for a specific deployment from an environment
*
* @param applicationEnvironmentId The environment we want to get events from
* @param from The initial position of the events to get (based on time desc sorting)
* @param size The number of events to get.
* @return A result that contains all events.
*/
public GetMultipleDataResult<?> getDeploymentEvents(String applicationEnvironmentId, int from, int size) {
Deployment deployment = deploymentService.getActiveDeploymentOrFail(applicationEnvironmentId);
String index = alienMonitorDao.getIndexForType(AbstractMonitorEvent.class);
QueryHelper.ISearchQueryBuilderHelper searchQueryHelperBuilder = queryHelper.buildQuery().types(PaaSDeploymentStatusMonitorEvent.class, PaaSInstanceStateMonitorEvent.class, PaaSMessageMonitorEvent.class, PaaSInstancePersistentResourceMonitorEvent.class).filters(MapUtil.newHashMap(new String[] { "deploymentId" }, new String[][] { new String[] { deployment.getId() } })).prepareSearch(index).fieldSort("_timestamp", true);
return alienMonitorDao.search(searchQueryHelperBuilder, from, size);
}
use of alien4cloud.model.deployment.Deployment in project alien4cloud by alien4cloud.
the class DeploymentService method getCloudActiveDeploymentContexts.
public Map<String, PaaSTopologyDeploymentContext> getCloudActiveDeploymentContexts(String orchestratorId) {
Deployment[] deployments = getOrchestratorActiveDeployments(orchestratorId);
Map<String, PaaSTopologyDeploymentContext> activeDeploymentContexts = Maps.newHashMap();
for (Deployment deployment : deployments) {
DeploymentTopology topology = deploymentRuntimeStateService.getRuntimeTopology(deployment.getId());
activeDeploymentContexts.put(deployment.getOrchestratorDeploymentId(), deploymentContextService.buildTopologyDeploymentContext(null, deployment, deploymentTopologyService.getLocations(topology), topology));
}
return activeDeploymentContexts;
}
use of alien4cloud.model.deployment.Deployment in project alien4cloud by alien4cloud.
the class DeploymentService method getDeployments.
/**
* Get all deployments for a given orchestrator an application
*
* @param orchestratorId Id of the cloud for which to get deployments (can be null to get deployments for all clouds).
* @param sourceId Id of the application for which to get deployments (can be null to get deployments for all applications).
* @param environmentId Id of the environment for which to get deployments (can be null to get deployments for all environments).
* @return An array of deployments.
*/
public Deployment[] getDeployments(String orchestratorId, String sourceId, String environmentId, int from, int size) {
FilterBuilder filterBuilder = buildDeploymentFilters(orchestratorId, sourceId, environmentId);
IESQueryBuilderHelper<Deployment> queryBuilderHelper = alienDao.buildQuery(Deployment.class);
return queryBuilderHelper.setFilters(filterBuilder).prepareSearch().setFieldSort("startDate", true).search(from, size).getData();
}
use of alien4cloud.model.deployment.Deployment in project alien4cloud by alien4cloud.
the class ApplicationService method delete.
/**
* Delete an existing application from it's id. This method ensures first that there is no running deployment of the application.
*
* @param applicationId The id of the application to remove.
* @return True if the application has been removed, false if not.
*/
public boolean delete(String applicationId) {
// Removal of a deployed application is not authorized
if (alienDAO.count(Deployment.class, null, fromKeyValueCouples("sourceId", applicationId, "endDate", null)) > 0) {
return false;
}
// Ensure that application related resources can be removed.
Application application = getOrFail(applicationId);
DeleteApplicationVersions deleteApplicationVersions = applicationVersionService.prepareDeleteByApplication(applicationId);
DeleteApplicationEnvironments deleteApplicationEnvironments = applicationEnvironmentService.prepareDeleteByApplication(applicationId);
// Delete the application.
deleteApplicationVersions.delete();
deleteApplicationEnvironments.delete();
publisher.publishEvent(new BeforeApplicationDeleted(this, applicationId));
alienDAO.delete(Application.class, applicationId);
if (application != null && StringUtils.isNotBlank(application.getImageId())) {
imageDAO.deleteAll(application.getImageId());
}
publisher.publishEvent(new AfterApplicationDeleted(this, applicationId));
return true;
}
Aggregations