本文整理汇总了Java中org.jclouds.compute.domain.Image类的典型用法代码示例。如果您正苦于以下问题:Java Image类的具体用法?Java Image怎么用?Java Image使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Image类属于org.jclouds.compute.domain包,在下文中一共展示了Image类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getImage
import org.jclouds.compute.domain.Image; //导入依赖的package包/类
@Override
public Image getImage(String id) {
Image image = null;
IAcsClient client = api.getAcsClient(api.decodeToRegion(id));
DescribeImagesRequest req = new DescribeImagesRequest();
req.setImageId(api.decodeToId(id));
try {
DescribeImagesResponse resp = client.getAcsResponse(req);
if (resp.getTotalCount() > 0) {
Iterator<Image> it = transform(resp.getImages(), new ImageToImage(api, resp.getRegionId())).iterator();
if (it.hasNext()) {
image = it.next();
}
}
} catch (Exception e) {
logger.warn(e.getMessage());
}
return image;
}
示例2: listImages
import org.jclouds.compute.domain.Image; //导入依赖的package包/类
@Override
public Iterable<Image> listImages() {
Builder<Image> builder = ImmutableSet.builder();
Set<String> regions = api.getAvailableRegions();
for (String region : regions) {
try {
IAcsClient client = api.getAcsClient(region);
DescribeImagesRequest req = new DescribeImagesRequest();
DescribeImagesResponse resp = client.getAcsResponse(req);
builder.addAll(transform(resp.getImages(), new ImageToImage(api, region)));
} catch (Exception e) {
logger.warn(e.getMessage());
}
}
return builder.build();
}
示例3: DimensionDataCloudControllerComputeService
import org.jclouds.compute.domain.Image; //导入依赖的package包/类
@Inject
protected DimensionDataCloudControllerComputeService(ComputeServiceContext context, Map<String, Credentials> credentialStore,
@Memoized Supplier<Set<? extends Image>> images, @Memoized Supplier<Set<? extends Hardware>> sizes,
@Memoized Supplier<Set<? extends Location>> locations, ListNodesStrategy listNodesStrategy,
GetImageStrategy getImageStrategy, GetNodeMetadataStrategy getNodeMetadataStrategy,
CreateNodesInGroupThenAddToSet runNodesAndAddToSetStrategy, RebootNodeStrategy rebootNodeStrategy,
DestroyNodeStrategy destroyNodeStrategy, ResumeNodeStrategy startNodeStrategy,
SuspendNodeStrategy stopNodeStrategy, Provider<TemplateBuilder> templateBuilderProvider,
@Named("DEFAULT") Provider<TemplateOptions> templateOptionsProvider,
@Named(TIMEOUT_NODE_RUNNING) Predicate<AtomicReference<NodeMetadata>> nodeRunning,
@Named(TIMEOUT_NODE_TERMINATED) Predicate<AtomicReference<NodeMetadata>> nodeTerminated,
@Named(TIMEOUT_NODE_SUSPENDED) Predicate<AtomicReference<NodeMetadata>> nodeSuspended,
InitializeRunScriptOnNodeOrPlaceInBadMap.Factory initScriptRunnerFactory,
RunScriptOnNode.Factory runScriptOnNodeFactory, InitAdminAccess initAdminAccess,
PersistNodeCredentials persistNodeCredentials, Timeouts timeouts,
@Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor,
CleanupServer cleanupServer,
Optional<ImageExtension> imageExtension,
Optional<SecurityGroupExtension> securityGroupExtension) {
super(context, credentialStore, images, sizes, locations, listNodesStrategy, getImageStrategy,
getNodeMetadataStrategy, runNodesAndAddToSetStrategy, rebootNodeStrategy, destroyNodeStrategy,
startNodeStrategy, stopNodeStrategy, templateBuilderProvider, templateOptionsProvider, nodeRunning,
nodeTerminated, nodeSuspended, initScriptRunnerFactory, initAdminAccess, runScriptOnNodeFactory,
persistNodeCredentials, timeouts, userExecutor, imageExtension, securityGroupExtension);
this.cleanupServer = checkNotNull(cleanupServer, "cleanupServer");
}
示例4: configure
import org.jclouds.compute.domain.Image; //导入依赖的package包/类
@Override
protected void configure() {
super.configure();
bind(new TypeLiteral<ComputeServiceAdapter<ServerWithExternalIp, OsImage, OsImage, Datacenter>>() {
}).to(DimensionDataCloudControllerComputeServiceAdapter.class);
bind(ComputeService.class).to(DimensionDataCloudControllerComputeService.class);
bind(new TypeLiteral<Function<ServerWithExternalIp, NodeMetadata>>() {
}).to(ServerWithNatRuleToNodeMetadata.class);
bind(new TypeLiteral<Function<OsImage, Image>>() {
}).to(OsImageToImage.class);
bind(new TypeLiteral<Function<OsImage, Hardware>>() {
}).to(OsImageToHardware.class);
bind(new TypeLiteral<Function<Datacenter, Location>>() {
}).to(DatacenterToLocation.class);
bind(TemplateOptions.class).to(DimensionDataCloudControllerTemplateOptions.class);
bind(CreateNodesInGroupThenAddToSet.class).to(GetOrCreateNetworkDomainThenCreateNodes.class);
bind(PrioritizeCredentialsFromTemplate.class).to(UseNodeCredentialsButOverrideFromTemplate.class);
// to have the compute service adapter override default locations
install(new LocationsFromComputeServiceAdapterModule<ServerWithExternalIp, OsImage, OsImage, Datacenter>() {
});
}
开发者ID:cloudsoft,项目名称:amp-dimensiondata,代码行数:24,代码来源:DimensionDataCloudControllerComputeServiceContextModule.java
示例5: apply
import org.jclouds.compute.domain.Image; //导入依赖的package包/类
@Override
public Image apply(OsImage from) {
OsFamily osFamily = osFamily().apply(from.description());
String osVersion = parseVersion(from.description());
OperatingSystem os = OperatingSystem.builder()
.description(from.description())
.family(osFamily)
.version(osVersion)
.is64Bit(is64bit(from))
.build();
return new ImageBuilder()
.id(from.id())
.name(from.name())
.status(Image.Status.AVAILABLE)
.operatingSystem(os)
.location(FluentIterable.from(locations.get()).firstMatch(LocationPredicates.idEquals(from.datacenterId())).orNull())
.build();
}
示例6: testListImages
import org.jclouds.compute.domain.Image; //导入依赖的package包/类
@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);
}
}
}
}
示例7: provideRegionAndNameToImageSupplierCacheLoader
import org.jclouds.compute.domain.Image; //导入依赖的package包/类
@Provides
@Singleton
protected Supplier<CacheLoader<RegionAndName, Image>> provideRegionAndNameToImageSupplierCacheLoader(
final RegionAndIdToImage delegate) {
return Suppliers.<CacheLoader<RegionAndName, Image>>ofInstance(new CacheLoader<RegionAndName, Image>() {
private final AtomicReference<AuthorizationException> authException = Atomics.newReference();
@Override
public Image load(final RegionAndName key) throws Exception {
// raw lookup of an image
Supplier<Image> rawSupplier = new Supplier<Image>() {
@Override public Image get() {
try {
return delegate.load(key);
} catch (ExecutionException e) {
throw Throwables.propagate(e);
}
}
};
return new SetAndThrowAuthorizationExceptionSupplier<Image>(rawSupplier, authException).get();
}
});
}
示例8: testCacheLoaderDoesNotReloadAfterAuthorizationException
import org.jclouds.compute.domain.Image; //导入依赖的package包/类
@Test
public void testCacheLoaderDoesNotReloadAfterAuthorizationException() throws Exception {
AWSEC2ComputeServiceContextModule module = new AWSEC2ComputeServiceContextModule() {
public Supplier<CacheLoader<RegionAndName, Image>> provideRegionAndNameToImageSupplierCacheLoader(RegionAndIdToImage delegate) {
return super.provideRegionAndNameToImageSupplierCacheLoader(delegate);
}
};
RegionAndName regionAndName = new RegionAndName("myregion", "myname");
AuthorizationException authException = new AuthorizationException();
RegionAndIdToImage mockRegionAndIdToImage = createMock(RegionAndIdToImage.class);
expect(mockRegionAndIdToImage.load(regionAndName)).andThrow(authException).once();
replay(mockRegionAndIdToImage);
CacheLoader<RegionAndName, Image> cacheLoader = module.provideRegionAndNameToImageSupplierCacheLoader(mockRegionAndIdToImage).get();
for (int i = 0; i < 2; i++) {
try {
Image image = cacheLoader.load(regionAndName);
fail("Expected Authorization exception, but got " + image);
} catch (AuthorizationException e) {
// success
}
}
}
示例9: getImage
import org.jclouds.compute.domain.Image; //导入依赖的package包/类
/**
* This method uses the generic ComputeService.listImages() to find the image.
*
* @return An Ubuntu 14.04 Image
*/
private Image getImage() {
System.out.format(" Images%n");
Set<? extends Image> images = computeService.listImages();
Image result = null;
for (Image image: images) {
System.out.format(" %s%n", image);
if (image.getOperatingSystem().getName().startsWith("Ubuntu 14.04 LTS")) {
result = image;
}
}
if (result == null) {
System.err.println("Image with Ubuntu 14.04 operating system not found. Using first image found.%n");
result = images.iterator().next();
}
return result;
}
示例10: createImage
import org.jclouds.compute.domain.Image; //导入依赖的package包/类
/**
* Create an image of a VM
* @param vmi the VMInstance to use
* @return id of the image
*/
public String createImage(VMInstance vmi){
AMIApi ami=ec2api.getAMIApi().get();
String id="";
Image img = checkIfImageExist(vmi.getName()+"-image");
if(img == null){
journal.log(Level.INFO, ">> Creating an image of VM: "+vmi.getName());
id=ami.createImageInRegion(vmi.getId().split("/")[0],vmi.getName()+"-image",vmi.getId().split("/")[1], CreateImageOptions.Builder.noReboot());
String status="";
while (!status.toLowerCase().equals("available")){
Image i=compute.getImage("eu-west-1/"+id);
status=i.getStatus().name();
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
journal.log(Level.INFO, ">> Image created with ID: "+id);
}else{
id=img.getId().split("/")[1];
}
return "eu-west-1/"+id;
}
示例11: testListImages
import org.jclouds.compute.domain.Image; //导入依赖的package包/类
@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);
}
}
}
}
示例12: ECSComputeService
import org.jclouds.compute.domain.Image; //导入依赖的package包/类
@Inject
protected ECSComputeService(
ComputeServiceContext context,
ECSComputeServiceAdapter client,
Map<String, Credentials> credentialStore,
@Memoized Supplier<Set<? extends Image>> images,
Supplier<Set<? extends Hardware>> hardwareProfiles,
@Memoized Supplier<Set<? extends Location>> locations,
ListNodesStrategy listNodesStrategy,
GetImageStrategy getImageStrategy,
GetNodeMetadataStrategy getNodeMetadataStrategy,
CreateNodesInGroupThenAddToSet runNodesAndAddToSetStrategy,
RebootNodeStrategy rebootNodeStrategy,
DestroyNodeStrategy destroyNodeStrategy,
ResumeNodeStrategy resumeNodeStrategy,
SuspendNodeStrategy suspendNodeStrategy,
@Named("ECS") Provider<TemplateBuilder> templateBuilderProvider,
@Named("ECS") Provider<TemplateOptions> templateOptionsProvider,
@Named(TIMEOUT_NODE_RUNNING) Predicate<AtomicReference<NodeMetadata>> nodeRunning,
@Named(TIMEOUT_NODE_TERMINATED) Predicate<AtomicReference<NodeMetadata>> nodeTerminated,
@Named(TIMEOUT_NODE_SUSPENDED) Predicate<AtomicReference<NodeMetadata>> nodeSuspended,
Factory initScriptRunnerFactory,
InitAdminAccess initAdminAccess,
org.jclouds.compute.callables.RunScriptOnNode.Factory runScriptOnNodeFactory,
PersistNodeCredentials persistNodeCredentials,
Timeouts timeouts,
@Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor,
Optional<ImageExtension> imageExtension,
Optional<SecurityGroupExtension> securityGroupExtension) {
super(context, credentialStore, images, hardwareProfiles, locations, listNodesStrategy, getImageStrategy,
getNodeMetadataStrategy, runNodesAndAddToSetStrategy, rebootNodeStrategy, destroyNodeStrategy, resumeNodeStrategy,
suspendNodeStrategy, templateBuilderProvider, templateOptionsProvider, nodeRunning, nodeTerminated, nodeSuspended,
initScriptRunnerFactory, initAdminAccess, runScriptOnNodeFactory, persistNodeCredentials, timeouts, userExecutor,
imageExtension, securityGroupExtension);
this.client = client;
}
示例13: configure
import org.jclouds.compute.domain.Image; //导入依赖的package包/类
@Override
protected void configure() {
super.configure();
bind(ECSApi.class).to(ECSApiImpl.class);
bind(ComputeService.class).to(ECSComputeService.class);
install(new LocationsFromComputeServiceAdapterModule<NodeMetadata, Hardware, Image, Location>() {});
}
示例14: apply
import org.jclouds.compute.domain.Image; //导入依赖的package包/类
@Override
public Image apply(DescribeImagesResponse.Image input) {
ImageBuilder builder = new ImageBuilder();
builder.id(api.encodeToId(region, input.getImageId()));
builder.name(input.getImageName());
builder.description(input.getDescription());
OperatingSystem os = OperatingSystem.builder()
.arch(input.getArchitecture().getStringValue())
.description(input.getOSName())
.build();
builder.operatingSystem(os);
builder.status(Image.Status.AVAILABLE);
return builder.build();
}
示例15: listImages
import org.jclouds.compute.domain.Image; //导入依赖的package包/类
@Override
public Iterable<Image> listImages() {
try (VSphereServiceInstance instance = serviceInstance.get();) {
Iterable<VirtualMachine> nodes = listNodes(instance);
Iterable<VirtualMachine> templates = Iterables.filter(nodes, VSpherePredicate.isTemplatePredicate);
Iterable<Image> images = Iterables.transform(templates, virtualMachineToImage);
return FluentIterable.from(images).toList();
} catch (Throwable t) {
Throwables.propagateIfPossible(t);
return ImmutableSet.of();
}
}