当前位置: 首页>>代码示例>>Java>>正文


Java Image类代码示例

本文整理汇总了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;
}
 
开发者ID:aliyun-beta,项目名称:aliyun-jclouds,代码行数:20,代码来源:ECSComputeServiceAdapter.java

示例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();
}
 
开发者ID:aliyun-beta,项目名称:aliyun-jclouds,代码行数:17,代码来源:ECSComputeServiceAdapter.java

示例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");
}
 
开发者ID:cloudsoft,项目名称:amp-dimensiondata,代码行数:27,代码来源:DimensionDataCloudControllerComputeService.java

示例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();
}
 
开发者ID:cloudsoft,项目名称:amp-dimensiondata,代码行数:21,代码来源:OsImageToImage.java

示例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);
            }
        }
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:18,代码来源:JcloudsSpringComputeTest.java

示例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();
      }

   });
}
 
开发者ID:apache,项目名称:stratos,代码行数:25,代码来源:AWSEC2ComputeServiceContextModule.java

示例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
      }
   }
}
 
开发者ID:apache,项目名称:stratos,代码行数:27,代码来源:AWSEC2ComputeServiceContextModuleTest.java

示例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;
}
 
开发者ID:jclouds,项目名称:jclouds-examples,代码行数:26,代码来源:CreateServer.java

示例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;
}
 
开发者ID:SINTEF-9012,项目名称:cloudml,代码行数:30,代码来源:JCloudsConnector.java

示例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);
            }
        }
    }
}
 
开发者ID:wildfly-extras,项目名称:wildfly-camel,代码行数:22,代码来源:JCloudsComputeIntegrationTest.java

示例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;
}
 
开发者ID:aliyun-beta,项目名称:aliyun-jclouds,代码行数:37,代码来源:ECSComputeService.java

示例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>() {});
}
 
开发者ID:aliyun-beta,项目名称:aliyun-jclouds,代码行数:8,代码来源:ECSComputeServiceContextModule.java

示例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();
}
 
开发者ID:aliyun-beta,项目名称:aliyun-jclouds,代码行数:15,代码来源:ImageToImage.java

示例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();
   }
}
 
开发者ID:igreenfield,项目名称:jcloud-vsphere,代码行数:14,代码来源:VSphereComputeServiceAdapter.java


注:本文中的org.jclouds.compute.domain.Image类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。