use of org.jclouds.compute.domain.Image in project camel by apache.
the class JcloudsSpringComputeTest method testListImages.
@Test
public void testListImages() throws InterruptedException {
result.expectedMessageCount(1);
template.sendBodyAndHeader("direct:start", null, JcloudsConstants.OPERATION, JcloudsConstants.LIST_IMAGES);
result.assertIsSatisfied();
List<Exchange> exchanges = result.getExchanges();
if (exchanges != null && !exchanges.isEmpty()) {
for (Exchange exchange : exchanges) {
Set<?> images = exchange.getIn().getBody(Set.class);
assertTrue(images.size() > 0);
for (Object obj : images) {
assertTrue(obj instanceof Image);
}
}
}
}
use of org.jclouds.compute.domain.Image in project wildfly-camel by wildfly-extras.
the class JCloudsComputeIntegrationTest method testListImages.
@Test
public void testListImages() throws Exception {
CamelContext camelctx = getCamelContext();
ProducerTemplate template = camelctx.createProducerTemplate();
MockEndpoint result = camelctx.getEndpoint("mock:result", MockEndpoint.class);
result.expectedMessageCount(1);
template.sendBodyAndHeader("direct:start", null, JcloudsConstants.OPERATION, JcloudsConstants.LIST_IMAGES);
result.assertIsSatisfied();
List<Exchange> exchanges = result.getExchanges();
if (exchanges != null && !exchanges.isEmpty()) {
for (Exchange exchange : exchanges) {
Set<?> images = exchange.getIn().getBody(Set.class);
Assert.assertTrue(images.size() > 0);
for (Object obj : images) {
Assert.assertTrue(obj instanceof Image);
}
}
}
}
use of org.jclouds.compute.domain.Image in project whirr by apache.
the class BootstrapTemplateTest method assertSpotPriceIs.
@SuppressWarnings("unchecked")
private void assertSpotPriceIs(ClusterSpec clusterSpec, final String templateGroup, float spotPrice) throws MalformedURLException {
InstanceTemplate instanceTemplate = getOnlyElement(filter(clusterSpec.getInstanceTemplates(), new Predicate<InstanceTemplate>() {
private Joiner plusJoiner = Joiner.on("+");
@Override
public boolean apply(InstanceTemplate group) {
return plusJoiner.join(group.getRoles()).equals(templateGroup);
}
}));
ComputeService computeService = mock(AWSEC2ComputeService.class);
ComputeServiceContext context = mock(ComputeServiceContext.class);
when(computeService.getContext()).thenReturn(context);
when(context.getComputeService()).thenReturn(computeService);
TemplateBuilder templateBuilder = mock(TemplateBuilder.class);
when(computeService.templateBuilder()).thenReturn(templateBuilder);
when(templateBuilder.from((TemplateBuilderSpec) any())).thenReturn(templateBuilder);
when(templateBuilder.options((TemplateOptions) any())).thenReturn(templateBuilder);
Template template = mock(Template.class);
TemplateOptions options = mock(TemplateOptions.class);
Image image = mock(Image.class);
when(templateBuilder.build()).thenReturn(template);
when(template.getOptions()).thenReturn(options);
when(template.getImage()).thenReturn(image);
AWSEC2TemplateOptions awsEec2TemplateOptions = mock(AWSEC2TemplateOptions.class);
when(options.as((Class<TemplateOptions>) any())).thenReturn(awsEec2TemplateOptions);
BootstrapTemplate.build(clusterSpec, computeService, statementBuilder, instanceTemplate);
verify(awsEec2TemplateOptions).spotPrice(spotPrice);
}
use of org.jclouds.compute.domain.Image in project legacy-jclouds-examples by jclouds.
the class CreateServer method getImage.
/**
* This method uses the generic ComputeService.listImages() to find the image.
*
* @return An Ubuntu 12.04 Image
*/
private Image getImage() {
System.out.println("Images");
Set<? extends Image> images = compute.listImages();
Image result = null;
for (Image image : images) {
System.out.println(" " + image);
if (image.getOperatingSystem().getName().equals("Ubuntu 12.04 LTS (Precise Pangolin)")) {
result = image;
}
}
if (result == null) {
System.err.println("Image with Ubuntu 12.04 operating system not found. Using first image found.");
result = images.iterator().next();
}
return result;
}
use of org.jclouds.compute.domain.Image in project whirr by apache.
the class RunningInstanceToNodeMetadata method apply.
@Override
public NodeMetadata apply(final RunningInstance instance) {
String id = checkNotNull(instance, "instance").getId();
// user doesn't determine a node name;
String name = null;
// no uri to get rest access to host info
URI uri = null;
String tag = getTagForInstace(instance);
Credentials credentials = getCredentialsForInstanceWithTag(instance, tag);
Map<String, String> userMetadata = ImmutableMap.<String, String>of();
NodeState state = instanceToNodeState.get(instance.getInstanceState());
Set<String> publicAddresses = nullSafeSet(instance.getIpAddress());
Set<String> privateAddresses = nullSafeSet(instance.getPrivateIpAddress());
Map<String, String> extra = getExtra(instance);
Location location = getLocationForAvailabilityZone(instance);
Image image = resolveImageForInstanceInLocation(instance, location);
return new NodeMetadataImpl(id, name, instance.getRegion() + "/" + instance.getId(), location, uri, userMetadata, tag, image, state, publicAddresses, privateAddresses, extra, credentials);
}
Aggregations