@Override @BeforeClass(groups = {"integration", "live"}) public void setupContext() { super.setupContext(); ec2Client = view.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi(); runningTester = retry(new InstanceStateRunning(ec2Client), 600, 5, SECONDS); client = ec2Client.getAMIServices(); if (ebsTemplate != null) { Template template = view.getComputeService().templateBuilder().from(ebsTemplate).build(); regionId = template.getLocation().getId(); imageId = template.getImage().getProviderId(); for (Image image : client.describeImagesInRegion(regionId)) { if (ebsBackedImageName.equals(image.getName())) client.deregisterImageInRegion(regionId, image.getId()); } } }
public Image getImageInRegion(String region, String id) { return getOnlyElement( client .getAMIServices() .describeImagesInRegion(region, DescribeImagesOptions.Builder.imageIds(id))); }