@Test(dataProvider = "PlaceFailureResultCodes") public void testFailedPlaceResultCodes(PlaceResultCode resultCode, Class<RuntimeException> exceptionClass) throws Throwable { PlacementTask placementTask = generateResourcePlacementList(); placementTask.resultCode = resultCode; Operation placementOperation = new Operation().setBody(placementTask); ResourceReserveStepCmd command = getVmReservationCommand(); when(photonControllerXenonRestClient.post(any(), any(), anyLong())).thenReturn(placementOperation); try { command.execute(); } catch (Exception e) { assertTrue(e.getClass().equals(exceptionClass)); } }
@Override protected void execute() throws ApiFeException, InterruptedException, RpcException { List<BaseEntity> entityList = step.getTransientResourceEntities(); for (BaseEntity entity : entityList) { if (!entity.getKind().equals(Vm.KIND) && !entity.getKind().equals(PersistentDisk.KIND)) { continue; } infrastructureEntity = (InfrastructureEntity) entity; } Preconditions.checkArgument(infrastructureEntity != null, "There should be at least one InfrastructureEntity referenced by step %s", step.getId()); Resource resource = createResource(infrastructureEntity); taskCommand.setResource(resource); String reservation; if (infrastructureEntity.getKind().equals(Vm.KIND)) { String targetHostIp = ((VmEntity) infrastructureEntity).getHostAffinity(); reservation = loadReservation(resource, targetHostIp, infrastructureEntity.getKind()); } else { reservation = loadReservation(resource, infrastructureEntity.getKind()); } taskCommand.setReservation(reservation); }
ResourceReserveStepCmd extends StepCommand { @Override protected void execute() throws ApiFeException, InterruptedException, RpcException { List<BaseEntity> entityList = step.getTransientResourceEntities(); for (BaseEntity entity : entityList) { if (!entity.getKind().equals(Vm.KIND) && !entity.getKind().equals(PersistentDisk.KIND)) { continue; } infrastructureEntity = (InfrastructureEntity) entity; } Preconditions.checkArgument(infrastructureEntity != null, "There should be at least one InfrastructureEntity referenced by step %s", step.getId()); Resource resource = createResource(infrastructureEntity); taskCommand.setResource(resource); String reservation; if (infrastructureEntity.getKind().equals(Vm.KIND)) { String targetHostIp = ((VmEntity) infrastructureEntity).getHostAffinity(); reservation = loadReservation(resource, targetHostIp, infrastructureEntity.getKind()); } else { reservation = loadReservation(resource, infrastructureEntity.getKind()); } taskCommand.setReservation(reservation); } }
ResourceReserveStepCmd extends StepCommand { @Override protected void execute() throws ApiFeException, InterruptedException, RpcException { List<BaseEntity> entityList = step.getTransientResourceEntities(); for (BaseEntity entity : entityList) { if (!entity.getKind().equals(Vm.KIND) && !entity.getKind().equals(PersistentDisk.KIND)) { continue; } infrastructureEntity = (InfrastructureEntity) entity; } Preconditions.checkArgument(infrastructureEntity != null, "There should be at least one InfrastructureEntity referenced by step %s", step.getId()); Resource resource = createResource(infrastructureEntity); taskCommand.setResource(resource); String reservation; if (infrastructureEntity.getKind().equals(Vm.KIND)) { String targetHostIp = ((VmEntity) infrastructureEntity).getHostAffinity(); reservation = loadReservation(resource, targetHostIp, infrastructureEntity.getKind()); } else { reservation = loadReservation(resource, infrastructureEntity.getKind()); } taskCommand.setReservation(reservation); } ResourceReserveStepCmd(TaskCommand taskCommand,
                                StepBackend stepBackend,
                                StepEntity step,
                                DiskBackend diskBackend,
                                VmBackend vmBackend,
                                NetworkBackend networkBackend,
                                FlavorBackend flavorBackend,
                                Boolean useVirtualNetwork); }
ResourceReserveStepCmd extends StepCommand { @Override protected void execute() throws ApiFeException, InterruptedException, RpcException { List<BaseEntity> entityList = step.getTransientResourceEntities(); for (BaseEntity entity : entityList) { if (!entity.getKind().equals(Vm.KIND) && !entity.getKind().equals(PersistentDisk.KIND)) { continue; } infrastructureEntity = (InfrastructureEntity) entity; } Preconditions.checkArgument(infrastructureEntity != null, "There should be at least one InfrastructureEntity referenced by step %s", step.getId()); Resource resource = createResource(infrastructureEntity); taskCommand.setResource(resource); String reservation; if (infrastructureEntity.getKind().equals(Vm.KIND)) { String targetHostIp = ((VmEntity) infrastructureEntity).getHostAffinity(); reservation = loadReservation(resource, targetHostIp, infrastructureEntity.getKind()); } else { reservation = loadReservation(resource, infrastructureEntity.getKind()); } taskCommand.setReservation(reservation); } ResourceReserveStepCmd(TaskCommand taskCommand,
                                StepBackend stepBackend,
                                StepEntity step,
                                DiskBackend diskBackend,
                                VmBackend vmBackend,
                                NetworkBackend networkBackend,
                                FlavorBackend flavorBackend,
                                Boolean useVirtualNetwork);  }
ResourceReserveStepCmd extends StepCommand { @Override protected void execute() throws ApiFeException, InterruptedException, RpcException { List<BaseEntity> entityList = step.getTransientResourceEntities(); for (BaseEntity entity : entityList) { if (!entity.getKind().equals(Vm.KIND) && !entity.getKind().equals(PersistentDisk.KIND)) { continue; } infrastructureEntity = (InfrastructureEntity) entity; } Preconditions.checkArgument(infrastructureEntity != null, "There should be at least one InfrastructureEntity referenced by step %s", step.getId()); Resource resource = createResource(infrastructureEntity); taskCommand.setResource(resource); String reservation; if (infrastructureEntity.getKind().equals(Vm.KIND)) { String targetHostIp = ((VmEntity) infrastructureEntity).getHostAffinity(); reservation = loadReservation(resource, targetHostIp, infrastructureEntity.getKind()); } else { reservation = loadReservation(resource, infrastructureEntity.getKind()); } taskCommand.setReservation(reservation); } ResourceReserveStepCmd(TaskCommand taskCommand,
                                StepBackend stepBackend,
                                StepEntity step,
                                DiskBackend diskBackend,
                                VmBackend vmBackend,
                                NetworkBackend networkBackend,
                                FlavorBackend flavorBackend,
                                Boolean useVirtualNetwork);  static final String LOGICAL_SWITCH_ID; static final String VIRTUAL_NETWORK_ID; static final String VM_ID; }