@Test public void testSuccessWithSdnDisabled() throws Throwable { VmReleaseIpStepCmd command = getVmReleaseIpStepCmd(); step.createOrUpdateTransientResource(ResourceReserveStepCmd.VM_ID, "vm-id"); Operation operation = mock(Operation.class); VmService.State state = new VmService.State(); state.networkInfo = new HashMap<>(); VmService.NetworkInfo networkInfo = new VmService.NetworkInfo(); networkInfo.privateIpAddress = "ipAddress"; state.networkInfo.put("network-id", networkInfo); networkInfo = new VmService.NetworkInfo(); networkInfo.privateIpAddress = "ipAddress2"; state.networkInfo.put("network-id2", networkInfo); doReturn(state).when(operation).getBody(any()); doReturn(operation).when(photonControllerXenonRestClient).get(anyString()); doReturn(false).when(networkHelper).isSdnEnabled(); command.execute(); verify(photonControllerXenonRestClient).get(eq(VmServiceFactory.SELF_LINK + "/vm-id")); verify(photonControllerXenonRestClient, times(2)).patch(anyString(), any(DhcpSubnetService.IpOperationPatch.class)); verify(networkHelper, times(2)).isSdnEnabled(); }
@Override protected void execute() throws ApiFeException, InterruptedException, RpcException { String vmId = (String) step.getTransientResource(ResourceReserveStepCmd.VM_ID); checkNotNull(vmId, "VM id is not available"); Map<String, VmService.NetworkInfo> networkInfoMap = getNetworkInfo(vmId); for (VmService.NetworkInfo networkInfo : networkInfoMap.values()) { releasePrivateIp(networkInfo.id, vmId, networkInfo.privateIpAddress); if (networkHelper.isSdnEnabled()) { releaseFloatingIp(networkInfo.id, vmId, networkInfo.floatingIpAddress); } } logger.info("Released IP for VM {}", vmId); }
VmReleaseIpStepCmd extends StepCommand { @Override protected void execute() throws ApiFeException, InterruptedException, RpcException { String vmId = (String) step.getTransientResource(ResourceReserveStepCmd.VM_ID); checkNotNull(vmId, "VM id is not available"); Map<String, VmService.NetworkInfo> networkInfoMap = getNetworkInfo(vmId); for (VmService.NetworkInfo networkInfo : networkInfoMap.values()) { releasePrivateIp(networkInfo.id, vmId, networkInfo.privateIpAddress); if (networkHelper.isSdnEnabled()) { releaseFloatingIp(networkInfo.id, vmId, networkInfo.floatingIpAddress); } } logger.info("Released IP for VM {}", vmId); } }
VmReleaseIpStepCmd extends StepCommand { @Override protected void execute() throws ApiFeException, InterruptedException, RpcException { String vmId = (String) step.getTransientResource(ResourceReserveStepCmd.VM_ID); checkNotNull(vmId, "VM id is not available"); Map<String, VmService.NetworkInfo> networkInfoMap = getNetworkInfo(vmId); for (VmService.NetworkInfo networkInfo : networkInfoMap.values()) { releasePrivateIp(networkInfo.id, vmId, networkInfo.privateIpAddress); if (networkHelper.isSdnEnabled()) { releaseFloatingIp(networkInfo.id, vmId, networkInfo.floatingIpAddress); } } logger.info("Released IP for VM {}", vmId); } VmReleaseIpStepCmd(
      TaskCommand taskCommand,
      StepBackend stepBackend,
      StepEntity step,
      NetworkHelper networkHelper); }
VmReleaseIpStepCmd extends StepCommand { @Override protected void execute() throws ApiFeException, InterruptedException, RpcException { String vmId = (String) step.getTransientResource(ResourceReserveStepCmd.VM_ID); checkNotNull(vmId, "VM id is not available"); Map<String, VmService.NetworkInfo> networkInfoMap = getNetworkInfo(vmId); for (VmService.NetworkInfo networkInfo : networkInfoMap.values()) { releasePrivateIp(networkInfo.id, vmId, networkInfo.privateIpAddress); if (networkHelper.isSdnEnabled()) { releaseFloatingIp(networkInfo.id, vmId, networkInfo.floatingIpAddress); } } logger.info("Released IP for VM {}", vmId); } VmReleaseIpStepCmd(
      TaskCommand taskCommand,
      StepBackend stepBackend,
      StepEntity step,
      NetworkHelper networkHelper);  }
VmReleaseIpStepCmd extends StepCommand { @Override protected void execute() throws ApiFeException, InterruptedException, RpcException { String vmId = (String) step.getTransientResource(ResourceReserveStepCmd.VM_ID); checkNotNull(vmId, "VM id is not available"); Map<String, VmService.NetworkInfo> networkInfoMap = getNetworkInfo(vmId); for (VmService.NetworkInfo networkInfo : networkInfoMap.values()) { releasePrivateIp(networkInfo.id, vmId, networkInfo.privateIpAddress); if (networkHelper.isSdnEnabled()) { releaseFloatingIp(networkInfo.id, vmId, networkInfo.floatingIpAddress); } } logger.info("Released IP for VM {}", vmId); } VmReleaseIpStepCmd(
      TaskCommand taskCommand,
      StepBackend stepBackend,
      StepEntity step,
      NetworkHelper networkHelper);   }