612: Treat empty-valued tags differently on running instance node metadata

This commit is contained in:
Andrew Donald Kennedy 2011-10-10 13:13:02 +01:00
parent f306137eb0
commit 83aae3fe08
2 changed files with 10 additions and 2 deletions

View File

@ -18,6 +18,9 @@
*/
package org.jclouds.aws.ec2.compute.functions;
import static com.google.common.base.Predicates.*;
import static com.google.common.collect.Maps.*;
import java.util.Map;
import java.util.Set;
@ -39,6 +42,7 @@ import org.jclouds.ec2.domain.RunningInstance;
import com.google.common.base.Supplier;
import com.google.common.cache.Cache;
import com.google.common.collect.ImmutableSet;
/**
* @author Adrian Cole
@ -68,6 +72,9 @@ public class AWSRunningInstanceToNodeMetadata extends RunningInstanceToNodeMetad
@Override
protected NodeMetadataBuilder buildInstance(RunningInstance instance, NodeMetadataBuilder builder) {
return super.buildInstance(instance, builder).userMetadata(AWSRunningInstance.class.cast(instance).getTags());
Map<String, String> tags = AWSRunningInstance.class.cast(instance).getTags();
return super.buildInstance(instance, builder)
.tags(filterValues(tags, in(ImmutableSet.<String>of(""))).keySet())
.userMetadata(filterValues(tags, not(in(ImmutableSet.<String>of("")))));
}
}

View File

@ -137,7 +137,8 @@ public class AWSRunningInstanceToNodeMetadataTest {
.imageId("us-east-1/ami-63be790a")
.id("us-east-1/i-911444f0")
.providerId("i-911444f0")
.userMetadata(ImmutableMap.of("Name", "foo", "Empty", "")).build().toString());
.tags(ImmutableSet.of("Empty"))
.userMetadata(ImmutableMap.of("Name", "foo")).build().toString());
assertEquals(
parser.apply(Iterables.get(contents, 1)),
new NodeMetadataBuilder()