本文整理汇总了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;
}
示例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));
}
示例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));
}
示例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));
}
示例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));
}
示例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));
}
示例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;
}
示例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;
}
示例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);
}
}
示例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));
}
示例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;
}
示例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();
}
示例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;
}
示例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 + ")";
}
};
}
示例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;
}