private List<CloudApplication> getExistingApps() { try { return client.getApplications(); } catch (CloudOperationException e) { throw new SLException(e, Messages.ERROR_GETTING_APPLICATIONS); } }
private DeployedComponents detectDeployedComponents(String spaceGuid) { List<CloudApplication> applications = getCloudFoundryClient(spaceGuid).getApplications("0"); return new DeployedComponentsDetector().detectAllDeployedComponents(applications); }
private void initApplicationsMock() throws IOException { applications.add(createApplication(APPLICATION_NAME_TO_KEEP, getAppEnvFromFile(RESOURCE_LOCATION))); applications.add(createApplication("app-2", new HashMap<>())); Mockito.when(client.getApplications()) .thenReturn(applications); }
private void unbindService(CloudControllerClient client, String serviceName) { CloudServiceInstance serviceInstance = client.getServiceInstance(serviceName); List<CloudServiceBinding> bindings = serviceInstance.getBindings(); if (bindings.isEmpty()) { return; } logBindings(bindings); for (CloudServiceBinding binding : bindings) { CloudApplication application = StepsUtil.getBoundApplication(client.getApplications(), binding.getAppGuid()); getStepLogger().info(Messages.UNBINDING_APP_FROM_SERVICE, application.getName(), serviceName); client.unbindService(application.getName(), serviceName); } }
private void unbindService(CloudControllerClient client, String serviceName) { CloudServiceInstance serviceInstance = client.getServiceInstance(serviceName); List<CloudServiceBinding> bindings = serviceInstance.getBindings(); if (bindings.isEmpty()) { return; } logBindings(bindings); for (CloudServiceBinding binding : bindings) { CloudApplication application = StepsUtil.getBoundApplication(client.getApplications(), binding.getAppGuid()); getStepLogger().info(Messages.UNBINDING_APP_FROM_SERVICE, application.getName(), serviceName); client.unbindService(application.getName(), serviceName); } }
@Override protected StepPhase executeStep(ExecutionWrapper execution) { try { getStepLogger().debug(Messages.DETECTING_DEPLOYED_MTA); CloudControllerClient client = execution.getControllerClient(); List<CloudApplication> deployedApps = client.getApplications("0"); StepsUtil.setDeployedApps(execution.getContext(), deployedApps); String mtaId = (String) execution.getContext() .getVariable(Constants.PARAM_MTA_ID); DeployedMta deployedMta = componentsDetector.apply(deployedApps) .findDeployedMta(mtaId); if (deployedMta == null) { getStepLogger().info(Messages.NO_DEPLOYED_MTA_DETECTED); } else { getStepLogger().debug(Messages.DEPLOYED_MTA, JsonUtil.toJson(deployedMta, true)); getStepLogger().info(MessageFormat.format(Messages.DEPLOYED_MTA_DETECTED_WITH_VERSION, deployedMta.getMetadata().getId(), deployedMta.getMetadata().getVersion())); } StepsUtil.setDeployedMta(execution.getContext(), deployedMta); getStepLogger().debug(Messages.DEPLOYED_APPS, secureSerializer.toJson(deployedApps)); return StepPhase.DONE; } catch (CloudOperationException coe) { CloudControllerException e = new CloudControllerException(coe); getStepLogger().error(e, Messages.ERROR_DETECTING_DEPLOYED_MTA); throw e; } catch (SLException e) { getStepLogger().error(e, Messages.ERROR_DETECTING_DEPLOYED_MTA); throw e; } }
@Override protected StepPhase executeStep(ExecutionWrapper execution) { try { getStepLogger().debug(Messages.DETECTING_DEPLOYED_MTA); CloudControllerClient client = execution.getControllerClient(); List<CloudApplication> deployedApps = client.getApplications("0"); StepsUtil.setDeployedApps(execution.getContext(), deployedApps); String mtaId = (String) execution.getContext() .getVariable(Constants.PARAM_MTA_ID); DeployedMta deployedMta = componentsDetector.apply(deployedApps) .findDeployedMta(mtaId); if (deployedMta == null) { getStepLogger().info(Messages.NO_DEPLOYED_MTA_DETECTED); } else { getStepLogger().debug(Messages.DEPLOYED_MTA, JsonUtil.toJson(deployedMta, true)); getStepLogger().info(MessageFormat.format(Messages.DEPLOYED_MTA_DETECTED_WITH_VERSION, deployedMta.getMetadata().getId(), deployedMta.getMetadata().getVersion())); } StepsUtil.setDeployedMta(execution.getContext(), deployedMta); getStepLogger().debug(Messages.DEPLOYED_APPS, secureSerializer.toJson(deployedApps)); return StepPhase.DONE; } catch (CloudOperationException coe) { CloudControllerException e = new CloudControllerException(coe); getStepLogger().error(e, Messages.ERROR_DETECTING_DEPLOYED_MTA); throw e; } catch (SLException e) { getStepLogger().error(e, Messages.ERROR_DETECTING_DEPLOYED_MTA); throw e; } }