@Test public void deployVmNonExistingImageRaisesException() { exception.expect(IllegalArgumentException.class); fakeCloudMiddleware.deploy(new Vm("testVm", "nonExistingImage", 1, 1024, 1, null, null), "nonExistingId"); }
@Override public String deploy(Vm vm, String hostname) { HostFake host = getHost(hostname); if (host == null) { throw new IllegalArgumentException( "Error during VM deployment. There is not a host with the given hostname."); } if (getVmImage(vm.getImage()) == null) { throw new IllegalArgumentException( "Error during VM deployment. There is not an image with the given ID."); } VmDeployed newVm = new VmDeployed( vm.getName(), vm.getImage(), vm.getCpus(), vm.getRamMb(), vm.getDiskGb(), vm.getSwapMb(), vm.getInitScript(), vm.getApplicationId(), nextVmId.toString(), nextVmIp.toString(), "active", new Date(), hostname ); deployedVms.add(newVm); host.updateAssignedResourcesAfterVmDeployed(vm); nextVmId.getAndIncrement(); nextVmIp.getAndIncrement(); return newVm.getId(); }
FakeCloudMiddleware implements CloudMiddleware { @Override public String deploy(Vm vm, String hostname) { HostFake host = getHost(hostname); if (host == null) { throw new IllegalArgumentException( "Error during VM deployment. There is not a host with the given hostname."); } if (getVmImage(vm.getImage()) == null) { throw new IllegalArgumentException( "Error during VM deployment. There is not an image with the given ID."); } VmDeployed newVm = new VmDeployed( vm.getName(), vm.getImage(), vm.getCpus(), vm.getRamMb(), vm.getDiskGb(), vm.getSwapMb(), vm.getInitScript(), vm.getApplicationId(), nextVmId.toString(), nextVmIp.toString(), "active", new Date(), hostname ); deployedVms.add(newVm); host.updateAssignedResourcesAfterVmDeployed(vm); nextVmId.getAndIncrement(); nextVmIp.getAndIncrement(); return newVm.getId(); } }
FakeCloudMiddleware implements CloudMiddleware { @Override public String deploy(Vm vm, String hostname) { HostFake host = getHost(hostname); if (host == null) { throw new IllegalArgumentException( "Error during VM deployment. There is not a host with the given hostname."); } if (getVmImage(vm.getImage()) == null) { throw new IllegalArgumentException( "Error during VM deployment. There is not an image with the given ID."); } VmDeployed newVm = new VmDeployed( vm.getName(), vm.getImage(), vm.getCpus(), vm.getRamMb(), vm.getDiskGb(), vm.getSwapMb(), vm.getInitScript(), vm.getApplicationId(), nextVmId.toString(), nextVmIp.toString(), "active", new Date(), hostname ); deployedVms.add(newVm); host.updateAssignedResourcesAfterVmDeployed(vm); nextVmId.getAndIncrement(); nextVmIp.getAndIncrement(); return newVm.getId(); } FakeCloudMiddleware(List<HostFake> hosts); }
FakeCloudMiddleware implements CloudMiddleware { @Override public String deploy(Vm vm, String hostname) { HostFake host = getHost(hostname); if (host == null) { throw new IllegalArgumentException( "Error during VM deployment. There is not a host with the given hostname."); } if (getVmImage(vm.getImage()) == null) { throw new IllegalArgumentException( "Error during VM deployment. There is not an image with the given ID."); } VmDeployed newVm = new VmDeployed( vm.getName(), vm.getImage(), vm.getCpus(), vm.getRamMb(), vm.getDiskGb(), vm.getSwapMb(), vm.getInitScript(), vm.getApplicationId(), nextVmId.toString(), nextVmIp.toString(), "active", new Date(), hostname ); deployedVms.add(newVm); host.updateAssignedResourcesAfterVmDeployed(vm); nextVmId.getAndIncrement(); nextVmIp.getAndIncrement(); return newVm.getId(); } FakeCloudMiddleware(List<HostFake> hosts); @Override String deploy(Vm vm, String hostname); @Override String deployWithVolume(Vm vm, String hostname, String isoPath); @Override void destroy(String vmId); @Override void migrate(String vmId, String destinationNodeHostName); @Override List<String> getAllVMsIds(); @Override List<String> getScheduledNonDeployedVmsIds(); @Override VmDeployed getVM(String vmId); @Override boolean existsVm(String vmId); @Override void rebootHardVm(String vmId); @Override void rebootSoftVm(String vmId); @Override void startVm(String vmId); @Override void stopVm(String vmId); @Override void suspendVm(String vmId); @Override void resumeVm(String vmId); @Override List<ImageUploaded> getVmImages(); @Override String createVmImage(ImageToUpload imageToUpload); @Override ImageUploaded getVmImage(String imageId); @Override void deleteVmImage(String id); @Override void assignFloatingIp(String vmId); void deleteAllVmImages(); HostFake getHost(String hostname); void addHost(HostFake host); @Override Map<String, String> getFlavours(); @Override void resize(String vmId, VmRequirements vm); @Override void confirmResize(String vmId); @Override Map<String, HardwareInfo> getHypervisors(String region); @Override Host createHost(String hostname); }
FakeCloudMiddleware implements CloudMiddleware { @Override public String deploy(Vm vm, String hostname) { HostFake host = getHost(hostname); if (host == null) { throw new IllegalArgumentException( "Error during VM deployment. There is not a host with the given hostname."); } if (getVmImage(vm.getImage()) == null) { throw new IllegalArgumentException( "Error during VM deployment. There is not an image with the given ID."); } VmDeployed newVm = new VmDeployed( vm.getName(), vm.getImage(), vm.getCpus(), vm.getRamMb(), vm.getDiskGb(), vm.getSwapMb(), vm.getInitScript(), vm.getApplicationId(), nextVmId.toString(), nextVmIp.toString(), "active", new Date(), hostname ); deployedVms.add(newVm); host.updateAssignedResourcesAfterVmDeployed(vm); nextVmId.getAndIncrement(); nextVmIp.getAndIncrement(); return newVm.getId(); } FakeCloudMiddleware(List<HostFake> hosts); @Override String deploy(Vm vm, String hostname); @Override String deployWithVolume(Vm vm, String hostname, String isoPath); @Override void destroy(String vmId); @Override void migrate(String vmId, String destinationNodeHostName); @Override List<String> getAllVMsIds(); @Override List<String> getScheduledNonDeployedVmsIds(); @Override VmDeployed getVM(String vmId); @Override boolean existsVm(String vmId); @Override void rebootHardVm(String vmId); @Override void rebootSoftVm(String vmId); @Override void startVm(String vmId); @Override void stopVm(String vmId); @Override void suspendVm(String vmId); @Override void resumeVm(String vmId); @Override List<ImageUploaded> getVmImages(); @Override String createVmImage(ImageToUpload imageToUpload); @Override ImageUploaded getVmImage(String imageId); @Override void deleteVmImage(String id); @Override void assignFloatingIp(String vmId); void deleteAllVmImages(); HostFake getHost(String hostname); void addHost(HostFake host); @Override Map<String, String> getFlavours(); @Override void resize(String vmId, VmRequirements vm); @Override void confirmResize(String vmId); @Override Map<String, HardwareInfo> getHypervisors(String region); @Override Host createHost(String hostname);  }