@Test public void testVmIdMissing() throws Throwable { VmGetIpStepCmd command = getVmGetIpStepCmd(); try { command.execute(); fail("Should have failed due to missing vm id"); } catch (NullPointerException e) { assertThat(e.getMessage(), containsString("VM id is not available")); } }
@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 = getVmNetworkInfo(vmId); logger.info("VM {} requested to be connected to {} network(s)", vmId, networkInfoMap.size()); if (networkInfoMap.size() > 0) { for (VmService.NetworkInfo networkInfo : networkInfoMap.values()) { networkInfo.privateIpAddress = allocateIpToMac(networkInfo.id, vmId, networkInfo.macAddress); taskCommand.getPhotonControllerXenonRestClient().post( SubnetIPLeaseSyncTriggerService.SELF_LINK , SubnetIPLeaseSyncUtils.buildSubnetIPLeaseSyncState(networkInfo.id)); } updateVmNetworkInfo(vmId, networkInfoMap); } }
VmGetIpStepCmd 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 = getVmNetworkInfo(vmId); logger.info("VM {} requested to be connected to {} network(s)", vmId, networkInfoMap.size()); if (networkInfoMap.size() > 0) { for (VmService.NetworkInfo networkInfo : networkInfoMap.values()) { networkInfo.privateIpAddress = allocateIpToMac(networkInfo.id, vmId, networkInfo.macAddress); taskCommand.getPhotonControllerXenonRestClient().post( SubnetIPLeaseSyncTriggerService.SELF_LINK , SubnetIPLeaseSyncUtils.buildSubnetIPLeaseSyncState(networkInfo.id)); } updateVmNetworkInfo(vmId, networkInfoMap); } } }
VmGetIpStepCmd 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 = getVmNetworkInfo(vmId); logger.info("VM {} requested to be connected to {} network(s)", vmId, networkInfoMap.size()); if (networkInfoMap.size() > 0) { for (VmService.NetworkInfo networkInfo : networkInfoMap.values()) { networkInfo.privateIpAddress = allocateIpToMac(networkInfo.id, vmId, networkInfo.macAddress); taskCommand.getPhotonControllerXenonRestClient().post( SubnetIPLeaseSyncTriggerService.SELF_LINK , SubnetIPLeaseSyncUtils.buildSubnetIPLeaseSyncState(networkInfo.id)); } updateVmNetworkInfo(vmId, networkInfoMap); } } VmGetIpStepCmd(TaskCommand taskCommand, StepBackend stepBackend, StepEntity step); }
VmGetIpStepCmd 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 = getVmNetworkInfo(vmId); logger.info("VM {} requested to be connected to {} network(s)", vmId, networkInfoMap.size()); if (networkInfoMap.size() > 0) { for (VmService.NetworkInfo networkInfo : networkInfoMap.values()) { networkInfo.privateIpAddress = allocateIpToMac(networkInfo.id, vmId, networkInfo.macAddress); taskCommand.getPhotonControllerXenonRestClient().post( SubnetIPLeaseSyncTriggerService.SELF_LINK , SubnetIPLeaseSyncUtils.buildSubnetIPLeaseSyncState(networkInfo.id)); } updateVmNetworkInfo(vmId, networkInfoMap); } } VmGetIpStepCmd(TaskCommand taskCommand, StepBackend stepBackend, StepEntity step);  }
VmGetIpStepCmd 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 = getVmNetworkInfo(vmId); logger.info("VM {} requested to be connected to {} network(s)", vmId, networkInfoMap.size()); if (networkInfoMap.size() > 0) { for (VmService.NetworkInfo networkInfo : networkInfoMap.values()) { networkInfo.privateIpAddress = allocateIpToMac(networkInfo.id, vmId, networkInfo.macAddress); taskCommand.getPhotonControllerXenonRestClient().post( SubnetIPLeaseSyncTriggerService.SELF_LINK , SubnetIPLeaseSyncUtils.buildSubnetIPLeaseSyncState(networkInfo.id)); } updateVmNetworkInfo(vmId, networkInfoMap); } } VmGetIpStepCmd(TaskCommand taskCommand, StepBackend stepBackend, StepEntity step);   }