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


Java ComputeMetadata类代码示例

本文整理汇总了Java中org.jclouds.compute.domain.ComputeMetadata的典型用法代码示例。如果您正苦于以下问题:Java ComputeMetadata类的具体用法?Java ComputeMetadata怎么用?Java ComputeMetadata使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ComputeMetadata类属于org.jclouds.compute.domain包,在下文中一共展示了ComputeMetadata类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: buildNodeFilter

import org.jclouds.compute.domain.ComputeMetadata; //导入依赖的package包/类
public Predicate<ComputeMetadata> buildNodeFilter() {
    nodesFilter = new Predicate<ComputeMetadata>() {
        @Override
        public boolean apply(ComputeMetadata nodeMetadata) {
            if (nodeMetadata == null) {
                return false;
            }
            if (tagPairs.size() > nodeMetadata.getUserMetadata().size()) {
                return false;
            }
            for (AbstractMap.SimpleImmutableEntry entry : tagPairs) {
                String value = nodeMetadata.getUserMetadata().get(entry.getKey());
                if (value == null || !value.equals(entry.getValue())) {
                    return false;
                }
            }
            return true;
        }
    };
    return nodesFilter;
}
 
开发者ID:hazelcast,项目名称:hazelcast-jclouds,代码行数:22,代码来源:ComputeServiceBuilder.java

示例2: test_buildNodeFilter_with_NodeMetadata_with_multiple_tags

import org.jclouds.compute.domain.ComputeMetadata; //导入依赖的package包/类
@Test
public void test_buildNodeFilter_with_NodeMetadata_with_multiple_tags() {
    Map<String, Comparable> properties = new HashMap<String, Comparable>();
    properties.put("tag-keys", "tag1,tag2");
    properties.put("tag-values", "value1,value2");
    ComputeServiceBuilder builder = new ComputeServiceBuilder(properties);
    builder.buildTagConfig();
    Predicate<ComputeMetadata> nodeFilter = builder.buildNodeFilter();

    Map<String, String> userMetaData = new HashMap<String, String>();
    userMetaData.put("tag1", "value1");

    NodeMetadata metadata = new NodeMetadataBuilder()
            .userMetadata(userMetaData)
            .id(newSecureUuidString())
            .status(NodeMetadata.Status.RUNNING)
            .build();

    assertFalse(nodeFilter.apply(metadata));
}
 
开发者ID:hazelcast,项目名称:hazelcast-jclouds,代码行数:21,代码来源:ComputeServiceBuilderTest.java

示例3: test_buildNodeFilter_with_NodeMetadata_with_single_tag

import org.jclouds.compute.domain.ComputeMetadata; //导入依赖的package包/类
@Test
public void test_buildNodeFilter_with_NodeMetadata_with_single_tag() {
    Map<String, Comparable> properties = new HashMap<String, Comparable>();
    properties.put("tag-keys", "tag1");
    properties.put("tag-values", "value1");
    ComputeServiceBuilder builder = new ComputeServiceBuilder(properties);
    builder.buildTagConfig();
    Predicate<ComputeMetadata> nodeFilter = builder.buildNodeFilter();

    Map<String, String> userMetaData = new HashMap<String, String>();
    userMetaData.put("tag1", "value2");

    NodeMetadata metadata = new NodeMetadataBuilder()
            .userMetadata(userMetaData)
            .id(newSecureUuidString())
            .status(NodeMetadata.Status.RUNNING)
            .build();

    assertFalse(nodeFilter.apply(metadata));
}
 
开发者ID:hazelcast,项目名称:hazelcast-jclouds,代码行数:21,代码来源:ComputeServiceBuilderTest.java

示例4: test_buildNodeFilter_with_NodeMetadata_with_multiple_tags_with_and_relation

import org.jclouds.compute.domain.ComputeMetadata; //导入依赖的package包/类
@Test
public void test_buildNodeFilter_with_NodeMetadata_with_multiple_tags_with_and_relation() {
    Map<String, Comparable> properties = new HashMap<String, Comparable>();
    properties.put("tag-keys", "Owner,Stack");
    properties.put("tag-values", "DbAdmin,Production");
    ComputeServiceBuilder builder = new ComputeServiceBuilder(properties);
    builder.buildTagConfig();
    Predicate<ComputeMetadata> nodeFilter = builder.buildNodeFilter();

    Map<String, String> userMetaData = new HashMap<String, String>();
    userMetaData.put("Owner", "DbAdmin");
    userMetaData.put("Stack", "Production");

    NodeMetadata metadata = new NodeMetadataBuilder()
            .userMetadata(userMetaData)
            .id(newSecureUuidString())
            .status(NodeMetadata.Status.RUNNING)
            .build();

    assertTrue(nodeFilter.apply(metadata));
}
 
开发者ID:hazelcast,项目名称:hazelcast-jclouds,代码行数:22,代码来源:ComputeServiceBuilderTest.java

示例5: ComputeServiceBuilder

import org.jclouds.compute.domain.ComputeMetadata; //导入依赖的package包/类
@Test
public void test_buildNodeFilter_with_NodeMetadata_with_multiple_tags_with_and_relation_where_user_metadata_has_more_elements() {
    Map<String, Comparable> properties = new HashMap<String, Comparable>();
    properties.put("tag-keys", "Owner,Stack");
    properties.put("tag-values", "DbAdmin,Production");
    ComputeServiceBuilder builder = new ComputeServiceBuilder(properties);
    builder.buildTagConfig();
    Predicate<ComputeMetadata> nodeFilter = builder.buildNodeFilter();

    Map<String, String> userMetaData = new HashMap<String, String>();
    userMetaData.put("Owner", "DbAdmin");
    userMetaData.put("Stack", "Production");
    userMetaData.put("Number", "1");

    NodeMetadata metadata = new NodeMetadataBuilder()
            .userMetadata(userMetaData)
            .id(newSecureUuidString())
            .status(NodeMetadata.Status.RUNNING)
            .build();

    assertTrue(nodeFilter.apply(metadata));
}
 
开发者ID:hazelcast,项目名称:hazelcast-jclouds,代码行数:23,代码来源:ComputeServiceBuilderTest.java

示例6: test_buildNodeFilter_with_NodeMetadata_with_single_value

import org.jclouds.compute.domain.ComputeMetadata; //导入依赖的package包/类
@Test
public void test_buildNodeFilter_with_NodeMetadata_with_single_value() {
    Map<String, Comparable> properties = new HashMap<String, Comparable>();
    properties.put("tag-keys", "tag1");
    properties.put("tag-values", "value1");
    ComputeServiceBuilder builder = new ComputeServiceBuilder(properties);
    builder.buildTagConfig();
    Predicate<ComputeMetadata> nodeFilter = builder.buildNodeFilter();

    Map<String, String> userMetaData = new HashMap<String, String>();
    userMetaData.put("tag1", "value1");

    NodeMetadata metadata = new NodeMetadataBuilder()
            .userMetadata(userMetaData)
            .id(newSecureUuidString())
            .status(NodeMetadata.Status.RUNNING)
            .build();

    assertTrue(nodeFilter.apply(metadata));
}
 
开发者ID:hazelcast,项目名称:hazelcast-jclouds,代码行数:21,代码来源:ComputeServiceBuilderTest.java

示例7: getComputePredicate

import org.jclouds.compute.domain.ComputeMetadata; //导入依赖的package包/类
/**
 * Returns the required {@ComputeMetadata} {@link Predicate} for the Exhcnage.
 * The predicate can be used for filtering.
 */
public Predicate<ComputeMetadata> getComputePredicate(final Exchange exchange) {
    final String nodeId = getNodeId(exchange);

    Predicate<ComputeMetadata> predicate = new Predicate<ComputeMetadata>() {
        public boolean apply(ComputeMetadata metadata) {
            if (nodeId != null && !nodeId.equals(metadata.getId())) {
                return false;
            }

            //If NodeMetadata also delegate to Node predicate.
            if (metadata instanceof NodeMetadataImpl) {
                Predicate<NodeMetadata> nodeMetadataPredicate = getNodePredicate(exchange);
                if (!nodeMetadataPredicate.apply((NodeMetadataImpl) metadata)) {
                    return false;
                }
            }
            return true;
        }
    };

    return predicate;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:27,代码来源:JcloudsComputeProducer.java

示例8: JCloudsCreateVirtualMachineStrategy

import org.jclouds.compute.domain.ComputeMetadata; //导入依赖的package包/类
@Inject
public JCloudsCreateVirtualMachineStrategy(JCloudsComputeClient jCloudsComputeClient,
    OneWayConverter<ComputeMetadata, VirtualMachine> computeMetadataVirtualMachineConverter,
    OneWayConverter<TemplateOptions, org.jclouds.compute.options.TemplateOptions> templateOptionsConverter,
    NamingStrategy namingStrategy) {

  checkNotNull(jCloudsComputeClient);
  checkNotNull(computeMetadataVirtualMachineConverter);
  checkNotNull(templateOptionsConverter);
  checkNotNull(namingStrategy);

  this.jCloudsComputeClient = jCloudsComputeClient;
  this.computeMetadataVirtualMachineConverter = computeMetadataVirtualMachineConverter;
  this.templateOptionsConverter = templateOptionsConverter;
  this.namingStrategy = namingStrategy;
}
 
开发者ID:cloudiator,项目名称:sword,代码行数:17,代码来源:JCloudsCreateVirtualMachineStrategy.java

示例9: handle

import org.jclouds.compute.domain.ComputeMetadata; //导入依赖的package包/类
@Override
public void handle(Upload command) {
    if (isDeploymentLoaded()) {
        ExternalComponentInstance ownerVM = null;
        for (ExternalComponentInstance ni: deploy.getComponentInstances().onlyExternals()) {
            if (ni.getName().equals(command.getArtifactId())) {
                ownerVM = ni;
            }
        }
        if (ownerVM != null && ownerVM instanceof VMInstance) {
            Provider p = ((VMInstance) ownerVM).getType().getProvider();
            JCloudsConnector jc = new JCloudsConnector(p.getName(), p.getCredentials().getLogin(), p.getCredentials().getPassword());
            ComputeMetadata c = jc.getVMByName(command.getArtifactId());
            jc.uploadFile(command.getLocalPath(), command.getRemotePath(), c.getId(), "ubuntu",
                    ((VM) ownerVM.getType()).getPrivateKey());
        } else {
            final String text = "There is no VM with this ID!";
            final Message message = new Message(command, Category.ERROR, text);
            dispatch(message);
        }

    } else {
        reportNoDeploymentLoaded(command);

    }
}
 
开发者ID:SINTEF-9012,项目名称:cloudml,代码行数:27,代码来源:Facade.java

示例10: test_buildNodeFilter_with_null_NodeMetadata

import org.jclouds.compute.domain.ComputeMetadata; //导入依赖的package包/类
@Test
public void test_buildNodeFilter_with_null_NodeMetadata() {
    ComputeServiceBuilder builder = new ComputeServiceBuilder(new HashMap<String, Comparable>());
    Predicate<ComputeMetadata> nodeFilter = builder.buildNodeFilter();

    assertFalse(nodeFilter.apply(null));
}
 
开发者ID:hazelcast,项目名称:hazelcast-jclouds,代码行数:8,代码来源:ComputeServiceBuilderTest.java

示例11: VirtualMachineSupplier

import org.jclouds.compute.domain.ComputeMetadata; //导入依赖的package包/类
@Inject
public VirtualMachineSupplier(JCloudsComputeClient jCloudsComputeClient,
    OneWayConverter<ComputeMetadata, VirtualMachine> jCloudsComputeMetadataToVirtualMachine,
    NamingStrategy namingStrategy) {

  checkNotNull(jCloudsComputeClient, "jCloudsComputeClient is null.");
  checkNotNull(jCloudsComputeMetadataToVirtualMachine,
      "jCloudsComputeMetadataToVirtualMachine is null.");
  checkNotNull(namingStrategy, "namingStrategy is null.");

  this.jCloudsComputeClient = jCloudsComputeClient;
  this.jCloudsComputeMetadataToVirtualMachine = jCloudsComputeMetadataToVirtualMachine;
  this.namingStrategy = namingStrategy;
}
 
开发者ID:cloudiator,项目名称:sword,代码行数:15,代码来源:VirtualMachineSupplier.java

示例12: apply

import org.jclouds.compute.domain.ComputeMetadata; //导入依赖的package包/类
@Override
public VirtualMachine apply(final ComputeMetadata computeMetadata) {

  checkArgument(computeMetadata instanceof NodeMetadata);

  VirtualMachineBuilder virtualMachineBuilder = VirtualMachineBuilder.newBuilder();
  virtualMachineBuilder.id(computeMetadata.getId())
      .providerId(computeMetadata.getProviderId()).name(forceName(computeMetadata));

  ((NodeMetadata) computeMetadata).getPrivateAddresses()
      .forEach(virtualMachineBuilder::addIpString);
  ((NodeMetadata) computeMetadata).getPublicAddresses()
      .forEach(virtualMachineBuilder::addIpString);
  if (((NodeMetadata) computeMetadata).getCredentials() != null) {
    virtualMachineBuilder.loginCredential(this.loginCredentialConverter
        .apply(((NodeMetadata) computeMetadata).getCredentials()));
  }

  virtualMachineBuilder
      .hardware(hardwareConverter.apply(((NodeMetadata) computeMetadata).getHardware()));

  String imageId = ((NodeMetadata) computeMetadata).getImageId();
  if (imageId != null) {
    virtualMachineBuilder.image(imageGetStrategy.get(imageId));
  }

  return virtualMachineBuilder.build();
}
 
开发者ID:cloudiator,项目名称:sword,代码行数:29,代码来源:JCloudsComputeMetadataToVirtualMachine.java

示例13: OpenstackCreateVirtualMachineStrategy

import org.jclouds.compute.domain.ComputeMetadata; //导入依赖的package包/类
@Inject
public OpenstackCreateVirtualMachineStrategy(JCloudsComputeClient jCloudsComputeClient,
    OneWayConverter<ComputeMetadata, VirtualMachine> computeMetadataVirtualMachineConverter,
    OneWayConverter<TemplateOptions, org.jclouds.compute.options.TemplateOptions> templateOptionsConverter,
    GetStrategy<String, Location> locationGetStrategy, NamingStrategy namingStrategy) {
  super(jCloudsComputeClient, computeMetadataVirtualMachineConverter,
      templateOptionsConverter, namingStrategy);
  this.locationGetStrategy = locationGetStrategy;
}
 
开发者ID:cloudiator,项目名称:sword,代码行数:10,代码来源:OpenstackCreateVirtualMachineStrategy.java

示例14: nameStartsWith

import org.jclouds.compute.domain.ComputeMetadata; //导入依赖的package包/类
public static Predicate<ComputeMetadata> nameStartsWith(final String prefix) {
   Preconditions.checkNotNull(prefix, "prefix must be defined");

   return new Predicate<ComputeMetadata>() {
      @Override
      public boolean apply(ComputeMetadata computeMetadata) {
         return computeMetadata.getName().startsWith(prefix);
      }

      @Override
      public String toString() {
         return "nameStartsWith(" + prefix + ")";
      }
   };
}
 
开发者ID:jclouds,项目名称:jclouds-examples,代码行数:16,代码来源:ListServersWithFiltering.java

示例15: findVMByName

import org.jclouds.compute.domain.ComputeMetadata; //导入依赖的package包/类
public ComputeMetadata findVMByName(String name, Provider p) {//TODO: use the connector factory
    JCloudsConnector jc = new JCloudsConnector(p.getName(), p.getCredentials().getLogin(),
            p.getCredentials().getPassword());
    ComputeMetadata cm = jc.getVMByName(name);
    jc.closeConnection();
    return cm;
}
 
开发者ID:SINTEF-9012,项目名称:cloudml,代码行数:8,代码来源:Facade.java


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