本文整理汇总了Java中org.jclouds.compute.domain.ComputeMetadata类的典型用法代码示例。如果您正苦于以下问题:Java ComputeMetadata类的具体用法?Java ComputeMetadata怎么用?Java ComputeMetadata使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ComputeMetadata类属于org.jclouds.compute.domain包,在下文中一共展示了ComputeMetadata类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: listOfVMs
import org.jclouds.compute.domain.ComputeMetadata; //导入依赖的package包/类
public Set<? extends ComputeMetadata> listOfVMs(Provider p) {//TODO: use the connector factory
JCloudsConnector jc = new JCloudsConnector(p.getName(), p.getCredentials().getLogin(),
p.getCredentials().getPassword());
Set<? extends ComputeMetadata> list = jc.listOfVMs();
jc.closeConnection();
return list;
}
开发者ID:SINTEF-9012,项目名称:cloudml,代码行数:8,代码来源:Facade.java
示例17: listNodes
import org.jclouds.compute.domain.ComputeMetadata; //导入依赖的package包/类
/**
* Sets the metadata of the available nodes to the out message.
*/
protected void listNodes(Exchange exchange) {
Predicate<ComputeMetadata> predicate = getComputePredicate(exchange);
Set<? extends ComputeMetadata> computeMetadatas = computeService.listNodesDetailsMatching(predicate);
exchange.getOut().setBody(computeMetadatas);
}
开发者ID:HydAu,项目名称:Camel,代码行数:9,代码来源:JcloudsComputeProducer.java
示例18: buildDynamicNodes
import org.jclouds.compute.domain.ComputeMetadata; //导入依赖的package包/类
@Override
public List<DiscoveryNode> buildDynamicNodes() {
List<DiscoveryNode> discoveryNodes = Lists.newArrayList();
String addressContains = componentSettings.get("address_contains", null);
@SuppressWarnings("unchecked")
Set<? extends ComputeMetadata> nodes = context.getComputeService().listNodesDetailsMatching(buildFilter());
for(ComputeMetadata metadata : nodes){
if(metadata instanceof NodeMetadata){
if(tags.size() > 0){
// filtering by tags
boolean hasTag = false;
for(String tag : metadata.getTags()){
if(tags.contains(tag)){
hasTag = true;
break;
}
}
if(!hasTag){
// this node does not have any of the tags we are looking for
continue;
}
}
Set<String> nodeAddresses;
if(privateIp){
nodeAddresses = ((NodeMetadata) metadata).getPrivateAddresses();
}
else{
nodeAddresses = ((NodeMetadata) metadata).getPublicAddresses();
}
String address = null;
for(String ip : nodeAddresses){
if(addressContains != null && ip.contains(addressContains)){
address = ip;
break;
}
else if(addressContains == null){
address = ip;
break;
}
}
if(address != null){
try {
TransportAddress[] addresses = transportService.addressesFromString(address);
for(int i = 0; (i < addresses.length && i < UnicastZenPing.LIMIT_PORTS_COUNT); i++){
logger.trace("adding {}, address {}, transport_address {}", ((NodeMetadata) metadata).getHostname(), address, addresses[i]);
discoveryNodes.add(new DiscoveryNode("#cloud-" + ((NodeMetadata) metadata).getHostname() + "-" + i, addresses[i], Version.CURRENT));
}
} catch (Exception e) {
logger.warn("failed to add {}, address {}", e, ((NodeMetadata) metadata).getHostname(), address);
}
}
else{
logger.trace("not adding {}, address is null, host_type {}", ((NodeMetadata) metadata).getHostname());
}
}
}
logger.debug("using dynamic discovery nodes {}", discoveryNodes);
return discoveryNodes;
}
开发者ID:jlinn,项目名称:elasticsearch-cloud-rackspace,代码行数:64,代码来源:CloudServersUnicastHostsProvider.java
示例19: listNodes
import org.jclouds.compute.domain.ComputeMetadata; //导入依赖的package包/类
@Override
public Set<? extends ComputeMetadata> listNodes() {
return this.computeServiceContext.getComputeService()
.listNodesDetailsMatching(input -> true);
}
开发者ID:cloudiator,项目名称:sword,代码行数:6,代码来源:JCloudsComputeClientImpl.java
示例20: configure
import org.jclouds.compute.domain.ComputeMetadata; //导入依赖的package包/类
@Override
protected void configure() {
super.configure();
//bind the compute context provider
bind(ComputeServiceContext.class).toProvider(ComputeServiceContextProvider.class)
.in(Singleton.class);
//bind the image converter
bind(new TypeLiteral<OneWayConverter<org.jclouds.compute.domain.Image, Image>>() {
}).to(JCloudsImageToImage.class);
//bind the operating system converter
bind(
new TypeLiteral<OneWayConverter<OperatingSystem, de.uniulm.omi.cloudiator.domain.OperatingSystem>>() {
}).to(JCloudsOperatingSystemConverter.class);
//bind the operating system family converter
bind(new TypeLiteral<OneWayConverter<OsFamily, OperatingSystemFamily>>() {
}).to(JCloudsOperatingSystemFamilyConverter.class);
//bind the location converter
bind(new TypeLiteral<OneWayConverter<org.jclouds.domain.Location, Location>>() {
}).to(JCloudsLocationToLocation.class);
//bind the reverse location converter
bind(new TypeLiteral<OneWayConverter<Location, org.jclouds.domain.Location>>() {
}).to(LocationToJCloudsLocation.class);
//bind the hardware converter
bind(new TypeLiteral<OneWayConverter<Hardware, HardwareFlavor>>() {
}).to(JCloudsHardwareToHardwareFlavor.class);
//bind the virtual machine converter
bind(new TypeLiteral<OneWayConverter<ComputeMetadata, VirtualMachine>>() {
}).to(virtualMachineConverter());
//bind the login credential converter
bind(new TypeLiteral<OneWayConverter<LoginCredentials, LoginCredential>>() {
}).to(JCloudsLoginCredentialsToLoginCredential.class);
//bind the security group converter
bind(
new TypeLiteral<OneWayConverter<org.jclouds.compute.domain.SecurityGroup, SecurityGroup>>() {
}).to(JCloudsSecurityGroupToSecurityGroup.class);
//bind the security group rule converter
bind(new TypeLiteral<OneWayConverter<IpPermission, SecurityGroupRule>>() {
}).to(JCloudsIpPermissionToSecurityGroupRule.class);
//bind the template options converter
bind(
new TypeLiteral<OneWayConverter<TemplateOptions, org.jclouds.compute.options.TemplateOptions>>() {
}).to(templateOptionsConverter());
}
开发者ID:cloudiator,项目名称:sword,代码行数:56,代码来源:JCloudsComputeModule.java
注:本文中的org.jclouds.compute.domain.ComputeMetadata类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论