@Override public boolean apply(Image input) { return input.getProviderId().equals(from.getTemplateId() + "") // either location free image (location is null) or in the same zone as the VM && (input.getLocation() == null || input.getId().equals(from.getZoneId() + "")); } }).orNull();
@Override public boolean apply(Image input) { return input.getProviderId().equals(from.getTemplateId() + "") // either location free image (location is null) or in the same zone as the VM && (input.getLocation() == null || input.getId().equals(from.getZoneId() + "")); } }).orNull();
@Override public boolean apply(Image input) { return input.getProviderId().equals(from.getTemplateId() + "") // either location free image (location is null) or in the same zone as the VM && (input.getLocation() == null || input.getId().equals(from.getZoneId() + "")); } }).orNull();
builder.location(FluentIterable.from(locations.get()).firstMatch(idEquals(from.getZoneId())).orNull()); if (from.getGroup() != null) { builder.group(from.getGroup());
builder.location(FluentIterable.from(locations.get()).firstMatch(idEquals(from.getZoneId())).orNull()); builder.group(nodeNamingConvention.groupInUniqueNameOrNull(from.getDisplayName())); Image image = FluentIterable.from(images.get()).firstMatch(new Predicate<Image>() {
public static VirtualMachine createVirtualMachineWithOptionsInZone(DeployVirtualMachineOptions options, String zoneId, String templateId, CloudStackClient client, Predicate<String> jobComplete, Predicate<VirtualMachine> virtualMachineRunning) { String serviceOfferingId = DEFAULT_SIZE_ORDERING.min(client.getOfferingClient().listServiceOfferings()).getId(); System.out.printf("serviceOfferingId %s, templateId %s, zoneId %s, options %s%n", serviceOfferingId, templateId, zoneId, options); AsyncCreateResponse job = client.getVirtualMachineClient().deployVirtualMachineInZone(zoneId, serviceOfferingId, templateId, options); assertTrue(jobComplete.apply(job.getJobId())); AsyncJob<VirtualMachine> jobWithResult = client.getAsyncJobClient().<VirtualMachine> getAsyncJob(job.getJobId()); if (jobWithResult.getError() != null) Throwables.propagate(new ExecutionException(String.format("job %s failed with exception %s", job.getId(), jobWithResult.getError().toString())) { }); VirtualMachine vm = jobWithResult.getResult(); if (vm.isPasswordEnabled()) { assert vm.getPassword() != null : vm; } assertTrue(virtualMachineRunning.apply(vm)); assertEquals(vm.getServiceOfferingId(), serviceOfferingId); assertEquals(vm.getTemplateId(), templateId); assertEquals(vm.getZoneId(), zoneId); return vm; }
builder.location(FluentIterable.from(locations.get()).firstMatch(idEquals(from.getZoneId())).orNull()); builder.group(nodeNamingConvention.groupInUniqueNameOrNull(from.getDisplayName())); Image image = FluentIterable.from(images.get()).firstMatch(new Predicate<Image>() {
public static VirtualMachine createVirtualMachineWithOptionsInZone(DeployVirtualMachineOptions options, String zoneId, String templateId, CloudStackApi client, Predicate<String> jobComplete, Predicate<VirtualMachine> virtualMachineRunning) { String serviceOfferingId = DEFAULT_SIZE_ORDERING.min(client.getOfferingApi().listServiceOfferings()).getId(); System.out.printf("serviceOfferingId %s, templateId %s, zoneId %s, options %s%n", serviceOfferingId, templateId, zoneId, options); AsyncCreateResponse job = client.getVirtualMachineApi().deployVirtualMachineInZone(zoneId, serviceOfferingId, templateId, options); assertTrue(jobComplete.apply(job.getJobId())); AsyncJob<VirtualMachine> jobWithResult = client.getAsyncJobApi().<VirtualMachine> getAsyncJob(job.getJobId()); if (jobWithResult.getError() != null) Throwables.propagate(new ExecutionException(String.format("job %s failed with exception %s", job.getId(), jobWithResult.getError().toString())) { }); VirtualMachine vm = jobWithResult.getResult(); if (vm.isPasswordEnabled()) { assert vm.getPassword() != null : vm; } assertTrue(virtualMachineRunning.apply(vm)); assertEquals(vm.getServiceOfferingId(), serviceOfferingId); assertEquals(vm.getTemplateId(), templateId); assertEquals(vm.getZoneId(), zoneId); return vm; }
@Test(enabled = true) public void testCreateTemplate() throws Exception { Zone zone = Iterables.getFirst(client.getZoneClient().listZones(), null); assertNotNull(zone); Iterable<Network> networks = client.getNetworkClient().listNetworks(ListNetworksOptions.Builder.zoneId(zone.getId()).isDefault(true)); networks = Iterables.filter(networks, new Predicate<Network>() { @Override public boolean apply(Network network) { return network != null && network.getState().equals("Implemented"); } }); assertTrue(Iterables.size(networks) >= 1); Network network = Iterables.get(networks, 0); assertNotNull(network); // Create a VM and stop it String defaultTemplate = template != null ? template.getImageId() : null; vmForCreation = VirtualMachineClientLiveTest.createVirtualMachineInNetwork(network, defaultTemplate, client, jobComplete, virtualMachineRunning); assertTrue(jobComplete.apply(client.getVirtualMachineClient().stopVirtualMachine(vmForCreation.getId())), vmForCreation.toString()); // Work out the VM's volume Set<Volume> volumes = client.getVolumeClient().listVolumes(ListVolumesOptions.Builder.virtualMachineId(vmForCreation.getId())); assertEquals(volumes.size(), 1); Volume volume = Iterables.getOnlyElement(volumes); // Create a template CreateTemplateOptions options = CreateTemplateOptions.Builder.volumeId(volume.getId()); AsyncCreateResponse response = client.getTemplateClient().createTemplate(TemplateMetadata.builder().name(prefix+"-createTemplate").osTypeId(vmForCreation.getGuestOSId()).displayText("jclouds live testCreateTemplate").build(), options); assertTrue(jobComplete.apply(response.getJobId()), vmForCreation.toString()); createdTemplate = client.getTemplateClient().getTemplateInZone(response.getId(), vmForCreation.getZoneId()); // Assertions assertNotNull(createdTemplate); }
@Test(enabled = true) public void testCreateTemplate() throws Exception { Zone zone = Iterables.getFirst(client.getZoneApi().listZones(), null); assertNotNull(zone); Iterable<Network> networks = client.getNetworkApi().listNetworks(ListNetworksOptions.Builder.zoneId(zone.getId()).isDefault(true)); networks = Iterables.filter(networks, new Predicate<Network>() { @Override public boolean apply(Network network) { return network != null && network.getState().equals("Implemented"); } }); assertTrue(Iterables.size(networks) >= 1); Network network = Iterables.get(networks, 0); assertNotNull(network); // Create a VM and stop it String defaultTemplate = templateBuilderSpec != null ? templateBuilderSpec.getImageId() : null; vmForCreation = VirtualMachineApiLiveTest.createVirtualMachineInNetwork(network, defaultTemplate, client, jobComplete, virtualMachineRunning); assertTrue(jobComplete.apply(client.getVirtualMachineApi().stopVirtualMachine(vmForCreation.getId())), vmForCreation.toString()); // Work out the VM's volume Set<Volume> volumes = client.getVolumeApi().listVolumes(ListVolumesOptions.Builder.virtualMachineId(vmForCreation.getId())); assertEquals(volumes.size(), 1); Volume volume = Iterables.getOnlyElement(volumes); // Create a template CreateTemplateOptions options = CreateTemplateOptions.Builder.volumeId(volume.getId()); AsyncCreateResponse response = client.getTemplateApi().createTemplate(TemplateMetadata.builder().name(prefix + "-createTemplate").osTypeId(vmForCreation.getGuestOSId()).displayText("jclouds live testCreateTemplate").build(), options); assertTrue(jobComplete.apply(response.getJobId()), vmForCreation.toString()); createdTemplate = client.getTemplateApi().getTemplateInZone(response.getId(), vmForCreation.getZoneId()); // Assertions assertNotNull(createdTemplate); }
.location(find(locations.get(), idEquals(vm.getZoneId()))) .id(newTemplate.getId()) .providerId(newTemplate.getId())
assert vm.getCreated() != null : vm; assert vm.getState() != null : vm; assert vm.getZoneId() != null : vm; assert vm.getZoneName() != null : vm; assert vm.getTemplateId() != null : vm;
assert vm.getCreated() != null : vm; assert vm.getState() != null : vm; assert vm.getZoneId() != null : vm; assert vm.getZoneName() != null : vm; assert vm.getTemplateId() != null : vm;
.templateId(in.getTemplateId()) .templateName(in.getTemplateName()) .zoneId(in.getZoneId()) .zoneName(in.getZoneName()) .nics(in.getNICs())
.templateId(in.getTemplateId()) .templateName(in.getTemplateName()) .zoneId(in.getZoneId()) .zoneName(in.getZoneName()) .nics(in.getNICs())
.templateId(in.getTemplateId()) .templateName(in.getTemplateName()) .zoneId(in.getZoneId()) .zoneName(in.getZoneName()) .nics(in.getNICs())