@Test public void testCreateOvfEnvironmentInstance() throws Exception { EnvironmentInstanceDto environmentInstanceDto = new EnvironmentInstanceDto(); environmentInstanceDto.setDescription("description"); environmentInstanceDto.setBlueprintName("BlueprintName"); environmentInstanceDto.setEnvironmentDto(environment.toDto()); Task task = environmentInstanceResource.create(org, vdc, environmentInstanceDto, callback); verify(environmentInstanceAsyncManager, times(1)).create(any(ClaudiaData.class), any(EnvironmentInstance.class), any(Task.class), any(String.class)); assertNotNull(task); }
public Task create(String org, String vdc, EnvironmentInstanceDto environmentInstanceDto, String callback) throws APIException { log.warn("Deploy an environment instance " + environmentInstanceDto.getBlueprintName() + " from environment " + environmentInstanceDto.getEnvironmentDto()); Task task = null; ClaudiaData claudiaData = new ClaudiaData(org, vdc, environmentInstanceDto.getBlueprintName()); OpenStackAuthenticationProvider.addCredentialsToClaudiaData(claudiaData); try { validator.validateCreate(environmentInstanceDto, systemPropertiesProvider, claudiaData); } catch (InvalidEntityException e) { log.error("The environment instance is not valid " + e.getMessage()); throw new APIException(e); } catch (QuotaExceededException e) { throw new APIException(e); } EnvironmentInstance environmentInstance = environmentInstanceDto.fromDto(); Environment environment = environmentInstance.getEnvironment(); log.info("Environment name " + environment.getName() + " " + environment.getVdc() + " " + environment.getOrg() + " "); for (Tier tier : environment.getTiers()) { log.info("Tier " + tier.getName() + " image " + tier.getImage()); } environmentInstance.setVdc(vdc); environmentInstance.setStatus(Status.INIT); environmentInstance.setDescription(environmentInstanceDto.getDescription()); environmentInstance.setBlueprintName(environmentInstanceDto.getBlueprintName()); log.info("EnvironmentInstance name " + environmentInstance.getBlueprintName() + " vdc " + environmentInstance.getVdc() + " description " + environmentInstance.getDescription() + " status " + environmentInstance.getStatus() + " environment " + environmentInstance.getEnvironment().getName()); task = createTask(MessageFormat.format("Create environment {0}", environmentInstance.getBlueprintName()), vdc, environmentInstance.getBlueprintName()); environmentInstance.setTaskId("" + task.getId()); environmentInstanceAsyncManager.create(claudiaData, environmentInstance, task, callback); return task; }
EnvironmentInstanceResourceImpl implements EnvironmentInstanceResource { public Task create(String org, String vdc, EnvironmentInstanceDto environmentInstanceDto, String callback) throws APIException { log.warn("Deploy an environment instance " + environmentInstanceDto.getBlueprintName() + " from environment " + environmentInstanceDto.getEnvironmentDto()); Task task = null; ClaudiaData claudiaData = new ClaudiaData(org, vdc, environmentInstanceDto.getBlueprintName()); OpenStackAuthenticationProvider.addCredentialsToClaudiaData(claudiaData); try { validator.validateCreate(environmentInstanceDto, systemPropertiesProvider, claudiaData); } catch (InvalidEntityException e) { log.error("The environment instance is not valid " + e.getMessage()); throw new APIException(e); } catch (QuotaExceededException e) { throw new APIException(e); } EnvironmentInstance environmentInstance = environmentInstanceDto.fromDto(); Environment environment = environmentInstance.getEnvironment(); log.info("Environment name " + environment.getName() + " " + environment.getVdc() + " " + environment.getOrg() + " "); for (Tier tier : environment.getTiers()) { log.info("Tier " + tier.getName() + " image " + tier.getImage()); } environmentInstance.setVdc(vdc); environmentInstance.setStatus(Status.INIT); environmentInstance.setDescription(environmentInstanceDto.getDescription()); environmentInstance.setBlueprintName(environmentInstanceDto.getBlueprintName()); log.info("EnvironmentInstance name " + environmentInstance.getBlueprintName() + " vdc " + environmentInstance.getVdc() + " description " + environmentInstance.getDescription() + " status " + environmentInstance.getStatus() + " environment " + environmentInstance.getEnvironment().getName()); task = createTask(MessageFormat.format("Create environment {0}", environmentInstance.getBlueprintName()), vdc, environmentInstance.getBlueprintName()); environmentInstance.setTaskId("" + task.getId()); environmentInstanceAsyncManager.create(claudiaData, environmentInstance, task, callback); return task; } }
EnvironmentInstanceResourceImpl implements EnvironmentInstanceResource { public Task create(String org, String vdc, EnvironmentInstanceDto environmentInstanceDto, String callback) throws APIException { log.warn("Deploy an environment instance " + environmentInstanceDto.getBlueprintName() + " from environment " + environmentInstanceDto.getEnvironmentDto()); Task task = null; ClaudiaData claudiaData = new ClaudiaData(org, vdc, environmentInstanceDto.getBlueprintName()); OpenStackAuthenticationProvider.addCredentialsToClaudiaData(claudiaData); try { validator.validateCreate(environmentInstanceDto, systemPropertiesProvider, claudiaData); } catch (InvalidEntityException e) { log.error("The environment instance is not valid " + e.getMessage()); throw new APIException(e); } catch (QuotaExceededException e) { throw new APIException(e); } EnvironmentInstance environmentInstance = environmentInstanceDto.fromDto(); Environment environment = environmentInstance.getEnvironment(); log.info("Environment name " + environment.getName() + " " + environment.getVdc() + " " + environment.getOrg() + " "); for (Tier tier : environment.getTiers()) { log.info("Tier " + tier.getName() + " image " + tier.getImage()); } environmentInstance.setVdc(vdc); environmentInstance.setStatus(Status.INIT); environmentInstance.setDescription(environmentInstanceDto.getDescription()); environmentInstance.setBlueprintName(environmentInstanceDto.getBlueprintName()); log.info("EnvironmentInstance name " + environmentInstance.getBlueprintName() + " vdc " + environmentInstance.getVdc() + " description " + environmentInstance.getDescription() + " status " + environmentInstance.getStatus() + " environment " + environmentInstance.getEnvironment().getName()); task = createTask(MessageFormat.format("Create environment {0}", environmentInstance.getBlueprintName()), vdc, environmentInstance.getBlueprintName()); environmentInstance.setTaskId("" + task.getId()); environmentInstanceAsyncManager.create(claudiaData, environmentInstance, task, callback); return task; }  }
EnvironmentInstanceResourceImpl implements EnvironmentInstanceResource { public Task create(String org, String vdc, EnvironmentInstanceDto environmentInstanceDto, String callback) throws APIException { log.warn("Deploy an environment instance " + environmentInstanceDto.getBlueprintName() + " from environment " + environmentInstanceDto.getEnvironmentDto()); Task task = null; ClaudiaData claudiaData = new ClaudiaData(org, vdc, environmentInstanceDto.getBlueprintName()); OpenStackAuthenticationProvider.addCredentialsToClaudiaData(claudiaData); try { validator.validateCreate(environmentInstanceDto, systemPropertiesProvider, claudiaData); } catch (InvalidEntityException e) { log.error("The environment instance is not valid " + e.getMessage()); throw new APIException(e); } catch (QuotaExceededException e) { throw new APIException(e); } EnvironmentInstance environmentInstance = environmentInstanceDto.fromDto(); Environment environment = environmentInstance.getEnvironment(); log.info("Environment name " + environment.getName() + " " + environment.getVdc() + " " + environment.getOrg() + " "); for (Tier tier : environment.getTiers()) { log.info("Tier " + tier.getName() + " image " + tier.getImage()); } environmentInstance.setVdc(vdc); environmentInstance.setStatus(Status.INIT); environmentInstance.setDescription(environmentInstanceDto.getDescription()); environmentInstance.setBlueprintName(environmentInstanceDto.getBlueprintName()); log.info("EnvironmentInstance name " + environmentInstance.getBlueprintName() + " vdc " + environmentInstance.getVdc() + " description " + environmentInstance.getDescription() + " status " + environmentInstance.getStatus() + " environment " + environmentInstance.getEnvironment().getName()); task = createTask(MessageFormat.format("Create environment {0}", environmentInstance.getBlueprintName()), vdc, environmentInstance.getBlueprintName()); environmentInstance.setTaskId("" + task.getId()); environmentInstanceAsyncManager.create(claudiaData, environmentInstance, task, callback); return task; }  Task create(String org, String vdc, EnvironmentInstanceDto environmentInstanceDto, String callback); List<EnvironmentInstancePDto> findAll(Integer page, Integer pageSize, String orderBy, String orderType,
            List<Status> status, String vdc); EnvironmentInstancePDto load(String vdc, String name); Task destroy(String org, String vdc, String name, String callback); void setValidator(EnvironmentInstanceResourceValidator validator); void setSystemPropertiesProvider(SystemPropertiesProvider systemPropertiesProvider); void setEnvironmentInstanceAsyncManager(EnvironmentInstanceAsyncManager environmentInstanceAsyncManager); void setEnvironmentInstanceManager(EnvironmentInstanceManager environmentInstanceManager); void setTaskManager(TaskManager taskManager); }
EnvironmentInstanceResourceImpl implements EnvironmentInstanceResource { public Task create(String org, String vdc, EnvironmentInstanceDto environmentInstanceDto, String callback) throws APIException { log.warn("Deploy an environment instance " + environmentInstanceDto.getBlueprintName() + " from environment " + environmentInstanceDto.getEnvironmentDto()); Task task = null; ClaudiaData claudiaData = new ClaudiaData(org, vdc, environmentInstanceDto.getBlueprintName()); OpenStackAuthenticationProvider.addCredentialsToClaudiaData(claudiaData); try { validator.validateCreate(environmentInstanceDto, systemPropertiesProvider, claudiaData); } catch (InvalidEntityException e) { log.error("The environment instance is not valid " + e.getMessage()); throw new APIException(e); } catch (QuotaExceededException e) { throw new APIException(e); } EnvironmentInstance environmentInstance = environmentInstanceDto.fromDto(); Environment environment = environmentInstance.getEnvironment(); log.info("Environment name " + environment.getName() + " " + environment.getVdc() + " " + environment.getOrg() + " "); for (Tier tier : environment.getTiers()) { log.info("Tier " + tier.getName() + " image " + tier.getImage()); } environmentInstance.setVdc(vdc); environmentInstance.setStatus(Status.INIT); environmentInstance.setDescription(environmentInstanceDto.getDescription()); environmentInstance.setBlueprintName(environmentInstanceDto.getBlueprintName()); log.info("EnvironmentInstance name " + environmentInstance.getBlueprintName() + " vdc " + environmentInstance.getVdc() + " description " + environmentInstance.getDescription() + " status " + environmentInstance.getStatus() + " environment " + environmentInstance.getEnvironment().getName()); task = createTask(MessageFormat.format("Create environment {0}", environmentInstance.getBlueprintName()), vdc, environmentInstance.getBlueprintName()); environmentInstance.setTaskId("" + task.getId()); environmentInstanceAsyncManager.create(claudiaData, environmentInstance, task, callback); return task; }  Task create(String org, String vdc, EnvironmentInstanceDto environmentInstanceDto, String callback); List<EnvironmentInstancePDto> findAll(Integer page, Integer pageSize, String orderBy, String orderType,
            List<Status> status, String vdc); EnvironmentInstancePDto load(String vdc, String name); Task destroy(String org, String vdc, String name, String callback); void setValidator(EnvironmentInstanceResourceValidator validator); void setSystemPropertiesProvider(SystemPropertiesProvider systemPropertiesProvider); void setEnvironmentInstanceAsyncManager(EnvironmentInstanceAsyncManager environmentInstanceAsyncManager); void setEnvironmentInstanceManager(EnvironmentInstanceManager environmentInstanceManager); void setTaskManager(TaskManager taskManager); static final int ERROR_NOT_FOUND; }