@Test(expectedExceptions = HostStateChangeException.class) public void testHostStatusChangeFailed() throws Throwable{ ChangeHostModeTaskService.State failedState = new ChangeHostModeTaskService.State(); failedState.hostMode = HostMode.ENTERING_MAINTENANCE; failedState.hostServiceLink = this.hostEntity.getId(); failedState.taskState = new TaskState(); failedState.taskState.stage = TaskState.TaskStage.FAILED; failedState.taskState.failure = new ServiceErrorResponse(); failedState.taskState.failure.message = "failed"; when(deployerClient.getHostChangeModeStatus(anyString())).thenReturn(failedState); commandStatus.execute(); Fail.fail("should have failed"); }
@Override protected void execute() throws ExternalException { List<BaseEntity> entityList = step.getTransientResourceEntities(); hostEntity = (HostEntity) Iterables.getOnlyElement(entityList); logger.info("Calling deployer to suspend host {}", hostEntity); ChangeHostModeTaskService.State serviceDocument = taskCommand.getDeployerXenonClient() .enterSuspendedMode(hostEntity.getId()); for (StepEntity nextStep : taskCommand.getTask().getSteps()) { nextStep.createOrUpdateTransientResource(XenonTaskStatusStepCmd.REMOTE_TASK_LINK_RESOURCE_KEY, serviceDocument.documentSelfLink); } }
HostEnterSuspendedModeStepCmd extends StepCommand { @Override protected void execute() throws ExternalException { List<BaseEntity> entityList = step.getTransientResourceEntities(); hostEntity = (HostEntity) Iterables.getOnlyElement(entityList); logger.info("Calling deployer to suspend host {}", hostEntity); ChangeHostModeTaskService.State serviceDocument = taskCommand.getDeployerXenonClient() .enterSuspendedMode(hostEntity.getId()); for (StepEntity nextStep : taskCommand.getTask().getSteps()) { nextStep.createOrUpdateTransientResource(XenonTaskStatusStepCmd.REMOTE_TASK_LINK_RESOURCE_KEY, serviceDocument.documentSelfLink); } } }
HostEnterSuspendedModeStepCmd extends StepCommand { @Override protected void execute() throws ExternalException { List<BaseEntity> entityList = step.getTransientResourceEntities(); hostEntity = (HostEntity) Iterables.getOnlyElement(entityList); logger.info("Calling deployer to suspend host {}", hostEntity); ChangeHostModeTaskService.State serviceDocument = taskCommand.getDeployerXenonClient() .enterSuspendedMode(hostEntity.getId()); for (StepEntity nextStep : taskCommand.getTask().getSteps()) { nextStep.createOrUpdateTransientResource(XenonTaskStatusStepCmd.REMOTE_TASK_LINK_RESOURCE_KEY, serviceDocument.documentSelfLink); } } HostEnterSuspendedModeStepCmd(TaskCommand taskCommand,
                                       StepBackend stepBackend,
                                       StepEntity stepEntity,
                                       HostBackend hostBackend); }
HostEnterSuspendedModeStepCmd extends StepCommand { @Override protected void execute() throws ExternalException { List<BaseEntity> entityList = step.getTransientResourceEntities(); hostEntity = (HostEntity) Iterables.getOnlyElement(entityList); logger.info("Calling deployer to suspend host {}", hostEntity); ChangeHostModeTaskService.State serviceDocument = taskCommand.getDeployerXenonClient() .enterSuspendedMode(hostEntity.getId()); for (StepEntity nextStep : taskCommand.getTask().getSteps()) { nextStep.createOrUpdateTransientResource(XenonTaskStatusStepCmd.REMOTE_TASK_LINK_RESOURCE_KEY, serviceDocument.documentSelfLink); } } HostEnterSuspendedModeStepCmd(TaskCommand taskCommand,
                                       StepBackend stepBackend,
                                       StepEntity stepEntity,
                                       HostBackend hostBackend);  }
HostEnterSuspendedModeStepCmd extends StepCommand { @Override protected void execute() throws ExternalException { List<BaseEntity> entityList = step.getTransientResourceEntities(); hostEntity = (HostEntity) Iterables.getOnlyElement(entityList); logger.info("Calling deployer to suspend host {}", hostEntity); ChangeHostModeTaskService.State serviceDocument = taskCommand.getDeployerXenonClient() .enterSuspendedMode(hostEntity.getId()); for (StepEntity nextStep : taskCommand.getTask().getSteps()) { nextStep.createOrUpdateTransientResource(XenonTaskStatusStepCmd.REMOTE_TASK_LINK_RESOURCE_KEY, serviceDocument.documentSelfLink); } } HostEnterSuspendedModeStepCmd(TaskCommand taskCommand,
                                       StepBackend stepBackend,
                                       StepEntity stepEntity,
                                       HostBackend hostBackend);   }